Wednesday, January 30, 2013

Passing custom attributes through Human workflow TaskQuery webservice

In my project there were multiple modules like task Management and Project Module. Each module has human workflow implemented .Customer requirement is to list all the tasks from different modules under a single Manage Tasks page.  So we had to differentiate the different human tasks from each module while listing and fetching details specific to the tasks.  So we had to pass some unique values as part of the payload while the j2ee application queries the TaskService API.
The way to do is to use the flex fields under systemMessageAttributes .
In the assign operation of Human task invocation assign the attributes that need to be passed. Since we pass in the category or module as textAttribute2 the web app will use that to identify which module the id belongs to and fetched details based on the id from corresponding module tables.
Refer table below.


Output values
Human TASKQueryAPI
ID
$initiateTaskInput.payload/task:task/task:systemMessageAttributes/task:textAttribute1
CATEGORY
$initiateTaskInput.payload/task:task/task:systemMessageAttributes/task:textAttribute2
ACTION
$initiateTaskInput.payload/task:task/task:systemMessageAttributes/task:textAttribute3
EXPIRYTIME
$initiateTaskInput.payload/task:task/task:systemMessageAttributes/task:textAttribute4


For Querying the task list and fetching flex fields

Refer sample payload  in table below.
Method:  queryTasks


Input
   <soapenv:Header/>
   <soapenv:Body>
      <tas:taskListRequest>
         <com:workflowContext>
<com:credential>
               <com:login>georgethomas@geo.com</com:login>
               <com:password>welcome1</com:password>
               <com:identityContext>myrealm</com:identityContext>
            </com:credential>
           </com:workflowContext>
         <tas1:taskPredicateQuery startRow="0" endRow="0">
            <tas1:displayColumnList>
                   <tas1:displayColumn>title</tas1:displayColumn>
                   <tas1:displayColumn>state</tas1:displayColumn>
                  <tas1:displayColumn>createdDate</tas1:displayColumn>
                  <tas1:displayColumn>expirationdate</tas1:displayColumn>
                  <tas1:displayColumn>priority</tas1:displayColumn>
                  <tas1:displayColumn>taskNumber</tas1:displayColumn>
                  <tas1:displayColumn>instanceid</tas1:displayColumn>
                   <tas1:displayColumn>textAttribute1</tas1:displayColumn>
                <tas1:displayColumn>textAttribute2</tas1:displayColumn>
                <tas1:displayColumn>textAttribute3</tas1:displayColumn>
                <tas1:displayColumn>textAttribute4</tas1:displayColumn>

              </tas1:displayColumnList>
          <tas1:predicate>             
            <tas1:assignmentFilter>My</tas1:assignmentFilter> 
              <tas1:clause joinOperator="AND" xmlns="http://xmlns.oracle.com/bpel/workflow/taskQuery">
                <tas1:column>state</tas1:column>
                <tas1:operator>eq</tas1:operator>
                <tas1:value>ASSIGNED</tas1:value>
                      </tas1:clause>
          </tas1:predicate>
         </tas1:taskPredicateQuery>
      </tas:taskListRequest>
   </soapenv:Body>
</soapenv:Envelope>




