Search in sources :

Example 51 with TaskData

use of org.kie.server.api.model.taskassigning.TaskData in project droolsjbpm-integration by kiegroup.

the class TaskAssigningRuntimeServiceQueryHelperTest method mockTasks.

private List<TaskData> mockTasks() {
    TaskData task1 = mockTaskData(TASK1_ID, Status.Ready, false, CONTAINER_ID);
    TaskData task2 = mockTaskData(TASK2_ID, Status.Reserved, true, CONTAINER_ID);
    TaskData task3 = mockTaskData(TASK3_ID, Status.Completed, true, CONTAINER_ID);
    TASK1_INPUTS.put(TASK1_PARAM1, TASK1_PARAM1_VALUE);
    TASK1_INPUTS.put(TASK1_PARAM2, null);
    TASK2_INPUTS.put(TASK2_PARAM1, TASK2_PARAM1_VALUE);
    TASK2_INPUTS.put(TASK2_PARAM2, null);
    TASK3_INPUTS.put(TASK3_PARAM1, TASK3_PARAM1_VALUE);
    TASK3_INPUTS.put(TASK3_PARAM2, null);
    TASK1_INPUTS_SANITIZED.put(TASK1_PARAM1, TASK1_PARAM1_VALUE);
    TASK2_INPUTS_SANITIZED.put(TASK2_PARAM1, TASK2_PARAM1_VALUE);
    TASK3_INPUTS_SANITIZED.put(TASK3_PARAM1, TASK3_PARAM1_VALUE);
    when(userTaskService.getTaskInputContentByTaskId(any(), eq(TASK1_ID))).thenReturn(TASK1_INPUTS);
    when(userTaskService.getTaskInputContentByTaskId(any(), eq(TASK2_ID))).thenReturn(TASK2_INPUTS);
    when(userTaskService.getTaskInputContentByTaskId(any(), eq(TASK3_ID))).thenReturn(TASK3_INPUTS);
    return Arrays.asList(task1, task2, task3);
}
Also used : TaskData(org.kie.server.api.model.taskassigning.TaskData)

Example 52 with TaskData

use of org.kie.server.api.model.taskassigning.TaskData in project droolsjbpm-integration by kiegroup.

the class SolutionChangesBuilderTest method discardDuplicatedChanges.

@Test
public void discardDuplicatedChanges() {
    TaskData taskData1 = mockTaskData(1, NAME, Ready, null);
    TaskData taskData2 = mockTaskData(2, NAME, InProgress, null);
    TaskData taskData3 = mockTaskData(3, NAME, Completed, null);
    TaskData taskData4 = mockTaskData(4, NAME, Suspended, null);
    Task task1 = mockTask(taskData1.getTaskId());
    Task task2 = mockTask(taskData2.getTaskId());
    Task task3 = mockTask(taskData3.getTaskId());
    Task task4 = mockTask(taskData4.getTaskId());
    List<TaskData> taskDataList = mockTaskDataList(taskData1, taskData2, taskData3, taskData4);
    TaskAssigningSolution solution = mockSolution(Arrays.asList(task1, task2, task3, task4), Collections.emptyList());
    taskDataList.forEach(taskData -> context.setTaskChangeTime(taskData.getTaskId(), taskData.getLastModificationDate()));
    List<ProblemFactChange<TaskAssigningSolution>> result = SolutionChangesBuilder.create().withSolution(solution).withTasks(taskDataList).withUserSystem(userSystemService).withContext(context).build();
    assertEquals(2, result.size());
    assertChangeIsTheChangeSetId(result, 0);
    assertChangeIsTheDummyTaskAssigned(result, ModelConstants.DUMMY_TASK_PLANNER_241, 1);
}
Also used : Task(org.kie.server.services.taskassigning.core.model.Task) PlanningTask(org.kie.server.api.model.taskassigning.PlanningTask) TaskAssigningSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution) TaskPropertyChangeProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange) DisableUserProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange) ReleaseTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange) UserPropertyChangeProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange) AssignTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange) AddTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange) AddUserProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.AddUserProblemFactChange) RemoveTaskProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveTaskProblemFactChange) ProblemFactChange(org.optaplanner.core.impl.solver.ProblemFactChange) RemoveUserProblemFactChange(org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveUserProblemFactChange) TaskData(org.kie.server.api.model.taskassigning.TaskData) TaskUtil.fromTaskData(org.kie.server.services.taskassigning.planning.util.TaskUtil.fromTaskData) Test(org.junit.Test)

Example 53 with TaskData

use of org.kie.server.api.model.taskassigning.TaskData in project droolsjbpm-integration by kiegroup.

the class LabelValueExtractorRegistryTest method applyTaskDataLabelValueExtractors.

@Test
public void applyTaskDataLabelValueExtractors() {
    Map<String, Object> inputData = new HashMap<>();
    inputData.put(SKILLS_ATTRIBUTE, null);
    inputData.put(AFFINITIES_ATTRIBUTE, SOME_VALUE);
    inputData.put(TestTaskDataLabelValueExtractor.TEST_LABEL, SOME_VALUE);
    TaskData taskData = TaskData.builder().inputData(inputData).build();
    Map<String, Set<Object>> result = new HashMap<>();
    BiConsumer<String, Set<Object>> consumer = result::put;
    LabelValueExtractorRegistry.getInstance().applyLabelValueExtractors(TaskData.class, taskData, consumer);
    assertThat(result.get(DefaultLabels.SKILLS.name())).isEqualTo(Collections.EMPTY_SET);
    assertThat(result.get(DefaultLabels.AFFINITIES.name())).isEqualTo(new HashSet<>(Collections.singleton(SOME_VALUE)));
    assertThat(result.get(TestTaskDataLabelValueExtractor.TEST_LABEL)).isEqualTo(new HashSet<>(Collections.singleton(TestTaskDataLabelValueExtractorOverride.EXAMPLE_LABEL_VALUE2)));
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) TaskData(org.kie.server.api.model.taskassigning.TaskData) Test(org.junit.Test)

