@Before public void setup() { for (int customerId = 1; customerId <= 5; customerId++) { ProcessInstance pi = sf.getWorkflowService() .startProcess(new QName(MODEL_NAME2, "OrderCreation").toString(), null, true); List<ActivityInstance> w = getWorklist(); Assert.assertEquals("worklist", 1, w.size()); ActivityInstance ai = w.get(0); Assert.assertEquals("process instance", pi.getOID(), ai.getProcessInstanceOID()); Assert.assertEquals("activity instance", "EnterOrderData", ai.getActivity().getId()); Map<String, Object> order = CollectionUtils.newMap(); order.put("date", new Date()); order.put("customerId", customerId); ai = complete( ai, PredefinedConstants.DEFAULT_CONTEXT, Collections.singletonMap("Order", order)); try { ProcessInstanceStateBarrier.instance().await(pi.getOID(), ProcessInstanceState.Completed); } catch (Exception e) { } w = getWorklist(); } }
@SuppressWarnings("unchecked") private List<ActivityInstance> getWorklist(ProcessInstance pi, EvaluationPolicy... policies) { WorkflowService ws = sf.getWorkflowService(); WorklistQuery query = WorklistQuery.findCompleteWorklist(); if (policies != null) { for (EvaluationPolicy policy : policies) { query.setPolicy(policy); } } query.getFilter().add(new ProcessInstanceFilter(pi.getOID(), false)); Worklist worklist = ws.getWorklist(query); return worklist.getCumulatedItems(); }
/** @return dataPathContacts */ private List<DataPathValue> generateDataPathContacts() { List<DataPathValue> dataPathContacts = new ArrayList<DataPathValue>(); ProcessDefinition processDefinition = null; try { processDefinition = ContextPortalServices.getQueryService() .getProcessDefinition(processInstance.getProcessID()); } catch (Exception e) { trace.error(e); } if (processDefinition != null) { List<DataPath> list = processDefinition.getAllDataPaths(); for (int n = 0; n < list.size(); ++n) { DataPath dataPath = list.get(n); if (dataPath.getDirection().equals(Direction.IN) || dataPath.getDirection().equals(Direction.IN_OUT)) { Object dataValue = null; try { dataValue = ContextPortalServices.getWorkflowService() .getInDataPath(processInstance.getOID(), dataPath.getId()); } catch (Exception e) { trace.error(e); } if (dataValue != null && EMailAddressValidator.validateEmailAddress(dataValue.toString())) { dataPathContacts.add( new DataPathValue( dataPath.getId(), dataPath.getName(), dataValue != null ? dataValue.toString() : "")); } } } } return dataPathContacts; }
private Object getCurrentProcessInstanceDataValue(String path) { return ContextPortalServices.getWorkflowService().getInDataPath(processInstance.getOID(), path); }