Search in sources :

Example 11 with InternalTask

use of org.kie.internal.task.api.model.InternalTask in project jbpm by kiegroup.

the class EGetTaskTest method testFormName.

@Test
public void testFormName() {
    Map<String, Object> params = new HashMap<>();
    params.put("userName", "johndoe");
    Long pid = ejb.startProcess(ProcessDefinitions.HUMAN_TASK_WITH_FORM, params);
    List<Status> statusList = new ArrayList<>();
    statusList.add(Status.Reserved);
    List<TaskSummary> summaryList = ejb.getTasksByStatusByProcessInstanceId(pid, statusList, new QueryFilter(0, 1));
    Assertions.assertThat(summaryList).isNotNull().isNotEmpty();
    TaskSummary summary = summaryList.get(0);
    Task task = ejb.getTask(summary.getId());
    String formName = ((InternalTask) task).getFormName();
    Assertions.assertThat(formName).as("Expected different form name.").isEqualTo("UserNameInputTask");
}
Also used : Status(org.kie.api.task.model.Status) Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) HashMap(java.util.HashMap) InternalTask(org.kie.internal.task.api.model.InternalTask) ArrayList(java.util.ArrayList) QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 12 with InternalTask

use of org.kie.internal.task.api.model.InternalTask in project jbpm by kiegroup.

the class UserTaskServiceImplTest method testGetTaskOfAbortedProcess.

@Test
public void testGetTaskOfAbortedProcess() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument.noform");
    assertNotNull(processInstanceId);
    List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
    assertNotNull(taskIds);
    assertEquals(1, taskIds.size());
    Long taskId = taskIds.get(0);
    Task taskInstance = userTaskService.getTask(taskId);
    assertNotNull(taskInstance);
    assertEquals(Status.Reserved, taskInstance.getTaskData().getStatus());
    assertEquals("Write a Document", taskInstance.getName());
    assertTrue(StringUtils.isEmpty(((InternalTask) taskInstance).getFormName()));
    processService.abortProcessInstance(processInstanceId);
    taskInstance = userTaskService.getTask(taskId);
    assertNotNull(taskInstance);
    assertEquals(Status.Exited, taskInstance.getTaskData().getStatus());
    assertEquals("Write a Document", taskInstance.getName());
    assertTrue(StringUtils.isEmpty(((InternalTask) taskInstance).getFormName()));
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) InternalTask(org.kie.internal.task.api.model.InternalTask) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 13 with InternalTask

use of org.kie.internal.task.api.model.InternalTask in project jbpm by kiegroup.

the class TaskInstanceServiceImpl method setSubject.

@Override
public void setSubject(long taskId, String subject) {
    Task task = persistenceContext.findTask(taskId);
    ((InternalTask) task).setSubject(subject);
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) InternalTask(org.kie.internal.task.api.model.InternalTask)

Example 14 with InternalTask

use of org.kie.internal.task.api.model.InternalTask in project jbpm by kiegroup.

the class TaskInstanceServiceImpl method setTaskNames.

public void setTaskNames(long taskId, List<I18NText> inputTaskNames) {
    Task task = persistenceContext.findTask(taskId);
    taskEventSupport.fireBeforeTaskUpdated(task, context);
    List<I18NText> taskNames = new ArrayList<I18NText>(inputTaskNames.size());
    for (I18NText inputText : inputTaskNames) {
        I18NText text = TaskModelProvider.getFactory().newI18NText();
        ((InternalI18NText) text).setLanguage(inputText.getLanguage());
        ((InternalI18NText) text).setText(inputText.getText());
        taskNames.add(text);
    }
    ((InternalTask) task).setNames(taskNames);
    ((InternalTask) task).setName(taskNames.get(0).getText());
    taskEventSupport.fireAfterTaskUpdated(task, context);
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalTask(org.kie.internal.task.api.model.InternalTask) ArrayList(java.util.ArrayList)

Example 15 with InternalTask

use of org.kie.internal.task.api.model.InternalTask in project jbpm by kiegroup.

the class TaskAdminServiceImpl method archiveTasks.

public int archiveTasks(List<TaskSummary> tasks) {
    int archivedTasks = 0;
    for (TaskSummary sum : tasks) {
        long taskId = sum.getId();
        Task task = persistenceContext.findTask(taskId);
        if (task != null) {
            ((InternalTask) task).setArchived(true);
            persistenceContext.updateTask(task);
            archivedTasks++;
        }
    }
    return archivedTasks;
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) InternalTask(org.kie.internal.task.api.model.InternalTask) TaskSummary(org.kie.api.task.model.TaskSummary)

Aggregations

InternalTask (org.kie.internal.task.api.model.InternalTask)50 Task (org.kie.api.task.model.Task)29 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)21 InternalTaskData (org.kie.internal.task.api.model.InternalTaskData)18 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)17 InputStreamReader (java.io.InputStreamReader)16 Reader (java.io.Reader)16 User (org.kie.api.task.model.User)16 CountDownTaskEventListener (org.jbpm.services.task.util.CountDownTaskEventListener)15 InternalPeopleAssignments (org.kie.internal.task.api.model.InternalPeopleAssignments)15 InternalOrganizationalEntity (org.kie.internal.task.api.model.InternalOrganizationalEntity)14 Date (java.util.Date)12 HashMap (java.util.HashMap)11 ContentData (org.kie.internal.task.api.model.ContentData)11 InternalContent (org.kie.internal.task.api.model.InternalContent)11 I18NText (org.kie.api.task.model.I18NText)10 InternalI18NText (org.kie.internal.task.api.model.InternalI18NText)8 TaskSummary (org.kie.api.task.model.TaskSummary)6 StringReader (java.io.StringReader)5