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();
}
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;
}
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());
}
}
}
Aggregations