Output
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header/>
   <env:Body>
      <taskListResponse xmlns="http://xmlns.oracle.com/bpel/workflow/taskQueryService">
         <task xmlns="http://xmlns.oracle.com/bpel/workflow/task">
            <title>Approve Project Tasks :Project Name - SOA Suite Full Migration TaskName data</title>
            <priority>3</priority>
            <processInfo/>
            <systemAttributes>
               <assignedDate>2013-01-29T03:54:59-05:00</assignedDate>
               <assigneeUsers>
                  <id>georgethomas@geo.com</id>
                  <type>user</type>
               </assigneeUsers>
               <createdDate>2013-01-29T03:54:59-05:00</createdDate>
               <digitalSignatureRequired>false</digitalSignatureRequired>
               <expirationDate>2013-01-29T03:59:59-05:00</expirationDate>
               <fromUser>
                  <type>user</type>
               </fromUser>
               <numberOfTimesModified>1</numberOfTimesModified>
               <state>ASSIGNED</state>
               <systemActions>
                  <action>VIEW_TASK</action>
                  <displayName>VIEW_TASK</displayName>
               </systemActions>
               <taskId>eb792a23-7b1a-4c95-bda6-897fe8e88c5f</taskId>
               <taskNumber>200070</taskNumber>
               <updatedBy>
                  <id>workflowsystem</id>
                  <type>user</type>
               </updatedBy>
               <updatedDate>2013-01-29T03:54:59-05:00</updatedDate>
               <version>1</version>
               <taskDefinitionId>dev/TaskExecutionApprovalProcess!1.0/PMTaskApproval</taskDefinitionId>
               <workflowPattern>Participant</workflowPattern>
               <participantName>Project Manager Approval</participantName>
               <assignees>
                  <id>georgethomas@geo.com</id>
                  <type>user</type>
               </assignees>
               <isPartialTask>true</isPartialTask>
            </systemAttributes>
         <systemMessageAttributes>
               <textAttribute1> 1234</textAttribute1>
               <textAttribute2>TASK</textAttribute2>
               <textAttribute3>APPROVE,REJECT </textAttribute3>
               <textAttribute4> </textAttribute4>
            </systemMessageAttributes>

            <callback/>
            <sca/>
            <taskDefinitionId>dev/TaskExecutionApprovalProcess!1.0/PMTaskApproval</taskDefinitionId>
            <mdsLabel>soa_c0dc1fb9-f1b7-4e5c-80d2-6520f9eb96d8</mdsLabel>
            <customAttributes/>
         </task>
     
</taskListResponse>
   </env:Body>
</env:Envelope>







Thursday, January 24, 2013

Human worklist API TaskQueryService-querying tasks and updating outcome from J2ee application


Querying the task list


Method:  queryTasks


Input
   <soapenv:Header/>
   <soapenv:Body>
      <tas:taskListRequest>
         <com:workflowContext>
<com:credential>
               <com:login>georgethomas@geo.com</com:login>
               <com:password>welcome1</com:password>
               <com:identityContext>myrealm</com:identityContext>
            </com:credential>
           </com:workflowContext>
         <tas1:taskPredicateQuery startRow="0" endRow="0">
            <tas1:displayColumnList>
                   <tas1:displayColumn>title</tas1:displayColumn>
                   <tas1:displayColumn>state</tas1:displayColumn>
                  <tas1:displayColumn>createdDate</tas1:displayColumn>
                  <tas1:displayColumn>expirationdate</tas1:displayColumn>
                  <tas1:displayColumn>priority</tas1:displayColumn>
                  <tas1:displayColumn>taskNumber</tas1:displayColumn>
                  <tas1:displayColumn>instanceid</tas1:displayColumn>
              </tas1:displayColumnList>
          <tas1:predicate>             
            <tas1:assignmentFilter>My</tas1:assignmentFilter> 
              <tas1:clause joinOperator="AND" xmlns="http://xmlns.oracle.com/bpel/workflow/taskQuery">
                <tas1:column>state</tas1:column>
                <tas1:operator>eq</tas1:operator>
                <tas1:value>ASSIGNED</tas1:value>
                      </tas1:clause>
          </tas1:predicate>
         </tas1:taskPredicateQuery>
      </tas:taskListRequest>
   </soapenv:Body>
</soapenv:Envelope>




Output
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header/>
   <env:Body>
      <taskListResponse xmlns="http://xmlns.oracle.com/bpel/workflow/taskQueryService">
         <task xmlns="http://xmlns.oracle.com/bpel/workflow/task">
            <title>Approve Project Tasks :Project Name - SOA Suite Full Migration TaskName data</title>
            <priority>3</priority>
            <processInfo/>
            <systemAttributes>
               <assignedDate>2013-01-29T03:54:59-05:00</assignedDate>
               <assigneeUsers>
                  <id>georgethomas@geo.com</id>
                  <type>user</type>
               </assigneeUsers>
               <createdDate>2013-01-29T03:54:59-05:00</createdDate>
               <digitalSignatureRequired>false</digitalSignatureRequired>
               <expirationDate>2013-01-29T03:59:59-05:00</expirationDate>
               <fromUser>
                  <type>user</type>
               </fromUser>
               <numberOfTimesModified>1</numberOfTimesModified>
               <state>ASSIGNED</state>
               <systemActions>
                  <action>VIEW_TASK</action>
                  <displayName>VIEW_TASK</displayName>
               </systemActions>
               <taskId>eb792a23-7b1a-4c95-bda6-897fe8e88c5f</taskId>
               <taskNumber>200070</taskNumber>
               <updatedBy>
                  <id>workflowsystem</id>
                  <type>user</type>
               </updatedBy>
               <updatedDate>2013-01-29T03:54:59-05:00</updatedDate>
               <version>1</version>
               <taskDefinitionId>dev/TaskExecutionApprovalProcess!1.0/PMTaskApproval</taskDefinitionId>
               <workflowPattern>Participant</workflowPattern>
               <participantName>Project Manager Approval</participantName>
               <assignees>
                  <id>georgethomas@geo.com</id>
                  <type>user</type>
               </assignees>
               <isPartialTask>true</isPartialTask>
            </systemAttributes>
            <systemMessageAttributes/>
            <callback/>
            <sca/>
            <taskDefinitionId>dev/TaskExecutionApprovalProcess!1.0/PMTaskApproval</taskDefinitionId>
            <mdsLabel>soa_c0dc1fb9-f1b7-4e5c-80d2-6520f9eb96d8</mdsLabel>
            <customAttributes/>
         </task>
     
