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());
}
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());
}
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);
}
}
Aggregations