Search in sources :

Example 11 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class TaskAuditBaseTest method testExitAfterClaim.

@Test
public void testExitAfterClaim() {
    // One potential owner, should go straight to state Reserved
    Task task = new TaskFluent().setName("This is my task name 2").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
    taskService.addTask(task, new HashMap<String, Object>());
    long taskId = task.getId();
    List<TaskSummary> allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
    assertEquals(1, allGroupAuditTasks.size());
    assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Ready"));
    taskService.claim(taskId, "Darth Vader");
    allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
    assertEquals(0, allGroupAuditTasks.size());
    allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", null, null, null);
    assertEquals(1, allGroupAuditTasks.size());
    assertTrue(allGroupAuditTasks.get(0).getStatusId().equals("Reserved"));
    taskService.exit(taskId, "Administrator");
    List<AuditTask> allHistoryAuditTasks = taskAuditService.getAllAuditTasks(new QueryFilter(0, 0));
    assertEquals(1, allHistoryAuditTasks.size());
    allGroupAuditTasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", null, null, null);
    assertEquals(0, allGroupAuditTasks.size());
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) TaskFluent(org.jbpm.services.task.utils.TaskFluent) TaskSummary(org.kie.api.task.model.TaskSummary) AuditTask(org.kie.internal.task.api.AuditTask) HumanTaskServicesBaseTest(org.jbpm.services.task.HumanTaskServicesBaseTest) Test(org.junit.Test)

Example 12 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class TaskAuditBaseTest method testDueDateUpdate.

private void testDueDateUpdate(Date oldDate, Date newDate, boolean changeExpected) {
    Task task = new TaskFluent().setDueDate(oldDate).setAdminUser("Administrator").getTask();
    taskService.addTask(task, new HashMap<String, Object>());
    long taskId = task.getId();
    taskService.setExpirationDate(taskId, newDate);
    task = taskService.getTaskById(taskId);
    Assertions.assertThat(task.getTaskData().getExpirationTime()).isEqualTo(newDate);
    List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
    Assertions.assertThat(auditTasks).hasSize(1);
    Assertions.assertThat(auditTasks.get(0).getDueDate()).isEqualTo(newDate);
    List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
    if (changeExpected) {
        Assertions.assertThat(taskEvents).hasSize(2);
        Assertions.assertThat(taskEvents.get(1).getMessage()).contains(String.valueOf(oldDate), String.valueOf(newDate));
    } else {
        Assertions.assertThat(taskEvents).hasSize(1);
    }
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) TaskFluent(org.jbpm.services.task.utils.TaskFluent) TaskEvent(org.kie.internal.task.api.model.TaskEvent) AuditTask(org.kie.internal.task.api.AuditTask)

Example 13 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class RuntimeDataServiceImpl method getTasksAssignedAsPotentialOwnerByExpirationDateOptional.

@Override
public List<TaskSummary> getTasksAssignedAsPotentialOwnerByExpirationDateOptional(String userId, List<Status> status, Date from, QueryFilter filter) {
    List<TaskSummary> taskSummaries = null;
    if (from != null) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("expirationDate", from);
        QueryFilter qf = new QueryFilter("(t.taskData.expirationTime = :expirationDate or t.taskData.expirationTime is null)", params, "order by t.id DESC", filter.getOffset(), filter.getCount());
        taskSummaries = getTasksAssignedAsPotentialOwnerByStatus(userId, status, qf);
    } else {
        QueryFilter qf = new QueryFilter(filter.getOffset(), filter.getCount());
        taskSummaries = getTasksAssignedAsPotentialOwnerByStatus(userId, status, qf);
    }
    return taskSummaries;
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary)

Example 14 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class RuntimeDataServiceImpl method getTasksOwnedByExpirationDateOptional.

@Override
public List<TaskSummary> getTasksOwnedByExpirationDateOptional(String userId, List<Status> strStatuses, Date from, QueryFilter filter) {
    List<TaskSummary> taskSummaries = null;
    if (from != null) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("expirationDate", from);
        QueryFilter qf = new QueryFilter("(t.taskData.expirationTime = :expirationDate or t.taskData.expirationTime is null)", params, "order by t.id DESC", filter.getOffset(), filter.getCount());
        taskSummaries = getTasksOwnedByStatus(userId, strStatuses, qf);
    } else {
        QueryFilter qf = new QueryFilter(filter.getOffset(), filter.getCount());
        taskSummaries = getTasksOwnedByStatus(userId, strStatuses, qf);
    }
    return taskSummaries;
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary)

