GEL Examples: Running the XOG

ccppmop1591
To allow GEL to communicate with the XOG web service, include the SOAP and XOG namespaces in your GEL scripts. Package each invocation in a proper SOAP envelope. The following GEL examples for running the XOG are provided:
Example: Log in to 
Classic PPM
 and Run the XOG to Read the List of Resources (Individual Calls)
This example logs in to 
Classic PPM
 and runs the XOG to read the list of resources. The script performs each of these actions as individual calls to the XOG server.
<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://nikuvm:80" var="XOGURL"/> <gel:parameter default="svong" var="XOGUsername"/> <gel:parameter default="svong" secure="true" var="XOGPassword"/> <!-- Log into XOG and get a session ID --> <soap:invoke endpoint="${XOGURL}/niku/xog" 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}/niku/xog" 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="C:\Clarity\XOG\xml\rsm_resources_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:out>Success! Total number of records: <gel:expr select="$stats/@totalNumberOfRecords"/></gel:out> </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}/niku/xog" 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> </gel:script>
Example: Log in to 
Classic PPM
 and Make a XOG Request (Single Invocation)
In this example, the script logs in and makes a XOG request in a single invocation. The XOG request is also included inline, which means it is included in the script instead of being retrieved from a file.
<gel:script xmlns:x="jelly:xml" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://pmo.sec.samsung.net/niku/xog"> <gel:parameter var="XOGusername" default="admin"/> <gel:parameter var="XOGpassword" default="admin"/> <soap:invoke endpoint="http://pmo.sec.samsung.net/niku/xog" var="result"> <soap:message> <soap-env:Envelope  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog"> <soap-env:Body> <xog:Login xmlns="http://www.niku.com/xog"> <xog:Username>${XOGusername}</xog:Username> <xog:Password>${XOGpassword}</xog:Password> </xog:Login> <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd"> <Header version="12.0.0.5028" action="read" objectType="resource" externalSource="NIKU"> <args name="include_contact" value="false"/> <args name="include_management" value="false"/> <args name="include_custom" value="false"/> <args name="include_financial" value="false"/> </Header> <Query> <Filter name="isActive" criteria="EQUALS">true</Filter> </Query> </NikuDataBus> </soap-env:Body> </soap-env:Envelope> </soap:message> </soap:invoke> <gel:out><gel:expr select="$result"/></gel:out> </gel:script>