Using Oracle BPM Activity Guide APIs

We have recently heard of the usage of the ‘Process Driven UI’ pattern fairly often (particularly with Oracle BPM 11 banking customers). I hope to be able to write up more about this pattern in a later blog. But the crux of the pattern is: BPM processes drive what UI screen needs to be painted next. As you can imagine, latency is all too important a criterion along with back-end processing for successful implementation of that pattern.

For now, my endeavour was to use the Activity Guide APIs to generate the data seen on the workspace Activity Guide tab. This is hopefully useful for customers who want to write their custom UI equivalent to the default Activity Guide tab off the default BPM workspace.  The screenshot is below. Please notice that my BPM process has two milestones and one Human Task under each milestone.

Assuming you have gotten the workflow context etc., fastforwarding to the meat of the issue: Using the PS4FP Activity Guide APIs, one needs to:

  • Get all Activity Guide instances for a given user (API call: agQuerySvc.queryAGDisplayInfos)
  • Iterate through the list of AGDisplayInfos and get an AGInstanceId
  • For each AGInstance Id, get the agDisplayInfo (agQuerySvc.getAGDisplayInfoDetailsById)
  • For each AGInstance Id, get the corresponding milestone (agDisplayInfo.getMilestoneDisplayInfo)
  • For each Milestone, get the taskList in that milestone (milestoneDisplayInfo.getTaskDisplayInfo)
  • For each task, fetch details, say status and title in this example (taskDisp1.getTask)

I have used the standard workflow java sample in Authenticate.java and enhanced it for this purpose. That is an easy starting point!
Please note the following in that context:
1. The build.xml needs another few jar files other than the one that is packaged with workflow java samples
2. As usual, the wf_client_config has connection details.
3. The bpm project MultipleTasks Project has 2 human tasks have been created, 2 milestones and each of these tasks belong to 1 milestone. The Process.Owner role is granted to jstein after deployment.

While the AGAPIs for PS4FP have been documented, please note that there are a few documentation bugs currently being worked on, including on the sample therein.
Caveat: Some code refactoring in terms of moving some constants to different jar files is expected. And so, the jars referenced here are likely to change in PS5 and beyond.

I am going to try putting the source code: The BPM Process and the java code on java.net..(If for whatever reason I cant, I will be sure to blog source code here soon…)

Happy exploring AG APIs.

(Editing post for source code etc. below)


import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.List;
import oracle.bpel.services.workflow.WorkflowException;
import oracle.bpel.services.workflow.client.IWorkflowServiceClient;
import oracle.bpel.services.workflow.client.IWorkflowServiceClientConstants;
import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory;
import oracle.bpel.services.workflow.query.ITaskQueryService;
import oracle.bpel.services.workflow.task.impl.TaskUtil;
import oracle.bpel.services.workflow.task.model.Task;
import oracle.bpel.services.workflow.verification.IWorkflowContext;

import oracle.bpel.services.bpm.common.IBPMContext;

import oracle.bpel.services.workflow.IWorkflowConstants;
import oracle.bpel.services.workflow.task.model.Task;
import oracle.bpel.services.workflow.verification.IWorkflowContext;
import oracle.bpel.services.workflow.query.impl.TaskQueryService;
import oracle.bpel.services.workflow.client.WorkflowServiceClientContext;
import oracle.bpel.services.workflow.metadata.config.ResourceBundleInfo;
import oracle.bpel.services.workflow.activityguide.query.IAGQueryService;
import oracle.bpel.services.workflow.activityguide.query.impl.AGQueryUtil;
import oracle.bpel.services.workflow.activityguide.query.*;
//import oracle.bpel.services.workflow.activityguide.query.impl.AGQueryService;
import oracle.bpel.services.workflow.activityguide.query.model.AGDisplayInfo;
import oracle.bpel.services.workflow.activityguide.query.model.MilestoneDisplayInfo;
import oracle.bpel.services.workflow.activityguide.metadata.IAGMetadataService;
import oracle.bpel.services.workflow.activityguide.metadata.impl.AGMetadataService;
import com.oracle.bpel.activityguide.instance.model.MilestoneInstanceType;
import oracle.bpel.services.workflow.activityguide.query.model.TaskDisplayInfoType;
import sun.security.util.Password;

import oracle.bpel.services.workflow.repos.Ordering;
import oracle.bpel.services.workflow.repos.Predicate;
import oracle.bpel.services.workflow.repos.TableConstants;