Example 54 with TaskData

use of org.kie.server.api.model.taskassigning.TaskData in project droolsjbpm-integration by kiegroup.

the class TaskAssigningTaskDataWithPotentialOwnersQueryMapperTest method assertTaskIsPresent.

protected void assertTaskIsPresent(List<TaskData> taskDataList, int index, Long taskId, Date createdOn, String actualOwner, String deploymentId, String taskName, Integer priority, String processId, Long processInstanceId, String status, Date lastModificationDate, PlanningTask planningTask, List<Pair<String, String>> potentialOwners) {
    TaskData taskData = taskDataList.get(index);
    Set<OrganizationalEntity> potentialOwnersSet = new HashSet<>();
    potentialOwners.forEach(potentialOwner -> potentialOwnersSet.add(OrganizationalEntity.builder().name(potentialOwner.getLeft()).type(potentialOwner.getRight()).build()));
    TaskData expectedTaskData = TaskData.builder().taskId(taskId).createdOn(createdOn != null ? LocalDateTime.ofInstant(createdOn.toInstant(), ZoneId.systemDefault()) : null).actualOwner(actualOwner).containerId(deploymentId).name(taskName).priority(priority).processId(processId).processInstanceId(processInstanceId).status(status).lastModificationDate(lastModificationDate != null ? LocalDateTime.ofInstant(lastModificationDate.toInstant(), ZoneId.systemDefault()) : null).planningTask(planningTask).potentialOwners(potentialOwnersSet).build();
    assertNotNull(taskData);
    assertEquals(expectedTaskData, taskData);
}
Also used : OrganizationalEntity(org.kie.server.api.model.taskassigning.OrganizationalEntity) TaskData(org.kie.server.api.model.taskassigning.TaskData) HashSet(java.util.HashSet)

Example 55 with TaskData

use of org.kie.server.api.model.taskassigning.TaskData in project droolsjbpm-integration by kiegroup.

the class TaskAssigningTaskDataSummaryQueryMapper method buildInstance.

@Override
protected TaskData buildInstance(DataSet dataSetResult, int index) {
    TaskData row = createInstance();
    final Long taskId = getColumnLongValue(dataSetResult, TASK_QUERY_COLUMN.TASK_ID.columnName(), index);
    final String status = getColumnStringValue(dataSetResult, TASK_QUERY_COLUMN.STATUS.columnName(), index);
    String actualOwner = getColumnStringValue(dataSetResult, TASK_QUERY_COLUMN.ACTUAL_OWNER.columnName(), index);
    if (isEmpty(actualOwner)) {
        actualOwner = null;
    }
    final String deploymentId = getColumnStringValue(dataSetResult, TASK_QUERY_COLUMN.DEPLOYMENT_ID.columnName(), index);
    final Long ptTaskId = getColumnLongValue(dataSetResult, TASK_QUERY_COLUMN.PLANNING_TASK_TASK_ID.columnName(), index);
    String assignedUser = null;
    Integer taskIndex = null;
    Integer published = null;
    if (ptTaskId != null) {
        assignedUser = getColumnStringValue(dataSetResult, TASK_QUERY_COLUMN.PLANNING_TASK_ASSIGNED_USER.columnName(), index);
        if (isEmpty(assignedUser)) {
            assignedUser = null;
        }
        taskIndex = getColumnIntValue(dataSetResult, TASK_QUERY_COLUMN.PLANNING_TASK_INDEX.columnName(), index);
        published = getColumnIntValue(dataSetResult, TASK_QUERY_COLUMN.PLANNING_TASK_PUBLISHED.columnName(), index);
    }
    setInstanceValues(row, taskId, null, null, null, deploymentId, status, null, null, null, actualOwner, assignedUser, taskIndex, published);
    return row;
}
Also used : TaskData(org.kie.server.api.model.taskassigning.TaskData)

Aggregations

TaskData (org.kie.server.api.model.taskassigning.TaskData)55 Test (org.junit.Test)30 PlanningTask (org.kie.server.api.model.taskassigning.PlanningTask)26 TaskAssigningSolution (org.kie.server.services.taskassigning.core.model.TaskAssigningSolution)14 TaskUtil.fromTaskData (org.kie.server.services.taskassigning.planning.util.TaskUtil.fromTaskData)13 PlanningExecutionResult (org.kie.server.api.model.taskassigning.PlanningExecutionResult)10 PlanningItemList (org.kie.server.api.model.taskassigning.PlanningItemList)10 Task (org.kie.server.services.taskassigning.core.model.Task)10 AddTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AddTaskProblemFactChange)10 AddUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AddUserProblemFactChange)10 AssignTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.AssignTaskProblemFactChange)10 DisableUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.DisableUserProblemFactChange)10 ReleaseTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.ReleaseTaskProblemFactChange)10 RemoveTaskProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveTaskProblemFactChange)10 RemoveUserProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.RemoveUserProblemFactChange)10 TaskPropertyChangeProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.TaskPropertyChangeProblemFactChange)10 UserPropertyChangeProblemFactChange (org.kie.server.services.taskassigning.core.model.solver.realtime.UserPropertyChangeProblemFactChange)10 ProblemFactChange (org.optaplanner.core.impl.solver.ProblemFactChange)10 PlanningItem (org.kie.server.api.model.taskassigning.PlanningItem)9 ArrayList (java.util.ArrayList)8