public UserInfo execute(Context cntxt) { TaskContext context = (TaskContext) cntxt; return (UserInfo) context.get(EnvironmentName.TASK_USER_INFO); } }
UserInfo userInfo = (UserInfo) ((org.jbpm.services.task.commands.TaskContext)context).get(EnvironmentName.TASK_USER_INFO); if (userInfo != null) { logger.debug("Groups going to be resolved by {}", userInfo);
UserInfo userInfo = (UserInfo) ctx.get(EnvironmentName.TASK_USER_INFO);
@Override public UserGroupCallback getUserGroupCallback() { return (UserGroupCallback) get(EnvironmentName.TASK_USER_GROUP_CALLBACK); }
protected ExecutionErrorHandler getExecutionErrorHandler() { ExecutionErrorManager errorManager = (ExecutionErrorManager) ((org.jbpm.services.task.commands.TaskContext) context).get(EnvironmentName.EXEC_ERROR_MANAGER); if (errorManager == null) { return new NoOpExecutionErrorHandler(); } return errorManager.getHandler(); } }
@Override public Assignment apply(Task task, TaskContext taskContext, String excludedUser) { UserInfo userInfo = (UserInfo) ((org.jbpm.services.task.commands.TaskContext)taskContext).get(EnvironmentName.TASK_USER_INFO); List<OrganizationalEntity> excluded = (getExcludedEntities(task, userInfo)); // Get the the users from the task's the potential owners, making sure that excluded users are not included List<OrganizationalEntity> potentialOwners = task.getPeopleAssignments().getPotentialOwners().stream() .filter(oe -> oe instanceof User && !excluded.contains(oe) && !oe.getId().equals(excludedUser)) .collect(Collectors.toList()); // Get the users belonging to groups that are potential owners task.getPeopleAssignments().getPotentialOwners().stream().filter(oe -> oe instanceof Group) .forEach(oe -> { Iterator<OrganizationalEntity> groupUsers = userInfo.getMembersForGroup((Group)oe); if (groupUsers != null) { groupUsers.forEachRemaining(user -> { if (user != null && !excluded.contains(user) && !potentialOwners.contains(user) && !user.getId().equals(excludedUser)) { potentialOwners.add(user); } }); } }); logger.debug("Asking the load calculator [{}] for task loads for the users {}",calculator.getIdentifier(),potentialOwners); List<User> users = potentialOwners.stream().map(entityToUser).collect(Collectors.toList()); Collection<UserTaskLoad> loads = calculator.getUserTaskLoads(users, taskContext); UserTaskLoad lightestLoad = loads.stream().min(UserTaskLoad::compareTo).orElse(null); return lightestLoad != null ? new Assignment(lightestLoad.getUser().getId()):null; }
@Override public Assignment apply(Task task, TaskContext taskContext, String excludedUser) { UserInfo userInfo = (UserInfo) ((org.jbpm.services.task.commands.TaskContext) taskContext).get(EnvironmentName.TASK_USER_INFO); List<OrganizationalEntity> excluded = getExcludedEntities(task, userInfo); // Get the the users from the task's the potential owners List<OrganizationalEntity> potentialOwners = task.getPeopleAssignments().getPotentialOwners().stream() .filter(oe -> oe instanceof User && !excluded.contains(oe)) .collect(Collectors.toList()); // Get the users belonging to groups that are potential owners task.getPeopleAssignments().getPotentialOwners().stream().filter(oe -> oe instanceof Group) .forEach(oe -> { Iterator<OrganizationalEntity> groupUsers = userInfo.getMembersForGroup((Group) oe); if (groupUsers != null) { groupUsers.forEachRemaining(user -> { if (user != null && !excluded.contains(user) && !potentialOwners.contains(user)) { potentialOwners.add(user); } }); } }); if (excludedUser != null) { logger.debug("Removing excluded user {} from the list of eligible users", excludedUser); potentialOwners.removeIf(entity -> entity.getId().equals(excludedUser)); } String queueName = getQueueName(task); CircularQueue<OrganizationalEntity> mappedQueue = synchronizedQueue(queueName, potentialOwners); OrganizationalEntity owner = mappedQueue.take(); return new Assignment(owner.getId()); }