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; }
private Invitation getInvitation(WorkflowTask startTask) { Invitation invitation = getNominatedInvitation(startTask); if(invitation == null) { invitation = getModeratedInvitation(startTask.getPath().getId()); } return invitation; }
private Invitation getInvitation(WorkflowTask startTask) { Invitation invitation = getNominatedInvitation(startTask); if(invitation == null) { invitation = getModeratedInvitation(startTask.getPath().getId()); } 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; }
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; }
@Override @SuppressWarnings("deprecation") public WorkflowPath getPath() { if(path == null) { if(task != null) { this.path = activitiTypeConverter.getWorkflowPath(task.getExecutionId(), true); } else { this.path = activitiTypeConverter.getWorkflowPath(historicTask); } } return super.getPath(); }
@Override @SuppressWarnings("deprecation") public WorkflowPath getPath() { if(path == null) { if(task != null) { this.path = activitiTypeConverter.getWorkflowPath(task.getExecutionId(), true); } else { this.path = activitiTypeConverter.getWorkflowPath(historicTask); } } return super.getPath(); }
private Invitation rejectModeratedInvitation(WorkflowTask startTask, String reason) { ModeratedInvitation invitation = getModeratedInvitation(startTask.getPath().getId()); // Check rejecter is a site manager and throw and exception if not String rejecterUserName = this.authenticationService.getCurrentUserName(); checkManagerRole(rejecterUserName, invitation.getResourceType(), invitation.getResourceName()); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); properties.put(ContentModel.PROP_OWNER, rejecterUserName); properties.put(WorkflowModelModeratedInvitation.WF_PROP_REVIEW_COMMENTS, reason); endInvitation(startTask, WorkflowModelModeratedInvitation.WF_TRANSITION_REJECT, properties, WorkflowModelModeratedInvitation.WF_ACTIVITI_REVIEW_TASK); return invitation; }
private Invitation rejectModeratedInvitation(WorkflowTask startTask, String reason) { ModeratedInvitation invitation = getModeratedInvitation(startTask.getPath().getId()); // Check rejecter is a site manager and throw and exception if not String rejecterUserName = this.authenticationService.getCurrentUserName(); checkManagerRole(rejecterUserName, invitation.getResourceType(), invitation.getResourceName()); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); properties.put(ContentModel.PROP_OWNER, rejecterUserName); properties.put(WorkflowModelModeratedInvitation.WF_PROP_REVIEW_COMMENTS, reason); endInvitation(startTask, WorkflowModelModeratedInvitation.WF_TRANSITION_REJECT, properties, WorkflowModelModeratedInvitation.WF_ACTIVITI_REVIEW_TASK); return invitation; }
/** * Send workflow assigned email notification. * * @param taskId workflow global task id * @param taskType task type * @param assignedAuthorites assigned authorities * @param pooled true if pooled task, false otherwise */ public void sendWorkflowAssignedNotificationEMail(String taskId, String taskType, String[] assignedAuthorites, boolean pooled) { // Get the workflow task WorkflowTask workflowTask = workflowService.getTaskById(taskId); // Get the workflow properties Map<QName, Serializable> props = workflowTask.getProperties(); // Get the title and description String title = taskType == null ? workflowTask.getTitle() : taskType + ".title"; String description = (String)props.get(WorkflowModel.PROP_DESCRIPTION); // Get the duedate, priority and workflow package Date dueDate = (Date)props.get(WorkflowModel.PROP_DUE_DATE); Integer priority = (Integer)props.get(WorkflowModel.PROP_PRIORITY); NodeRef workflowPackage = workflowTask.getPath().getInstance().getWorkflowPackage(); // Send notification sendWorkflowAssignedNotificationEMail(taskId, title, description, dueDate, priority, workflowPackage, assignedAuthorites, pooled); }
/** * 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; } }
/** * 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; } }
/** * Get the available transition ids. * * @return ScriptableHashMap */ public ScriptableHashMap<String, String> getTransitions() { ScriptableHashMap<String, String> transitions = new ScriptableHashMap<String, String>(); WorkflowNode workflowNode = task.getPath().getNode(); if (workflowNode != null) { for (WorkflowTransition transition : workflowNode.getTransitions()) { transitions.put(transition.getId(), transition.getTitle()); } } return transitions; }
/** * Get the available transition ids. * * @return ScriptableHashMap */ public ScriptableHashMap<String, String> getTransitions() { ScriptableHashMap<String, String> transitions = new ScriptableHashMap<String, String>(); WorkflowNode workflowNode = task.getPath().getNode(); if (workflowNode != null) { for (WorkflowTransition transition : workflowNode.getTransitions()) { transitions.put(transition.getId(), transition.getTitle()); } } return transitions; }
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; }
private Invitation cancelModeratedInvitation(WorkflowTask startTask) { ModeratedInvitation invitation = getModeratedInvitation(startTask.getPath().getId()); String currentUserName = this.authenticationService.getCurrentUserName(); if (!AuthenticationUtil.isRunAsUserTheSystemUser()) { if (false == currentUserName.equals(invitation.getInviteeUserName())) { checkManagerRole(currentUserName, invitation.getResourceType(), invitation.getResourceName()); } } // Only proceed with the cancel if the site still exists (the site may have been deleted and invitations may be // getting cancelled in the background) if (this.siteService.getSite(invitation.getResourceName()) != null) { workflowService.cancelWorkflow(invitation.getInviteId()); } return invitation; }
private Invitation cancelModeratedInvitation(WorkflowTask startTask) { ModeratedInvitation invitation = getModeratedInvitation(startTask.getPath().getId()); String currentUserName = this.authenticationService.getCurrentUserName(); if (!AuthenticationUtil.isRunAsUserTheSystemUser()) { if (false == currentUserName.equals(invitation.getInviteeUserName())) { checkManagerRole(currentUserName, invitation.getResourceType(), invitation.getResourceName()); } } // Only proceed with the cancel if the site still exists (the site may have been deleted and invitations may be // getting cancelled in the background) if (this.siteService.getSite(invitation.getResourceName()) != null) { workflowService.cancelWorkflow(invitation.getInviteId()); } return invitation; }
@Test public void testGetStartTaskById() throws Exception { WorkflowTask result = workflowEngine.getTaskById(ActivitiConstants.ENGINE_ID + "$Foo"); assertNull("Should not find any result for fake (but valid) Id.", result); WorkflowPath path = workflowEngine.startWorkflow(workflowDef.getId(), new HashMap<QName, Serializable>()); Task task = taskService.createTaskQuery() .executionId(BPMEngineRegistry.getLocalId(path.getId())) .singleResult(); // A start task should be available for the process instance String startTaskId = ActivitiConstants.START_TASK_PREFIX + task.getProcessInstanceId(); String taskId = createGlobalId(startTaskId); WorkflowTask wfTask = workflowEngine.getTaskById(taskId); assertNotNull(wfTask); assertEquals(createGlobalId(task.getProcessInstanceId()), wfTask.getPath().getId()); }