Search in sources :

Example 1 with TaskDataImpl

use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.

the class TaskQueryServiceBaseTest method testGetTasksByStatusByProcessIdByTaskName.

@Test
public void testGetTasksByStatusByProcessIdByTaskName() {
    // One potential owner, should go straight to state Reserved
    String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) {processInstanceId = 99 } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')],businessAdministrators = [ new User('Administrator') ], }),";
    str += "name =  'This is my task name' })";
    Task task = TaskFactory.evalTask(new StringReader(str));
    String otherProcessId = "org.process.task.other";
    ((TaskDataImpl) task.getTaskData()).setProcessId(otherProcessId);
    ;
    taskService.addTask(task, new HashMap<String, Object>());
    str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) {processInstanceId = 100 } ), ";
    str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')],businessAdministrators = [ new User('Administrator') ], }),";
    str += "name =  'Another name' })";
    task = TaskFactory.evalTask(new StringReader(str));
    String processId = "org.process.task.test";
    ((TaskDataImpl) task.getTaskData()).setProcessId(processId);
    taskService.addTask(task, new HashMap<String, Object>());
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Reserved);
    List<TaskSummary> tasks = taskService.getTasksByStatusByProcessInstanceIdByTaskName(99L, statuses, "This is my task name");
    assertEquals(1, tasks.size());
    tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Bobba Fet", processId);
    assertEquals(1, tasks.size());
    tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Administrator", processId);
    assertEquals(0, tasks.size());
    tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Bobba Fet", otherProcessId);
    assertEquals(1, tasks.size());
    tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Bobba Fet", "bad.process.id");
    assertEquals(0, tasks.size());
}
Also used : Status(org.kie.api.task.model.Status) Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) TaskDataImpl(org.jbpm.services.task.impl.model.TaskDataImpl) Test(org.junit.Test)

Example 2 with TaskDataImpl

use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.

the class FormProviderServiceImplTest method testGetFormDisplayTaskWithoutProcess.

@Test
public void testGetFormDisplayTaskWithoutProcess() {
    long taskId = 1;
    final TaskImpl task = new TaskImpl();
    task.setId(taskId);
    task.setName("TaskName");
    task.setTaskData(new TaskDataImpl());
    when(taskService.getTaskById(taskId)).thenReturn(task);
    final String form = formProviderService.getFormDisplayTask(1);
    assertEquals("", form);
    verify(dataService, never()).getProcessesByDeploymentIdProcessId(anyString(), anyString());
    verify(formProvider).render(eq(task.getName()), eq(task), isNull(ProcessDefinition.class), anyMap());
}
Also used : TaskImpl(org.jbpm.services.task.impl.model.TaskImpl) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) Matchers.anyString(org.mockito.Matchers.anyString) TaskDataImpl(org.jbpm.services.task.impl.model.TaskDataImpl) Test(org.junit.Test)

Example 3 with TaskDataImpl

use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.

the class FormProviderServiceImplTest method testGetFormDisplayTask.

@Test
public void testGetFormDisplayTask() {
    long taskId = 1;
    final TaskImpl task = new TaskImpl();
    task.setId(taskId);
    task.setName("TaskName");
    final TaskDataImpl taskData = new TaskDataImpl();
    final String deploymentId = "org.jbpm";
    taskData.setDeploymentId(deploymentId);
    final String processId = "org.jbpm.evaluation";
    taskData.setProcessId(processId);
    task.setTaskData(taskData);
    when(taskService.getTaskById(taskId)).thenReturn(task);
    final ProcessDefinition processDefinition = mock(ProcessDefinition.class);
    when(dataService.getProcessesByDeploymentIdProcessId(deploymentId, processId)).thenReturn(processDefinition);
    final String form = formProviderService.getFormDisplayTask(1);
    assertEquals("", form);
    verify(dataService).getProcessesByDeploymentIdProcessId(deploymentId, processId);
    verify(formProvider).render(eq(task.getName()), eq(task), eq(processDefinition), anyMap());
}
Also used : TaskImpl(org.jbpm.services.task.impl.model.TaskImpl) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) Matchers.anyString(org.mockito.Matchers.anyString) TaskDataImpl(org.jbpm.services.task.impl.model.TaskDataImpl) Test(org.junit.Test)

Example 4 with TaskDataImpl

use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.