import oracle.bpel.services.workflow.IWorkflowConstants;
import oracle.bpel.services.workflow.client.IWorkflowServiceClient;
import oracle.bpel.services.workflow.client.IWorkflowServiceClientConstants;
import oracle.bpel.services.workflow.client.WorkflowServiceClientFactory;
import oracle.bpel.services.workflow.repos.Ordering;
import oracle.bpel.services.workflow.repos.Predicate;
import oracle.bpel.services.workflow.repos.TableConstants;

import oracle.bpel.services.workflow.repos.PredicateConstants;

import oracle.bpel.services.workflow.task.model.Task;
import oracle.bpel.services.workflow.verification.IWorkflowContext;
import oracle.bpel.services.workflow.activityguide.query.model.AGDisplayInfo;
import oracle.bpel.services.workflow.activityguide.query.model.MilestoneDisplayInfoType;
import com.oracle.bpel.activityguide.instance.model.MilestoneInstanceTypeImpl;
import oracle.bpel.services.workflow.task.model.Task;
import oracle.bpel.services.workflow.task.model.TaskType;

public class Authenticate
{

private static IWorkflowContext ctx;
 private static ITaskQueryService querySvc ;
 private static IWorkflowServiceClient wfSvcClient;
 public static void main(String[] args) throws Exception {
 if (args.length != 3 || !("SOAP".equals(args[0]) || "REMOTE".equals(args[0]))) {
   System.out.print("Usage java Authenticate protocol(SOAP/REMOTE) user(jcooper) password(welcome1)");
   return;
 }
 authenticate(args[0], args[1], args[2]);
}

public static void authenticate(String protocol, String user, String password)
 throws WorkflowException {

System.out.println("Authenticating user " + user + ".....");

Map<IWorkflowServiceClientConstants.CONNECTION_PROPERTY, String> properties =
 new HashMap<IWorkflowServiceClientConstants.CONNECTION_PROPERTY, String>();
 //added below and commented out from wfclientconfig.xml
 properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_PRINCIPAL, "weblogic");//weblogic username
 properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_CREDENTIALS, "welcome1");//plain pwd

 // get the client
 //IWorkflowServiceClient wfSvcClient = WorkflowServiceClientFactory.getWorkflowServiceClient(protocol, properties, Util.getLogger());
 wfSvcClient = WorkflowServiceClientFactory.getWorkflowServiceClient(protocol, properties, Util.getLogger());
 querySvc = wfSvcClient.getTaskQueryService();
 // IWorkflowContext ctx = querySvc.authenticate(user, password.toCharArray(), "jazn.com");
 IWorkflowContext ctx = querySvc.authenticate(user, password.toCharArray(), "jazn.com");
 if (ctx == null)
 {
   System.out.println("ctx is null");
 } else {
   System.out.println("Authenticated successfully");
   System.out.println("Authenticated user info from IWorkflowContext:");
   System.out.println("Context created time: " + (new Date(ctx.getStartDateTime())));
   System.out.println("User: " + ctx.getUser());
   System.out.println("User Time Zone: " + ctx.getTimeZone().getDisplayName());
   System.out.println("User Locale: " + ctx.getLocale());
 }

 try{
   //calling testquery
   testQueryAGDisplayInfos();
 }
 catch (Exception eee){
   System.out.println("error");
   eee.printStackTrace();
 }

 }

