Search in sources :

Example 36 with Group

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

the class LDAPUserInfoImplTest method testGetMembersForGroup.

private void testGetMembersForGroup(boolean emptyGroup, boolean customAttribute, boolean distinguishedName) {
    Properties properties = createUserInfoProperties();
    if (customAttribute) {
        properties.setProperty(LDAPUserInfoImpl.MEMBER_ATTR_ID, "representative");
    }
    if (distinguishedName) {
        properties.setProperty(LDAPUserInfoImpl.IS_ENTITY_ID_DN, "true");
    }
    UserInfo ldapUserInfo = new LDAPUserInfoImpl(properties);
    Group group;
    if (distinguishedName) {
        group = emptyGroup ? USER_DN : MANAGER_DN;
    } else {
        group = emptyGroup ? USER : MANAGER;
    }
    Iterator<OrganizationalEntity> iterator = ldapUserInfo.getMembersForGroup(group);
    if (emptyGroup) {
        Assertions.assertThat(iterator.hasNext()).isFalse();
        return;
    }
    Assertions.assertThat(iterator.hasNext()).isTrue();
    User user = (User) iterator.next();
    if (customAttribute) {
        Assertions.assertThat(user.getId()).isEqualTo(MARY_DN.getId());
    } else {
        Assertions.assertThat(user.getId()).isEqualTo(JOHN_DN.getId());
    }
    Assertions.assertThat(iterator.hasNext()).isFalse();
}
Also used : Group(org.kie.api.task.model.Group) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) UserInfo(org.kie.internal.task.api.UserInfo) Properties(java.util.Properties)

Example 37 with Group

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

the class CollectionUtils method readOrganizationalEntityList.

public static List<OrganizationalEntity> readOrganizationalEntityList(ObjectInput in) throws IOException, ClassNotFoundException {
    int size = in.readInt();
    List<OrganizationalEntity> list = new ArrayList<OrganizationalEntity>(size);
    for (int i = 0; i < size; i++) {
        short type = in.readShort();
        if (type == 0) {
            User user = new UserImpl();
            user.readExternal(in);
            list.add(user);
        } else {
            Group group = new GroupImpl();
            group.readExternal(in);
            list.add(group);
        }
    }
    return list;
}
Also used : Group(org.kie.api.task.model.Group) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) GroupImpl(org.jbpm.services.task.impl.model.GroupImpl) ArrayList(java.util.ArrayList) UserImpl(org.jbpm.services.task.impl.model.UserImpl)

Example 38 with Group

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

the class LocalHTWorkItemHandler method abortWorkItem.

@Override
public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
    RuntimeEngine runtime = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get(workItem.getProcessInstanceId()));
    Task task = runtime.getTaskService().getTaskByWorkItemId(workItem.getId());
    if (task != null) {
        try {
            String adminUser = ADMIN_USER;
            List<OrganizationalEntity> businessAdmins = task.getPeopleAssignments().getBusinessAdministrators();
            for (OrganizationalEntity admin : businessAdmins) {
                if (admin instanceof Group) {
                    continue;
                }
                if (!admin.getId().equals(ADMIN_USER)) {
                    adminUser = admin.getId();
                    break;
                }
            }
            logger.debug("Task {} is going to be exited by {} who is business admin", task.getId(), adminUser);
            runtime.getTaskService().exit(task.getId(), adminUser);
        } catch (PermissionDeniedException e) {
            logger.info(e.getMessage());
        }
    }
}
Also used : Group(org.kie.api.task.model.Group) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) Task(org.kie.api.task.model.Task) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException)

Aggregations

Group (org.kie.api.task.model.Group)38 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)29 User (org.kie.api.task.model.User)27 ArrayList (java.util.ArrayList)17 InternalOrganizationalEntity (org.kie.internal.task.api.model.InternalOrganizationalEntity)14 Task (org.kie.api.task.model.Task)11 InternalPeopleAssignments (org.kie.internal.task.api.model.InternalPeopleAssignments)9 Test (org.junit.Test)8 List (java.util.List)6 WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)5 InternalTask (org.kie.internal.task.api.model.InternalTask)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 WorkItem (org.drools.core.process.instance.WorkItem)4 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)4 PeopleAssignments (org.kie.api.task.model.PeopleAssignments)4 Iterator (java.util.Iterator)3