Clarity

  • 1.  Xog in using the output file of a xogout command

    Posted Jul 13, 2012 09:10 AM
    Hi Friends,

    Can we create a xog output file from a process(gel script) and xog in using the same file, all done in a process?

    Thanks,
    Georgy


  • 2.  RE: Xog in using the output file of a xogout command
    Best Answer

    Posted Jul 13, 2012 09:34 AM
    Yes.


  • 3.  RE: Xog in using the output file of a xogout command

    Posted Jul 13, 2012 09:38 AM
    If you use the XOG query api you might be able to create an output file which is close to be used as the input file.
    There is a little you need to do more to the that before you use it as in the input like putting the header and the footer and maybe some editing.
    That was slightly touched in
    How to XOG out (read) resource using filter for Termination Date attribute
    98362667
    and there is a reference to examples using the query api in that thread.

    Martti K.


  • 4.  RE: Xog in using the output file of a xogout command

    Posted Jul 13, 2012 09:50 AM
    On the other hand if your GEL script uses the normal XOG object api that will create an output file which is ready for writing in (in most cases).

    Martti K.


  • 5.  RE: Xog in using the output file of a xogout command

    Posted Jul 13, 2012 09:57 AM
    Just to repeat the other replies, yes you can!
    And there are a few ways to deal with it. You can either just keep the XOG output in memory and use it later on in your script, or you could use gel:serialize to write it out to a file and then read it in again later, or you can use gel:setDocument and gel:getDocument to save and retrieve the XML between steps in the same process.
    Lots of options to play with :grin:


  • 6.  RE: Xog in using the output file of a xogout command

    Posted Jul 18, 2012 04:22 AM
    Hi Friends,

    I tried with this GEL script given below. The XOG didn't work and gave no errors too.

    CODE:
    ----------
    <gel:script xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:core="jelly:core"
    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:sql="jelly:sql"
    xmlns:xog="http://www.niku.com/xog"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <gel:parameter default="http://******:2840" var="XOGURL"/>
    <gel:parameter default="admin" var="XOGUsername"/>
    <gel:parameter default="xxxxx" secure="true" var="XOGPassword"/>
    <!-- Log into XOG and get a session ID -->
    <soap:invoke endpoint="${XOGURL}" var="auth">
    <soap:message>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xog="http://www.niku.com/xog">
    <soapenv:Header/>
    <soapenv:Body>
    <xog:Login>
    <xog:Username>${XOGUsername}</xog:Username>
    <xog:Password>${XOGPassword}</xog:Password>
    </xog:Login>
    </soapenv:Body>
    </soapenv:Envelope>
    </soap:message>
    </soap:invoke>
    <!-- Checking whether a sessionID is returned. If not, it means that Login was unsuccessful -->

    <gel:set asString="true" select="$auth/SOAP-ENV:Envelope/SOAP-ENV:Body/xog:SessionID/text()" var="sessionID"/>
    <core:choose>
    <core:when test="${sessionID == null}">
    <gel:out>Couldn't Log in. Check the username/password.</gel:out>
    </core:when>
    <core:otherwise></core:otherwise>
    </core:choose>
    <!--Run XOG and attach an input file...alternatively the Body section can be the NikuDatabus section of an input file-->
    <soap:invoke endpoint="${XOGURL}" var="runresult">
    <soap:message>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xog="http://www.niku.com/xog">
    <soapenv:Header>
    <xog:Auth>
    <xog:SessionID>${sessionID}</xog:SessionID>
    </xog:Auth>
    </soapenv:Header>
    <soapenv:Body>
    <gel:parse var="xmlindoc" file="/opt/clarity/clarity/portlets_read.xml"/>
    <gel:include select="$xmlindoc"/>
    </soapenv:Body>
    </soapenv:Envelope>
    </soap:message>
    </soap:invoke>



    <!-- Read the output and extract some information from it -->
    <gel:set asString="true" select="$runresult/SOAP-ENV:Envelope/SOAP-ENV:Body/NikuDataBus/XOGOutput/Status/@state" var="XOGoutcome"/>
    <core:switch on="${XOGoutcome}">
    <core:case value="SUCCESS">
    <gel:forEach select="$runresult/SOAP-ENV:Envelope/SOAP-ENV:Body/NikuDataBus/Resources/Resource" var="outputnode">
    <gel:out><gel:expr select="$outputnode/PersonalInformation/@displayName"/></gel:out>
    </gel:forEach>
    <gel:set asString="false" select="$runresult/SOAP-ENV:Envelope/SOAP-ENV:Body/NikuDataBus/XOGOutput/Statistics" var="stats"/>
    <gel:log>Success! Total number of records: <gel:expr select="$stats/@totalNumberOfRecords"/></gel:log>
    </core:case>
    <core:case value="FAILURE">
    <gel:set asString="false" select="$runresult/SOAP-ENV:Envelope/SOAP-ENV:Body/NikuDataBus/XOGOutput/Statistics" var="stats"/>
    <gel:out>XOG failed. Out of <gel:expr select="$stats/@totalNumberOfRecords"/> records, <gel:expr select="$stats/@failureRecords"/> failed.</gel:out>
    </core:case>
    <core:default>
    <gel:out>Couldn't find XOG output summary. Please check the output file manually.</gel:out>
    </core:default>
    </core:switch>
    <!-- Log out of the XOG -->
    <soap:invoke endpoint="${XOGURL}" var="logoutresult">
    <soap:message>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xog="http://www.niku.com/xog">
    <soapenv:Header>
    <xog:Auth>
    <xog:SessionID>${sessionID}</xog:SessionID>
    </xog:Auth>
    </soapenv:Header>
    <soapenv:Body>
    <xog:Logout/>
    </soapenv:Body>
    </soapenv:Envelope>
    </soap:message>
    </soap:invoke>


    <soap:invoke endpoint="${XOGURL}" var="Xogoutresult">
    <soap:message>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xog="http://www.niku.com/xog">
    <soapenv:Header>
    <xog:Auth>
    <xog:SessionID>${sessionID}</xog:SessionID>
    </xog:Auth>
    </soapenv:Header>
    <soapenv:Body>
    <gel:include select="${runresult}"/>
    </soapenv:Body>
    </soapenv:Envelope>
    </soap:message>
    </soap:invoke>



    <gel:set asString="true" select="$Xogoutresult/SOAP-ENV:Envelope/SOAP-ENV:Body/NikuDataBus/XOGOutput/Status/@state" var="XOGoutcome"/>
    <core:switch on="${XOGoutcome}">
    <core:case value="SUCCESS">
    <gel:forEach select="$Xogoutresult/SOAP-ENV:Envelope/SOAP-ENV:Body/NikuDataBus/Resources/Resource" var="outputnodes">
    <gel:out><gel:expr select="$outputnodes/PersonalInformation/@displayName"/></gel:out>
    </gel:forEach>
    <gel:set asString="false" select="$Xogoutresult/SOAP-ENV:Envelope/SOAP-ENV:Body/NikuDataBus/XOGOutput/Statistics" var="Xogoutstats"/>
    <gel:log>Success! Total number of records: <gel:expr select="$Xogoutstats/@totalNumberOfRecords"/></gel:log>
    </core:case>
    <core:case value="FAILURE">
    <gel:set asString="false" select="${Xogoutresult}/SOAP-ENV:Envelope/SOAP-ENV:Body/NikuDataBus/XOGOutput/Statistics" var="Xogoutstats"/>
    <gel:out>XOG failed. Out of <gel:expr select="$statss/@totalNumberOfRecords"/> records, <gel:expr select="$Xogoutstats/@failureRecords"/> failed.</gel:out>
    </core:case>
    <core:default>
    <gel:out>Couldn't find XOG output summary. Please check the output file manually.</gel:out>
    </core:default>
    </core:switch>

    </gel:script>


    Any tips?
    Georgy


  • 7.  RE: Xog in using the output file of a xogout command

    Posted Jul 18, 2012 04:48 AM

    Georgy wrote:

    Hi Friends,

    I tried with this GEL script given below. The XOG didn't work and gave no errors too.

    .
    .
    .
    .

    Any tips?
    Georgy
    No idea - and I am not going to debug your entire process for you! (and "didn't work and gave no errors" hardly gives an idea of the problem does it ? )

    I suggest you break your GEL script down into small separate stages and check each stage one at a time, debugging the output using <gel:out> and dumping the produced XML to the filesystem so you can see what it contains.


  • 8.  RE: Xog in using the output file of a xogout command

    Posted Jul 18, 2012 05:10 AM
    Hi Georgy,
    From a quick skim over the code, it looks like you are logging out of XOG before invoking your XOG write code :blink:

    Regards
    Steve