use of org.kie.server.services.taskassigning.core.model.Group in project droolsjbpm-integration by kiegroup.
the class SolutionChangesBuilderTest method buildUsersForEqualityCase.
private Pair<User, org.kie.server.services.taskassigning.user.system.api.User> buildUsersForEqualityCase() {
Map<String, Set<Object>> labelValues = new HashMap<>();
labelValues.put(DefaultLabels.SKILLS.name(), Collections.singleton(SKILL1));
labelValues.put(DefaultLabels.AFFINITIES.name(), Collections.emptySet());
Map<String, Object> attributes = new HashMap<>();
attributes.put(SKILLS_ATTRIBUTE_NAME, SKILL1);
attributes.put(ATTRIBUTE1_ID, ATTRIBUTE1_VALUE);
User user1 = mockUser(USER1_ID, true, Collections.singleton(new Group(GROUP1_ID.hashCode(), GROUP1_ID)), attributes, labelValues);
Map<String, Object> externalUserAttributes = new HashMap<>();
externalUserAttributes.put(ATTRIBUTE1_ID, ATTRIBUTE1_VALUE);
externalUserAttributes.put(SKILLS_ATTRIBUTE_NAME, SKILL1);
Set<org.kie.server.services.taskassigning.user.system.api.Group> externalUserGroups = new HashSet<>();
externalUserGroups.add(mockExternalGroup(GROUP1_ID));
org.kie.server.services.taskassigning.user.system.api.User externalUser = mockExternalUser(USER1_ID, externalUserGroups, externalUserAttributes);
return Pair.of(user1, externalUser);
}
use of org.kie.server.services.taskassigning.core.model.Group in project droolsjbpm-integration by kiegroup.
the class TaskUtilTest method fromTaskData.
private void fromTaskData(Map<String, Object> inputData, Set<Object> expectedSkills, Set<Object> expectedAffinities) {
Set<OrganizationalEntity> potentialOwners = new HashSet<>();
potentialOwners.add(OE_1);
potentialOwners.add(OE_2);
TaskData taskData = TaskData.builder().taskId(TASK_ID).processInstanceId(PROCESS_INSTANCE_ID).processId(PROCESS_ID).containerId(CONTAINER_ID).name(NAME).priority(PRIORITY).status(STATUS).inputData(inputData).potentialOwners(potentialOwners).build();
Task task = TaskUtil.fromTaskData(taskData);
assertEquals(TASK_ID, task.getId(), 0);
assertEquals(PROCESS_INSTANCE_ID, task.getProcessInstanceId(), 0);
assertEquals(PROCESS_ID, task.getProcessId());
assertEquals(CONTAINER_ID, task.getContainerId());
assertEquals(NAME, task.getName());
assertEquals(PRIORITY, task.getPriority(), 0);
assertEquals(STATUS, task.getStatus());
assertEquals(inputData, task.getInputData());
assertEquals(potentialOwners.size(), task.getPotentialOwners().size(), 2);
User user = task.getPotentialOwners().stream().filter(u -> OE_1.getName().equals(u.getEntityId()) && u.isUser()).map(u -> (User) u).findFirst().orElse(null);
assertNotNull(user);
Group group = task.getPotentialOwners().stream().filter(g -> OE_2.getName().equals(g.getEntityId()) && !g.isUser()).map(g -> (Group) g).findFirst().orElse(null);
assertNotNull(group);
assertEquals(expectedSkills, task.getLabelValues(SKILLS.name()));
assertEquals(expectedAffinities, task.getLabelValues(AFFINITIES.name()));
}
use of org.kie.server.services.taskassigning.core.model.Group in project droolsjbpm-integration by kiegroup.
the class TaskAssigningGenerator method createUserList.
private void createUserList(TaskAssigningSolution solution, int userListSize, List<Group> groupList) {
List<User> userList = new ArrayList<>(userListSize);
userNameGenerator.predictMaximumSizeAndReset(userListSize);
for (int i = 0; i < userListSize; i++) {
User user = new User();
user.setId((long) i);
String userName = userNameGenerator.generateNextValue();
user.setEntityId(userName);
int groupListSize = USER_GROUP_SET_SIZE_MINIMUM + random.nextInt(USER_GROUP_SET_MAXIMUM - USER_GROUP_SET_SIZE_MINIMUM);
if (groupListSize > groupList.size()) {
groupListSize = groupList.size();
}
Set<Group> groupSet = new LinkedHashSet<>(groupListSize);
int groupListIndex = random.nextInt(groupList.size());
for (int j = 0; j < groupListSize; j++) {
groupSet.add(groupList.get(groupListIndex));
groupListIndex = (groupListIndex + 1) % groupList.size();
}
user.setGroups(groupSet);
logger.trace("Created user with entityId ({}).", userName);
userList.add(user);
}
solution.setUserList(userList);
}
use of org.kie.server.services.taskassigning.core.model.Group in project droolsjbpm-integration by kiegroup.
the class TaskAssigningGenerator method createTaskAssigningSolution.
private TaskAssigningSolution createTaskAssigningSolution(String fileName, int taskListSize, int groupListSize, int userListSize) {
TaskAssigningSolution solution = new TaskAssigningSolution();
solution.setId(0L);
List<Group> groupList = createGroupList(groupListSize);
createUserList(solution, userListSize, groupList);
createTaskList(solution, taskListSize, groupList);
BigInteger totalFacts = AbstractSolutionImporter.factorial(taskListSize + userListSize - 1);
BigInteger fixedFacts = AbstractSolutionImporter.factorial(userListSize - 1);
BigInteger possibleSolutionSize = (totalFacts == null || fixedFacts == null) ? null : totalFacts.divide(fixedFacts);
logger.info("TaskAssigningSolution {} has {} tasks, {} groups, and {} users with a search space of {}.", fileName, taskListSize, groupListSize, userListSize, AbstractSolutionImporter.getFlooredPossibleSolutionSize(possibleSolutionSize));
return solution;
}
use of org.kie.server.services.taskassigning.core.model.Group in project droolsjbpm-integration by kiegroup.
the class TaskUtil method fromTaskData.
public static Task fromTaskData(TaskData taskData) {
final Task task = new Task(taskData.getTaskId(), taskData.getProcessInstanceId(), taskData.getProcessId(), taskData.getContainerId(), taskData.getName(), taskData.getPriority(), taskData.getStatus(), taskData.getInputData());
if (taskData.getPotentialOwners() != null) {
taskData.getPotentialOwners().forEach(potentialOwner -> {
if (isUser(potentialOwner.getType())) {
task.getPotentialOwners().add(new User(potentialOwner.getName().hashCode(), potentialOwner.getName()));
} else {
task.getPotentialOwners().add(new Group(potentialOwner.getName().hashCode(), potentialOwner.getName()));
}
});
}
LabelValueExtractorRegistry.getInstance().applyLabelValueExtractors(TaskData.class, taskData, task::setLabelValues);
return task;
}
Aggregations