AnsweredAssumed Answered

INSERT RESOURCES VIA PROCESS

Question asked by VicenteRJ on Jul 30, 2012
Latest reply on Aug 31, 2012 by splogad
Hi,

we need to include in the project team all the people involved until the project creation.

To do this, create an action to insert them, but it occurs error "No project manager right."

Using the client, the xog works correctly.



script
----------------
<gel:script xmlns:core="jelly:core"
xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"
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:sql="jelly:sql" xmlns:x="jelly:xml"
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://server" var="XOGURL"/>
<gel:parameter default="xoguser" var="XOGusername"/>
<gel:parameter default="xogpass" var="XOGpassword"/>
<soap:invoke endpoint="${XOGURL}/niku/xog" var="xog_login">
<soap:message>
<soap-env:Envelope
xmlns:soap-env="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>
</soap-env:Body>
</soap-env:Envelope>
</soap:message>
</soap:invoke>
<gel:set asString="true"
select="$xog_login/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>
<gel:out>
<gel:expr select="$xog_login"/>
</gel:out>
<!-- Verify a connection with the database -->
<core:catch var="errorVar">
<gel:setDataSource dbId="Niku"/>
</core:catch>
<core:choose>
<core:when test="${errorVar == null}">
<sql:query var="dual">SELECT 1 FROM DUAL</sql:query>
<core:if test="${debug}">
<gel:log level="INFO">Database connection established</gel:log>
</core:if>
</core:when>
<core:otherwise>
<gel:log level="ERROR">Database connection NOT established</gel:log>
</core:otherwise>
</core:choose>
<gel:log level="INFO">Resources from '${gel_objectInstanceId}'.</gel:log>
<sql:query var="rs">
select REC.UNIQUE_NAME,


INV.NAME,


INV.CODE

from


(


select ID, obj_pat c
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_gespro
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, pro_soldemori
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_soldem
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_conqua
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_ageraqu
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_gercom
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_gercus
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_plager
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_gerqua
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_gerrech
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_gerris
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, pro_gertem
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, obj_geresc
from odf_ca_project where id = '${gel_objectInstanceId}' union


select ID, manager_id
from inv_investments where id = '${gel_objectInstanceId}'


) tab,


srm_resources REC,


INV_INVESTMENTS INV

where tab.partic is not null

AND
REC.USER_ID = TAB.partic

AND
INV.ID = TAB.ID

</sql:query>
<!-- Skip the column headers on the first line -->
<core:forEach items="${rs.rowsByIndex}" trim="true" var="row">

<!-- ======= order of columns in my tab-delimited file moved to variables =================== -->


<gel:log level="INFO">Resource : ${row[0]}/${row[1]}.</gel:log>

<soap:invoke endpoint="${XOGURL}/niku/xog" var="XOG_result">
<soap:message>
<soap-env:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
<soap-env:Header>
<xog:Auth>
<xog:SessionID>${sessionID}</xog:SessionID>
</xog:Auth>
</soap-env:Header>
<soap-env:Body>
<!-- ================================================= -->
<!-- Insert your XOG out format for your custom object -->
<!-- ================================================= -->

<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">



<Header action="write" externalSource="NIKU" objectType="project" version="12.1.1.1208"/>



<Projects>



<Project name="${row[1]}" projectID="${row[2]}">



<Resources>




<Resource bookingStatus="5" resourceID="${row[0]}"></Resource>


</Resources>



</Project>



</Projects>



</NikuDataBus>

<!-- ================================================= -->
</soap-env:Body>
</soap-env:Envelope>
</soap:message>
</soap:invoke>


<gel:log level="INFO"> "$XOG_result" </gel:log>

<!-- ================================================= -->
<!-- Error/status reporting - optional -->
<!-- ================================================= -->
<gel:set asString="true"
select="$XOG_result/soap-env:Envelope/soap-env:Body/XOGOutput/Status/@state" var="XOG_STATUS"/>
<core:switch on="${XOG_STATUS}">
<core:case value="SUCCESS">
<gel:log level="INFO"> Sucesso no XOG.</gel:log>
</core:case>
<core:case value="FAILURE">

<gel:log level="ERROR"> Erro no XOG . <gel:expr select="$XOG_result"/> </gel:log>

</core:case>
</core:switch>
<!-- ======= end error reporting ===================== -->
</core:forEach>

</core:otherwise>
</core:choose>
<soap:invoke endpoint="${XOGURL}/niku/xog" var="xog_logout">
<soap:message>
<soap-env:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
<soap-env:Header>
<xog:Auth>
<xog:SessionID>${sessionID}</xog:SessionID>
</xog:Auth>
</soap-env:Header>
<soap-env:Body>
<xog:Logout/>
</soap-env:Body>
</soap-env:Envelope>
</soap:message>
</soap:invoke>
<gel:out>
<gel:expr select="$xog_logout"/>
</gel:out>
</gel:script>

