Saturday 28 June 2014

Custom Escalation in human workflow in SOA 11g


To do a custom escalation in human task so when it a fixed duration expires it gets escalated to a different user.


For that we need to write a java class that implements IDynamicTaskEscalationPattern interface
You need to place this class into oracle.bpel.services.workflow.assignment.dynamic package
Create a CustomEscalator project 
Make sure you select the below mentioned libraries

 


Create a class CustomEscalator that implements IDynamicTaskEscalationPattern interface.
 
package oracle.bpel.services.workflow.assignment.dynamic;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import oracle.bpel.services.workflow.task.model.Task;

public class CustomEscalator implements IDynamicTaskEscalationPattern {
    String user;
   
    public CustomEscalator() { 
        super();
        System.out.println("***************default constructor****************");
    }

    public String getTaskEscalationUser(Task task) throws DynamicPatternException {
         System.out.println ("***************getTaskEscalationUser**************");
         System.out.println("Escalation User is "+user);
      //   task.setTitle("");
      //   String title="Escalated Task: "+"User” +task.getOwnerGroup() +task.getTitle();
      //   System.out.println("Title "+title);
      //   task.setTitle (title);
        if (user!=null)
            return user;
        else
        return "testuser1";
    }
    public void setInitParams(Map<String, String> map) throws DynamicPatternException {
        System.out.println("**********setInitParams********************");
        System.out.println(map);
        String escalatedUser=map.get ("user");
        System.out.println("Escalated UserName is "+escalatedUser);
        user=escalatedUser;
    }

    public String getName() {
        return "CustomEscalator";
    }

    public String getLabel(Locale locale) {
        return null;
    }

    public String getDescription(Locale locale) {
        return null;
    }
    public Set<IDynamicPattern.IDynamicPatternParameter> getPatternParameters() {
        System.out.println("*******************getPatternParameters*****************");
        return Collections.emptySet();
    }



Deploy this as a jar.
Now we need to place this jar into soa server but before doing we will configure this escalation class through EM
 Login to EM
Navigate to SOA-infra/SOA-Administration/Workflow-Properties
Click on Task
Click on add function
Function Name- CustomEscalator.
Classpath- oracle.bpel.services.workflow.assignment.dynamic.CustomEscalator.

 
We can also specify function parameter also but they are optional
We can get these properties in our custom java class
Here for example I am setting an escalation username as ‘escalationUser’  in this function parameter but this user should  exist in weblogic realm.




Now we will set the customEscalation.jar  to weblogic Classpath.
Navigate to C :\< Middleware Home> \Oracle_SOA1\soa\modules\oracle.soa.ext_11.1.1
Place this jar in this folder and run ant in this folder.
Restart the soa server after doing this.

Now go to human task deadline section and set escalation after 3 minute for testing set Custom Escalation Java Class-CustomEscalation

 


Once this task get expires after 3 minutes it gets assigned to escalated user.
 
 

2 comments:

  1. Hi Pankaj,

    Nice Post.
    We have a requirement where we need to escalate the task to managers manager of some days ex 3days. after escalation the task should be available in both managers queue and managers manager queue ie both can approve the task.

    Using this approach we can set any user after the task gets escalated. can we assign the task to two users, in my case to manager and managers manager?
    If yes, Please let me know the approach.

    Please let me know if you did not understood my question.

    Thanks,
    Ravi

    ReplyDelete
  2. Thanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle SOA . Actually I was looking for the same information on internet for Oracle SOA and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can learn more aboutOracle SOA . By attending Oracle SOA Training .

    ReplyDelete