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

The following examples show how to use org.flowable.task.api.Task#setDescription() . 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: FlowableTaskService.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public TaskRepresentation updateTask(String taskId, TaskUpdateRepresentation updated) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();

    if (task == null) {
        throw new NotFoundException("Task with id: " + taskId + " does not exist");
    }

    permissionService.validateReadPermissionOnTask(SecurityUtils.getCurrentUserObject(), task.getId());

    if (updated.isNameSet()) {
        task.setName(updated.getName());
    }

    if (updated.isDescriptionSet()) {
        task.setDescription(updated.getDescription());
    }

    if (updated.isDueDateSet()) {
        task.setDueDate(updated.getDueDate());
    }

    taskService.saveTask(task);

    return new TaskRepresentation(task);
}
 
Example 2
Source File: AsyncHistoryTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetTaskDescription() {
    Task task = startOneTaskprocess();
    assertThat(task.getDescription()).isNull();

    waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L);
    HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertThat(historicTaskInstance.getDescription()).isNull();

    task.setDescription("test description");
    taskService.saveTask(task);

    waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L);
    historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertThat(historicTaskInstance.getDescription()).isNotNull();

    task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    task.setDescription(null);
    taskService.saveTask(task);

    waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L);
    historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(historicTaskInstance.getId()).singleResult();
    assertThat(historicTaskInstance.getDescription()).isNull();

    finishOneTaskProcess(task);
}
 
Example 3
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 4
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 5
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 6
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 7
Source File: AsyncHistoryUpgradeTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetTaskDescription() {
    Task task = startOneTaskprocess();
    assertThat(task.getDescription()).isNull();

    waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L);
    HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertThat(historicTaskInstance.getDescription()).isNull();

    removeRuntimeActivityInstances(task.getProcessInstanceId());

    task.setDescription("test description");
    taskService.saveTask(task);

    downgradeHistoryJobConfigurations();

    waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L);
    historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertThat(historicTaskInstance.getDescription()).isNotNull();

    task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    task.setDescription(null);
    taskService.saveTask(task);

    waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L);
    historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(historicTaskInstance.getId()).singleResult();
    assertThat(historicTaskInstance.getDescription()).isNull();

    finishOneTaskProcess(task);
}
 
Example 8
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 9
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 10
Source File: AsyncCmmnHistoryTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
@CmmnDeployment(resources = "org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHumanTask.cmmn")
public void testHumanTaskWithNameDueDateAndDescription() {
    CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("oneHumanTaskCase").start();
    Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
    assertThat(task).isNotNull();
    task.setName("Test name");
    task.setDescription("Test description");
    cmmnTaskService.saveTask(task);

    waitForAsyncHistoryExecutorToProcessAllJobs();

    // Create
    HistoricTaskInstance historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult();
    assertThat(historicTaskInstance).isNotNull();
    assertThat(historicTaskInstance.getName()).isEqualTo("Test name");
    assertThat(historicTaskInstance.getDescription()).isEqualTo("Test description");
    assertThat(historicTaskInstance.getDueDate()).isNull();

    // Set due date
    Date dueDate = Date.from(Instant.now().with(ChronoField.MILLI_OF_SECOND, 0));
    cmmnTaskService.setDueDate(task.getId(), dueDate);

    waitForAsyncHistoryExecutorToProcessAllJobs();

    historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult();
    assertThat(historicTaskInstance.getDueDate()).isEqualTo(dueDate);

    // Update name and description to null
    task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
    task.setName(null);
    task.setDescription(null);
    cmmnTaskService.saveTask(task);

    // Before the history jobs it has the old data
    historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult();
    assertThat(historicTaskInstance.getName()).isEqualTo("Test name");
    assertThat(historicTaskInstance.getDescription()).isEqualTo("Test description");

    waitForAsyncHistoryExecutorToProcessAllJobs();

    // After the history jobs it has the new data
    historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult();
    assertThat(historicTaskInstance.getName()).isNull();
    assertThat(historicTaskInstance.getDescription()).isNull();

    // Update dueDate to null
    cmmnTaskService.setDueDate(task.getId(), null);

    // Before the history jobs it has the old data
    historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult();
    assertThat(historicTaskInstance.getDueDate()).isEqualTo(dueDate);

    waitForAsyncHistoryExecutorToProcessAllJobs();

    // After the history jobs it has the new data
    historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult();
    assertThat(historicTaskInstance.getDueDate()).isNull();
}