-------------

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<XOGOutput xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/status.xsd">
<Object type="project"/>
<Status state="FAILURE"/>
<Statistics failureRecords="1" insertedRecords="0"
totalNumberOfRecords="1" updatedRecords="0"/>
<Records>
<Record>
<KeyInformation>
<column name="ID">5030032</column>
<column name="name">VP26JUL 02</column>
<column name="UNIQUE_NAME">00001033</column>
</KeyInformation>
<ErrorInformation>
<Severity>FATAL</Severity>
<Description>Project Object update failed</Description>
<Exception><![CDATA[
java.lang.Exception: 30 : No project manager right.

at com.niku.xog.functions.XOGProjectAPI.returnErrorMessage(XOGProjectAPI.java:454)

at com.niku.xog.functions.XOGProjectAPI.process(XOGProjectAPI.java:290)

at com.niku.xog.functions.XOGProjectAPI.eval(XOGProjectAPI.java:155)

at com.niku.xql2.eval.XQLFunctionNode.eval(XQLFunctionNode.java:27)

at com.niku.xql2.eval.XQLEvaluator.parse(XQLEvaluator.java:40)

at com.niku.xql2.XQLVisitor.eval(XQLVisitor.java:1043)

at com.niku.xql2.XQLVisitor.eval(XQLVisitor.java:1017)

at com.niku.xql2.XQLVisitor.process(XQLVisitor.java:1249)

at com.niku.xql2.XQLVisitor.process(XQLVisitor.java:1285)

at com.niku.union.xml.dom.DOMWalker.preProcess(DOMWalker.java:178)

at com.niku.union.xml.dom.DOMWalker.traverseIntern(DOMWalker.java:74)

at com.niku.union.xml.dom.DOMWalker.traverse(DOMWalker.java:51)

at com.niku.xql2.handlers.TryHandler.preProcess(TryHandler.java:50)

at com.niku.xql2.XQLVisitor.preProcess(XQLVisitor.java:1342)

at com.niku.union.xml.dom.DOMWalker.preProcess(DOMWalker.java:194)

at com.niku.union.xml.dom.DOMWalker.traverseIntern(DOMWalker.java:74)

at com.niku.union.xml.dom.DOMWalker.traverse(DOMWalker.java:51)

at com.niku.xql2.handlers.LoopHandler.processObject(LoopHandler.java:161)

at com.niku.xql2.handlers.LoopHandler.preProcess(LoopHandler.java:91)

at com.niku.xql2.XQLVisitor.preProcess(XQLVisitor.java:1342)

at com.niku.union.xml.dom.DOMWalker.preProcess(DOMWalker.java:194)

at com.niku.union.xml.dom.DOMWalker.traverseIntern(DOMWalker.java:74)

at com.niku.union.xml.dom.DOMWalker.traverse(DOMWalker.java:51)

at com.niku.xql2.handlers.LoopHandler.processObject(LoopHandler.java:161)

at com.niku.xql2.handlers.LoopHandler.preProcess(LoopHandler.java:91)

at com.niku.xql2.XQLVisitor.preProcess(XQLVisitor.java:1342)

at com.niku.union.xml.dom.DOMWalker.preProcess(DOMWalker.java:194)

at com.niku.union.xml.dom.DOMWalker.traverseIntern(DOMWalker.java:74)

at com.niku.union.xml.dom.DOMWalker.traverse(DOMWalker.java:51)

at com.niku.xql2.handlers.LoopHandler.processObject(LoopHandler.java:161)

at com.niku.xql2.handlers.LoopHandler.preProcess(LoopHandler.java:91)

at com.niku.xql2.XQLVisitor.preProcess(XQLVisitor.java:1342)

at com.niku.union.xml.dom.DOMWalker.preProcess(DOMWalker.java:194)

at com.niku.union.xml.dom.DOMWalker.traverseIntern(DOMWalker.java:74)

at com.niku.union.xml.dom.DOMWalker.traverseIntern(DOMWalker.java:92)

at com.niku.union.xml.dom.DOMWalker.traverseIntern(DOMWalker.java:92)

at com.niku.union.xml.dom.DOMWalker.traverse(DOMWalker.java:36)

at com.niku.xog.service.XOGXBLHandler.processXBL(XOGXBLHandler.java:245)

at com.niku.xog.service.XOGXBLHandler.process(XOGXBLHandler.java:151)

at co...

Outcomes