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; }
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; }
public WorkflowPath startWorkflow(String workflowDefinitionId, Map<QName, Serializable> parameters) { String engineId = BPMEngineRegistry.getEngineId(workflowDefinitionId); WorkflowComponent component = getWorkflowComponent(engineId); WorkflowPath path = component.startWorkflow(workflowDefinitionId, parameters); if(path != null && parameters!=null && parameters.containsKey(WorkflowModel.ASSOC_PACKAGE)) { WorkflowInstance instance = path.getInstance(); workflowPackageComponent.setWorkflowForPackage(instance); } return path; }
public WorkflowPath startWorkflow(String workflowDefinitionId, Map<QName, Serializable> parameters) { String engineId = BPMEngineRegistry.getEngineId(workflowDefinitionId); WorkflowComponent component = getWorkflowComponent(engineId); WorkflowPath path = component.startWorkflow(workflowDefinitionId, parameters); if(path != null && parameters!=null && parameters.containsKey(WorkflowModel.ASSOC_PACKAGE)) { WorkflowInstance instance = path.getInstance(); workflowPackageComponent.setWorkflowForPackage(instance); } return path; }
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; }
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 WorkflowInstance build() { NodeRef packageRef = packageMgr.create(packageNode); params.put(WorkflowModel.ASSOC_PACKAGE, packageRef); WorkflowPath path = workflowService.startWorkflow(definition.getId(), params); if (path.isActive()){ signalStartTask(path); } return path.getInstance(); }
public WorkflowInstance build() { NodeRef packageRef = packageMgr.create(packageNode); params.put(WorkflowModel.ASSOC_PACKAGE, packageRef); WorkflowPath path = workflowService.startWorkflow(definition.getId(), params); if (path.isActive()){ signalStartTask(path); } return path.getInstance(); }
/** * Returns the username of the user that initiated the workflow the * given task is part of. * * @param task The task to get the workflow initiator for * @return Username or null if the initiator could not be found */ private String getWorkflowInitiatorUsername(WorkflowTask task) { String initiator = null; NodeRef initiatorRef = task.getPath().getInstance().getInitiator(); if (initiatorRef != null && this.nodeService.exists(initiatorRef)) { initiator = (String)this.nodeService.getProperty(initiatorRef, ContentModel.PROP_USERNAME); } return initiator; } }
/** * @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); } }
/** * @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); } }
/** * Returns the username of the user that initiated the workflow the * given task is part of. * * @param task The task to get the workflow initiator for * @return Username or null if the initiator could not be found */ private String getWorkflowInitiatorUsername(WorkflowTask task) { String initiator = null; NodeRef initiatorRef = task.getPath().getInstance().getInitiator(); if (initiatorRef != null && this.nodeService.exists(initiatorRef)) { initiator = (String)this.nodeService.getProperty(initiatorRef, ContentModel.PROP_USERNAME); } return initiator; } }
private boolean fromSameParallelReviewWorkflow(WorkflowTask wt, String userName) { // check whether this is parallel review workflow, "parallel" will match all parallel workflows (any engine) if (wt.getPath().getInstance().getDefinition().getName().toLowerCase().contains("parallel")) { WorkflowTaskQuery tasksQuery = new WorkflowTaskQuery(); tasksQuery.setTaskState(null); tasksQuery.setActive(null); tasksQuery.setProcessId(wt.getPath().getInstance().getId()); List<WorkflowTask> allWorkflowTasks = workflowService.queryTasks(tasksQuery, true); for (WorkflowTask task : allWorkflowTasks) { if (isInitiatorOrAssignee(task, userName)) { // if at list one match then user has task from the same workflow return true; } } } return false; }
public WorkflowTask createTask (String id, WorkflowTaskDefinition taskDef, String name, String defaultTitle, String defaultDescription, WorkflowTaskState state, WorkflowPath path, String workflowDefinitionName, Map<QName, Serializable> properties) { String actualId = buildGlobalId(id); String processKey = getProcessKey(workflowDefinitionName) + ".task." + name; TypeDefinition metadata = taskDef.getMetadata(); String title = getLabel(processKey, TITLE_LABEL, metadata.getTitle(dictionaryService), defaultTitle, name); defaultDescription = (defaultDescription !=null && defaultDescription.trim().length() == 0) ? null : defaultDescription; String description = getLabel(processKey, DESC_LABEL, defaultDescription, metadata.getDescription(dictionaryService), title); return new WorkflowTask(actualId, taskDef, name, title, description, state, path, properties); }
public WorkflowTask createTask (String id, WorkflowTaskDefinition taskDef, String name, String defaultTitle, String defaultDescription, WorkflowTaskState state, WorkflowPath path, String workflowDefinitionName, Map<QName, Serializable> properties) { String actualId = buildGlobalId(id); String processKey = getProcessKey(workflowDefinitionName) + ".task." + name; TypeDefinition metadata = taskDef.getMetadata(); String title = getLabel(processKey, TITLE_LABEL, metadata.getTitle(dictionaryService), defaultTitle, name); defaultDescription = (defaultDescription !=null && defaultDescription.trim().length() == 0) ? null : defaultDescription; String description = getLabel(processKey, DESC_LABEL, defaultDescription, metadata.getDescription(dictionaryService), title); return new WorkflowTask(actualId, taskDef, name, title, description, state, path, properties); }
protected String startAdhocWorkflow(WorkflowDefinition workflowDef, String assigneeId) { // Create params Map<QName, Serializable> params = new HashMap<QName, Serializable>(); Serializable wfPackage = workflowService.createPackage(null); params.put(WorkflowModel.ASSOC_PACKAGE, wfPackage); Date dueDate = new Date(); params.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, dueDate); params.put(WorkflowModel.PROP_WORKFLOW_PRIORITY, 1); params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "Test workflow description"); params.put(customStringProp, "stringValue"); // Assign to USER2 NodeRef assignee = personManager.get(assigneeId); params.put(WorkflowModel.ASSOC_ASSIGNEE, assignee); // Start a workflow instance WorkflowPath path = workflowService.startWorkflow(workflowDef.getId(), params); assertNotNull(path); assertTrue(path.isActive()); return path.getInstance().getId(); }
private boolean isUserPartOfProcess(WorkflowTask wt, String userName) { WorkflowTaskQuery tasksQuery = new WorkflowTaskQuery(); tasksQuery.setTaskState(null); tasksQuery.setActive(null); tasksQuery.setProcessId(wt.getPath().getInstance().getId()); List<WorkflowTask> allWorkflowTasks = workflowService.queryTasks(tasksQuery, true); for (WorkflowTask task : allWorkflowTasks) { if (isInitiatorOrAssignee(task, userName)) { // if at list one match then user has task from the same workflow return true; } } return false; }
private boolean isUserPartOfProcess(WorkflowTask wt, String userName) { WorkflowTaskQuery tasksQuery = new WorkflowTaskQuery(); tasksQuery.setTaskState(null); tasksQuery.setActive(null); tasksQuery.setProcessId(wt.getPath().getInstance().getId()); List<WorkflowTask> allWorkflowTasks = workflowService.queryTasks(tasksQuery, true); for (WorkflowTask task : allWorkflowTasks) { if (isInitiatorOrAssignee(task, userName)) { // if at list one match then user has task from the same workflow return true; } } return false; }
@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); }
public void testStartWorkflow() { WorkflowDefinition definition = deployDefinition(getTestDefinitionPath()); WorkflowPath path = workflowService.startWorkflow(definition.getId(), null); assertNotNull(path); assertTrue(path.isActive()); assertNotNull(path.getNode()); WorkflowInstance instance = path.getInstance(); assertNotNull(instance); assertEquals(definition.getId(), instance.getDefinition().getId()); }