public List<WorkflowInstance> getWorkflowsForContent(NodeRef packageItem, boolean active) { List<String> workflowIds = workflowPackageComponent.getWorkflowIdsForContent(packageItem); List<WorkflowInstance> workflowInstances = new ArrayList<WorkflowInstance>(workflowIds.size()); for (String workflowId : workflowIds) { try { String engineId = BPMEngineRegistry.getEngineId(workflowId); WorkflowComponent component = getWorkflowComponent(engineId); WorkflowInstance instance = component.getWorkflowById(workflowId); if (instance != null && instance.isActive() == active) { workflowInstances.add(instance); } } catch (WorkflowException componentForEngineNotRegistered) { String message = componentForEngineNotRegistered.getMessage(); logger.debug(message + ". Ignored workflow on " + packageItem); } } return workflowInstances; }
public List<WorkflowInstance> getWorkflowsForContent(NodeRef packageItem, boolean active) { List<String> workflowIds = workflowPackageComponent.getWorkflowIdsForContent(packageItem); List<WorkflowInstance> workflowInstances = new ArrayList<WorkflowInstance>(workflowIds.size()); for (String workflowId : workflowIds) { try { String engineId = BPMEngineRegistry.getEngineId(workflowId); WorkflowComponent component = getWorkflowComponent(engineId); WorkflowInstance instance = component.getWorkflowById(workflowId); if (instance != null && instance.isActive() == active) { workflowInstances.add(instance); } } catch (WorkflowException componentForEngineNotRegistered) { String message = componentForEngineNotRegistered.getMessage(); logger.debug(message + ". Ignored workflow on " + packageItem); } } return workflowInstances; }
private boolean isActive(String workflowId) { WorkflowInstance workflowInstance = workflowService.getWorkflowById(workflowId); assertNotNull(workflowInstance); return workflowInstance.isActive(); }
if (workflowInstance.isActive())
if (workflowInstance.isActive())
@Test public void testCancelWorkflow() throws Exception { WorkflowDefinition def = deployTestAdhocDefinition(); ProcessInstance processInstance = runtime.startProcessInstanceById(BPMEngineRegistry.getLocalId(def.getId())); // Validate if a workflow exists List<WorkflowInstance> instances = workflowEngine.getActiveWorkflows(def.getId()); assertNotNull(instances); assertEquals(1, instances.size()); assertEquals(processInstance.getId(), BPMEngineRegistry.getLocalId(instances.get(0).getId())); // Call cancel method on component WorkflowInstance cancelledWorkflow = workflowEngine.cancelWorkflow(instances.get(0).getId()); assertFalse(cancelledWorkflow.isActive()); instances = workflowEngine.getActiveWorkflows(def.getId()); assertNotNull(instances); assertEquals(0, instances.size()); // Histrotic process instance shouldn't be present HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(processInstance.getProcessInstanceId()) .singleResult(); if(workflowEngine.activitiUtil.isRetentionHistoricProcessInstanceEnabled()==false){ assertNull(historicProcessInstance); } }
out.println("id: " + workflow.getId()); out.println("description: " + workflow.getDescription()); out.println("active: " + workflow.isActive()); out.println("start date: " + workflow.getStartDate()); out.println("end date: " + workflow.getEndDate()); out.println("workflow: " + ((currentPath == null) ? "None" : currentPath.getInstance().getId() + " , active: " + currentPath.getInstance().isActive())); out.println("path: " + ((currentPath == null) ? "None" : currentPath.getId() + " , node: " + currentPath.getNode().getTitle()));
out.println("id: " + workflow.getId()); out.println("description: " + workflow.getDescription()); out.println("active: " + workflow.isActive()); out.println("start date: " + workflow.getStartDate()); out.println("end date: " + workflow.getEndDate()); out.println("workflow: " + ((currentPath == null) ? "None" : currentPath.getInstance().getId() + " , active: " + currentPath.getInstance().isActive())); out.println("path: " + ((currentPath == null) ? "None" : currentPath.getId() + " , node: " + currentPath.getNode().getTitle()));
assertTrue(workflowInstance.isActive()); assertEquals("I'm the description", workflowInstance.getDescription()); assertEquals(dueDate, workflowInstance.getDueDate());
assertFalse(workflowInstance.isActive()); assertEquals("I'm the description", workflowInstance.getDescription()); assertEquals(dueDate, workflowInstance.getDueDate());
private void executeAdhocWorkflow(WorkflowDefinition workflowDef) { personManager.setUser(USER3); String workflowId = startAdhocWorkflow(workflowDef, USER3); // End start task to progress workflow WorkflowTask startTask = workflowService.getStartTask(workflowId); String startTaskId = startTask.getId(); workflowService.endTask(startTaskId, null); // finish the adhoc task WorkflowTask adhocTask = getNextTaskForWorkflow(workflowId); workflowService.endTask(adhocTask.getId(), null); // finish the workflow WorkflowTask lastTask = getNextTaskForWorkflow(workflowId); workflowService.endTask(lastTask.getId(), null); // ensure the workflow has completed assertFalse(workflowService.getWorkflowById(workflowId).isActive()); }