Java Code Examples for org.flowable.task.api.Task#setPriority()

The following examples show how to use org.flowable.task.api.Task#setPriority() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskResource.java    From plumdo-work with Apache License 2.0 5 votes vote down vote up
@PutMapping(value = "/tasks/{taskId}", name = "任务修改")
public TaskResponse updateTask(@PathVariable String taskId, @RequestBody TaskEditRequest taskEditRequest) {
    Task task = getTaskFromRequest(taskId);
    task.setName(taskEditRequest.getName());
    task.setDescription(taskEditRequest.getDescription());
    task.setAssignee(taskEditRequest.getAssignee());
    task.setOwner(taskEditRequest.getOwner());
    task.setDueDate(taskEditRequest.getDueDate());
    task.setPriority(taskEditRequest.getPriority());
    task.setCategory(taskEditRequest.getCategory());
    taskService.saveTask(task);
    return restResponseFactory.createTaskResponse(task);
}
 
Example 2
Source File: TaskRepresentation.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void fillTask(Task task) {
    task.setName(name);
    task.setDescription(description);
    if (assignee != null && assignee.getId() != null) {
        task.setAssignee(String.valueOf(assignee.getId()));
    }
    task.setDueDate(dueDate);
    if (priority != null) {
        task.setPriority(priority);
    }
    task.setCategory(category);
}
 
Example 3
Source File: TaskBaseResource.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Populate the task based on the values that are present in the given {@link TaskRequest}.
 */
protected void populateTaskFromRequest(Task task, TaskRequest taskRequest) {
    if (taskRequest.isNameSet()) {
        task.setName(taskRequest.getName());
    }
    if (taskRequest.isAssigneeSet()) {
        task.setAssignee(taskRequest.getAssignee());
    }
    if (taskRequest.isDescriptionSet()) {
        task.setDescription(taskRequest.getDescription());
    }
    if (taskRequest.isDuedateSet()) {
        task.setDueDate(taskRequest.getDueDate());
    }
    if (taskRequest.isOwnerSet()) {
        task.setOwner(taskRequest.getOwner());
    }
    if (taskRequest.isParentTaskIdSet()) {
        task.setParentTaskId(taskRequest.getParentTaskId());
    }
    if (taskRequest.isPrioritySet()) {
        task.setPriority(taskRequest.getPriority());
    }
    if (taskRequest.isCategorySet()) {
        task.setCategory(taskRequest.getCategory());
    }
    if (taskRequest.isTenantIdSet()) {
        task.setTenantId(taskRequest.getTenantId());
    }
    if (taskRequest.isFormKeySet()) {
        task.setFormKey(taskRequest.getFormKey());
    }

    if (taskRequest.isDelegationStateSet()) {
        DelegationState delegationState = getDelegationState(taskRequest.getDelegationState());
        task.setDelegationState(delegationState);
    }
}
 
Example 4
Source File: TaskBaseResource.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Populate the task based on the values that are present in the given {@link TaskRequest}.
 */
protected void populateTaskFromRequest(Task task, TaskRequest taskRequest) {
    if (taskRequest.isNameSet()) {
        task.setName(taskRequest.getName());
    }
    if (taskRequest.isAssigneeSet()) {
        task.setAssignee(taskRequest.getAssignee());
    }
    if (taskRequest.isDescriptionSet()) {
        task.setDescription(taskRequest.getDescription());
    }
    if (taskRequest.isDuedateSet()) {
        task.setDueDate(taskRequest.getDueDate());
    }
    if (taskRequest.isOwnerSet()) {
        task.setOwner(taskRequest.getOwner());
    }
    if (taskRequest.isParentTaskIdSet()) {
        task.setParentTaskId(taskRequest.getParentTaskId());
    }
    if (taskRequest.isPrioritySet()) {
        task.setPriority(taskRequest.getPriority());
    }
    if (taskRequest.isCategorySet()) {
        task.setCategory(taskRequest.getCategory());
    }
    if (taskRequest.isTenantIdSet()) {
        task.setTenantId(taskRequest.getTenantId());
    }
    if (taskRequest.isFormKeySet()) {
        task.setFormKey(taskRequest.getFormKey());
    }

    if (taskRequest.isDelegationStateSet()) {
        DelegationState delegationState = getDelegationState(taskRequest.getDelegationState());
        task.setDelegationState(delegationState);
    }
}
 
Example 5
Source File: TaskQueryResourceTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
/**
 * Test querying tasks. GET cmmn-runtime/tasks
 */
