I deploy this simple process
I then map the roles as follows -
Then I create a ws proxy to programmatically instantiate a BPM instance.
Essentially, what's covered in post #283.
I add the necessary code to the ...PortClient
Test - check em to see that an instance has been created.
Now we need to update this from priority 3 to 1.
First I use the API to query the current tasks for jcooper -
Method: getTaskDetails()
-----------------------------------------------------------------
public String getTaskdetails(String user, String pwd) {
System.out.println("getTaskdetails()");
Map properties = new HashMap();
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL,
"t3://localhost:7001");
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_CREDENTIALS,
pwd);
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_PRINCIPAL,
user);
try {
//Create JAVA WorflowServiceClient
IWorkflowServiceClient wfSvcClient =
WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.REMOTE_CLIENT,
properties,
null);
//Get the task query service
ITaskQueryService querySvc = wfSvcClient.getTaskQueryService();
//Login as jcooper
IWorkflowContext ctx =
querySvc.authenticate(user, pwd.toCharArray(), null);
//Set up list of columns to query
List queryColumns = new ArrayList();
queryColumns.add("TASKID");
queryColumns.add("TASKNUMBER");
queryColumns.add("TITLE");
queryColumns.add("OUTCOME");
//Query a list of tasks assigned to jcooper
List tasks =
querySvc.queryTasks(ctx, queryColumns, null, //Do not query additional info
ITaskQueryService.AssignmentFilter.MY_AND_GROUP, null, //No keywords
null, //No custom predicate
null, //No special ordering
0, //Do not page the query result
0);
//Get the task service
ITaskService taskSvc = wfSvcClient.getTaskService();
//Loop over the tasks, outputting task information, and approving any
//tasks whose outcome has not been set...
System.out.println("getTaskdetails() nr of Tasks = " +
tasks.size());
for (int i = 0; i < tasks.size(); i++) {
System.out.println("In task loop...");
Task task = (Task)tasks.get(i);
int taskNumber = task.getSystemAttributes().getTaskNumber();
String title = task.getTitle();
String taskId = task.getSystemAttributes().getTaskId();
String outcome = task.getSystemAttributes().getOutcome();
int priority = task.getPriority();
int taskNr = task.getSystemAttributes().getTaskNumber();
String taskDefId =
task.getSystemAttributes().getTaskDefinitionId();
System.out.println("In task loop... title/taskDefId = " +
title + " / " + taskDefId);
// Change priority from 3 to 1 for SimpleApprove
System.out.println("Task #" + taskNumber + " (" + title +
") is " + outcome + " has priority " +
priority + " Id = " + taskId + " taskNr= " +
taskNr);
}
} catch (Exception e) {
//Handle any exceptions raised here...
System.out.println("Caught workflow exception: " + e.getMessage());
}
return "done";
}
----------------------------------------------------------------------
This produces the following output -
Task 206277 is the one we just created.
TaskId is - 98f2fcc8-b3d1-4d65-a837-fb2e747763b4
Now I want to update this task to priority 1 -
So essentially I use the query service again, adding a predicate for the taskId -
I then use the updatePriority() method as shown below.
Test -
full method code -
public String updateTaskPriority4Task(String myTaskId, int newPriority) {
System.out.println("updateTaskPriority()");
Map properties = new HashMap();
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL,
"t3://localhost:7001");
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_CREDENTIALS,
"welcome1");
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_PRINCIPAL,
"weblogic");
try {
//Create JAVA WorkflowServiceClient
IWorkflowServiceClient wfSvcClient =
WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.REMOTE_CLIENT,
properties,
null);
//Get the task query service
ITaskQueryService querySvc = wfSvcClient.getTaskQueryService();
//Login as jcooper
IWorkflowContext ctx =
querySvc.authenticate("jcooper", "welcome1".toCharArray(),
null);
//Set up list of columns to query
List queryColumns = new ArrayList();
queryColumns.add("TASKID");
queryColumns.add("TASKNUMBER");
queryColumns.add("TITLE");
queryColumns.add("OUTCOME");
Predicate pred = new Predicate(TableConstants.WFTASK_TASKID_COLUMN,
Predicate.OP_EQ, myTaskId);
//Query a list of tasks assigned to jcooper
List tasks =
querySvc.queryTasks(ctx, queryColumns, null, //Do not query additional info
ITaskQueryService.AssignmentFilter.MY_AND_GROUP, null, //No keywords
pred, //No custom predicate
null, //No special ordering
0, //Do not page the query result
0);
//Get the task service
ITaskService taskSvc = wfSvcClient.getTaskService();
taskSvc.updatePriority(ctx, myTaskId, ITaskService.UpdatePriorityType.UPDATE, newPriority);
} catch (Exception e) {
//Handle any exceptions raised here...
System.out.println("Caught workflow exception: " + e.getMessage());
}
return "done";
}
---------------------------------------------------
Project Libraries -
No comments:
Post a Comment