Search in sources :

Example 26 with RichAttribute

use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.

the class AttributesManagerBlImpl method removeAttribute.

public void removeAttribute(PerunSession sess, UserExtSource ues, AttributeDefinition attribute) throws InternalErrorException, WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException {
    if (removeAttributeWithoutCheck(sess, ues, attribute)) {
        checkAttributeValue(sess, ues, new Attribute(attribute));
        this.checkAttributeDependencies(sess, new RichAttribute(ues, null, new Attribute(attribute)));
    }
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute)

Example 27 with RichAttribute

use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.

the class AttributesManagerEntryIntegrationTest method getRichAttributesWithHoldersForAttributeDefinitionGetVosFromGroup.

@Test
public void getRichAttributesWithHoldersForAttributeDefinitionGetVosFromGroup() throws Exception {
    System.out.println(CLASS_NAME + "getRichAttributesWithHoldersForAttributeDefinitionGetVosFromGroup");
    //Prepare attribute, create it and set it with testing value
    Attribute attribute = setAttributeInNamespace(AttributesManager.NS_VO_ATTR);
    perun.getAttributesManagerBl().setAttribute(sess, vo2, attribute);
    //Prepare richAttribute with holders (attribute is not needed but holders are needed)
    RichAttribute richAttr = new RichAttribute();
    richAttr.setPrimaryHolder(group2InVo2);
    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 vo2", vo2.equals(listOfRichAttributes.get(0).getPrimaryHolder()));
    assertTrue("attribute in richAttribute is equals to our attribute", (listOfRichAttributes.get(0).getAttribute()).equals(attribute));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) Vo(cz.metacentrum.perun.core.api.Vo) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 28 with RichAttribute

use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.

the class AttributesManagerEntryIntegrationTest method getRichAttributesWithHoldersForAttributeDefinitionGetVosFromUser.

@Test
public void getRichAttributesWithHoldersForAttributeDefinitionGetVosFromUser() throws Exception {
    System.out.println(CLASS_NAME + "getRichAttributesWithHoldersForAttributeDefinitionGetVosFromUser");
    //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();
    richAttr.setPrimaryHolder(user1);
    List<RichAttribute> listOfRichAttributes = perun.getAttributesManagerBl().getRichAttributesWithHoldersForAttributeDefinition(sess, new AttributeDefinition(attribute), richAttr);
    assertTrue("return 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));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) Vo(cz.metacentrum.perun.core.api.Vo) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 29 with RichAttribute

use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.

the class AttributesManagerEntryIntegrationTest method getRichAttributesWithHoldersForAttributeDefinitionGetVosFromMember.

@Test
public void getRichAttributesWithHoldersForAttributeDefinitionGetVosFromMember() throws Exception {
    System.out.println(CLASS_NAME + "getRichAttributesWithHoldersForAttributeDefinitionGetVosFromMember");
    //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();
    richAttr.setPrimaryHolder(member2OfUser2);
    List<RichAttribute> listOfRichAttributes = perun.getAttributesManagerBl().getRichAttributesWithHoldersForAttributeDefinition(sess, new AttributeDefinition(attribute), richAttr);
    assertTrue("Return no vo.", listOfRichAttributes.size() == 0);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 30 with RichAttribute

use of cz.metacentrum.perun.core.api.RichAttribute in project perun by CESNET.

the class AttributesManagerEntryIntegrationTest method getRichAttributesWithHoldersForAttributeDefinitionGetVosFromUserAndFacility.

@Test
public void getRichAttributesWithHoldersForAttributeDefinitionGetVosFromUserAndFacility() throws Exception {
    System.out.println(CLASS_NAME + "getRichAttributesWithHoldersForAttributeDefinitionGetVosFromUserAndFacility");
    //Prepare attribute, create it and set it with testing value
    Attribute attribute = setAttributeInNamespace(AttributesManager.NS_VO_ATTR);
    perun.getAttributesManagerBl().setAttribute(sess, vo1, attribute);
    perun.getAttributesManagerBl().setAttribute(sess, vo2, attribute);
    //Prepare richAttribute with holders (attribute is not needed but holders are needed)
    RichAttribute richAttr = new RichAttribute<User, Facility>(user2, facility2, 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 vo2", vo2.equals(listOfRichAttributes.get(0).getPrimaryHolder()));
    assertTrue("attribute in richAttribute is equals to our attribute", (listOfRichAttributes.get(0).getAttribute()).equals(attribute));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) Vo(cz.metacentrum.perun.core.api.Vo) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)42 Attribute (cz.metacentrum.perun.core.api.Attribute)29 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)14 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)14 Test (org.junit.Test)14 Vo (cz.metacentrum.perun.core.api.Vo)11 ArrayList (java.util.ArrayList)6 Group (cz.metacentrum.perun.core.api.Group)3 Facility (cz.metacentrum.perun.core.api.Facility)2 User (cz.metacentrum.perun.core.api.User)2 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)2 Host (cz.metacentrum.perun.core.api.Host)1 Member (cz.metacentrum.perun.core.api.Member)1 Resource (cz.metacentrum.perun.core.api.Resource)1 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)1 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)1 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)1 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)1 HashSet (java.util.HashSet)1 List (java.util.List)1