Below is the java code and screenshot for getting task query service and Task service to query and update tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.raylab.util; | |
import java.util.HashMap; | |
import java.util.Map; | |
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.ITaskService; | |
import oracle.bpel.services.workflow.task.model.Task; | |
import oracle.bpel.services.workflow.verification.IWorkflowContext; | |
public class Class1 { | |
public Class1() { | |
super(); | |
} | |
public static void main(String[] args){ | |
IWorkflowServiceClient wfSvcClient = null; | |
ITaskQueryService querySvc = null; | |
ITaskService taskSvc=null; | |
Map connectionProperties=null; | |
String taskId="2add9056-3f50-4f19-9ff1-8eaad99aedbb"; | |
connectionProperties=getConnectionforTaskDetails(); | |
try{ | |
wfSvcClient=WorkflowServiceClientFactory.getWorkflowServiceClient(connectionProperties,null ); | |
}catch(WorkflowException wex){ | |
System.out.println("Exception while getting client factor :"+wex.getMessage()); | |
} | |
System.out.println("Got workflow client"); | |
querySvc=wfSvcClient.getTaskQueryService(); | |
IWorkflowContext authenticate; | |
try { | |
authenticate = | |
querySvc.authenticate("adminUser", "adminPassword".toCharArray(), null); | |
authenticate=querySvc.authenticateOnBehalfOf(authenticate, "user"); | |
Task task= querySvc.getTaskDetailsById(authenticate, taskId); | |
System.out.println(task.getSystemAttributes().getState()); | |
taskSvc=wfSvcClient.getTaskService(); | |
} catch (WorkflowException e) { | |
e.printStackTrace(); | |
} | |
} | |
public static Map getConnectionforTaskDetails(){ | |
Map jndiProps = new HashMap(); | |
jndiProps.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); | |
jndiProps.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL,"t3://xxx:1234"); | |
jndiProps.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_PRINCIPAL,"admin"); | |
jndiProps.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_CREDENTIALS,"adminPassword"); | |
jndiProps.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.CLIENT_TYPE,WorkflowServiceClientFactory.REMOTE_CLIENT); | |
return jndiProps; | |
} | |
} | |
Libraries
Hi Ravi,
ReplyDeleteCan you please provide the name of the jars you have in your libraries?