navzjoshi00:
Any error in the xog output ?
NJ
I have rewritten the code of the GEL-script completely, however, the GEL-script is still not completing. The error log reads as follows:
org.apache.commons.jelly.JellyTagException: null:115:90: <gel:set> Missing or invalid XML
Caused by: org.apache.commons.jelly.JellyTagException: null:-1:-1: <null> <gel:set> attribute 'select' $v_xml_root/NikuDataBus/Projects does not refer to an existing node.
at com.niku.union.gel.tags.SetTag.doTag(SetTag.java:72)
<!--################################################################################################################################################################## -->
<!--################## -->
<!-- 1 establish GEL -->
<!--################## -->
<gel:script xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:core="jelly:core"
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"
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">
<core:invokeStatic className="com.niku.union.config.ConfigurationManager" method="getInstance" var="config"/>
<core:set value="${config.getProperties().getWebServer().getWebServerInstance(0).getEntryUrl()}" var="EntryURL"/>
<core:set value="${EntryURL}/niku/xog" var="p_XOGURL"/>
<!-- <gel:parameter var="p_XOGURL" default="http://claritydev:80"/> -->
<gel:parameter var="p_XOGUsername" />
<gel:parameter var="p_XOGPassword" secure="true"/>
<!--################## -->
<!--2 Set up datasources -->
<!--################## -->
<gel:setDataSource dbId="niku"/>
<!--################## -->
<!-- 3 set up the XOG document shell -->
<!--################## -->
<gel:parse var="v_xml_root">
<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
<Header action="write" externalSource="NIKU" objectType="project" version="13.3.0.286"/>
<Tasks>
</Tasks>
</NikuDataBus>
</gel:parse>
<!--################## -->
<!-- 4 get data using sql --> <!-- EXAMPLE ONLY -->
<!--################## -->
<core:set var="v_project_id" value="${gel_objectInstanceId}"/>
<sql:query var="SQLres1" escapeText="false">
select
inv.name,
inv.code,
ocp.a1_ancestor_fgap
FROM niku.inv_investments inv
join niku.odf_ca_project ocp on ocp.id=inv.id
WHERE
inv.id=${v_project_id}
</sql:query>
<core:forEach trim="true" items="${SQLres1.rowsByIndex}" var="row">
<core:set var="vs_prj_name_new" value="${row[0]}"/> <!-- Projektname (neu) -->
<core:set var="vs_prj_code_new" value="${row[1]}"/> <!-- Projektcode (neu) -->
<core:set var="vs_prj_ancestor_fgap" value="${row[2]}" /> <!-- Projektid (alt) -->
</core:forEach>
<gel:log>ancestor: ${vs_prj_ancestor_fgap}</gel:log>
<gel:log>project (cur): ${vs_prj_name_new}</gel:log>
<gel:log>project-code: ${vs_prj_code_new}</gel:log>
<!-- For the test, select only the first row, i. e. TOP 1 -->
<sql:query var="SQLres2" escapeText="false">
SELECT TOP 1
CONVERT(VARCHAR(23), t.PRFINISH, 126) task_fin,
CONVERT(VARCHAR(23), t.LAST_UPDATED_BY, 126) task_last_upd,
CONVERT(VARCHAR(23), t.LAST_UPDATED_DATE, 126) task_last_upd_d,
t.PRNAME,
CONVERT(VARCHAR(23), t.PRSTART, 126) task_start,
CAST(oct.A1_DEL_MATRIX_VER as varchar) del_matrix,
oct.A1_DEL_REQUIRED
FROM niku.prtask t
join niku.inv_investments inv on t.prprojectid=inv.id
join niku.odf_ca_task oct on t.prid=oct.id
join niku.odf_ca_project ocp on ocp.id=inv.id
WHERE
ocp.id=${vs_prj_ancestor_fgap}
AND oct.a1_is_deliverable=1
</sql:query>
<!--########################################## -->
<!-- 5 Loop through the array of data provied by SQL -->
<!--########################################## -->
<core:forEach trim="true" items="${SQLres2.rowsByIndex}" var="row">
<core:set var="vs_prfinish" value="${row[0]}"/>
<core:set var="vs_last_upd_by" value="${row[1]}"/>
<core:set var="vs_last_upd_date" value="${row[2]}"/>
<core:set var="vs_prname" value="${row[3]}"/>
<core:set var="vs_prstart" value="${row[4]}"/>
<core:set var="vs_a1_del_matrix_ver" value="${row[5]}"/>
<core:set var="vs_a1_del_required" value="${row[6]}"/>
<!--########################################## -->
<!-- 6 Format looped data relevant into XOG format -->
<!--########################################## -->
<gel:parse var="task_data">
<Tasks>
<Task evCalcMethod="0" finish="${vs_prfinish}" fixed="false" key="false" lastUpdatedBy="${vs_last_upd_by}" lastUpdatedDate="${vs_last_upd_date}" lockedForScheduling="false" milestone="true" name="${vs_prname}" openForTimeEntry="true" orderID="1" outlineLevel="1" percComp="0" start="${vs_prstart}" status="0" summary="true">
<CustomInformation>
<ColumnValue name="a1_del_matrix_ver">${vs_a1_del_matrix_ver}
</ColumnValue>
<ColumnValue name="a1_del_required">${vs_a1_del_required}
</ColumnValue>
<ColumnValue name="a1_deliverable_appr">NEW
</ColumnValue>
<ColumnValue name="partition_code">NIKU.ROOT
</ColumnValue>
</CustomInformation>
</Task>
</Tasks>
</gel:parse>
<!--########################################## -->
<!-- 7 Merge looped data into XOG shell -->
<!--########################################## -->
<gel:set select="$v_xml_root/NikuDataBus/Projects" value="${task_data}" insert="true"/>
</core:forEach>
<!--########################################## -->
<!-- 8 Invoke SOAP --> <!-- EXAMPLE ONLY -->
<!--########################################## -->
<gel:out>[XOG]Logging into Clarity XOG at ${p_XOGURL}.</gel:out>
<gel:log level="INFO" category="XOG">Logging into Clarity XOG at ${p_XOGURL}.</gel:log>
<core:catch var="v_xog_exception">
<soap:invoke endpoint="${p_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>${p_XOGUsername}</xog:Username>
<xog:Password>${p_XOGPassword}</xog:Password>
</xog:Login>
</soapenv:Body>
</soapenv:Envelope>
</soap:message>
</soap:invoke>
<!-- Check whether a sessionID is returned. If not, it means that Login was unsuccessful -->
<gel:set asString="true" select="$auth/soapenv:Envelope/soapenv:Body/xog:SessionID/text()" var="sessionID"/>
<core:choose>
<!-- Check XOG sessionID -->
<core:when test="${sessionID == null}">
<gel:out>[XOG]Couldn't Log in to XOG. Check the username/password and Application has started.</gel:out>
<gel:log level="ERROR" category="XOG">Couldn't Log in to XOG. Check the username/password and Application has started.</gel:log>
</core:when>
<core:otherwise>
<!-- XOG if session ID is valid -->
<gel:out>[XOG]Log in successful ${sessionID}</gel:out>
<gel:log level="INFO" category="XOG">[XOG]Log in successful ${sessionID}</gel:log>
<!--########################################## -->
<!-- 9 Now call the XOG -->
<!--########################################## -->
<core:catch var="v_xog_exception">
<soap:invoke endpoint="${p_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:include select="$v_xml_root/NikuDataBus"/>
</soapenv:Body>
</soapenv:Envelope>
</soap:message>
</soap:invoke>
</core:catch>
<core:choose>
<core:when test="${v_xog_exception != null}">
<gel:out>[XOG]XOG operation failed: ${v_xog_exception}</gel:out>
<gel:log level="ERROR" category="XOG">XOG operation failed: ${v_xog_exception}</gel:log>
</core:when>
<core:otherwise>
<!-- Check the XOG result -->
<gel:set select="$runresult/soapenv:Envelope/soapenv:Body/XOGOutput" var="writeOutputRoot"/>
<gel:set asString="true" select="$writeOutputRoot/Status/@state" var="XOGoutcome"/>
<gel:set asString="true" select="$writeOutputRoot/Records/Record" var="XOGoutputrecords"/>
<gel:set asString="true" select="$writeOutputRoot/Statistics/@totalNumberOfRecords" var="XOGtotalrecords"/>
<gel:set asString="true" select="$writeOutputRoot/Statistics/@insertedRecords" var="XOGinsertedrecords"/>
<gel:set asString="true" select="$writeOutputRoot/Statistics/@updatedRecords" var="XOGupdatedrecords"/>
<gel:set asString="true" select="$writeOutputRoot/Statistics/@failureRecords" var="XOGfailurerecords"/>
<gel:out>[XOG]XOG operation completed [Total ${XOGtotalrecords}, Inserted ${XOGinsertedrecords}, Updated ${XOGupdatedrecords}, Failed ${XOGfailurerecords}</gel:out>
<gel:log level="INFO" category="XOG">XOG operation completed [Total ${XOGtotalrecords}, Inserted ${XOGinsertedrecords}, Updated ${XOGupdatedrecords}, Failed ${XOGfailurerecords}]</gel:log>
</core:otherwise>
</core:choose>
<!--########################################## -->
<!-- 10 Close down grecefully, starting with XOG Log out -->
<!--########################################## -->
<soap:invoke endpoint="${p_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>
<gel:out>[XOG]Logged out </gel:out>
<gel:log level="INFO" category="XOG">Logged out </gel:log>
</core:otherwise>
<!-- XOG if session ID is valid -->
</core:choose>
<!-- Check XOG session ID -->
</core:catch>
<!-- Exception for XOG -->
<core:if test="${v_xog_exception != null}">
<gel:out>XOG failed: ${v_xog_exception}</gel:out>
<gel:log level="ERROR" category="XOG">XOG failed: ${v_xog_exception}</gel:log>
</core:if>
</gel:script>