<gel:script
xmlns:soapenv="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:sql="jelly:sql"
xmlns:util="jelly:util"
xmlns:xog="http://www.niku.com/xog"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- SQL tag -->
<gel:parameter default="" var="p_XOGURL"/>
<gel:parameter default="" var="p_XOGUsername"/>
<gel:parameter default="" secure="true" var="p_XOGPassword"/>
<!-- Setup SQL datasources -->
<gel:setDataSource dbId="niku"/>
<!-- ================================================= -->
<!-- Here is my SQL Statement...-->
<!-- ================================================= -->
<sql:query var="InactivateLinkRequests" escapeText="false">
SELECT LINKAGE_ID
, ACTION_REQUESTED
, APPLICATION_NAME
, APPLICATION_CODE
, ODF_PARENT_ID
, DIVC
, DIVISION_NUMBER
, DIVISION_NAME
, COST_CENTER
, CC_NAME_NUMBER
, CC_MGR_NAME
, FUNCTIONNAME
, decode(BFPRIORITY, 1, 'priority_1', 2, 'priority_2', 3, 'priority_3', 4, 'priority_4')
, CUST_NAME
,CUST_EMAIL
, CUST_FLNAME
, PRIMARY_FLNAME
, PRIMARY_EMAIL
, SECONDARY_FLNAME
, SECONDARY_EMAIL
, TRANSMITTED_DATE
, UPDATED_DATE
, CREATED_DATE
, BFL_ID
, BIANO
, LINK_STATUS
, INDICATOR
, CODE
, BIANO_ACTIVE
FROM Z_BOH_PENDING_BF_LINKAGES
WHERE ACTION_REQUESTED = 'Inactivate'
</sql:query>
<!-- ============================================================================== -->
<!-- Build the XML file using Parse tag and incorporating those variables' values . ..-->
<!-- ============================================================================== -->
<gel:parse var="object_xml">
<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_application.xsd">
<Header action="write" externalSource="NIKU" objectType="application" version="8.0" overrideAutoNumbering="false" />
<Applications>
<core:forEach items="${InactivateLinkRequests.rowsByIndex}" var="row">
<core:set var="v_link_id">${row[0]}</core:set>
<core:set var="v_action_requested">${row[1]}</core:set>
<core:set var="v_application_name">${row[2]}</core:set>
<util:replace
new = ""
old = "amp;"
value = "${v_application_name}"
var = "v_cleaned_application_name"/>
<core:set var="v_application_code">${row[3]}</core:set>
<core:set var="v_odf_parent_id">${row[4]}</core:set>
<core:set var="v_divc">${row[5]}</core:set>
<core:set var="v_division_number">${row[6]}</core:set>
<core:set var="v_division_name">${row[7]}</core:set>
<util:replace
new = ""
old = "amp;"
value = "${v_division_name}"
var = "v_cleaned_division_name"/>
<core:set var="v_cost_center">${row[8]}</core:set>
<core:set var="v_cc_name_number">${row[9]}</core:set>
<core:set var="v_cc_mgr_name">${row[10]}</core:set>
<core:set var="v_functionname">${row[11]}</core:set>
<util:replace
new = ""
old = "amp;"
value = "${v_functionname}"
var = "v_cleaned_functionname"/>
<core:set var="v_bfpriority">${row[12]}</core:set>
<core:set var="v_cust_name">${row[13]}</core:set>
<core:set var="v_cust_email">${row[14]}</core:set>
<core:set var="v_cust_flname">${row[15]}</core:set>
<core:set var="v_primary_flname">${row[16]}</core:set>
<core:set var="v_primary_email">${row[17]}</core:set>
<core:set var="v_secondary_flname">${row[18]}</core:set>
<core:set var="v_secondary_email">${row[19]}</core:set>
<core:set var="v_transmitted_date">${row[20]}</core:set>
<core:set var="v_updated_date">${row[21]}</core:set>
<core:set var="v_created_date">${row[22]}</core:set>
<core:set var="v_bfl_id">${row[23]}</core:set>
<core:set var="v_biano">${row[24]}</core:set>
<core:set var="v_link_status">${row[25]}</core:set>
<core:set var="v_indicator">${row[26]}</core:set>
<core:set var="v_bfl_code">${row[27]}</core:set>
<core:set var="v_biano_active">${row[28]}</core:set>
<Application active="true"
name="${v_cleaned_application_name}"
objectID="${v_application_code}"
progress="2" status="1">
<CustomInformation>
<instance instanceCode="${v_bfl_code}"
objectCode="appl_bus_function"
parentInstanceCode="${v_application_code}" parentObjectCode="application">
<CustomInformation>
<ColumnValue name="bus_function_name">${v_cleaned_functionname}</ColumnValue>
<ColumnValue name="cost_center">${v_cost_center}</ColumnValue>
<ColumnValue name="division_number">${v_division_number}</ColumnValue>
<ColumnValue name="biano">${v_biano}</ColumnValue>
<ColumnValue name="bus_func_priority">${v_bfpriority}</ColumnValue>
<ColumnValue name="division_name">${v_cleaned_division_name}</ColumnValue>
<ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
<ColumnValue name="name">Link</ColumnValue>
<ColumnValue name="code">${v_bfl_code}</ColumnValue>
<ColumnValue name="odf_parent_id">${v_odf_parent_id}</ColumnValue>
<ColumnValue name="odf_cncrt_parent_id">${v_odf_parent_id}</ColumnValue>
<ColumnValue name="indicator">${v_indicator}</ColumnValue>
<ColumnValue name="biano_active">${v_biano_active}</ColumnValue>
<ColumnValue name="divc">${v_divc}</ColumnValue>
<ColumnValue name="link_status">inactive</ColumnValue>
</CustomInformation>
</instance>
</CustomInformation>
</Application>
</core:forEach>
</Applications>
</NikuDataBus>
</gel:parse>
<!-- display the generated XML from the application query -->
<gel:log>
<gel:log>Step 1 - XML Generated is below -</gel:log>
<gel:expr select="$object_xml"/>
</gel:log>
<gel:log>AppName=${v_cleaned_application_name}=</gel:log>
<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}/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>${p_XOGUsername}</xog:Username>
<xog:Password>${p_XOGPassword}</xog:Password>
</xog:Login>
</soapenv:Body>
</soapenv:Envelope>
</soap:message>
</soap:invoke>
<gel:set asString="true" select="$auth/soapenv:Envelope/soapenv:Body/xog:SessionID/text()" var="sessionID"/>
<core:choose>
<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">Log Couldn't Log in to XOG. Check the username/password and Application has started.</gel:log>
</core:when>
<core:otherwise>
<gel:out>[XOG]Log in successful ${sessionID}</gel:out>
<gel:log level="INFO" category="XOG">[XOG]Log in successful ${sessionID}</gel:log>
<core:catch var="v_xog_exception">
<soap:invoke endpoint="${p_XOGURL}/niku/xog" var="object_xml">
<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="$object_xml/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:choose>
<soap:invoke endpoint="${p_XOGURL}/niku/xog" var="object_xml_result">
<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>
</core:choose>
</core:catch>
<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>
.