</taskListResponse>
   </env:Body>
</env:Envelope>


Updating the outcome of a task(without modifying payload)

Method:  updateTaskOutcome
Notes:  The tags which need to be modified for each invoke are shown.
The credentials will have to be the assignee of the task


Input
   <soapenv:Header/>
   <soapenv:Body>
      <tas:updateTaskOutcome>
         <com:workflowContext>
            <com:credential>
               <com:login>georgethomas@geo.com</com:login>
               <com:password>welcome1</com:password>
               <com:identityContext>myrealm</com:identityContext>

            </com:credential>

         </com:workflowContext>
         <tas:taskId>cffb7b12-c5ba-4e6b-85fb-961ee0504f4f</tas:taskId>
         <tas:outcome>APPROVE</tas:outcome>
      </tas:updateTaskOutcome>
   </soapenv:Body>
</soapenv:Envelope>

Tuesday, December 4, 2012

Incrementing Logic in XSL for SEQUENCE in multiple for-loops



I had a requirement where there was multiple for-loops and they wanted to increment the sequence value in loop under the inner loop but counter should be unique irrespective of the loop.
I will take the example of ShipmentItem &ShipmentStop. So if there are 2 ShipmentItems and 3 ShipmentStops then it should be incremented from 1 to 6. Since XSL
Doesn’t support out-of-the box increment as it is not a programming logic,I had to look for a work-around.
ShipmentItem records will form the outer loop and ShipmentStop records the inner loop.
So for using the increment logic I used count(preceding-sibling:: NODE) function .

I am attaching the XSL code snippet for easier implementation and understanding.

$SEQ_COUNTER variable will have the unique sequence ID.

  
  <xsl:template match="/">
    <top:testCollection>
      <xsl:for-each select="/eboebo:UpdateShipmentEBM/eboebo:DataArea/eboebo:UpdateShipment/ns5:ShipmentItem">
  <xsl:variable name="LOOP1_COUNTER">
     <xsl:value-of select="count(preceding-sibling::ns5:ShipmentItem)"/>
   </xsl:variable>
  <xsl:variable name="COUNTER">
     <xsl:value-of select="count(../ns5:Custom/ns6:ShipmentStop)"/>
  </xsl:variable>     
     
  <xsl:for-each select="../ns5:Custom/ns6:ShipmentStop">
    
   <!--looping logic for sequence ids  -->
  <xsl:variable name="LOOP2_COUNTER">
    <xsl:value-of select="count(preceding-sibling::ns6:ShipmentStop)+1"/>
  </xsl:variable>
  <xsl:variable name="SEQ_COUNTER">
   <xsl:choose>
   <xsl:when test="$LOOP1_COUNTER='0'">
     <xsl:value-of select="$LOOP2_COUNTER"/>
   </xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="($LOOP1_COUNTER*$COUNTER)+$LOOP2_COUNTER"/>
   </xsl:otherwise>
   </xsl:choose>
    </xsl:variable>
    <top:test1>
    
   <top:ID_counter>
    
     <xsl:value-of select="number($NN) +number($SEQ_COUNTER)"/>
   </top:ID_counter>
     
     ................
     .............
     
   <top:test1>   
   
     </xsl:for-each>
          
        </xsl:for-each>