public void testQueryTasksWithPaging() throws Exception {
    try {
        Calendar adhocTaskCreate = Calendar.getInstance();
        adhocTaskCreate.set(Calendar.MILLISECOND, 0);

        cmmnEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime());
        List<String> taskIdList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Task adhocTask = taskService.newTask();
            adhocTask.setAssignee("gonzo");
            adhocTask.setOwner("owner");
            adhocTask.setDelegationState(DelegationState.PENDING);
            adhocTask.setDescription("Description one");
            adhocTask.setName("Name one");
            adhocTask.setDueDate(adhocTaskCreate.getTime());
            adhocTask.setPriority(100);
            taskService.saveTask(adhocTask);
            taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT);
            taskIdList.add(adhocTask.getId());
        }
        Collections.sort(taskIdList);

        // Check filter-less to fetch all tasks
        String url = CmmnRestUrls.createRelativeResourceUrl(CmmnRestUrls.URL_TASK_QUERY);
        ObjectNode requestNode = objectMapper.createObjectNode();
        String[] taskIds = new String[] { taskIdList.get(0), taskIdList.get(1), taskIdList.get(2) };
        assertResultsPresentInPostDataResponse(url + "?size=3&sort=id&order=asc", requestNode, taskIds);

        taskIds = new String[] { taskIdList.get(4), taskIdList.get(5), taskIdList.get(6), taskIdList.get(7) };
        assertResultsPresentInPostDataResponse(url + "?start=4&size=4&sort=id&order=asc", requestNode, taskIds);

        taskIds = new String[] { taskIdList.get(8), taskIdList.get(9) };
        assertResultsPresentInPostDataResponse(url + "?start=8&size=10&sort=id&order=asc", requestNode, taskIds);

    } finally {
        // Clean adhoc-tasks even if test fails
        List<Task> tasks = taskService.createTaskQuery().list();
        for (Task task : tasks) {
            if (task.getScopeId() == null) {
                taskService.deleteTask(task.getId(), true);
            }
        }
    }
}
 
Example 6
Source File: TaskQueryResourceTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
/**
 * Test querying tasks. GET runtime/tasks
 */
@Test
public void testQueryTasksWithPaging() throws Exception {
    try {
        Calendar adhocTaskCreate = Calendar.getInstance();
        adhocTaskCreate.set(Calendar.MILLISECOND, 0);

        processEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime());
        List<String> taskIdList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Task adhocTask = taskService.newTask();
            adhocTask.setAssignee("gonzo");
            adhocTask.setOwner("owner");
            adhocTask.setDelegationState(DelegationState.PENDING);
            adhocTask.setDescription("Description one");
            adhocTask.setName("Name one");
            adhocTask.setDueDate(adhocTaskCreate.getTime());
            adhocTask.setPriority(100);
            taskService.saveTask(adhocTask);
            taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT);
            taskIdList.add(adhocTask.getId());
        }
        Collections.sort(taskIdList);

        // Check filter-less to fetch all tasks
        String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_QUERY);
        ObjectNode requestNode = objectMapper.createObjectNode();
        String[] taskIds = new String[] { taskIdList.get(0), taskIdList.get(1), taskIdList.get(2) };
        assertResultsPresentInPostDataResponse(url + "?size=3&sort=id&order=asc", requestNode, taskIds);

        taskIds = new String[] { taskIdList.get(4), taskIdList.get(5), taskIdList.get(6), taskIdList.get(7) };
        assertResultsPresentInPostDataResponse(url + "?start=4&size=4&sort=id&order=asc", requestNode, taskIds);

        taskIds = new String[] { taskIdList.get(8), taskIdList.get(9) };
        assertResultsPresentInPostDataResponse(url + "?start=8&size=10&sort=id&order=asc", requestNode, taskIds);

    } finally {
        // Clean adhoc-tasks even if test fails
        List<Task> tasks = taskService.createTaskQuery().list();
        for (Task task : tasks) {
            if (task.getExecutionId() == null) {
                taskService.deleteTask(task.getId(), true);
            }
        }
    }
}
 
Example 7
Source File: AsyncCmmnHistoryTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void createCmmnAsynchUserTaskLogEntries() {
    CaseInstance caseInstance = deployAndStartOneHumanTaskCaseModel();

    Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
    task.setName("newName");
    task.setPriority(0);
    cmmnTaskService.saveTask(task);
    cmmnTaskService.setAssignee(task.getId(), "newAssignee");
    cmmnTaskService.setOwner(task.getId(), "newOwner");
    cmmnTaskService.setDueDate(task.getId(), new Date());
    cmmnTaskService.addUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT);
    cmmnTaskService.addGroupIdentityLink(task.getId(), "testGroup", IdentityLinkType.PARTICIPANT);
    cmmnTaskService.deleteUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT);
    cmmnTaskService.deleteGroupIdentityLink(task.getId(), "testGroup", IdentityLinkType.PARTICIPANT);
    cmmnTaskService.complete(task.getId());

    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().count()).isZero();
    assertThat(cmmnManagementService.createHistoryJobQuery().count()).isEqualTo(10l);

    waitForAsyncHistoryExecutorToProcessAllJobs();

    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).count()).isEqualTo(11l);
    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_CREATED.name()).count())
            .isEqualTo(1);
    assertThat(
            cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_NAME_CHANGED.name()).count())
            .isEqualTo(1);
    assertThat(
            cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_PRIORITY_CHANGED.name())
                    .count())
            .isEqualTo(1);
    assertThat(
            cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_ASSIGNEE_CHANGED.name())
                    .count())
            .isEqualTo(1);
    assertThat(
            cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_OWNER_CHANGED.name()).count())
            .isEqualTo(1);
    assertThat(
            cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_DUEDATE_CHANGED.name())
                    .count())
            .isEqualTo(1);
    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_IDENTITY_LINK_ADDED.name())
            .count()).isEqualTo(2);
    assertThat(
            cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_IDENTITY_LINK_REMOVED.name())
                    .count()).isEqualTo(2);
    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_COMPLETED.name()).count())
            .isEqualTo(1);
}
 
