Clarity

  • 1.  How to XOG new task (copied from another project)

    Posted May 28, 2014 03:48 PM

    Hello, I want to XOG new tasks into an existing project. The process runs, but does not create any new tasks: 

     

    <soap:invoke  endpoint="${p_XOGURL}" var="task_create">
      <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="xogbody">
         <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
          <Header version="6.0.11" action="write" objectType="project" externalSource="NIKU"/>
           <Projects>
           <Project projectID="${v_prj_code_new}" name="${v_prj_name_new}">
           <Tasks>${v_tasks_all}
           </Tasks>
           </Project>
          </Projects>
         </NikuDataBus>
        </gel:parse>
       </soapenv:Body>
       </soapenv:Envelope>
      </soap:message>
    </soap:invoke>

    The variable ${v_tasks_all} holds:

    <Task lastUpdatedBy="5014001" name="Deliverable - Stakeholder matrix" milestone="true" start="Sep 2 2014 5:00PM" openForTimeEntry="true" lockedForScheduling="false" fixed="false" status="0" lastUpdatedDate="Mar 21 2014 12:58PM" orderID="1" evCalcMethod="0" summary="true" outlineLevel="1" finish="Sep 2 2014 5:00PM" key="false" percComp="0"><CustomInformation><ColumnValue name="a1_del_matrix_ver">0</ColumnValue><ColumnValue name="a1_del_required">Yes</ColumnValue><ColumnValue name="a1_deliverable_appr">NEW</ColumnValue><ColumnValue name="a1_is_deliverable">true</ColumnValue></CustomInformation></Task><Task lastUpdatedBy="5014001" name="Deliverable - Task Plan" milestone="true" start="Sep 8 2014 8:00AM" openForTimeEntry="true" lockedForScheduling="false" fixed="false" status="0" lastUpdatedDate="Mar 17 2014 11:37PM" orderID="1" evCalcMethod="0" summary="true" outlineLevel="1" finish="Sep 8 2014 8:00AM" key="false" percComp="0"><CustomInformation><ColumnValue name="a1_del_matrix_ver">0</ColumnValue><ColumnValue name="a1_del_required">Yes</ColumnValue><ColumnValue name="a1_deliverable_appr">NEW</ColumnValue><ColumnValue name="a1_is_deliverable">true</ColumnValue></CustomInformation></Task><Task lastUpdatedBy="-99" name="Deliverable - Business Requirements Document (BRD)" milestone="true" start="Sep 5 2014 8:00AM" openForTimeEntry="true" lockedForScheduling="false" fixed="false" status="0" lastUpdatedDate="Mar 20 2014 12:30AM" orderID="1" evCalcMethod="0" summary="true" outlineLevel="1" finish="Sep 5 2014 8:00AM" key="false" percComp="0"><CustomInformation><ColumnValue name="a1_del_matrix_ver">0</ColumnValue><ColumnValue name="a1_del_required">Yes</ColumnValue><ColumnValue name="a1_deliverable_appr">NEW</ColumnValue><ColumnValue name="a1_is_deliverable">true</ColumnValue></CustomInformation></Task><Task lastUpdatedBy="5014001" name="Deliverable - RTB cost agreement" milestone="true" start="Sep 8 2014 8:00AM" openForTimeEntry="true" lockedForScheduling="false" fixed="false" status="0" lastUpdatedDate="Mar 21 2014 9:43AM" orderID="1" evCalcMethod="0" summary="true" outlineLevel="1" finish="Sep 8 2014 8:00AM" key="false" percComp="0"><CustomInformation><ColumnValue name="a1_del_matrix_ver">0</ColumnValue><ColumnValue name="a1_del_required">Yes</ColumnValue><ColumnValue name="a1_deliverable_appr">NEW</ColumnValue><ColumnValue name="a1_is_deliverable">true</ColumnValue></CustomInformation></Task><Task lastUpdatedBy="5014001" name="Deliverable - Cost & Benefit Plan (incl. Pricing Sheet)" milestone="true" start="Sep 12 2014 8:00AM" openForTimeEntry="true" lockedForScheduling="false" fixed="false" status="0" lastUpdatedDate="Mar 13 2014 11:53AM" orderID="1" evCalcMethod="0" summary="true" outlineLevel="1" finish="Sep 12 2014 8:00AM" key="false" percComp="0"><CustomInformation><ColumnValue name="a1_del_matrix_ver">0</ColumnValue><ColumnValue name="a1_del_required">Yes</ColumnValue><ColumnValue name="a1_deliverable_appr">NEW</ColumnValue><ColumnValue name="a1_is_deliverable">true</ColumnValue></CustomInformation></Task><Task lastUpdatedBy="5014001" name="Deliverable - FSD" milestone="true" start="Oct 6 2014 8:00AM" openForTimeEntry="true" lockedForScheduling="false" fixed="false" status="0" lastUpdatedDate="Mar 13 2014 11:53AM" orderID="1" evCalcMethod="0" summary="true" outlineLevel="1" finish="Oct 6 2014 8:00AM" key="false" percComp="0"><CustomInformation><ColumnValue name="a1_del_matrix_ver">0</ColumnValue><ColumnValue name="a1_del_required">Yes</ColumnValue><ColumnValue name="a1_deliverable_appr">NEW</ColumnValue><ColumnValue name="a1_is_deliverable">true</ColumnValue></CustomInformation></Task><Task lastUpdatedBy="5014001" name="Deliverable - Authorisation conc...

    This above is a copy of the process log. However, the tasks are not created. Any ideas on this would be appreciated.



  • 2.  RE: How to XOG new task (copied from another project)

    Posted May 28, 2014 04:28 PM

    Any error in the xog output ?

    NJ



  • 3.  RE: How to XOG new task (copied from another project)

    Posted May 28, 2014 04:35 PM
    navzjoshi00:

    Any error in the xog output ?

    NJ


    Error importing tasks. Task insert status: ; Total number of objects:

    Error importing tasks. Number of failed objects: ; Total number of objects

    Error severity: ; Error message:

    Logging out 

    Script goes like:

    <gel:set asString="true" var="task_insert_status" select="$task_create/soapenv:Envelope/soapenv:Body/XOGOutput/Status/@state"/>
     <gel:set asString="true" var="total_records" select="$task_create/soapenv:Envelope/soapenv:Body/XOGOutput/Statistics/@totalNumberOfRecords"/>
     <gel:set asString="true" var="failed_records" select="$task_create/soapenv:Envelope/soapenv:Body/XOGOutput/Statistics/@failureRecords" />
     <gel:set asString="true" var="updated_records" select="$task_create/soapenv:Envelope/soapenv:Body/XOGOutput/Statistics/@updatedRecords"/>
     
     <gel:log>Error importing tasks. Task insert status: ${task_insert_status}; Total number of objects: ${total_records}</gel:log>
     
     
     <core:if test="${failed_records !=0}"> <!-- ERROR -->      
      <gel:log>Error importing tasks. Number of failed objects: ${failed_records}; Total number of objects: ${total_records}</gel:log>
      
      <gel:set asString="true" var="err_severity" select="$task_create/soapenv:Envelope/soapenv:Body/XOGOutput/Records/Record/ErrorInformation/Severity/text()" />
      <gel:set asString="true" var="err_message" select="$task_create/soapenv:Envelope/soapenv:Body/XOGOutput/Records/Record/ErrorInformation/Description/text()"/>
      <gel:log> Error severity: ${err_severity}; Error message: ${err_message}</gel:log>
     </core:if>
     
     





  • 4.  RE: How to XOG new task (copied from another project)

    Posted May 28, 2014 05:18 PM
    navzjoshi00:

    Any error in the xog output ?

    NJ


    I have tried to import the xml via XOG client. That invokes a lot of errors:
    Request Document: C:\Users\rnitram\Documents\XOG\MY_XOG\Tasktest.xml
    Writing output to 20140528_v03.xml
    Failed to retrieve response document
    com.niku.xog.XOGException: java.lang.RuntimeException: HTTP Error: Status-Code:
    500: Internal Server Error
            at com.niku.xog.client.XOGClient.processRequest(XOGClient.java:1096)
            at com.niku.xog.client.XOGClient.processRequest(XOGClient.java:1007)
            at com.niku.xog.client.XOGClient.processRequest(XOGClient.java:679)
            at com.niku.xog.client.XOGClient.processRequest(XOGClient.java:589)
            at com.niku.xog.client.XOGClient.processRequests(XOGClient.java:1435)
            at com.niku.xog.client.XOGClient.processCmd(XOGClient.java:1358)
            at com.niku.xog.client.XOGClient.startShell(XOGClient.java:1287)
            at com.niku.xog.client.XOGClient.invokeCommand(XOGClient.java:1248)
            at com.niku.xog.client.XOGClient.main(XOGClient.java:142)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at com.werken.forehead.Forehead.run(Forehead.java:551)
            at com.werken.forehead.Forehead.main(Forehead.java:581)
    Caused by: java.lang.RuntimeException: HTTP Error: Status-Code: 500: Internal Se
    rver Error
            at com.niku.union.xml.SimpleSOAPMessage.processRequest(SimpleSOAPMessage
    .java:316)
            at com.niku.union.xml.SimpleSOAPMessage.send(SimpleSOAPMessage.java:88)
            at com.niku.union.xml.SimpleSOAPMessage.send(SimpleSOAPMessage.java:79)
            at com.niku.union.xml.SimpleSOAPMessage.send(SimpleSOAPMessage.java:56)
            at com.niku.xog.client.XOGClient.processRequest(XOGClient.java:1092)
            ... 14 more
      
    The xml-file looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
     <Header action="write" externalSource="NIKU" objectType="project" version="6.0.11"/>
     <Projects>
      <Project projectID="PRJ0000208" name="Test FGAP-Anlage wg. Stages und Tasks (20140528-MR / JL)">
      <Tasks>
      <Task evCalcMethod="0" finish="2014-09-02T17:00:00" fixed="false" internalTaskID="5033812" key="false" lastUpdatedBy="5014001" lastUpdatedDate="2014-03-21T12:58:04.940" lockedForScheduling="false" milestone="true" name="Deliverable - Stakeholder matrix" openForTimeEntry="true" orderID="1" outlineLevel="1" percComp="0" start="2014-09-02T17:00:00" status="0" summary="true"/>
      <CustomInformation>
       <ColumnValue name="a1_del_matrix_ver">0</ColumnValue>
       <ColumnValue name="a1_del_required">Yes</ColumnValue>
       <ColumnValue name="a1_deliverable_appr">NEW</ColumnValue>
       <ColumnValue name="a1_is_deliverable">true</ColumnValue>
      </CustomInformation>
      </Task>
      </Tasks>
      </Project>
     </Projects>
    </NikuDataBus>

     



  • 5.  RE: How to XOG new task (copied from another project)

    Posted May 28, 2014 07:31 PM
    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>





  • 6.  RE: How to XOG new task (copied from another project)

    Posted May 29, 2014 06:42 PM

    I found now that the header section was incomplete. However, if I adjust the script to simply:

      <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"/>
       <Projects>
        <Project name="${vs_prj_name_new}" projectID="${vs_prj_code_new}">
         <Tasks>
          <Task taskID="PROJECT_OLD" finish="2014-05-25T08:00:00" fixed="false" key="false" lockedForScheduling="false" milestone="true" name="Import - Test" openForTimeEntry="true" orderID="1" outlineLevel="1" percComp="0" start="2014-05-15T08:00:00" status="0" summary="true">
          </Task>
         </Tasks>
        </Project>
       </Projects>
      </NikuDataBus>
     </gel:parse>

    The taskid is only a test, I still want to insert new tasks into project without any...

     

    It throws an error still:

    org.apache.commons.jelly.JellyTagException: null:104:96:

    The Soap-Envelope reads like this:

         <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"/>
            </soapenv:Body>
           </soapenv:Envelope>
          </soap:message>
         </soap:invoke>
     

    If anyone could provide me with a sample on how to insert new tasks into an existing project, that would be of great convenience... Please...



  • 7.  RE: How to XOG new task (copied from another project)

    Posted May 30, 2014 03:08 AM

     

    I did this a while back as an exercise to a earlier post.

    It inserts a summary task and a task to each level 1 task within a given project.

    <?xml version="1.0" encoding="utf-8"?>
    <gel:script
        xmlns:core="jelly:core"
        xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"
        xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
        xmlns:nikuq="http://www.niku.com/xog/Query"
        xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:sql="jelly:sql"
        xmlns:util="jelly:util"
        xmlns:x="jelly:org.apache.commons.jelly.tags.xml.XMLTagLibrary"
        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:out>Pull Project list via SQL</gel:out>
    
        <!-- Connecting to Database -->
        <gel:setDataSource dbId="niku"/>
    
        <!-- Pull a list of projects along with the id of the task that is at level=1 and prwbssequence=1 -->
        <sql:query dataSource="${clarityDS}" var="queryResults">
            <![CDATA[    
    with havesupport as (
    select pr.prid, pr.prstart, pr.prfinish, pt.prname, pt.prwbslevel
    from prj_projects pr
    left outer join prtask pt on pt.prprojectid = pr.prid
    where pt.prname = '08_SUPPORT_A'),
    phasetask as (
    select pt.prprojectid, pt.prid as phaseid
    from prtask  pt
    where pt.prwbslevel = 1 and pt.prwbssequence = 1
    )
    select pp.prid, iv.code, iv.name, pp.prstart, pp.prfinish, pt.phaseid
    from prj_projects pp
    inner join inv_investments iv on iv.id = pp.prid
    left outer join phasetask pt on pt.prprojectid = pp.prid
    left outer join havesupport hs on pp.prid = hs.prid
    where hs.prid is null
    order by iv.name
    ]]>
        </sql:query>
    
        <!-- The project read project request xml -->
        <gel:parse var="readProject">
            <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">
                <Header version="6.0.11" action="read" objectType="project" externalSource="NIKU">
                    <!-- you change the order by simply swap 1 and 2 number in the name attribute -->
                    <args name="order_by_1" value="name"/>
                    <args name="order_by_2" value="projectID"/>
                    <args name="include_tasks" value="true"/>
                    <args name="include_dependencies" value="false"/>
                    <args name="include_subprojects" value="false"/>
                    <args name="include_resources" value="false"/>
                    <args name="include_baselines" value="false"/>
                    <args name="include_allocations" value="false"/>
                    <args name="include_estimates" value="false"/>
                    <args name="include_actuals" value="false"/>
                    <args name="include_custom" value="false"/>
                    <args name="include_burdening" value="false"/>
                </Header>
                <Query>
                    <Filter name="projectID" criteria="EQUALS">PRJ00000728</Filter>
                </Query>
            </NikuDataBus>
        </gel:parse>
    
    
        <!-- The write project request xml -->
        <gel:parse var="tasks">
            <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_project.xsd">
                <Header version="6.0.11" action="write" objectType="project" externalSource="NIKU"/>
                <Projects>
                    <Project projectID="projectID" name="name">
                        <Tasks>
                            <Task name="SUPPORT_A" outlineLevel="2"
                                summary="true" taskID=" 08_SUPPORT_A">
                            </Task>
                            <Task name="SUPPORT" outlineLevel="3"
                                summary="false" taskID=" 08_SUPPORT">
                            </Task>
                        </Tasks>
                    </Project>
                </Projects>
            </NikuDataBus>
        </gel:parse>
    
    
        <gel:out>Log into Clarity</gel:out>
    
        <!-- Set our url to our clariy xog endpoint -->
        <core:set var="urlEndpoint" value="${hostUrl}/niku/xog"/>
    
        <!-- Log into XOG and get a session ID     -->
        <soap:invoke endpoint="${urlEndpoint}" 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>${username}</xog:Username>
                            <xog:Password>${password}</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" var="sessionID" select="$auth//xog:SessionID/text()" />
        <core:choose>
            <core:when test="${sessionID == null}">
                <gel:out>Couldn't Log in.  Check the username/password.</gel:out>
                <!-- Is there a way to end the script at this point? -->
            </core:when>
            <core:otherwise>
                <gel:out>SessionID = ${sessionID}</gel:out>
            </core:otherwise>
        </core:choose>
    
        <!-- Loop through our records an add task to projects that have a summary / phase task -->
        <core:set var="loopBreak" value="1" />
        <core:forEach items="${queryResults.rowsByIndex}" trim="true" var="row">
            <core:set var="prid" value="${row[0]}" />
            <core:set var="code" value="${row[1]}"/>
            <core:set var="prname" value="${row[2]}"/>
            <core:set var="prStart" value="${row[3]}"/>
            <core:set var="prFinish" value="${row[4]}"/>
            <core:set var="phaseId" value="${row[5]}"/>
    
            <!-- Check to see if the project has a level 1 task to attach our tasks to -->
            <core:if trim="true" test="${phaseId gt 0}">
                <gel:log message="Processing  ${prname}" />
                <gel:set value="${code}" select="$readProject/NikuDataBus[1]/Query[1]/Filter[1]/text()" />
    
                <!-- Read our Project Object into our projectResults -->
                <soap:invoke endpoint="${urlEndpoint}" var="projectResults">
                    <soap:message>
                        <soapenv:Envelope>
                            <soapenv:Header>
                                <Auth>
                                    <xog:SessionID>${sessionID}</xog:SessionID>
                                </Auth>
                            </soapenv:Header>
                            <soapenv:Body>
                                <xog:ReadProject>
                                    <gel:include select="$readProject"/>
                                </xog:ReadProject>
                            </soapenv:Body>
                        </soapenv:Envelope>
                    </soap:message>
                </soap:invoke>
    
                <!-- Add our task to the project we retrieved  -->
                <gel:set value="${code}" select="$tasks/NikuDataBus[1]/Projects[1]/Project[1]/@projectID" />
                <gel:set value="${prname}" select="$tasks/NikuDataBus[1]/Projects[1]/Project[1]/@name" />
    
                <!-- Write our Project Object into our projectResults including our new tasks -->
                <soap:invoke endpoint="${urlEndpoint}" var="projectResults">
                    <soap:message>
                        <soapenv:Envelope>
                            <soapenv:Header>
                                <Auth>
                                    <xog:SessionID>${sessionID}</xog:SessionID>
                                </Auth>
                            </soapenv:Header>
                            <soapenv:Body>
                                <xog:WriteProject>
                                    <gel:include select="$tasks"/>
                                </xog:WriteProject>
                            </soapenv:Body>
                        </soapenv:Envelope>
                    </soap:message>
                </soap:invoke>
            </core:if>
    
    
            <!-- Loop a couple to time  to see if we got it right then comment out to do all -->
            <core:set var="loopBreak" value="${loopBreak + 1}" />
            <core:break test="${loopBreak gt 3}" />
    
        </core:forEach>
    
    </gel:script>

     

    V/r,

    Gene



  • 8.  RE: How to XOG new task (copied from another project)

    Posted May 30, 2014 04:48 PM

    Thank you very much for this sample script, Gene. - Unfortunately, no task is created in the target-project. Could this be due to the outline levels (no task exists in the current project)? - Even if I create a "root node" task called Project I do not receive any additional ones... Probably I need to write the XML output to a file, but do not know how to do this...



  • 9.  RE: How to XOG new task (copied from another project)
    Best Answer

    Posted May 30, 2014 05:17 PM

     

        <gel:serialize fileName="savedXmlOutput.xml" var="${theXmlVariable}" />

     

    Once you have your XML file you can check if it is well formed.  You can also test it against the Object wsdl with SoapUi.

    V/r,

    Gene



  • 10.  RE: How to XOG new task (copied from another project)

    Posted Jun 02, 2014 11:15 AM

    Thank you, Gene! Unfortunately our XOG-user does not have the appropriate privileg to do so. Is there a way to gel:log specific nodes?



  • 11.  RE: How to XOG new task (copied from another project)

    Posted Jun 02, 2014 11:54 AM

     

    Try

    <gel:log><gel:expr select="$theXmlVariable"></gel:log>

    V/r,

    Geen