Search in sources :

Example 1 with InternalTaskData

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

the class DefaultChecklistManager method addTask.

public ChecklistItem addTask(String userId, String[] actorIds, String[] groupIds, String name, String orderingId, long processInstanceId) {
    RuntimeEngine runtime = getRuntime();
    InternalTask task = (InternalTask) TaskModelProvider.getFactory().newTask();
    ;
    setTaskName(task, name);
    setTaskDescription(task, orderingId);
    // task.setPriority(priority);
    InternalTaskData taskData = (InternalTaskData) TaskModelProvider.getFactory().newTaskData();
    taskData.setProcessInstanceId(processInstanceId);
    // taskData.setProcessSessionId(sessionId);
    taskData.setSkipable(false);
    taskData.setDeploymentId("default-singleton");
    User cuser = TaskModelProvider.getFactory().newUser();
    ((InternalOrganizationalEntity) cuser).setId(userId);
    taskData.setCreatedBy(cuser);
    task.setTaskData(taskData);
    InternalPeopleAssignments peopleAssignments = (InternalPeopleAssignments) task.getPeopleAssignments();
    if (peopleAssignments == null) {
        peopleAssignments = (InternalPeopleAssignments) TaskModelProvider.getFactory().newPeopleAssignments();
        peopleAssignments.setPotentialOwners(new ArrayList<OrganizationalEntity>());
        peopleAssignments.setBusinessAdministrators(new ArrayList<OrganizationalEntity>());
        peopleAssignments.setExcludedOwners(new ArrayList<OrganizationalEntity>());
        peopleAssignments.setRecipients(new ArrayList<OrganizationalEntity>());
        peopleAssignments.setTaskStakeholders(new ArrayList<OrganizationalEntity>());
        task.setPeopleAssignments(peopleAssignments);
    }
    List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>();
    for (String actorId : actorIds) {
        User user = TaskModelProvider.getFactory().newUser();
        ((InternalOrganizationalEntity) user).setId(actorId);
        potentialOwners.add(user);
    }
    for (String groupId : groupIds) {
        Group group = TaskModelProvider.getFactory().newGroup();
        ((InternalOrganizationalEntity) group).setId(groupId);
        potentialOwners.add(group);
    }
    setTaskPotentialOwners(task, potentialOwners);
    List<OrganizationalEntity> businessAdministrators = peopleAssignments.getBusinessAdministrators();
    User administrator = TaskModelProvider.getFactory().newUser();
    ((InternalOrganizationalEntity) administrator).setId("Administrator");
    businessAdministrators.add(administrator);
    TaskService taskService = runtime.getTaskService();
    long taskId = taskService.addTask(task, (Map<String, Object>) null);
    manager.disposeRuntimeEngine(runtime);
    return ChecklistItemFactory.createChecklistItem(taskService.getTaskById(taskId));
}
Also used : Group(org.kie.api.task.model.Group) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) InternalTask(org.kie.internal.task.api.model.InternalTask) InternalTaskService(org.kie.internal.task.api.InternalTaskService) TaskService(org.kie.api.task.TaskService) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) ArrayList(java.util.ArrayList) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments)

Example 2 with InternalTaskData

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

the class TaskAuditBaseTest method testLifeCycleWithBAMEndWithObsolete.

@Test
public void testLifeCycleWithBAMEndWithObsolete() {
    Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
    ((InternalTaskData) task.getTaskData()).setSkipable(true);
    taskService.addTask(task, new HashMap<String, Object>());
    long taskId = task.getId();
    List<AuditTask> allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
    assertEquals(1, allGroupAuditTasks.size());
    assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
    assertBAMTask(taskId, "Ready");
    taskService.claim(taskId, "Darth Vader");
    allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
    assertEquals(1, allGroupAuditTasks.size());
    assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
    assertBAMTask(taskId, "Reserved");
    taskService.release(taskId, "Darth Vader");
    allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
    assertEquals(1, allGroupAuditTasks.size());
    assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
    assertBAMTask(taskId, "Ready");
    taskService.claim(taskId, "Darth Vader");
    allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
    ;
    assertEquals(1, allGroupAuditTasks.size());
    assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
    assertBAMTask(taskId, "Reserved");
    // Go straight from Ready to Inprogress
    taskService.start(taskId, "Darth Vader");
    allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
    ;
    assertEquals(1, allGroupAuditTasks.size());
    assertEquals("InProgress", allGroupAuditTasks.get(0).getStatus());
    assertBAMTask(taskId, "InProgress");
    taskService.skip(taskId, "Darth Vader");
    allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
    ;
    assertEquals(1, allGroupAuditTasks.size());
    assertEquals("Obsolete", allGroupAuditTasks.get(0).getStatus());
    assertBAMTask(taskId, "Obsolete");
}
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) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) AuditTask(org.kie.internal.task.api.AuditTask) HumanTaskServicesBaseTest(org.jbpm.services.task.HumanTaskServicesBaseTest) Test(org.junit.Test)

