Search in sources :

Example 1 with AttributesManager

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

the class ElixirBonaFideStatus method approveApplication.

/**
 * Add new bonaFideStatus to the user attribute.
 */
@Override
public Application approveApplication(PerunSession session, Application app) throws GroupNotExistsException, WrongAttributeAssignmentException, AttributeNotExistsException, PrivilegeException, UserNotExistsException, WrongAttributeValueException, WrongReferenceAttributeValueException {
    User user = app.getUser();
    Group group = app.getGroup();
    AttributesManager am = session.getPerun().getAttributesManager();
    Attribute attestation = am.getAttribute(session, group, A_G_D_groupAttestation);
    String newValue = attestation.valueAsString();
    Attribute bonaFideStatus = am.getAttribute(session, user, A_U_D_userBonaFideStatus);
    List<String> value = new ArrayList<>();
    if (bonaFideStatus.getValue() != null && bonaFideStatus.valueAsList() != null) {
        value = bonaFideStatus.valueAsList();
    }
    value.add(newValue);
    bonaFideStatus.setValue(value);
    am.setAttribute(session, user, bonaFideStatus);
    return app;
}
Also used : Group(cz.metacentrum.perun.core.api.Group) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) AttributesManager(cz.metacentrum.perun.core.api.AttributesManager) ArrayList(java.util.ArrayList)

Aggregations

Attribute (cz.metacentrum.perun.core.api.Attribute)1 AttributesManager (cz.metacentrum.perun.core.api.AttributesManager)1 Group (cz.metacentrum.perun.core.api.Group)1 User (cz.metacentrum.perun.core.api.User)1 ArrayList (java.util.ArrayList)1