use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getRichAttributesWithHoldersForAttributeDefinitionGetVosFromResourceAndGroup.
@Test
public void getRichAttributesWithHoldersForAttributeDefinitionGetVosFromResourceAndGroup() throws Exception {
System.out.println(CLASS_NAME + "getRichAttributesWithHoldersForAttributeDefinitionGetVosFromResourceAndGroup");
//Prepare attribute, create it and set it with testing value
Attribute attribute = setAttributeInNamespace(AttributesManager.NS_VO_ATTR);
perun.getAttributesManagerBl().setAttribute(sess, vo1, attribute);
//Prepare richAttribute with holders (attribute is not needed but holders are needed)
RichAttribute richAttr = new RichAttribute<Resource, Group>(resource1InVo1, group1InVo1, null);
List<RichAttribute> listOfRichAttributes = perun.getAttributesManagerBl().getRichAttributesWithHoldersForAttributeDefinition(sess, new AttributeDefinition(attribute), richAttr);
assertTrue("return only 1 vo", listOfRichAttributes.size() == 1);
assertTrue("primary holder is type of vo", listOfRichAttributes.get(0).getPrimaryHolder() instanceof Vo);
assertTrue("secondary holder is null", listOfRichAttributes.get(0).getSecondaryHolder() == null);
assertTrue("the Vo is vo1", vo1.equals(listOfRichAttributes.get(0).getPrimaryHolder()));
assertTrue("attribute in richAttribute is equals to our attribute", (listOfRichAttributes.get(0).getAttribute()).equals(attribute));
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method setAttribute.
public void setAttribute(PerunSession sess, Member member, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException {
if (attribute.getValue() == null) {
removeAttribute(sess, member, attribute);
return;
}
if (setAttributeWithoutCheck(sess, member, attribute)) {
checkAttributeValue(sess, member, attribute);
this.checkAttributeDependencies(sess, new RichAttribute(member, null, attribute));
}
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method setAttribute.
public void setAttribute(PerunSession sess, Resource resource, Group group, Attribute attribute) throws InternalErrorException, WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongReferenceAttributeValueException {
if (attribute.getValue() == null) {
removeAttribute(sess, resource, group, attribute);
return;
}
if (setAttributeWithoutCheck(sess, resource, group, attribute)) {
this.checkAttributeDependencies(sess, new RichAttribute(resource, group, attribute));
checkAttributeValue(sess, resource, group, attribute);
}
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttribute.
public boolean removeAttribute(PerunSession sess, Resource resource, AttributeDefinition attribute) throws InternalErrorException, WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException {
boolean changed = removeAttributeWithoutCheck(sess, resource, attribute);
if (changed) {
checkAttributeValue(sess, resource, new Attribute(attribute));
this.checkAttributeDependencies(sess, new RichAttribute(resource, null, new Attribute(attribute)));
}
return changed;
}
use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttribute.
public void removeAttribute(PerunSession sess, Facility facility, User user, AttributeDefinition attribute) throws InternalErrorException, WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException {
if (removeAttributeWithoutCheck(sess, facility, user, attribute)) {
checkAttributeValue(sess, facility, user, new Attribute(attribute));
this.checkAttributeDependencies(sess, new RichAttribute(facility, user, new Attribute(attribute)));
}
}
Aggregations