the class TaskImpl method readExternal.

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    id = in.readLong();
    priority = in.readInt();
    archived = in.readShort();
    taskType = in.readUTF();
    formName = in.readUTF();
    names = CollectionUtils.readI18NTextList(in);
    subjects = CollectionUtils.readI18NTextList(in);
    descriptions = CollectionUtils.readI18NTextList(in);
    if (in.readBoolean()) {
        subTaskStrategy = SubTasksStrategy.valueOf(in.readUTF());
    }
    if (in.readBoolean()) {
        peopleAssignments = new PeopleAssignmentsImpl();
        peopleAssignments.readExternal(in);
    }
    if (in.readBoolean()) {
        delegation = new DelegationImpl();
        delegation.readExternal(in);
    }
    if (in.readBoolean()) {
        taskData = new TaskDataImpl();
        taskData.readExternal(in);
    }
    if (in.readBoolean()) {
        deadlines = new DeadlinesImpl();
        deadlines.readExternal(in);
    }
}
Also used : PeopleAssignmentsImpl(org.jbpm.services.task.impl.model.PeopleAssignmentsImpl) DelegationImpl(org.jbpm.services.task.impl.model.DelegationImpl) TaskDataImpl(org.jbpm.services.task.impl.model.TaskDataImpl) DeadlinesImpl(org.jbpm.services.task.impl.model.DeadlinesImpl)

Example 5 with TaskDataImpl

use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.

the class DistincVsJoinPerformanceTest method doJoinQuery.

private long doJoinQuery(EntityManager em, String userId, List<String> groupIds, int total) {
    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<TaskImpl> joinQuery = builder.createQuery(TaskImpl.class);
    Root<TaskImpl> taskRoot = joinQuery.from(TaskImpl.class);
    Join<TaskImpl, TaskDataImpl> join = taskRoot.join(TaskImpl_.taskData);
    Selection select = getTaskSummarySelect(builder, taskRoot);
    joinQuery.select(select);
    Join<TaskImpl, PeopleAssignmentsImpl> peopleAssign = taskRoot.join(TaskImpl_.peopleAssignments);
    ListJoin<PeopleAssignmentsImpl, OrganizationalEntityImpl> busAdmins = peopleAssign.join(PeopleAssignmentsImpl_.businessAdministrators, JoinType.LEFT);
    ListJoin<PeopleAssignmentsImpl, OrganizationalEntityImpl> potOwners = peopleAssign.join(PeopleAssignmentsImpl_.potentialOwners, JoinType.LEFT);
    ListJoin<PeopleAssignmentsImpl, OrganizationalEntityImpl> stakeHols = peopleAssign.join(PeopleAssignmentsImpl_.taskStakeholders, JoinType.LEFT);
    List<Predicate> predicates = new ArrayList<Predicate>();
    predicates.add(builder.equal(taskRoot.get(TaskImpl_.taskData).get(TaskDataImpl_.actualOwner).get(UserImpl_.id), userId));
    predicates.add(builder.equal(taskRoot.get(TaskImpl_.taskData).get(TaskDataImpl_.createdBy).get(UserImpl_.id), userId));
    predicates.add(builder.or(builder.equal(busAdmins.get(OrganizationalEntityImpl_.id), userId), busAdmins.get(OrganizationalEntityImpl_.id).in(groupIds)));
    predicates.add(builder.or(builder.equal(potOwners.get(OrganizationalEntityImpl_.id), userId), potOwners.get(OrganizationalEntityImpl_.id).in(groupIds)));
    predicates.add(builder.or(builder.equal(stakeHols.get(OrganizationalEntityImpl_.id), userId), stakeHols.get(OrganizationalEntityImpl_.id).in(groupIds)));
    if (!predicates.isEmpty()) {
        joinQuery.where(builder.or(predicates.toArray(new Predicate[predicates.size()])));
    }
    return timeQueryExecution(em, joinQuery, null, total);
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) OrganizationalEntityImpl(org.jbpm.services.task.impl.model.OrganizationalEntityImpl) TaskImpl(org.jbpm.services.task.impl.model.TaskImpl) Selection(javax.persistence.criteria.Selection) ArrayList(java.util.ArrayList) TaskDataImpl(org.jbpm.services.task.impl.model.TaskDataImpl) Predicate(javax.persistence.criteria.Predicate) PeopleAssignmentsImpl(org.jbpm.services.task.impl.model.PeopleAssignmentsImpl)

Aggregations

TaskDataImpl (org.jbpm.services.task.impl.model.TaskDataImpl)7 TaskImpl (org.jbpm.services.task.impl.model.TaskImpl)4 PeopleAssignmentsImpl (org.jbpm.services.task.impl.model.PeopleAssignmentsImpl)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)2 Matchers.anyString (org.mockito.Matchers.anyString)2 StringReader (java.io.StringReader)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Expression (javax.persistence.criteria.Expression)1 From (javax.persistence.criteria.From)1 Join (javax.persistence.criteria.Join)1 ListJoin (javax.persistence.criteria.ListJoin)1 Predicate (javax.persistence.criteria.Predicate)1 Root (javax.persistence.criteria.Root)1 Selection (javax.persistence.criteria.Selection)1 Attribute (javax.persistence.metamodel.Attribute)1 CollectionAttribute (javax.persistence.metamodel.CollectionAttribute)1 ListAttribute (javax.persistence.metamodel.ListAttribute)1 PluralAttribute (javax.persistence.metamodel.PluralAttribute)1