Search in sources :

Example 1 with ProcessInstanceUserTaskWithVariables

use of org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariables in project droolsjbpm-integration by kiegroup.

the class ConvertUtils method convertToUserTaskWithVariablesList.

public static ProcessInstanceUserTaskWithVariablesList convertToUserTaskWithVariablesList(List<UserTaskInstanceWithPotOwnerDesc> queryUserTasksByVariables) {
    List<ProcessInstanceUserTaskWithVariables> data = new ArrayList<>();
    for (UserTaskInstanceWithPotOwnerDesc desc : queryUserTasksByVariables) {
        ProcessInstanceUserTaskWithVariables var = new ProcessInstanceUserTaskWithVariables();
        var.setId(desc.getTaskId());
        var.setName(desc.getName());
        var.setDescription(desc.getDescription());
        var.setCorrelationKey(desc.getCorrelationKey());
        var.setActualOwner(desc.getActualOwner());
        var.setProcessDefinitionId(desc.getProcessId());
        var.setPotentialOwners(desc.getPotentialOwners());
        var.setProcessInstanceId(desc.getProcessInstanceId());
        var.setProcessVariables(desc.getProcessVariables());
        var.setInputVariables(desc.getInputdata());
        var.setStatus(desc.getStatus());
        data.add(var);
    }
    ProcessInstanceUserTaskWithVariablesList result = new ProcessInstanceUserTaskWithVariablesList();
    result.setUserTaskWithVariables(data.parallelStream().toArray(ProcessInstanceUserTaskWithVariables[]::new));
    return result;
}
Also used : UserTaskInstanceWithPotOwnerDesc(org.jbpm.services.api.model.UserTaskInstanceWithPotOwnerDesc) ProcessInstanceUserTaskWithVariablesList(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList) ArrayList(java.util.ArrayList) ProcessInstanceUserTaskWithVariables(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariables)

Example 2 with ProcessInstanceUserTaskWithVariables

use of org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariables in project droolsjbpm-integration by kiegroup.

the class RuntimeDataServiceIntegrationTest method testQueryProcessesByVariables.

@Test
public void testQueryProcessesByVariables() throws Exception {
    Assume.assumeTrue(configuration.isRest());
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("stringData", "waiting for signal");
    parameters.put("personData", createPersonInstance(USER_JOHN));
    Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK, parameters);
    List<TaskSummary> tasks = taskClient.findTasksByStatusByProcessInstanceId(processInstanceId, null, 0, 10);
    Assertions.assertThat(tasks).hasSize(1);
    SearchQueryFilterSpec spec = new SearchQueryFilterSpec();
    spec.setAttributesQueryParams(list(equalsTo(PROCESS_ATTR_DEPLOYMENT_ID, CONTAINER_ID)));
    List<ProcessInstanceCustomVars> listProcesses = queryClient.queryProcessesByVariables(spec, 0, 2);
    Assertions.assertThat(listProcesses).extracting(ProcessInstanceCustomVars::getContainerId).containsOnly(CONTAINER_ID);
    SearchQueryFilterSpec specHistory = new SearchQueryFilterSpec();
    specHistory.setAttributesQueryParams(list(history(), equalsTo(PROCESS_ATTR_DEPLOYMENT_ID, CONTAINER_ID)));
    List<ProcessInstanceCustomVars> listHistoryProcesses = queryClient.queryProcessesByVariables(specHistory, 0, 2, "processInstanceId", false);
    assertNotNull(listHistoryProcesses);
    listHistoryProcesses.stream().forEach(e -> assertEquals(CONTAINER_ID, e.getContainerId()));
    spec = new SearchQueryFilterSpec();
    spec.setAttributesQueryParams(list(onlyActiveTasks(), equalsTo(PROCESS_ATTR_DEFINITION_ID, PROCESS_ID_USERTASK)));
    List<ProcessInstanceUserTaskWithVariables> listTasks = queryClient.queryUserTaskByVariables(spec, 0, 2, "processInstanceId", true);
    Assertions.assertThat(listTasks).hasSize(1).extracting(ProcessInstanceUserTaskWithVariables::getProcessDefinitionId).containsOnly(PROCESS_ID_USERTASK);
    this.taskClient.startTask(CONTAINER_ID, listTasks.get(0).getId(), "yoda");
    this.taskClient.completeTask(CONTAINER_ID, listTasks.get(0).getId(), "yoda", Collections.emptyMap());
    spec = new SearchQueryFilterSpec();
    spec.setAttributesQueryParams(list(onlyCompletedTasks(), equalsTo(PROCESS_ATTR_DEFINITION_ID, PROCESS_ID_USERTASK)));
    listTasks = queryClient.queryUserTaskByVariables(spec, 0, 2, "task.id", false);
    Assertions.assertThat(listTasks).hasSize(1);
    spec = new SearchQueryFilterSpec();
    spec.setAttributesQueryParams(list(onlyActiveTasks(), equalsTo(PROCESS_ATTR_DEFINITION_ID, PROCESS_ID_USERTASK)));
    listTasks = queryClient.queryUserTaskByVariables(spec, 0, 2, "task.id", true);
    Assertions.assertThat(listTasks).hasSize(1);
    this.taskClient.startTask(CONTAINER_ID, listTasks.get(0).getId(), "yoda");
    this.taskClient.completeTask(CONTAINER_ID, listTasks.get(0).getId(), "yoda", Collections.emptyMap());
    spec = new SearchQueryFilterSpec();
    spec.setAttributesQueryParams(list(onlyActiveTasks(), equalsTo(PROCESS_ATTR_DEFINITION_ID, PROCESS_ID_USERTASK)));
    listTasks = queryClient.queryUserTaskByVariables(spec, 0, 2);
    Assertions.assertThat(listTasks).isEmpty();
    spec = new SearchQueryFilterSpec();
    spec.setAttributesQueryParams(list(onlyCompletedTasks(), equalsTo(PROCESS_ATTR_DEFINITION_ID, PROCESS_ID_USERTASK)));
    listTasks = queryClient.queryUserTaskByVariables(spec, 0, 2);
    Assertions.assertThat(listTasks).isEmpty();
}
Also used : ProcessInstanceCustomVars(org.kie.server.api.model.instance.ProcessInstanceCustomVars) HashMap(java.util.HashMap) TaskSummary(org.kie.server.api.model.instance.TaskSummary) SearchQueryFilterSpec(org.kie.server.api.model.definition.SearchQueryFilterSpec) ProcessInstanceUserTaskWithVariables(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariables) Test(org.junit.Test)

Aggregations

ProcessInstanceUserTaskWithVariables (org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariables)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 UserTaskInstanceWithPotOwnerDesc (org.jbpm.services.api.model.UserTaskInstanceWithPotOwnerDesc)1 Test (org.junit.Test)1 SearchQueryFilterSpec (org.kie.server.api.model.definition.SearchQueryFilterSpec)1 ProcessInstanceCustomVars (org.kie.server.api.model.instance.ProcessInstanceCustomVars)1 ProcessInstanceUserTaskWithVariablesList (org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList)1 TaskSummary (org.kie.server.api.model.instance.TaskSummary)1