use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getUserFacilityAttributes.
// --------------------------------USER-FACILITY-------------------------------
/**
* Returns all relevant UserFacility RichAttributes for given user.
* That means, returns all UserFacility rich attributes for the given user and for facilities it can access.
* 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 RichAttribute
*/
private List<RichAttribute> getUserFacilityAttributes(PerunSession sess, User user, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Facility> facilities = getPerunBl().getFacilitiesManagerBl().getAllowedFacilities(sess, user);
for (Facility facilityElement : facilities) {
Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, facilityElement, user, attrDef.getName());
listOfRichAttributes.add(new RichAttribute<>(facilityElement, user, attribute));
}
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 getGroupAttributes.
/**
* Returns all relevant Group RichAttributes for given facility.
* Finds groups that are assigned to given facility. For each group returns its rich attribute.
* Each rich attribute is returned only once.
*
* @param sess session
* @param facility facility
* @param attrDef type of attribute that will be returned
* @return List of RichAttributes
*/
private List<RichAttribute> getGroupAttributes(PerunSession sess, Facility facility, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Group> groupsFromFacility = getPerunBl().getGroupsManagerBl().getAssignedGroupsToFacility(sess, facility);
for (Group groupElement : groupsFromFacility) {
listOfRichAttributes.addAll(getGroupAttributes(sess, groupElement, 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, Member member, Group group, AttributeDefinition attribute) throws WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException, MemberGroupMismatchException {
if (removeAttributeWithoutCheck(sess, member, group, attribute)) {
checkAttributeSemantics(sess, member, group, new Attribute(attribute));
checkAttributeDependencies(sess, new RichAttribute<>(member, group, new Attribute(attribute)));
}
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getGroupAttributes.
/**
* Returns all relevant Group RichAttributes for given group.
* Finds rich attribute for given group directly.
* Each rich attribute is returned only once.
*
* @param sess session
* @param group group
* @param attrDef type of attribute that will be returned
* @return List of RichAttribute
*/
private List<RichAttribute> getGroupAttributes(PerunSession sess, Group group, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, attrDef.getName());
listOfRichAttributes.add(new RichAttribute<>(group, null, attribute));
return listOfRichAttributes;
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method getMemberAttributes.
/**
* Returns all relevant Member RichAttributes for given resource.
* Finds allowed members who can access the resource.
* For those members that are allowed returns theirs rich attributes.
* Each rich attribute is returned only once.
*
* @param sess session
* @param resource resource
* @param attrDef type of attribute that will be returned
* @return List of RichAttributes
*/
private List<RichAttribute> getMemberAttributes(PerunSession sess, Resource resource, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Member> membersFromResource = getPerunBl().getResourcesManagerBl().getAllowedMembers(sess, resource);
for (Member memberElement : membersFromResource) {
listOfRichAttributes.addAll(getMemberAttributes(sess, memberElement, attrDef));
}
listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
return listOfRichAttributes;
}
Aggregations