Clarity

  • 1.  Using core:include in Gel Scripts

    Posted Mar 03, 2014 04:59 AM

     

    Is anyone using core:include for reusable gel script components?

    I have been looking over our scripts and I see a lot of code snippets (login, logout, read,…) that are the same.

    I have played around with core:include and found it works as advertised with the benefit of reducing the script verbiage.  Has anyone stubbed their toes using core:include or see any issue with it in a production environment?

    Here is the test script I was using to test-out core:include for Login/Logout/ReadProjects.

    <?xml version="1.0" encoding="utf-8"?>
    <gel:script
        xmlns:core="jelly:core"
        xmlns:xog="http://www.niku.com/xog"
        xmlns:x="jelly:org.apache.commons.jelly.tags.xml.XMLTagLibrary"
        xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
        xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:nikuq="http://www.niku.com/xog/Query"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <gel:out>Starting Test Include</gel:out>
        <!-- Setup our script exception catch -->
        <core:catch var="exception">
            <gel:parameter var="XogUserName" />
            <gel:parameter var="XogPassword" />
            <!-- Wrap our script in a loop so we can use break to exit cleanly -->
            <core:set var="scriptBreak" value="[1]" />
            <core:forEach var="dummy" items="${scriptBreak}">
                <!-- Login -->
                <core:include file="gel/Login_Include.xml" />
                <core:if test="${XogSessionId == null}">
                    <core:break />
                </core:if>
                <!-- Get our xogReadProjects soap:message query -->
                <core:include file="gel/XogReadProjects_Include.xml" />
                <!-- Add a filter to our read -->
                <gel:parse var="readProjectFilter">
                    <Filter name="projectID" criteria="OR">PRJ00000539,PRJ00000645,PRJ00000728</Filter>
                </gel:parse>
                <gel:set value="${readProjectFilter}" select="$xogReadProjects//Query" insert="true" />
                <!-- Save our results into a file just to see what we get -->
                <gel:serialize fileName="xogReadProjects1.xml" var="${xogReadProjects}" />
                <!-- Invoke our soap endpoint -->
                <soap:invoke endpoint="${XogUrl}" var="projectResults">
                    <soap:message>
                        <gel:include select="$xogReadProjects" />
                    </soap:message>
                </soap:invoke>
                <!-- Save our results into a file just to see what we get -->
                <gel:serialize fileName="projectResults1.xml" var="${projectResults}" />
                <!-- Logout -->
                <core:include file="gel/Logout_Include.xml" />
            </core:forEach>
            <gel:out>Finish Test Include</gel:out>
        </core:catch>
        <core:if test="${exception != null}">
            <gel:log level="FATAL" message="    ${exception}" />
        </core:if>
    </gel:script>

     

    V/r,

    Gene



  • 2.  RE: Using core:include in Gel Scripts
    Best Answer

    Posted Mar 03, 2014 05:13 AM

    I haven't, but I raised the same sort of thoughts a while back (reusable GEL code) and that was one of the suggestions.

    GEL Script : "Subprocedures"?

    (but I chickened out of trying to do anything clever then and just ended up with a lot of repeated code in my script at that time frown)
     



  • 3.  RE: Using core:include in Gel Scripts

    Posted Mar 03, 2014 04:12 PM

     

    I really like the jelly:define tag.  That coupled with core:include you could build a whole library of "Subprocedures".  Well being OnDemand there isn't a define taglib.

    V/r,

    Gene



  • 4.  RE: Using core:include in Gel Scripts

    Posted Mar 04, 2014 03:43 AM

    But doesn't "On Demand" stop you from doing anything "clever" - you would need access to the server to deploy the files that you would want to "include" and access to the server in order to deploy the jelly:define stuff? sad

    (unless I am misunderstanding from where stuff can be "included")



  • 5.  RE: Using core:include in Gel Scripts

    Posted Mar 04, 2014 10:06 AM

    Most “clever” things are not allowed but they do let you have access to a folder location (via ftp) that you can upload / download files from the server. 

    So for includes, one would need to upload the files into a folder that the gel scripts have access to.

    As for define taglib, there isn’t a way to upload jars so that gel can use to them.

    V/r,

    Gene



  • 6.  RE: Using core:include in Gel Scripts

    Posted Mar 04, 2014 10:28 AM

    ^ OK yes ; that FTP location business makes sense.