Add the following code to your test class, to check out a task.
private com.sun.saw.vo.OutputVO checkoutTasks (String userId,java.util.List taskIdList,Workflow workflowImpl) throws com.sun.saw.WorkflowException { com.sun.saw.vo.CheckoutTaskVO checkoutTaskVO = new com.sun.saw.vo.CheckoutTaskVO(); checkoutTaskVO.setTaskIdList(taskIdList); checkoutTaskVO.setUserId(userId); com.sun.saw.vo.OutputVO outputVO = null; outputVO = workflowImpl.checkoutTasks(checkoutTaskVO); return outputVO; } //Call the above method from the main(). For example public static void main(String args) { TestClient client = new TestClient(); List taskIdList = new ArrayList(); taskIdList.add("4ce71ee0:11420e51eca:-6388"); Workflow workflowImpl = this.getWorkflowImpl(); try { client.checkoutTasks("CPina", taskIdList,workflowImpl); } catch (com.sun.saw.WorkflowException e) { e.printStackTrace(); } } private com.sun.saw.Workflow getWorkflowImpl() throws com.sun.saw.WorkflowException{ // This assumes that the property file is there in classpath. com.sun.saw.Workflow workflow = null; com.sun.saw.WorkflowFactory workflowFactory = WorkflowFactory.getInstance(); workflow = workflowFactory.getWorkflowInstance(); return workflow; } |
The above code does the following functions:
The main() calls the getWorkflowImpl() to get the reference of the SAW Workflow Implementation object, which is JCAPSWorkflow class.
The getWorkflowImpl() gets reference to the WorkflowFactory, and calls the getWorkflowInstance() on the factory.
The factory looks for the WorkflowConfig.properties in the classpath, reads the sawworkflowimplclass key and instantiates that.
The main() then calls the checkoutTasks() passing the userId, taskIdList and the appropriate workflowImpl object.
The checkoutTasks() constructs the CheckoutTaskVO object and sets taskIdList and UserId into the CheckoutTaskVO.
Invokes the checkoutTasks() on the SAW Workflow Implementation object, which is on JCAPSWorkflow class.
Invokes the checkoutTasks() on the Sun Java Composite Application Platform Workflow Service that is running as an Enterprise Java Beans (EJB) and does the actual checking out of the task.
The task is then marked as "checked out" by CPina.