Example 15 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class CaseRuntimeDataServiceImplTest method testTransitionBetweenStagesWithConditionsInCase.

@Test
public void testTransitionBetweenStagesWithConditionsInCase() {
    Map<String, OrganizationalEntity> roleAssignments = new HashMap<>();
    roleAssignments.put("owner", new UserImpl(USER));
    Map<String, Object> data = new HashMap<>();
    data.put("customData", "none");
    CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), TWO_STAGES_CONDITIONS_CASE_P_ID, data, roleAssignments);
    String caseId = caseService.startCase(deploymentUnit.getIdentifier(), TWO_STAGES_CONDITIONS_CASE_P_ID, caseFile);
    assertNotNull(caseId);
    try {
        Collection<CaseStageInstance> stage = caseRuntimeDataService.getCaseInstanceStages(caseId, true, new QueryContext(0, 1));
        assertNotNull(stage);
        assertEquals(1, stage.size());
        assertEquals("Stage One", stage.iterator().next().getName());
        assertEquals(StageStatus.Active, stage.iterator().next().getStatus());
        Collection<AdHocFragment> adhocTasks = caseRuntimeDataService.getAdHocFragmentsForCase(caseId);
        assertNotNull(adhocTasks);
        assertEquals(1, adhocTasks.size());
        assertEquals("Task 1", adhocTasks.iterator().next().getName());
        caseService.triggerAdHocFragment(caseId, "Task 1", null);
        List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
        assertNotNull(tasks);
        assertEquals(1, tasks.size());
        assertTask(tasks.get(0), "john", "Task 1", Status.Reserved);
        Map<String, Object> params = new HashMap<>();
        params.put("myData", "nextStage");
        userTaskService.completeAutoProgress(tasks.get(0).getId(), "john", params);
        stage = caseRuntimeDataService.getCaseInstanceStages(caseId, true, new QueryContext(0, 1));
        assertNotNull(stage);
        assertEquals(1, stage.size());
        assertEquals("Stage Two", stage.iterator().next().getName());
        assertEquals(StageStatus.Active, stage.iterator().next().getStatus());
        adhocTasks = caseRuntimeDataService.getAdHocFragmentsForCase(caseId);
        assertNotNull(adhocTasks);
        assertEquals(1, adhocTasks.size());
        assertEquals("Task 2", adhocTasks.iterator().next().getName());
        caseService.triggerAdHocFragment(caseId, "Task 2", null);
        tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
        assertNotNull(tasks);
        assertEquals(1, tasks.size());
        assertTask(tasks.get(0), "john", "Task 2", Status.Reserved);
        params = new HashMap<>();
        params.put("myData", "none");
        userTaskService.completeAutoProgress(tasks.get(0).getId(), "john", params);
        CaseInstance instance = caseService.getCaseInstance(caseId);
        Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CLOSED.getId());
        caseId = null;
    } catch (Exception e) {
        logger.error("Unexpected error {}", e.getMessage(), e);
        fail("Unexpected exception " + e.getMessage());
    } finally {
        if (caseId != null) {
            caseService.cancelCase(caseId);
        }
    }
}
Also used : OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) HashMap(java.util.HashMap) CaseStageInstance(org.jbpm.casemgmt.api.model.instance.CaseStageInstance) QueryContext(org.kie.api.runtime.query.QueryContext) AdHocFragment(org.jbpm.casemgmt.api.model.AdHocFragment) CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CaseInstance(org.jbpm.casemgmt.api.model.instance.CaseInstance) QueryFilter(org.kie.internal.query.QueryFilter) UserImpl(org.jbpm.services.task.impl.model.UserImpl) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractCaseServicesBaseTest(org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest) Test(org.junit.Test)

Aggregations

QueryFilter (org.kie.internal.query.QueryFilter)149 Test (org.junit.Test)127 TaskSummary (org.kie.api.task.model.TaskSummary)122 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)52 HashMap (java.util.HashMap)47 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)31 KModuleDeploymentServiceTest (org.jbpm.kie.services.test.KModuleDeploymentServiceTest)26 AuditTask (org.kie.internal.task.api.AuditTask)25 ArrayList (java.util.ArrayList)24 QueryContext (org.kie.api.runtime.query.QueryContext)24 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)23 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)21 Task (org.kie.api.task.model.Task)19 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)18 TaskFluent (org.jbpm.services.task.utils.TaskFluent)17 TaskEvent (org.kie.internal.task.api.model.TaskEvent)17 HumanTaskServicesBaseTest (org.jbpm.services.task.HumanTaskServicesBaseTest)14 Status (org.kie.api.task.model.Status)13 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)11 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)10