Java Code Examples for org.activiti.engine.task.IdentityLink#getUserId()
The following examples show how to use
org.activiti.engine.task.IdentityLink#getUserId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskIdentityLinksTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testCustomIdentityLink() { runtimeService.startProcessInstanceByKey("customIdentityLink"); List<Task> tasks = taskService.createTaskQuery().taskInvolvedUser("kermit").list(); assertEquals(1, tasks.size()); List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(tasks.get(0).getId()); assertEquals(2, identityLinks.size()); for (IdentityLink idLink : identityLinks) { assertEquals("businessAdministrator", idLink.getType()); String userId = idLink.getUserId(); if (userId == null) { assertEquals("management", idLink.getGroupId()); } else { assertEquals("kermit", userId); } } }
Example 2
Source File: ProcessDefinitionIdentityLinkResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@ApiOperation(value = "Delete a candidate starter from a process definition", tags = {"Process Definitions"}) @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates the process definition was found and the identity link was removed. The response body is intentionally empty."), @ApiResponse(code = 404, message = "Indicates the requested process definition was not found or the process definition doesn’t have an identity-link that matches the url.") }) @RequestMapping(value = "/repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}", method = RequestMethod.DELETE) public void deleteIdentityLink(@ApiParam(name = "processDefinitionId", value="The id of the process definition.") @PathVariable("processDefinitionId") String processDefinitionId,@ApiParam(name = "family", value="Either users or groups, depending on the type of identity link.") @PathVariable("family") String family,@ApiParam(name = "identityId", value="Either the user or group of the identity to remove as candidate starter.") @PathVariable("identityId") String identityId, HttpServletResponse response) { ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId); validateIdentityLinkArguments(family, identityId); // Check if identitylink to delete exists IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId()); if (link.getUserId() != null) { repositoryService.deleteCandidateStarterUser(processDefinition.getId(), link.getUserId()); } else { repositoryService.deleteCandidateStarterGroup(processDefinition.getId(), link.getGroupId()); } response.setStatus(HttpStatus.NO_CONTENT.value()); }
Example 3
Source File: TaskIdentityLinksTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testCustomIdentityLink() { runtimeService.startProcessInstanceByKey("customIdentityLink"); List<Task> tasks = taskService.createTaskQuery().taskInvolvedUser("kermit").list(); assertEquals(1, tasks.size()); List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(tasks.get(0).getId()); assertEquals(2, identityLinks.size()); for (IdentityLink idLink : identityLinks) { assertEquals("businessAdministrator", idLink.getType()); String userId = idLink.getUserId(); if (userId == null) { assertEquals("management", idLink.getGroupId()); } else { assertEquals("kermit", userId); } } }
Example 4
Source File: ActivitiPropertyConverter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public List<NodeRef> getPooledActorsReference(Collection<IdentityLink> links) { List<NodeRef> pooledActorRefs = new ArrayList<NodeRef>(); if(links != null) { for(IdentityLink link : links) { if(IdentityLinkType.CANDIDATE.equals(link.getType())) { String id = link.getGroupId(); if(id == null) { id = link.getUserId(); } NodeRef pooledNodeRef = authorityManager.mapNameToAuthority(id); if (pooledNodeRef != null) { pooledActorRefs.add(pooledNodeRef); } } } } return pooledActorRefs; }
Example 5
Source File: ActivitiPooledActorsPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void updateTaskCandidates(DelegateTask task, UserAndGroupUpdates updates) { // Only new candidates are present in pooledUsers and pooledGroups, create Links for these for (String user : updates.getUsers()) { task.addCandidateUser( user); } for (String group : updates.getGroups()) { task.addCandidateGroup( group); } // Remove all candidates which have been removed for (IdentityLink link : updates.linksToRemove) { if (link.getUserId() != null) { task.deleteUserIdentityLink(link.getUserId(), link.getType()); } else { task.deleteGroupIdentityLink(link.getGroupId(), link.getType()); } } }
Example 6
Source File: TaskDelagationAssignmentHandler.java From openwebflow with BSD 2-Clause "Simplified" License | 6 votes |
private void retrieveCandidateUserIdsAndGroupIds(TaskEntity task, Map<String, Object> userIdMap, Map<String, Object> groupIdMap) { for (IdentityLink link : task.getCandidates()) { String userId = link.getUserId(); if (userId != null) { userIdMap.put(userId, 0); } String groupId = link.getGroupId(); if (groupId != null) { groupIdMap.put(groupId, 0); } } }
Example 7
Source File: AbstractWorkflowUsersResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected Set<String> getInvolvedUsersAsSet(List<IdentityLink> involvedPeople) { Set<String> involved = null; if (involvedPeople.size() > 0) { involved = new HashSet<String>(); for (IdentityLink link : involvedPeople) { if (link.getUserId() != null) { involved.add(link.getUserId()); } } } return involved; }
Example 8
Source File: DelegateTaskTestTaskListener.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void notify(DelegateTask delegateTask) { Set<IdentityLink> candidates = delegateTask.getCandidates(); Set<String> candidateUsers = new HashSet<String>(); Set<String> candidateGroups = new HashSet<String>(); for (IdentityLink candidate : candidates) { if (candidate.getUserId() != null) { candidateUsers.add(candidate.getUserId()); } else if (candidate.getGroupId() != null) { candidateGroups.add(candidate.getGroupId()); } } delegateTask.setVariable(VARNAME_CANDIDATE_USERS, candidateUsers); delegateTask.setVariable(VARNAME_CANDIDATE_GROUPS, candidateGroups); }
Example 9
Source File: TaskIdentityLinkFamilyResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@ApiOperation(value = "Get all identitylinks for a task for either groups or users", tags = {"Tasks"}, notes="## Get all identitylinks for a task URL\n\n" + " ```\n GET runtime/tasks/{taskId}/identitylinks/users\n" + "GET runtime/tasks/{taskId}/identitylinks/groups ```" + "\n\n\n" + "Returns only identity links targetting either users or groups. Response body and status-codes are exactly the same as when getting the full list of identity links for a task." ) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the task was found and the requested identity links are returned."), @ApiResponse(code = 404, message = "Indicates the requested task was not found.") }) @RequestMapping(value = "/runtime/tasks/{taskId}/identitylinks/{family}", method = RequestMethod.GET, produces = "application/json") public List<RestIdentityLink> getIdentityLinksForFamily(@ApiParam(name="taskId") @PathVariable("taskId") String taskId,@ApiParam(name="family") @PathVariable("family") String family, HttpServletRequest request) { Task task = getTaskFromRequest(taskId); if (family == null || (!RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_GROUPS.equals(family) && !RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS.equals(family))) { throw new ActivitiIllegalArgumentException("Identity link family should be 'users' or 'groups'."); } boolean isUser = family.equals(RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS); List<RestIdentityLink> results = new ArrayList<RestIdentityLink>(); List<IdentityLink> allLinks = taskService.getIdentityLinksForTask(task.getId()); for (IdentityLink link : allLinks) { boolean match = false; if (isUser) { match = link.getUserId() != null; } else { match = link.getGroupId() != null; } if (match) { results.add(restResponseFactory.createRestIdentityLink(link)); } } return results; }
Example 10
Source File: DelegateTaskTestTaskListener.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void notify(DelegateTask delegateTask) { Set<IdentityLink> candidates = delegateTask.getCandidates(); Set<String> candidateUsers = new HashSet<String>(); Set<String> candidateGroups = new HashSet<String>(); for (IdentityLink candidate : candidates) { if (candidate.getUserId() != null) { candidateUsers.add(candidate.getUserId()); } else if (candidate.getGroupId() != null) { candidateGroups.add(candidate.getGroupId()); } } delegateTask.setVariable(VARNAME_CANDIDATE_USERS, candidateUsers); delegateTask.setVariable(VARNAME_CANDIDATE_GROUPS, candidateGroups); }
Example 11
Source File: ActivitiPooledActorsPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private void updateTaskCandidates(String taskId, UserAndGroupUpdates updates) { // Only new candidates are present in pooledUsers and pooledGroups, create Links for these for (String user : updates.getUsers()) { taskService.addCandidateUser(taskId, user); } for (String group : updates.getGroups()) { taskService.addCandidateGroup(taskId, group); } // Remove all candidates which have been removed for (IdentityLink link : updates.getLinksToRemove()) { if (link.getUserId() != null) { taskService.deleteUserIdentityLink(link.getTaskId(), link.getUserId(), link.getType()); } else { taskService.deleteGroupIdentityLink(link.getTaskId(), link.getGroupId(), link.getType()); } } }
Example 12
Source File: TaskCandidate.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public TaskCandidate(IdentityLink identityLink) { if (StringUtils.isNotEmpty(identityLink.getUserId())) { candidateId = identityLink.getUserId(); candidateType = "user"; } else { candidateId = identityLink.getGroupId(); candidateType = "group"; } }
Example 13
Source File: IdentityUtils.java From openwebflow with BSD 2-Clause "Simplified" License | 5 votes |
public static List<String> getInvolvedUsers(TaskService taskService, Task task, IdentityMembershipManager membershipManager) throws Exception { Map<String, Object> userIds = new HashMap<String, Object>(); String assignee = task.getAssignee(); //如果直接指定了任务执行人,则忽略其他候选人 if (assignee != null) { userIds.put(assignee, new Object()); } else { for (IdentityLink link : taskService.getIdentityLinksForTask(task.getId())) { String userId = link.getUserId(); if (userId != null) { userIds.put(userId, new Object()); } String groupId = link.getGroupId(); if (groupId != null) { for (String gUserId : membershipManager.findUserIdsByGroup(groupId)) { userIds.put(gUserId, new Object()); } } } } return new ArrayList<String>(userIds.keySet()); }
Example 14
Source File: ActivitiPooledActorsPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Returns a DTO containing the users and groups to add and the links to remove. * * @param value Serializable * @param links Collection<? extends IdentityLink> * @return UserAndGroupUpdates */ private UserAndGroupUpdates getUserAndGroupUpdates(Serializable value, Collection<? extends IdentityLink> links) { Collection<NodeRef> actors = getNodes(value); List<String> users = new ArrayList<String>(); List<String> groups = new ArrayList<String>(); for (NodeRef actor : actors) { String authorityName = authorityManager.getAuthorityName(actor); List<String> pooledAuthorities = authorityManager.isUser(authorityName)? users : groups; pooledAuthorities.add(authorityName); } // Removes all users and groups that are already links. // Also records links that are not part of the new set of users and // groups, in order to delete them. List<IdentityLink> linksToRemove = new LinkedList<IdentityLink>(); for (IdentityLink link : links) { if (IdentityLinkType.CANDIDATE.equals(link.getType())) { String userId = link.getUserId(); if (userId != null) { if (users.remove(userId)==false) { linksToRemove.add(link); } } else { String groupId = link.getGroupId(); if (groupId != null && groups.remove(groupId) == false) { linksToRemove.add(link); } } } } return new UserAndGroupUpdates(users, groups, linksToRemove); }
Example 15
Source File: AutoCompleteFirstTaskListener.java From lemon with Apache License 2.0 | 4 votes |
@Override public void onCreate(DelegateTask delegateTask) throws Exception { String initiatorId = Authentication.getAuthenticatedUserId(); if (initiatorId == null) { return; } String assignee = delegateTask.getAssignee(); if (assignee == null) { return; } PvmActivity targetActivity = this.findFirstActivity(delegateTask .getProcessDefinitionId()); if (!targetActivity.getId().equals( delegateTask.getExecution().getCurrentActivityId())) { return; } if (!initiatorId.equals(assignee)) { return; } logger.debug("auto complete first task : {}", delegateTask); for (IdentityLink identityLink : delegateTask.getCandidates()) { String userId = identityLink.getUserId(); String groupId = identityLink.getGroupId(); if (userId != null) { delegateTask.deleteCandidateUser(userId); } if (groupId != null) { delegateTask.deleteCandidateGroup(groupId); } } // 对提交流程的任务进行特殊处理 HumanTaskDTO humanTaskDto = humanTaskConnector .findHumanTaskByTaskId(delegateTask.getId()); humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_START); humanTaskConnector.saveHumanTask(humanTaskDto); // ((TaskEntity) delegateTask).complete(); // Context.getCommandContext().getHistoryManager().recordTaskId((TaskEntity) delegateTask); new CompleteTaskWithCommentCmd(delegateTask.getId(), null, "发起流程") .execute(Context.getCommandContext()); }
Example 16
Source File: AutoCompleteFirstTaskEventListener.java From lemon with Apache License 2.0 | 4 votes |
public void onCreate(DelegateTask delegateTask) throws Exception { String initiatorId = Authentication.getAuthenticatedUserId(); if (initiatorId == null) { return; } String assignee = delegateTask.getAssignee(); if (assignee == null) { return; } if (!initiatorId.equals(assignee)) { return; } PvmActivity targetActivity = this.findFirstActivity(delegateTask .getProcessDefinitionId()); logger.debug("targetActivity : {}", targetActivity); if (!targetActivity.getId().equals( delegateTask.getExecution().getCurrentActivityId())) { return; } logger.debug("auto complete first task : {}", delegateTask); for (IdentityLink identityLink : delegateTask.getCandidates()) { String userId = identityLink.getUserId(); String groupId = identityLink.getGroupId(); if (userId != null) { delegateTask.deleteCandidateUser(userId); } if (groupId != null) { delegateTask.deleteCandidateGroup(groupId); } } // 对提交流程的任务进行特殊处理 HumanTaskDTO humanTaskDto = humanTaskConnector .findHumanTaskByTaskId(delegateTask.getId()); humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_START); humanTaskConnector.saveHumanTask(humanTaskDto); // ((TaskEntity) delegateTask).complete(); // Context.getCommandContext().getHistoryManager().recordTaskId((TaskEntity) delegateTask); // Context.getCommandContext().getHistoryManager().recordTaskId((TaskEntity) delegateTask); // new CompleteTaskWithCommentCmd(delegateTask.getId(), null, "发起流程") // .execute(Context.getCommandContext()); // 因为recordTaskId()会判断endTime,而complete以后会导致endTime!=null, // 所以才会出现record()放在complete后面导致taskId没记录到historyActivity里的情况 delegateTask.getExecution().setVariableLocal( "_ACTIVITI_SKIP_EXPRESSION_ENABLED", true); TaskDefinition taskDefinition = ((TaskEntity) delegateTask) .getTaskDefinition(); ExpressionManager expressionManager = Context .getProcessEngineConfiguration().getExpressionManager(); Expression expression = expressionManager .createExpression("${_ACTIVITI_SKIP_EXPRESSION_ENABLED}"); taskDefinition.setSkipExpression(expression); }