Tuesday, January 31, 2012

To retrieve the Oracle BPM worklist payload in ADF taskflow


// Get the faces context object
FacesContext context = FacesContext.getCurrentInstance();

// get the worklist context and taskid (of the task selected), these are by default part of the page
//flowscope in the BPM workspace where the taskflow will be included
String ctx = (String) context.getApplication().evaluateExpressionGet(context, "#{pageFlowScope.bpmWorklistContext}", String.class);
String tskId = (String)context.getApplication().evaluateExpressionGet(context, "#{pageFlowScope.bpmWorklistTaskId}", String.class);

// Get the workflow service client and task query service
IWorkflowServiceClient workflowSvcClient = WorkflowService.getWorkflowServiceClient();
ITaskQueryService wfQueryService = workflowSvcClient.getTaskQueryService();
IWorkflowContext wfContext = wfQueryService.getWorkflowContext(ctx);
Task myTask = wfQueryService.getTaskDetailsById(wfContext, tskId);

// Now get the payload
Element rootelement= myTask.getPayloadAsElement();

// parse the payload to get the required information.
NodeList nl= rootelement.getElementsByTagName("Information");
Node fstnode= nl.item(0);
Element fstElmnt = (Element) fstnode;
NodeList tstNmElmntLst = fstElmnt.getElementsByTagName("Id");
Element tstNmElmnt = (Element) tstNmElmntLst.item(0);
String Id = tstNmElmnt.getFirstChild().getNodeValue();
NodeList tstNmElmntLst1 = fstElmnt.getElementsByTagName("po");
Element tstNmElmnt1 = (Element) tstNmElmntLst.item(0);
String po = tstNmElmnt1.getFirstChild().getNodeValue();
context.getExternalContext().getRequestMap().put("Id", Id);
context.getExternalContext().getRequestMap().put("po", po);

2 comments:

  1. Hi, can you say what package for WorkflowService?

    ReplyDelete
  2. Hi,

    Can you please share what package we need use for " WorkflowService "?

    Thanks with regards,
    Praveen.

    ReplyDelete