/** * Returns whether the task is complete 'true':complete, 'false':in-progress * * @return the complete */ public boolean isComplete() { return task.getState().equals(WorkflowTaskState.COMPLETED); }
/** * Returns whether the task is complete 'true':complete, 'false':in-progress * * @return the complete */ public boolean isComplete() { return task.getState().equals(WorkflowTaskState.COMPLETED); }
try if (startTask != null && startTask.getState() != WorkflowTaskState.COMPLETED)
try if (startTask != null && startTask.getState() != WorkflowTaskState.COMPLETED)
if (task.getState() == WorkflowTaskState.COMPLETED)
if (task.getState() == WorkflowTaskState.COMPLETED)
if (task.getState() == WorkflowTaskState.COMPLETED)
if (task.getState() == WorkflowTaskState.COMPLETED)
if (task.getState() == WorkflowTaskState.COMPLETED)
if (task.getState() == WorkflowTaskState.COMPLETED)
public TaskFormPersister(ContentModelItemData<WorkflowTask> itemData, NamespaceService namespaceService, DictionaryService dictionaryService, WorkflowService workflowService, NodeService nodeService, AuthenticationService authenticationService, BehaviourFilter behaviourFilter, Log logger) { super(itemData, namespaceService, dictionaryService, logger); WorkflowTask item = itemData.getItem(); // make sure that the task is not already completed if (item.getState().equals(WorkflowTaskState.COMPLETED)) { throw new AlfrescoRuntimeException("workflowtask.already.done.error"); } // make sure the current user is able to edit the task if (!workflowService.isTaskEditable(item, authenticationService.getCurrentUserName())) { throw new AccessDeniedException("Failed to update task with id '" + item.getId() + "'."); } this.updater = new TaskUpdater(item.getId(), workflowService, nodeService, behaviourFilter); }
public TaskFormPersister(ContentModelItemData<WorkflowTask> itemData, NamespaceService namespaceService, DictionaryService dictionaryService, WorkflowService workflowService, NodeService nodeService, AuthenticationService authenticationService, BehaviourFilter behaviourFilter, Log logger) { super(itemData, namespaceService, dictionaryService, logger); WorkflowTask item = itemData.getItem(); // make sure that the task is not already completed if (item.getState().equals(WorkflowTaskState.COMPLETED)) { throw new AlfrescoRuntimeException("workflowtask.already.done.error"); } // make sure the current user is able to edit the task if (!workflowService.isTaskEditable(item, authenticationService.getCurrentUserName())) { throw new AccessDeniedException("Failed to update task with id '" + item.getId() + "'."); } this.updater = new TaskUpdater(item.getId(), workflowService, nodeService, behaviourFilter); }
@SuppressWarnings("deprecation") public LazyActivitiWorkflowTask(Task task, ActivitiTypeConverter typeConverter, TenantService tenantService, String workflowDefinitionName) { super(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, task.getId()), null, null, null, null, null, null, null); this.task = task; this.activitiTypeConverter = typeConverter; this.lazyPropertiesMap = new LazyPropertiesMap(); // Fetch task-definition and a partially-initialized WorkflowTask (not including properties and path) WorkflowTaskDefinition taskDefinition = activitiTypeConverter.getTaskDefinition(task); WorkflowTask partiallyInitialized = typeConverter.getWorkflowObjectFactory().createTask(task.getId(), taskDefinition, taskDefinition.getId(), task.getName(), task.getDescription(), WorkflowTaskState.IN_PROGRESS, null, workflowDefinitionName , lazyPropertiesMap); this.definition = taskDefinition; this.name = taskDefinition.getId(); this.title = partiallyInitialized.getTitle(); this.description = partiallyInitialized.getDescription(); this.state = partiallyInitialized.getState(); }
@SuppressWarnings("deprecation") public LazyActivitiWorkflowTask(Task task, ActivitiTypeConverter typeConverter, TenantService tenantService, String workflowDefinitionName) { super(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, task.getId()), null, null, null, null, null, null, null); this.task = task; this.activitiTypeConverter = typeConverter; this.lazyPropertiesMap = new LazyPropertiesMap(); // Fetch task-definition and a partially-initialized WorkflowTask (not including properties and path) WorkflowTaskDefinition taskDefinition = activitiTypeConverter.getTaskDefinition(task); WorkflowTask partiallyInitialized = typeConverter.getWorkflowObjectFactory().createTask(task.getId(), taskDefinition, taskDefinition.getId(), task.getName(), task.getDescription(), WorkflowTaskState.IN_PROGRESS, null, workflowDefinitionName , lazyPropertiesMap); this.definition = taskDefinition; this.name = taskDefinition.getId(); this.title = partiallyInitialized.getTitle(); this.description = partiallyInitialized.getDescription(); this.state = partiallyInitialized.getState(); }
private void checkTransitionTask(String defName, String transitionId, String expOutcome) { WorkflowTask task = getWorkflowTask(defName); QName descName = WorkflowModel.PROP_DESCRIPTION; Serializable initialDesc = task.getProperties().get(descName); String testDesc = "Foo-Bar-Test-String"; assertFalse(testDesc.equals(initialDesc)); Item item = new Item("task", task.getId()); FormData data = new FormData(); String descFieldName = FormFieldConstants.PROP_DATA_PREFIX + descName.toPrefixString(namespaceService).replace(":", "_"); data.addFieldData(descFieldName, testDesc, true); String reviewOutcomeFieldName = FormFieldConstants.PROP_DATA_PREFIX + "wf_reviewOutcome"; data.addFieldData(reviewOutcomeFieldName, "Approve", true); String transitionDataKey = FormFieldConstants.PROP_DATA_PREFIX + TransitionFieldProcessor.KEY; data.addFieldData(transitionDataKey, transitionId); formService.saveForm(item, data); WorkflowTask newTask = workflowService.getTaskById(task.getId()); assertEquals("The description should have been updated!", testDesc, newTask.getProperties().get(descName)); // Check the task is completed assertEquals("The task should have been completed!", WorkflowTaskState.COMPLETED, newTask.getState()); Serializable outcome = newTask.getProperties().get(WorkflowModel.PROP_OUTCOME); assertEquals("The transition is wrong!", expOutcome, outcome); }
@Test public void testStartTaskEndsAutomatically() { // Deploy the test workflow definition which uses the // default Start Task type, so it should end automatically. WorkflowDefinition definition = deployDefinition(getTestDefinitionPath()); // Start the Workflow WorkflowPath path = workflowService.startWorkflow(definition.getId(), null); String instanceId = path.getInstance().getId(); // Check the Start Task is completed. WorkflowTask startTask = workflowService.getStartTask(instanceId); assertEquals(WorkflowTaskState.COMPLETED, startTask.getState()); List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(path.getId()); assertEquals(1, tasks.size()); String taskName = tasks.get(0).getName(); assertEquals("bpm_foo_task", taskName); }
/** * Actually tests if the priority is the default value. This is based on the assumption that custom * tasks are defaulted to a priority of 50 (which is invalid). I'm testing that the code I wrote decides this is an * invalid number and sets it to the default value (2). */ @Test public void testPriorityIsValid() { WorkflowDefinition definition = deployDefinition("activiti/testCustomActiviti.bpmn20.xml"); personManager.setUser(USER1); // Start the Workflow WorkflowPath path = workflowService.startWorkflow(definition.getId(), null); String instanceId = path.getInstance().getId(); // Check the Start Task is completed. WorkflowTask startTask = workflowService.getStartTask(instanceId); assertEquals(WorkflowTaskState.COMPLETED, startTask.getState()); List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(path.getId()); for (WorkflowTask workflowTask : tasks) { Map<QName, Serializable> props = workflowTask.getProperties(); TypeDefinition typeDefinition = workflowTask.getDefinition().getMetadata(); Map<QName, PropertyDefinition> propertyDefs = typeDefinition.getProperties(); PropertyDefinition priorDef = propertyDefs.get(WorkflowModel.PROP_PRIORITY); assertEquals(props.get(WorkflowModel.PROP_PRIORITY),Integer.valueOf(priorDef.getDefaultValue())); } }
@SuppressWarnings("deprecation") public LazyActivitiWorkflowTask(HistoricTaskInstance historicTask, ActivitiTypeConverter typeConverter, TenantService tenantService) { super(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, historicTask.getId()), null, null, null, null, null, null, null); this.historicTask = historicTask; this.activitiTypeConverter = typeConverter; this.lazyPropertiesMap = new LazyPropertiesMap(); // Fetch task-definition and a partially-initialized WorkflowTask (not including properties and path) WorkflowTaskDefinition taskDefinition = activitiTypeConverter.getTaskDefinition(historicTask.getTaskDefinitionKey(), historicTask.getProcessDefinitionId()); String workflowDefinitionName = activitiTypeConverter.getWorkflowDefinitionName(historicTask.getProcessDefinitionId()); workflowDefinitionName = tenantService.getBaseName(workflowDefinitionName); WorkflowTask partiallyInitialized = typeConverter.getWorkflowObjectFactory().createTask(historicTask.getId(), taskDefinition, taskDefinition.getId(), historicTask.getName(), historicTask.getDescription(), WorkflowTaskState.COMPLETED, null, workflowDefinitionName , lazyPropertiesMap); this.definition = taskDefinition; this.name = taskDefinition.getId(); this.title = partiallyInitialized.getTitle(); this.description = partiallyInitialized.getDescription(); this.state = partiallyInitialized.getState(); }
@SuppressWarnings("deprecation") public LazyActivitiWorkflowTask(HistoricTaskInstance historicTask, ActivitiTypeConverter typeConverter, TenantService tenantService) { super(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, historicTask.getId()), null, null, null, null, null, null, null); this.historicTask = historicTask; this.activitiTypeConverter = typeConverter; this.lazyPropertiesMap = new LazyPropertiesMap(); // Fetch task-definition and a partially-initialized WorkflowTask (not including properties and path) WorkflowTaskDefinition taskDefinition = activitiTypeConverter.getTaskDefinition(historicTask.getTaskDefinitionKey(), historicTask.getProcessDefinitionId()); String workflowDefinitionName = activitiTypeConverter.getWorkflowDefinitionName(historicTask.getProcessDefinitionId()); workflowDefinitionName = tenantService.getBaseName(workflowDefinitionName); WorkflowTask partiallyInitialized = typeConverter.getWorkflowObjectFactory().createTask(historicTask.getId(), taskDefinition, taskDefinition.getId(), historicTask.getName(), historicTask.getDescription(), WorkflowTaskState.COMPLETED, null, workflowDefinitionName , lazyPropertiesMap); this.definition = taskDefinition; this.name = taskDefinition.getId(); this.title = partiallyInitialized.getTitle(); this.description = partiallyInitialized.getDescription(); this.state = partiallyInitialized.getState(); }
Assert.assertEquals("bpm_foo_task", finishedTask.getName()); Assert.assertEquals("Task", finishedTask.getTitle()); Assert.assertEquals(WorkflowTaskState.COMPLETED, finishedTask.getState());