Search in sources :

Example 71 with OrganizationalEntity

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

the class PeopleAssignmentHelperTest method testAssignBusinessAdministratorsChangedDefaults.

@Test
public void testAssignBusinessAdministratorsChangedDefaults() {
    peopleAssignmentHelper = new PeopleAssignmentHelper("myadmin", "mygroup");
    Task task = TaskModelProvider.getFactory().newTask();
    PeopleAssignments peopleAssignments = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    WorkItem workItem = new WorkItemImpl();
    peopleAssignmentHelper.assignBusinessAdministrators(workItem, peopleAssignments);
    assertEquals(2, peopleAssignments.getBusinessAdministrators().size());
    OrganizationalEntity organizationalEntity1 = peopleAssignments.getBusinessAdministrators().get(0);
    assertTrue(organizationalEntity1 instanceof User);
    assertEquals("myadmin", organizationalEntity1.getId());
    OrganizationalEntity organizationalEntity2 = peopleAssignments.getBusinessAdministrators().get(1);
    assertTrue(organizationalEntity2 instanceof Group);
    assertEquals("mygroup", organizationalEntity2.getId());
}
Also used : Group(org.kie.api.task.model.Group) Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) PeopleAssignments(org.kie.api.task.model.PeopleAssignments) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 72 with OrganizationalEntity

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

the class PeopleAssignmentHelperTest method testHandleMultiPeopleAssignments.

@Test
public void testHandleMultiPeopleAssignments() {
    InternalTask task = (InternalTask) TaskModelProvider.getFactory().newTask();
    InternalTaskData taskData = (InternalTaskData) TaskModelProvider.getFactory().newTaskData();
    InternalPeopleAssignments peopleAssignment = peopleAssignmentHelper.getNullSafePeopleAssignments(task);
    assertNotNull(peopleAssignment);
    assertEquals(0, peopleAssignment.getPotentialOwners().size());
    assertEquals(0, peopleAssignment.getBusinessAdministrators().size());
    assertEquals(0, peopleAssignment.getTaskStakeholders().size());
    String actorId = "espiegelberg,john";
    String taskStakeholderId = "drmary,krisv";
    String businessAdministratorId = "drbug,peter";
    String businessAdministratorGroupId = "Super users,Flow administrators";
    String excludedOwnerId = "john,poul";
    String recipientId = "mary,steve";
    WorkItem workItem = new WorkItemImpl();
    workItem.setParameter(PeopleAssignmentHelper.ACTOR_ID, actorId);
    workItem.setParameter(PeopleAssignmentHelper.TASKSTAKEHOLDER_ID, taskStakeholderId);
    workItem.setParameter(PeopleAssignmentHelper.BUSINESSADMINISTRATOR_ID, businessAdministratorId);
    workItem.setParameter(PeopleAssignmentHelper.BUSINESSADMINISTRATOR_GROUP_ID, businessAdministratorGroupId);
    workItem.setParameter(PeopleAssignmentHelper.EXCLUDED_OWNER_ID, excludedOwnerId);
    workItem.setParameter(PeopleAssignmentHelper.RECIPIENT_ID, recipientId);
    peopleAssignmentHelper.handlePeopleAssignments(workItem, task, taskData);
    List<OrganizationalEntity> potentialOwners = task.getPeopleAssignments().getPotentialOwners();
    assertEquals(2, potentialOwners.size());
    assertEquals("espiegelberg", potentialOwners.get(0).getId());
    assertEquals("john", potentialOwners.get(1).getId());
    List<OrganizationalEntity> businessAdministrators = task.getPeopleAssignments().getBusinessAdministrators();
    assertEquals(6, businessAdministrators.size());
    assertEquals("Administrator", businessAdministrators.get(0).getId());
    // Admin group
    assertEquals("Administrators", businessAdministrators.get(1).getId());
    assertEquals("drbug", businessAdministrators.get(2).getId());
    assertEquals("peter", businessAdministrators.get(3).getId());
    assertEquals("Super users", businessAdministrators.get(4).getId());
    assertEquals("Flow administrators", businessAdministrators.get(5).getId());
    List<OrganizationalEntity> taskStakehoders = ((InternalPeopleAssignments) task.getPeopleAssignments()).getTaskStakeholders();
    assertEquals(2, taskStakehoders.size());
    assertEquals("drmary", taskStakehoders.get(0).getId());
    assertEquals("krisv", taskStakehoders.get(1).getId());
    List<OrganizationalEntity> excludedOwners = ((InternalPeopleAssignments) task.getPeopleAssignments()).getExcludedOwners();
    assertEquals(2, excludedOwners.size());
    assertEquals("john", excludedOwners.get(0).getId());
    assertEquals("poul", excludedOwners.get(1).getId());
    List<OrganizationalEntity> recipients = ((InternalPeopleAssignments) task.getPeopleAssignments()).getRecipients();
    assertEquals(2, recipients.size());
    assertEquals("mary", recipients.get(0).getId());
    assertEquals("steve", recipients.get(1).getId());
}
Also used : InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) InternalTask(org.kie.internal.task.api.model.InternalTask) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) WorkItem(org.drools.core.process.instance.WorkItem) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 73 with OrganizationalEntity

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

