Saturday 25 May 2013

HumanTask expiration setting using xpath in SOA 11g


Use Case-The scenario is suppose we have a single Human Task in a composite that required a multiple approval level by users from different roles or groups and in some initial level if user not approves it on time then exit the Human Task for that group after certain time limit and escalate to his manager or other group or take some other action.
So to achieve this we will create a HumanTask and a one way Bpel process that will use this Human Task
So First create a SOA application SampleHumanTask and a SOA project SampleHumanTask.
The sample xsd(SampleHTRequest.xsd) that is used in the is as mentioned below.

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://www.sampleHW.org"
            targetNamespace="http://www.sampleHW.org"
            elementFormDefault="qualified">
  <xsd:element name="HTRequest">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="ProjectName" type="xsd:string"/>
        <xsd:element name="URL"   type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

So first create a Human Task named as ApprovalHumanTask and select HTRequest as data in HumanTask data section.


Now go to assignment section to assign task owner-
Click on the Edit participant section-
Here I am assigning user using expression-
/task:task/task:systemAttributes/task:approvers


 
Now in Human task Deadlines section –
 
Task Duration setting by default is set to never expire
Set it to expire after and select by expression. In this you can set expiration detail data dynamically.
Either you can create a variable in your payload that will have expiration detail. Here for sample I am using custom attribute.
/task:task/task:customAttributes/task:customAttributeString1
So here customAttributeString1 will be used here to set the task expiration time
Task should look like this

Now create SampleBpel (one way)
Composite Should look as shown below.

  
Drop a human task in your bpel process and select the ApprovalHumanTask.


Now we will set the expiration duration dynamically.
So here I am going to set task expiration to 1 day from the assigned date.
For that Duration Data Type I need to set value to P1D.like if you want to set the expiration to 1 minutes for that the value need to be PT1M.
For more details please check Duration Data Type link (http://www.w3schools.com/schema/schema_dtypes_date.asp).

Assign approver user and expiration duration

NOTE-If you are using the same HumanTask for other groups or roles where there is no expiration duration for that also you need to P0D.if you leave it blank or set some other data that not follows the standard you will get the routing slip error in other task invocation.

Once the task expires the task state will be EXPIRED.By using that you can check that task is expired and the the necessary action.

Deploy  it and test it we will see the task expiration time also.