use of cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleImplApi in project perun by CESNET.
the class UsersManagerBlImpl method getUsersByVirtualAttribute.
private List<User> getUsersByVirtualAttribute(PerunSession sess, AttributeDefinition attributeDef, String attributeValue) {
// try to find method in attribute module
UserVirtualAttributesModuleImplApi attributeModule = perunBl.getAttributesManagerBl().getUserVirtualAttributeModule(sess, attributeDef);
List<User> listOfUsers = attributeModule.searchInAttributesValues((PerunSessionImpl) sess, attributeValue);
if (listOfUsers != null) {
return listOfUsers;
}
// iterate over all users
List<User> matchedUsers = new ArrayList<>();
for (User user : perunBl.getUsersManagerBl().getUsers(sess)) {
Attribute userAttribute;
try {
userAttribute = perunBl.getAttributesManagerBl().getAttribute(sess, user, attributeDef.getName());
} catch (AttributeNotExistsException | WrongAttributeAssignmentException e) {
throw new InternalErrorException(e);
}
if (userAttribute.valueContains(attributeValue)) {
matchedUsers.add(user);
}
}
return matchedUsers;
}
Aggregations