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

The following examples show how to use org.flowable.task.api.Task#setFormKey() . 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: TaskQueryTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testQueryByFormKey() {
    Task task = taskService.newTask();
    task.setFormKey("testFormKey");
    taskService.saveTask(task);
    taskIds.add(task.getId());

    List<Task> tasks = taskService.createTaskQuery().taskFormKey("testFormKey").list();
    assertThat(tasks)
            .extracting(Task::getFormKey)
            .containsExactly("testFormKey");

    if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.AUDIT, processEngineConfiguration)) {
        List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery()
                .taskFormKey("testFormKey")
                .list();
        assertThat(historicTasks)
                .extracting(HistoricTaskInstance::getFormKey)
                .containsExactly("testFormKey");
    }
}
 
Example 2
Source File: TaskQueryTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testQueryByFormKeyOr() {
    Task task = taskService.newTask();
    task.setFormKey("testFormKey");
    taskService.saveTask(task);
    taskIds.add(task.getId());

    List<Task> tasks = taskService.createTaskQuery().or().taskId("invalid").taskFormKey("testFormKey").list();
    assertThat(tasks)
            .extracting(Task::getFormKey)
            .containsExactly("testFormKey");

    if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.AUDIT, processEngineConfiguration)) {
        List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery().or()
                .taskFormKey("testFormKey")
                .list();
        assertThat(historicTasks)
                .extracting(HistoricTaskInstance::getFormKey)
                .containsExactly("testFormKey");
    }
}
 
Example 3
Source File: TaskQueryTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testQueryWithFormKey() {
    Task task = taskService.newTask();
    task.setFormKey("testFormKey");
    taskService.saveTask(task);
    taskIds.add(task.getId());

    List<Task> tasks = taskService.createTaskQuery().taskWithFormKey().list();
    assertThat(tasks)
            .extracting(Task::getFormKey)
            .containsExactly("testFormKey");

    if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.AUDIT, processEngineConfiguration)) {
        List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery()
                .taskWithFormKey()
                .list();
        assertThat(historicTasks)
                .extracting(HistoricTaskInstance::getFormKey)
                .containsExactly("testFormKey");
    }
}
 
Example 4
Source File: AsyncHistoryUpgradeTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetTaskFormKey() {
    Task task = startOneTaskprocess();
    assertThat(task.getFormKey()).isNull();

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

    removeRuntimeActivityInstances(task.getProcessInstanceId());

    task.setFormKey("test form key");
    taskService.saveTask(task);

    downgradeHistoryJobConfigurations();

    waitForHistoryJobExecutorToProcessAllJobs(10000L, 100L);
    historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertThat(historicTaskInstance.getFormKey()).isEqualTo("test form key");

    finishOneTaskProcess(task);
}
 
Example 5
Source File: AsyncHistoryTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetTaskFormKey() {
    Task task = startOneTaskprocess();
    assertThat(task.getFormKey()).isNull();

    waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L);
    HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertThat(historicTaskInstance.getFormKey()).isNull();
    task.setFormKey("test form key");
    taskService.saveTask(task);

    waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L);
    historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertThat(historicTaskInstance.getFormKey()).isEqualTo("test form key");

    finishOneTaskProcess(task);
}
 
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: 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);
    }
}