Example 3 with InternalTaskData

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

the class DistincVsJoinPerformanceTest method addTask.

private TaskImpl addTask(long workItemId, long procInstId, String busAdmin, String potOwner, String name, String deploymentId) {
    String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
    String potOwnerType = potOwner.equals("Hideo") ? "User" : "Group";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { " + "taskStakeholders = [new User('" + stakeHolder + "')]," + "businessAdministrators = [new User('" + busAdmin + "')]," + "potentialOwners = [new " + potOwnerType + "('" + potOwner + "')]" + " }),";
    str += "name =  '" + name + "' })";
    Task taskImpl = TaskFactory.evalTask(new StringReader(str));
    ((InternalTaskData) taskImpl.getTaskData()).setWorkItemId(workItemId);
    ((InternalTaskData) taskImpl.getTaskData()).setProcessInstanceId(procInstId);
    ((InternalTaskData) taskImpl.getTaskData()).setDeploymentId(deploymentId);
    taskService.addTask(taskImpl, new HashMap<String, Object>());
    assertNotNull("Null task id", taskImpl.getId());
    return (TaskImpl) taskImpl;
}
Also used : Task(org.kie.api.task.model.Task) TaskImpl(org.jbpm.services.task.impl.model.TaskImpl) StringReader(java.io.StringReader) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData)

Example 4 with InternalTaskData

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

the class TaskQueryBuilderLocalTest method addTask.

private TaskImpl addTask(long workItemId, long procInstId, String busAdmin, String potOwner, String name, String deploymentId) {
    String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { " + "taskStakeholders = [new User('" + stakeHolder + "')]," + "businessAdministrators = [new User('" + busAdmin + "')]," + "potentialOwners = [new User('" + potOwner + "')]" + " }),";
    str += "name =  '" + name + "' })";
    Task taskImpl = TaskFactory.evalTask(new StringReader(str));
    ((InternalTaskData) taskImpl.getTaskData()).setWorkItemId(workItemId);
    ((InternalTaskData) taskImpl.getTaskData()).setProcessInstanceId(procInstId);
    ((InternalTaskData) taskImpl.getTaskData()).setDeploymentId(deploymentId);
    taskService.addTask(taskImpl, new HashMap<String, Object>());
    assertNotNull("Null task id", taskImpl.getId());
    return (TaskImpl) taskImpl;
}
Also used : Task(org.kie.api.task.model.Task) TaskImpl(org.jbpm.services.task.impl.model.TaskImpl) StringReader(java.io.StringReader) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData)

Example 5 with InternalTaskData

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

the class TaskQueryBuilderLocalTest method testGetTasksByVariousFieldsWithUserGroupCallbackAdmin.

@Test
public void testGetTasksByVariousFieldsWithUserGroupCallbackAdmin() {
    String potOwner = "Administrator";
    List<String> busAdmins = new ArrayList<String>();
    busAdmins.add(potOwner);
    String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { " + "businessAdministrators = [new Group('Administrators')]," + "potentialOwners = [new Group('Crusaders')]" + " }),";
    str += "name =  'This is my task name' })";
    Task task = TaskFactory.evalTask(new StringReader(str));
    ((InternalTaskData) task.getTaskData()).setWorkItemId(1);
    ((InternalTaskData) task.getTaskData()).setProcessInstanceId(1);
    taskService.addTask(task, new HashMap<String, Object>());
    List<TaskSummary> results = taskService.taskSummaryQuery(potOwner).businessAdmin(busAdmins.toArray(new String[0])).build().getResultList();
    assertNotNull(results);
    assertEquals(1, results.size());
}
Also used : Task(org.kie.api.task.model.Task) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) TaskSummary(org.kie.api.task.model.TaskSummary) HumanTaskServicesBaseTest(org.jbpm.services.task.HumanTaskServicesBaseTest) Test(org.junit.Test)

Aggregations

InternalTaskData (org.kie.internal.task.api.model.InternalTaskData)45 InternalTask (org.kie.internal.task.api.model.InternalTask)23 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)22 Task (org.kie.api.task.model.Task)22 Test (org.junit.Test)21 User (org.kie.api.task.model.User)20 InternalPeopleAssignments (org.kie.internal.task.api.model.InternalPeopleAssignments)20 InternalContent (org.kie.internal.task.api.model.InternalContent)15 ContentData (org.kie.internal.task.api.model.ContentData)14 InternalOrganizationalEntity (org.kie.internal.task.api.model.InternalOrganizationalEntity)14 ArrayList (java.util.ArrayList)13 InputStreamReader (java.io.InputStreamReader)11 Reader (java.io.Reader)11 HashMap (java.util.HashMap)10 CountDownTaskEventListener (org.jbpm.services.task.util.CountDownTaskEventListener)10 Date (java.util.Date)7 StringReader (java.io.StringReader)6 WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)6 Content (org.kie.api.task.model.Content)6 Map (java.util.Map)5