tdas.setWorkflowInstanceId(wf.getId()); WorkflowInstance wfi = new WorkflowInstance(); wfi.setWorkflowClassId(tdas.getCalcLevel()); wfi.setStartedBy(authenticatedUser.getBadge()); wfi.setStatus("0"); wfi.setLastDate(new Date());
assertNotNull(workflowInstance); assertEquals(globalProcessInstanceId, workflowInstance.getId()); assertNull(workflowInstance.getEndDate()); assertTrue(workflowInstance.isActive()); assertEquals("I'm the description", workflowInstance.getDescription()); assertEquals(dueDate, workflowInstance.getDueDate()); assertEquals(def.getId(), workflowInstance.getDefinition().getId()); assertEquals(adminHomeNode, workflowInstance.getInitiator()); assertEquals(testWorkflowContext, workflowInstance.getContext()); assertEquals(testWorkflowPackage, workflowInstance.getWorkflowPackage()); assertNotNull(workflowInstance.getPriority()); assertEquals(3, workflowInstance.getPriority().intValue()); assertEquals(startTime, workflowInstance.getStartDate());
public boolean setWorkflowForPackage(WorkflowInstance instance) NodeRef packageNode = instance.getWorkflowPackage(); if(packageNode==null) return false; if(pckgInstanceId != null) if(pckgInstanceId.equals(instance.getId())) instance.getId(), pckgInstanceId); throw new WorkflowException(msg); String definitionId = instance.getDefinition().getId(); String definitionName = instance.getDefinition().getName(); String instanceId = instance.getId(); nodeService.setProperty(packageNode, WorkflowModel.PROP_WORKFLOW_DEFINITION_ID, definitionId); nodeService.setProperty(packageNode, WorkflowModel.PROP_WORKFLOW_DEFINITION_NAME, definitionName);
private NominatedInvitation getNominatedInvitation(WorkflowTask startTask) { NominatedInvitation invitation = null; if (taskTypeMatches(startTask, WorkflowModelNominatedInvitation.WF_TASK_INVITE_TO_SITE)) { Date inviteDate = startTask.getPath().getInstance().getStartDate(); String invitationId = startTask.getPath().getInstance().getId(); invitation = new NominatedInvitationImpl(invitationId, inviteDate, startTask.getProperties()); } return invitation; }
public String apply(WorkflowInstance workflow) { return workflow.getId(); } });
String instanceId = task.getPath().getInstance().getId(); WorkflowTask startTask = component.getStartTask(instanceId); String workflowDefId = task.getPath().getInstance().getDefinition().getName(); if (workflowDefId.indexOf('$') != -1 && (workflowDefId.indexOf('$') < workflowDefId.length() -1))
String procInstanceId = BPMEngineRegistry.getLocalId(instance.getId()); ProcessInstance procInstance = runtime.createProcessInstanceQuery() .processInstanceId(procInstanceId) assertNotNull(path.getInstance().getStartDate()); assertNull(path.getInstance().getEndDate());
@SuppressWarnings("unchecked") private WorkflowService makeWorkflowService() { WorkflowService service = mock(WorkflowService.class); when(service.getDefinitionByName(WF_DEF_NAME)).thenReturn(definition); String instanceId = "foo$instanceId"; newInstance = new WorkflowInstance(instanceId, definition, null, null, null, null, true, null, null); WorkflowTask startTask = new WorkflowTask("foo$taskId", null, null, null, null, null, null, null); String pathId = "foo$pathId"; final WorkflowPath path = new WorkflowPath(pathId, newInstance, null, true); when(service.startWorkflow(eq(definition.getId()), anyMap())) .thenAnswer(new Answer<WorkflowPath>() { public WorkflowPath answer(InvocationOnMock invocation) throws Throwable { Object[] arguments = invocation.getArguments(); actualProperties = (Map<QName, Serializable>) arguments[1]; return path; } }); when(service.getTasksForWorkflowPath(path.getId())) .thenReturn(Collections.singletonList(startTask)); when(service.createPackage(null)).thenReturn(PCKG_NODE); return service; }
workflowPackageComponent.deletePackage(instance.getWorkflowPackage()); result.add(instance);
@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); } }
/** * @param path WorkflowPath * @param instance ProcessInstance */ private void endStartTaskAutomatically(WorkflowPath path, ProcessInstance instance) { // Check if StartTask Needs to be ended automatically WorkflowDefinition definition = path.getInstance().getDefinition(); TypeDefinition metadata = definition.getStartTaskDefinition().getMetadata(); Set<QName> aspects = metadata.getDefaultAspectNames(); if(aspects.contains(WorkflowModel.ASPECT_END_AUTOMATICALLY)) { String taskId = ActivitiConstants.START_TASK_PREFIX + instance.getId(); endStartTask(taskId); } }
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; }
accessUseres.addAll(getUserGroupRefs(props.get(WorkflowModel.ASSOC_ASSIGNEES))); accessUseres.addAll(getUserGroupRefs(wt.getProperties().get(WorkflowModel.ASSOC_POOLED_ACTORS))); accessUseres.add(wt.getPath().getInstance().getInitiator());
@Test public void testBuildWorkflowWithNoUserTasks() throws Exception { // Deploy a definition containing only a service task WorkflowDefinition testDefinition = deployDefinition("activiti/testWorkflowNoUserTasks.bpmn20.xml"); WorkflowBuilder builder = new WorkflowBuilder(testDefinition, workflowService, nodeService, null); // Build a workflow WorkflowInstance builtInstance = builder.build(); assertNotNull(builtInstance); // Check that there is no active workflow for the deployed definition(it should have finished already due to absence of user tasks) List<WorkflowInstance> activeInstances = workflowService.getActiveWorkflows(testDefinition.getId()); assertNotNull(activeInstances); assertEquals(0, activeInstances.size()); // Check that there's a historic record of our 'only service task' workflow being run. HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .finishedAfter(builtInstance.getStartDate()) .singleResult(); assertNotNull(historicProcessInstance); }
private Map<String, WorkflowTask> getInvitationTasks(List<String> invitationIds) { for (String invitationId: invitationIds) { validateInvitationId(invitationId); } // query for invite workflow task associate long start = (logger.isDebugEnabled()) ? System.currentTimeMillis() : 0; List<WorkflowTask> inviteStartTasks = workflowService.getStartTasks(invitationIds, true); if (logger.isDebugEnabled()) { logger.debug(" getInvitationTask("+invitationIds.size()+") in "+ (System.currentTimeMillis()-start) + " ms"); } Map<String, WorkflowTask> result = new HashMap<String, WorkflowTask>(inviteStartTasks.size() * 2); for(WorkflowTask inviteStartTask: inviteStartTasks) { String invitationId = inviteStartTask.getPath().getInstance().getId(); // The following does not work for moderated tasks // String invitationId = (String) // inviteStartTask.getProperties().get(WorkflowModel.PROP_WORKFLOW_INSTANCE_ID); result.put(invitationId, inviteStartTask); } return result; }
String instanceId = task.getPath().getInstance().getId(); WorkflowTask startTask = component.getStartTask(instanceId); String workflowDefId = task.getPath().getInstance().getDefinition().getName(); if (workflowDefId.indexOf('$') != -1 && (workflowDefId.indexOf('$') < workflowDefId.length() -1))
public boolean setWorkflowForPackage(WorkflowInstance instance) NodeRef packageNode = instance.getWorkflowPackage(); if(packageNode==null) return false; if(pckgInstanceId != null) if(pckgInstanceId.equals(instance.getId())) instance.getId(), pckgInstanceId); throw new WorkflowException(msg); String definitionId = instance.getDefinition().getId(); String definitionName = instance.getDefinition().getName(); String instanceId = instance.getId(); nodeService.setProperty(packageNode, WorkflowModel.PROP_WORKFLOW_DEFINITION_ID, definitionId); nodeService.setProperty(packageNode, WorkflowModel.PROP_WORKFLOW_DEFINITION_NAME, definitionName);
private NominatedInvitation getNominatedInvitation(WorkflowTask startTask) { NominatedInvitation invitation = null; if (taskTypeMatches(startTask, WorkflowModelNominatedInvitation.WF_TASK_INVITE_TO_SITE)) { Date inviteDate = startTask.getPath().getInstance().getStartDate(); String invitationId = startTask.getPath().getInstance().getId(); invitation = new NominatedInvitationImpl(invitationId, inviteDate, startTask.getProperties()); } return invitation; }
NodeRef workflowPackage= getNodeVariable(variables, WorkflowModel.ASSOC_PACKAGE); WorkflowInstance workflowInstance = new WorkflowInstance( actualId, definition, description, initiator,
public WorkflowTask update() { WorkflowTask task = workflowService.getTaskById(taskId); NodeRef packageNode = task.getPath().getInstance().getWorkflowPackage(); packageMgr.update(packageNode); WorkflowTask result = workflowService.updateTask(taskId, properties, add, remove); properties.clear(); add.clear(); remove.clear(); return result; }