use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getUserExtSourceAttributes.
/**
* Returns RichAttributes for all userExtSource.
* Each rich attribute is returned only once.
*
* @param sess session
* @param attrDef type of attribute that will be returned
* @return List of RichAttribute
*/
private List<RichAttribute> getUserExtSourceAttributes(PerunSession sess, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Facility> facilities = getPerunBl().getFacilitiesManagerBl().getFacilities(sess);
for (Facility facilityElement : facilities) {
listOfRichAttributes.addAll(getUserExtSourceAttributes(sess, facilityElement, attrDef));
}
listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
return listOfRichAttributes;
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttribute.
@Override
public void removeAttribute(PerunSession sess, Resource resource, Group group, AttributeDefinition attribute) throws WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException, GroupResourceMismatchException {
if (removeAttributeWithoutCheck(sess, resource, group, attribute)) {
checkAttributeSemantics(sess, resource, group, new Attribute(attribute));
checkAttributeDependencies(sess, new RichAttribute<>(resource, group, new Attribute(attribute)));
}
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getUserAttributes.
// --------------------------------USER----------------------------------------
/**
* Returns all relevant User RichAttributes for given user.
* Finds attributes for given user directly.
* Each rich attribute is returned only once.
*
* @param sess session
* @param user user
* @param attrDef type of attribute that will be returned
* @return List of RichAttributes
*/
private List<RichAttribute> getUserAttributes(PerunSession sess, User user, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, user, attrDef.getName());
listOfRichAttributes.add(new RichAttribute<>(user, null, attribute));
return listOfRichAttributes;
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getUserAttributes.
/**
* Returns RichAttributes for all users.
* Finds all users. Returns theirs rich attributes.
* Each rich attribute is returned only once.
*
* @param sess session
* @param attrDef type of attribute that will be returned
* @return List of RichAttributes
*/
private List<RichAttribute> getUserAttributes(PerunSession sess, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<User> allUsers = getPerunBl().getUsersManagerBl().getUsers(sess);
for (User userElement : allUsers) {
listOfRichAttributes.addAll(getUserAttributes(sess, userElement, attrDef));
}
listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
return listOfRichAttributes;
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getGroupAttributesByFacility.
@SuppressWarnings({ "unchecked" })
@Test
public void getGroupAttributesByFacility() throws Exception {
System.out.println(CLASS_NAME + "getGroupAttributesByFacility");
setAttributesForGroupAttributesTest();
Method testedMethod = getPrivateMethodFromAtrManager("getGroupAttributes", PerunSession.class, Facility.class, AttributeDefinition.class);
// find email group attributes by facility1
List<RichAttribute> ra_facility1 = (List<RichAttribute>) testedMethod.invoke(attributesManagerBl, sess, facility1, group_fromEmail_atr_def);
List<Attribute> attrs_facility1 = new ArrayList<>();
ra_facility1.forEach(ra -> attrs_facility1.add(ra.getAttribute()));
assertEquals("Invalid number of attributes found", 2, attrs_facility1.size());
assertTrue(attrs_facility1.contains(group1InVo1_email_atr));
assertTrue(attrs_facility1.contains(group2InVo1_email_atr));
// find email group attributes by facility2
List<RichAttribute> ra_facility2 = (List<RichAttribute>) testedMethod.invoke(attributesManagerBl, sess, facility2, group_fromEmail_atr_def);
List<Attribute> attrs_facility2 = new ArrayList<>();
ra_facility2.forEach(ra -> attrs_facility2.add(ra.getAttribute()));
assertEquals("Invalid number of attributes found", 3, attrs_facility2.size());
assertTrue(attrs_facility2.contains(group2InVo1_email_atr));
assertTrue(attrs_facility2.contains(group1InVo2_email_atr));
assertTrue(attrs_facility2.contains(group2InVo2_email_atr));
}
Aggregations