Example 8
Source File: AsyncHistoryTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void testAsynchUsertTaskLogEntries() {
    deployOneTaskTestProcess();
    ProcessInstance oneTaskProcess = runtimeService.startProcessInstanceByKey("oneTaskProcess");

    Task task = taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult();
    task.setName("newName");
    task.setPriority(0);
    taskService.saveTask(task);
    taskService.setAssignee(task.getId(), "newAssignee");
    taskService.setOwner(task.getId(), "newOwner");
    taskService.setDueDate(task.getId(), new Date());
    taskService.addUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT);
    taskService.addGroupIdentityLink(task.getId(), "testGroup", IdentityLinkType.PARTICIPANT);
    taskService.deleteUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT);
    taskService.deleteGroupIdentityLink(task.getId(), "testGroup", IdentityLinkType.PARTICIPANT);
    runtimeService.suspendProcessInstanceById(oneTaskProcess.getId());
    runtimeService.activateProcessInstanceById(oneTaskProcess.getId());
    taskService.complete(task.getId());

    assertThat(historyService.createHistoricTaskLogEntryQuery().count()).isZero();
    assertThat(managementService.createHistoryJobQuery().count()).isEqualTo(12l);

    waitForHistoryJobExecutorToProcessAllJobs(7000, 200);

    assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).count()).isEqualTo(13);
    assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_CREATED.name()).count())
            .isEqualTo(1);
    assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_NAME_CHANGED.name()).count())
            .isEqualTo(1);
    assertThat(
            historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_PRIORITY_CHANGED.name()).count())
            .isEqualTo(1);
    assertThat(
            historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_ASSIGNEE_CHANGED.name()).count())
            .isEqualTo(1);
    assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_OWNER_CHANGED.name()).count())
            .isEqualTo(1);
    assertThat(
            historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_DUEDATE_CHANGED.name()).count())
            .isEqualTo(1);
    assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_SUSPENSIONSTATE_CHANGED.name())
            .count()).isEqualTo(2);
    assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_IDENTITY_LINK_ADDED.name())
            .count()).isEqualTo(2);
    assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_IDENTITY_LINK_REMOVED.name())
            .count()).isEqualTo(2);
    assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_COMPLETED.name()).count())
            .isEqualTo(1);
}
 
Example 9
Source File: CaseWithFormTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void completeTaskWithFormAndCheckTaskLogEntries() {
    CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder()
            .caseDefinitionKey("oneTaskCaseWithForm")
            .start();

    Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
    FormDefinition formDefinition = formRepositoryService.createFormDefinitionQuery().formDefinitionKey(task.getFormKey()).singleResult();

    task.setName("newName");
    task.setPriority(0);
    cmmnTaskService.saveTask(task);
    cmmnTaskService.setAssignee(task.getId(), "newAssignee");
    cmmnTaskService.setOwner(task.getId(), "newOwner");
    cmmnTaskService.setDueDate(task.getId(), new Date());
    cmmnTaskService.addUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT);
    cmmnTaskService.addGroupIdentityLink(task.getId(), "testGroup", IdentityLinkType.PARTICIPANT);
    cmmnTaskService.deleteUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT);
    cmmnTaskService.deleteGroupIdentityLink(task.getId(), "testGroup", IdentityLinkType.PARTICIPANT);
    cmmnTaskService.completeTaskWithForm(task.getId(), formDefinition.getId(), "__COMPLETE", Collections.singletonMap("doNotThrowException", ""));

    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).count()).isEqualTo(11);
    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_CREATED.name()).count())
            .isEqualTo(1);
    assertThat(
            cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_NAME_CHANGED.name()).count())
            .isEqualTo(1);
    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_PRIORITY_CHANGED.name())
            .count()).isEqualTo(1);
    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_ASSIGNEE_CHANGED.name())
            .count()).isEqualTo(1);
    assertThat(
            cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_OWNER_CHANGED.name()).count())
            .isEqualTo(1);
    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_DUEDATE_CHANGED.name())
            .count()).isEqualTo(1);
    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_IDENTITY_LINK_ADDED.name())
            .count()).isEqualTo(2);
    assertThat(
            cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_IDENTITY_LINK_REMOVED.name())
                    .count()).isEqualTo(2);
    assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_COMPLETED.name()).count())
            .isEqualTo(1);
}