Search in sources :

Example 1 with MembersManagerBl

use of cz.metacentrum.perun.core.bl.MembersManagerBl in project perun by CESNET.

the class urn_perun_user_attribute_def_virt_sponsoredMembershipInOrganizations method getSponsorOrganizationIdentifiersFromGroups.

/**
 * Collect sponsor organization's identifiers from perun Groups
 * @param sess Perun session
 * @param user User for whom the values should be collected
 * @return List of collected identifiers
 * @throws InternalErrorException When some error occurs, see exception cause for details.
 */
private List<String> getSponsorOrganizationIdentifiersFromGroups(PerunSessionImpl sess, User user) {
    GroupsManagerBl groupsManagerBl = sess.getPerunBl().getGroupsManagerBl();
    MembersManagerBl membersManagerBl = sess.getPerunBl().getMembersManagerBl();
    return membersManagerBl.getMembersByUserWithStatus(sess, user, Status.VALID).stream().flatMap(validMember -> groupsManagerBl.getGroupsWhereMemberIsActive(sess, validMember).stream()).map(groupWhereMemberIsActive -> getOrganizationIdentifierAttribute(sess, groupWhereMemberIsActive, user)).filter(Objects::nonNull).map(Attribute::valueAsString).filter(Objects::nonNull).distinct().collect(Collectors.toList());
}
Also used : UserVirtualAttributesModuleImplApi(cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleImplApi) Attribute(cz.metacentrum.perun.core.api.Attribute) Member(cz.metacentrum.perun.core.api.Member) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Arrays(java.util.Arrays) Logger(org.slf4j.Logger) SkipValueCheckDuringDependencyCheck(cz.metacentrum.perun.core.implApi.modules.attributes.SkipValueCheckDuringDependencyCheck) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) LoggerFactory(org.slf4j.LoggerFactory) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) AttributesManager(cz.metacentrum.perun.core.api.AttributesManager) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) Collectors(java.util.stream.Collectors) Group(cz.metacentrum.perun.core.api.Group) UserVirtualAttributesModuleAbstract(cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleAbstract) User(cz.metacentrum.perun.core.api.User) ArrayList(java.util.ArrayList) Objects(java.util.Objects) MembersManagerBl(cz.metacentrum.perun.core.bl.MembersManagerBl) List(java.util.List) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) Status(cz.metacentrum.perun.core.api.Status) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) MembersManagerBl(cz.metacentrum.perun.core.bl.MembersManagerBl) Objects(java.util.Objects)

Example 2 with MembersManagerBl

use of cz.metacentrum.perun.core.bl.MembersManagerBl in project perun by CESNET.

the class RegistrarBaseIntegrationTest method testRejectApplicationsAfterMemberRemoval.

@Test
public void testRejectApplicationsAfterMemberRemoval() throws PerunException {
    GroupsManagerBl groupsManager = perun.getGroupsManagerBl();
    MembersManagerBl membersManager = perun.getMembersManagerBl();
    // create group in VO, generate group application form
    Group group1 = new Group("GroupA", "Cool folks");
    groupsManager.createGroup(session, vo, group1);
    registrarManager.createApplicationFormInGroup(session, group1);
    // create user
    User user = new User(-1, "Jo", "Doe", "", "", "");
    user = perun.getUsersManagerBl().createUser(session, user);
    Member member = membersManager.createMember(session, vo, user);
    Application groupApplication = prepareApplicationToGroup(user, group1);
    List<ApplicationFormItemData> appItemsData = new ArrayList<>();
    registrarManager.submitApplication(session, groupApplication, appItemsData);
    membersManager.deleteMember(session, member);
    List<Application> group1Apps = registrarManager.getApplicationsForGroup(session, group1, List.of("REJECTED"));
    assertEquals(1, group1Apps.size());
}
Also used : Group(cz.metacentrum.perun.core.api.Group) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) User(cz.metacentrum.perun.core.api.User) MembersManagerBl(cz.metacentrum.perun.core.bl.MembersManagerBl) ApplicationFormItemData(cz.metacentrum.perun.registrar.model.ApplicationFormItemData) Member(cz.metacentrum.perun.core.api.Member) Application(cz.metacentrum.perun.registrar.model.Application) RichApplication(cz.metacentrum.perun.registrar.model.RichApplication) Test(org.junit.Test)

Example 3 with MembersManagerBl

use of cz.metacentrum.perun.core.bl.MembersManagerBl in project perun by CESNET.

the class VosManagerBlImpl method removeSponsorFromSponsoredMembers.

private void removeSponsorFromSponsoredMembers(PerunSession sess, Vo vo, User user) {
    log.debug("removeSponsorFromSponsoredMembers(vo={},user={})", vo.getShortName(), user.getLastName());
    MembersManagerBl membersManagerBl = getPerunBl().getMembersManagerBl();
    for (Member sponsoredMember : membersManagerBl.getSponsoredMembers(sess, vo, user)) {
        log.debug("removing sponsor from sponsored member {}", sponsoredMember.getId());
        membersManagerBl.removeSponsor(sess, sponsoredMember, user);
    }
}
Also used : MembersManagerBl(cz.metacentrum.perun.core.bl.MembersManagerBl) Member(cz.metacentrum.perun.core.api.Member)

Aggregations

Member (cz.metacentrum.perun.core.api.Member)3 MembersManagerBl (cz.metacentrum.perun.core.bl.MembersManagerBl)3 Group (cz.metacentrum.perun.core.api.Group)2 User (cz.metacentrum.perun.core.api.User)2 GroupsManagerBl (cz.metacentrum.perun.core.bl.GroupsManagerBl)2 Attribute (cz.metacentrum.perun.core.api.Attribute)1 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)1 AttributesManager (cz.metacentrum.perun.core.api.AttributesManager)1 Status (cz.metacentrum.perun.core.api.Status)1 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)1 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)1 SkipValueCheckDuringDependencyCheck (cz.metacentrum.perun.core.implApi.modules.attributes.SkipValueCheckDuringDependencyCheck)1 UserVirtualAttributesModuleAbstract (cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleAbstract)1 UserVirtualAttributesModuleImplApi (cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleImplApi)1 Application (cz.metacentrum.perun.registrar.model.Application)1 ApplicationFormItemData (cz.metacentrum.perun.registrar.model.ApplicationFormItemData)1 RichApplication (cz.metacentrum.perun.registrar.model.RichApplication)1 ArrayList (java.util.ArrayList)1