the class TestPersistenceContext method createSomeTask.

public void createSomeTask() {
    testIsInitialized();
    TaskImpl task = new TaskImpl();
    InternalI18NText name = (InternalI18NText) TaskModelProvider.getFactory().newI18NText();
    name.setText("Some Task");
    List<I18NText> names = new ArrayList<I18NText>();
    names.add(name);
    task.setNames(names);
    InternalTaskData taskData = (InternalTaskData) TaskModelProvider.getFactory().newTaskData();
    taskData.setWorkItemId(12);
    taskData.setProcessInstanceId(1);
    taskData.setProcessId("someprocess");
    taskData.setDeploymentId("org.jbpm.test:someprocess:1.0");
    taskData.setProcessSessionId(1);
    task.setTaskData(taskData);
    InternalPeopleAssignments 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>());
    InternalOrganizationalEntity jdoe = (InternalOrganizationalEntity) TaskModelProvider.getFactory().newUser();
    jdoe.setId("jdoe");
    peopleAssignments.getPotentialOwners().add(jdoe);
    peopleAssignments.getBusinessAdministrators().add(jdoe);
    task.setPeopleAssignments(peopleAssignments);
    final boolean txOwner = transactionManager.begin();
    try {
        EntityManager em = entityManagerFactory.createEntityManager();
        em.persist(jdoe);
        em.persist(task);
        transactionManager.commit(txOwner);
    } catch (Exception ex) {
        ex.printStackTrace();
        transactionManager.rollback(txOwner);
        throw new RuntimeException(ex.getMessage(), ex);
    }
}
Also used : I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) TaskImpl(org.jbpm.persistence.scripts.oldentities.TaskImpl) ArrayList(java.util.ArrayList) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) SQLException(java.sql.SQLException) ParseException(java.text.ParseException) IOException(java.io.IOException) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) EntityManager(javax.persistence.EntityManager)

Example 74 with OrganizationalEntity

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

the class TaskFluent method setAdminGroup.

public TaskFluent setAdminGroup(String groupId) {
    if (assignments.getBusinessAdministrators().isEmpty()) {
        List<OrganizationalEntity> businessAdmins = new ArrayList<OrganizationalEntity>();
        assignments.setBusinessAdministrators(businessAdmins);
    }
    assignments.getBusinessAdministrators().add(new GroupImpl(groupId));
    return this;
}
Also used : OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) GroupImpl(org.jbpm.services.task.impl.model.GroupImpl) ArrayList(java.util.ArrayList)

Example 75 with OrganizationalEntity

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

the class TaskFluent method addPotentialUser.

public TaskFluent addPotentialUser(String userId) {
    if (assignments.getPotentialOwners().isEmpty()) {
        List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>();
        assignments.setPotentialOwners(potentialOwners);
    }
    assignments.getPotentialOwners().add(new UserImpl(userId));
    return this;
}
Also used : OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) ArrayList(java.util.ArrayList) UserImpl(org.jbpm.services.task.impl.model.UserImpl)

Aggregations

OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)147 Test (org.junit.Test)94 HashMap (java.util.HashMap)69 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)55 ArrayList (java.util.ArrayList)54 User (org.kie.api.task.model.User)52 UserImpl (org.jbpm.services.task.impl.model.UserImpl)51 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)48 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)41 InternalPeopleAssignments (org.kie.internal.task.api.model.InternalPeopleAssignments)36 InternalTask (org.kie.internal.task.api.model.InternalTask)35 InternalOrganizationalEntity (org.kie.internal.task.api.model.InternalOrganizationalEntity)34 Task (org.kie.api.task.model.Task)33 QueryContext (org.kie.api.runtime.query.QueryContext)32 Group (org.kie.api.task.model.Group)29 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)26 TaskSummary (org.kie.api.task.model.TaskSummary)25 AdHocFragmentNotFoundException (org.jbpm.casemgmt.api.AdHocFragmentNotFoundException)24 CaseActiveException (org.jbpm.casemgmt.api.CaseActiveException)24 CaseCommentNotFoundException (org.jbpm.casemgmt.api.CaseCommentNotFoundException)24