Showing posts with label Oracle SOA 11g. Show all posts
Showing posts with label Oracle SOA 11g. Show all posts

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.