use of cz.metacentrum.perun.core.api.MemberGroupStatus in project perun by CESNET.
the class GroupsManagerBlImpl method getMemberGroupStatusesForGroupAndForMembersFromOtherGroup.
// /**
// * Returns map containing statuses for each group and for each member
// *
// * @param sess session
// * @param groups groups where statuses are calculated
// * @return Map containing groups with members and their statuses
// * @throws InternalErrorException internal error
// */
// private Map<Group, Map<Member, MemberGroupStatus>> getMemberGroupStatusesForGroups(PerunSession sess, List<Group> groups) throws InternalErrorException {
// Map<Group, Map<Member, MemberGroupStatus>> previousStatuses = new HashMap<>();
// for (Group previousResultGroup : groups) {
// previousStatuses.put(previousResultGroup, getMemberGroupStatusesForGroup(sess, previousResultGroup));
// }
// return previousStatuses;
// }
//
// /**
// * Returns map containing statuses for each member in given group
// *
// * @param sess session
// * @param group group
// * @return map containing statuses for each member in given group
// * @throws InternalErrorException internal error
// */
// private Map<Member, MemberGroupStatus> getMemberGroupStatusesForGroup(PerunSession sess, Group group) throws InternalErrorException {
// return getMemberGroupStatusesForGroupAndForMembersFromOtherGroup(sess, group, group);
// }
/**
* Returns map containing statuses for members from 'fromGroup' inside given group
*
* @param sess session
* @param group group
* @return map containing statuses for each member in given group
* @throws InternalErrorException internal error
*/
private Map<Member, MemberGroupStatus> getMemberGroupStatusesForGroupAndForMembersFromOtherGroup(PerunSession sess, Group group, Group fromGroup) {
Map<Member, MemberGroupStatus> groupStatuses = new HashMap<>();
List<Member> groupMembers = getGroupMembers(sess, fromGroup);
for (Member groupMember : groupMembers) {
groupStatuses.put(groupMember, getTotalMemberGroupStatus(sess, groupMember, group));
}
return groupStatuses;
}
use of cz.metacentrum.perun.core.api.MemberGroupStatus in project perun by CESNET.
the class GroupsManagerEntryIntegrationTest method getGroupMembersCountsByGroupStatus.
@Test
public void getGroupMembersCountsByGroupStatus() throws Exception {
System.out.println(CLASS_NAME + "getGroupMembersCountsByGroupStatus");
vo = setUpVo();
setUpGroup(vo);
Member member = setUpMember(vo);
groupsManager.addMember(sess, group, member);
Member expiredMember = setUpMember(vo);
groupsManager.addMember(sess, group, expiredMember);
groupsManager.setMemberGroupStatus(sess, expiredMember, group, MemberGroupStatus.EXPIRED);
Map<MemberGroupStatus, Integer> counts = groupsManager.getGroupMembersCountsByGroupStatus(sess, group);
assertThat(counts.get(MemberGroupStatus.VALID)).isEqualTo(1);
assertThat(counts.get(MemberGroupStatus.EXPIRED)).isEqualTo(1);
}
use of cz.metacentrum.perun.core.api.MemberGroupStatus in project perun by CESNET.
the class ExpirationNotifScheduler method auditOldGroupExpirations.
/**
* Logs expirations that happened a week ago for a group
*
* @param allowedStatuses allowed Statuses
* @param group group
* @throws InternalErrorException internal error
*/
private void auditOldGroupExpirations(List<Status> allowedStatuses, Group group) {
// log message for all members which expired 7 days ago
LocalDate expiredWeekAgo = getCurrentLocalDate().minusDays(7);
List<Member> expired7DaysAgo = perun.getSearcherBl().getMembersByGroupExpiration(sess, group, "=", expiredWeekAgo);
for (Member m : expired7DaysAgo) {
if (allowedStatuses.contains(m.getStatus())) {
MemberGroupStatus status = perun.getGroupsManagerBl().getDirectMemberGroupStatus(sess, m, group);
// we don't notify members in indirect only relation
if (status != null) {
if (didntSubmitGroupExtensionApplication(m, group)) {
// still didn't apply for extension
getPerun().getAuditer().log(sess, new GroupMembershipExpired(m, 7, group));
} else {
log.debug("{} not notified about expiration in {}, has submitted - pending application.", m, group);
}
} else {
log.debug("{} not notified about expiration in {}, isn't DIRECT member but still has expiration set!", m, group);
}
} else {
log.debug("{} not notified about expiration in {}, is not in VALID, SUSPENDED or EXPIRED state.", m, group);
}
}
}
use of cz.metacentrum.perun.core.api.MemberGroupStatus in project perun by CESNET.
the class urn_perun_member_group_attribute_def_virt_groupStatus method getAttributeValue.
@Override
public Attribute getAttributeValue(PerunSessionImpl sess, Member member, Group group, AttributeDefinition attribute) {
// Source member object can't be trusted to hold correct group membership status, since we don't know in which context
// it was originally retrieved. Hence we get member of a group once more.
Attribute newAttribute = new Attribute(attribute);
try {
Member retrievedMember = sess.getPerunBl().getGroupsManagerBl().getGroupMemberById(sess, group, member.getId());
MemberGroupStatus result = retrievedMember.getGroupStatus();
newAttribute.setValue((result != null) ? result.toString() : null);
return newAttribute;
} catch (NotGroupMemberException e) {
log.warn("{} is not member of a {} when retrieving member_group:virt:groupStatus attribute.", member, group);
}
return newAttribute;
}
Aggregations