AnsweredAssumed Answered

Creating Task using GEL/XOG

Question asked by Inhesta-Unilever_Third on Dec 21, 2010
Latest reply on Jan 6, 2011 by Inhesta-Unilever_Third
Hi,

I need create one or more task (depending of the return of my SQL) into a project. :blink:

Below my Gel script:

<!-- Created by Marcio Inhesta - 20/12/2010 -->
<!--################## -->
<!-- 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">


<gel:parameter default="XOG_proc" var="XOGUsername"/>


<!--###################### -->

<!--2 Set up datasources -->

<!--###################### -->

<gel:setDataSource dbId="niku"/>


<!--###################### -->

<!-- 3 get data using sql -->

<!--###################### -->
<sql:query var="SQLname" escapeText="false">
select inv_investments.name, inv_investments.code, to_char(sysdate,'YYYY-MM-DD"T"HH24:MI:SS'),
CASE WHEN uni_get_countries(inv_investments.id) like '%Argentina%'

THEN '<Task finish="2011-01-01T16:00:00" key="true" lockedForScheduling="false" milestone="true" name="Go Live Argentina" openForTimeEntry="true" outlineLevel="2" parent="MIL" percComp="0" start="2011-01-01T16:00:00" status="0" taskID="090 010"></Task>'

END,

CASE WHEN uni_get_countries(inv_investments.id) like '%Brazil%'

THEN '<Task finish="2011-01-01T16:00:00" key="true" lockedForScheduling="false" milestone="true" name="Go Live Brazil" openForTimeEntry="true" outlineLevel="2" parent="MIL" percComp="0" start="2011-01-01T16:00:00" status="0" taskID="090 020"></Task>'

END
FROM inv_investments
WHERE id = '${gel_objectInstanceId}'
</sql:query>

<core:choose>

<core:when test="${SQLname.RowCount == 1}">


<!--################################################## -->

<!-- 4 Loop through the array of data provied by SQL -->

<!--################################################## -->

<core:forEach trim="true" items="${SQLname.rowsByIndex}" var="row">
<core:set var="vs_name">${row[0]}</core:set>


<core:set var="vs_code">${row[1]}</core:set>


<core:set var="vs_date">${row[2]}</core:set>
<core:set var="vs_golive1">${row[3]}</core:set>
<core:set var="vs_golive2">${row[4]}</core:set>

</core:forEach>

<!--################################## -->

<!-- 5 set up the XOG document shell -->

<!--################################## -->

<gel:parse var="v_xml_root">
<NikuDataBus>
<Header externalSource="NIKU" version="12.0.4.5283" action="write" objectType="project"/>
<Projects>
<Project name="${vs_name}" projectID="${vs_code}">
<Tasks>${vs_golive1}${vs_golive2}</Tasks>
</Project>
</Projects>
</NikuDataBus>

</gel:parse>

<!-- This code is a cheat and needs to be changed for Phase 2 but it works fine for now and does cause Clarity to get the Update message which will trigger the re-assignment of Project Manager rights -->

<core:new className="com.niku.xog.client.XOGClientInterface" var="xogcaller"/>

<core:invoke method="invoke" on="${xogcaller}" var="xogresponse">


<core:arg type="java.lang.String" value="${XOGUsername}"/>


<core:arg type="org.w3c.dom.Document" value="${v_xml_root}"/>

</core:invoke>

<gel:log level="INFO"><gel:expr select="$xogresponse/"/></gel:log>

</core:when>

<core:otherwise>

<gel:log level="WARN">Cannot set Information, expected exactly 1 database row, got ${SQLname.RowCount}</gel:log>
</core:otherwise>

</core:choose>

</gel:script>

Outcomes