private static void testQueryAGDisplayInfos()
 throws Exception
 {
   List agQueryColumns = new ArrayList();
   // agQueryColumns.add("MILESTONE_STATE");
   // agQueryColumns.add("DEFINITION_ID");
   //List agQueryColumns = new ArrayList();
   agQueryColumns.add("IDENTIFICATION_KEY");
   agQueryColumns.add("TITLE");
   agQueryColumns.add("CREATOR");
   agQueryColumns.add("CREATION_DATE");
   agQueryColumns.add("STATUS");
   IAGQueryService agQuerySvc = wfSvcClient.getAGQueryService();
   System.out.println("after AGQuerySVC");
   //Ordering order = new Ordering(TableConstants.WFTASK_INSTANCEID_COLUMN, false, true);

   // Query for all AG instances belonging to user say jstein
   List agDisplayInfoList =
   agQuerySvc.queryAGDisplayInfos(IAGQueryService.AG_PROCESS_TYPE_BPM, ctx,
   new ArrayList(),
   IAGQueryService.AGAssignmentFilter.ADMIN,
   null, //agPredicate,
   null, //ordering,
   0,
   0);

   List taskList=null;
   for (int a=0; a<agDisplayInfoList.size();a++)
   {
     String instanceId = ((AGDisplayInfo) agDisplayInfoList.get(a)).getInstanceId();
     //AGDisplayInfo agDisplayInfo = (AGDisplayInfo) agDisplayInfoList.get(a);
     AGDisplayInfo agDisplayInfo = agQuerySvc.getAGDisplayInfoDetailsById(IAGQueryService.AG_PROCESS_TYPE_BPM,
     ctx,
     new Long(instanceId), new ArrayList(),
     IAGQueryService.AGASSIGNMENT_FILTER_ADMIN);
     System.out.println("******for AGInstancID :"+instanceId+"********");

     System.out.println("AG title:" + agDisplayInfo.getTitle());

     System.out.println("milestone display info list size:" + agDisplayInfo.getMilestoneDisplayInfo().size());
     //MilestoneDisplayInfo msDisplayInfo = (MilestoneDisplayInfo)agDisplayInfo.getMilestoneDisplayInfo();

     for (int i=0; i< agDisplayInfo.getMilestoneDisplayInfo().size(); i++)
     {
       MilestoneDisplayInfo milestoneDisplayInfo = ((MilestoneDisplayInfo) agDisplayInfo.getMilestoneDisplayInfo().get(i));
       System.out.println("-----------------for milestone name :"+milestoneDisplayInfo.getTitle()+"---------");

       System.out.println("Milestone title: " + milestoneDisplayInfo.getTitle());
       System.out.println("Milestone Name: " + milestoneDisplayInfo.getName());

       List<TaskDisplayInfoType> taskDisplayInfoList = milestoneDisplayInfo.getTaskDisplayInfo();
       System.out.println("Total number of tasks: " + taskDisplayInfoList.size());
       for(int j=0; j< taskDisplayInfoList.size();j++)
       {

         TaskDisplayInfoType taskDisp1 = taskDisplayInfoList.get(j);
         TaskType task1 = taskDisp1.getTask();
         System.out.println("^^^^^^^^^^^^^^^^^^for task Id:"+task1.getSystemAttributes().getTaskNumber()+"^^^^^^^^^^^^^^^^^^");
         System.out.println("Task Status: "+task1.getSystemAttributes().getState());
         System.out.println("Task Title: "+task1.getTitle());

       } //taskDisplayInfoList

     } //MilestoneDisplayInfoList
   } //agDisplayInfoList
 } //method
} //class

Note: the classes in build.xml (for the most part the same as in the Workflow Java samples)


<path id="client.classpath">
 <pathelement path="${bea.home}/wlserver_10.3/server/lib/wlfullclient.jar"/>
 <pathelement path="${bea.home}/wlserver_10.3/server/lib/wlclient.jar"/>
 <pathelement path="${bea.home}/oracle_common/webservices/wsclient_extended.jar"/>
 <pathelement path="${bea.home}/Oracle_SOA1/soa/modules/oracle.soa.fabric_11.1.1/bpm-infra.jar"/>
 <pathelement path="${bea.home}/Oracle_SOA1/soa/modules/oracle.soa.fabric_11.1.1/fabric-runtime.jar"/>
 <pathelement path="${bea.home}/Oracle_SOA1/soa/modules/oracle.soa.workflow_11.1.1/bpm-services.jar"/>
 <pathelement path="${bea.home}/Oracle_SOA1/soa/modules/soa-startup.jar"/>
 <pathelement path="${bea.home}/Oracle_SOA1/soa/modules/oracle.soa.bpel_11.1.1/orabpel.jar"/>

<pathelement path="./config"/>
 </path>

Note: wf_client_config.xml


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <workflowServicesClientConfiguration xmlns="http://xmlns.oracle.com/bpel/services/client">
 <server default="true" name="default">
 <localClient>
 <participateInClientTransaction>false</participateInClientTransaction>
 </localClient>
 <remoteClient>
 <serverURL>t3://localhost:7001</serverURL>
 <!--userName>jstein</userName>
 <password encrypted="true">4tORP+F+3jNupTEwSeZj3A==</password-->
 <initialContextFactory>weblogic.jndi.WLInitialContextFactory</initialContextFactory>
 <participateInClientTransaction>false</participateInClientTransaction>
 </remoteClient>
 </server>
 </workflowServicesClientConfiguration>

This entry was posted in Uncategorized. Bookmark the permalink.

1 Response to Using Oracle BPM Activity Guide APIs

  1. Pingback: Using Oracle BPM Activity Guide APIs « oracle fusion identity

Leave a comment