use of edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceImpl method groupingsToOptInto.
// returns the list of groupings that the user is allowed to opt-in to
public List<Grouping> groupingsToOptInto(String optInUsername, List<String> groupPaths) {
logger.info("groupingsToOptInto; username: " + optInUsername + "; groupPaths : " + groupPaths + ";");
List<String> trios = new ArrayList<>();
List<String> opts = new ArrayList<>();
List<String> excludes = groupPaths.stream().map(group -> group + EXCLUDE).collect(Collectors.toList());
WsGetAttributeAssignmentsResults assignmentsResults = grouperFS.makeWsGetAttributeAssignmentsResultsTrio(ASSIGN_TYPE_GROUP, TRIO, OPT_IN);
if (assignmentsResults.getWsAttributeAssigns() != null) {
for (WsAttributeAssign assign : assignmentsResults.getWsAttributeAssigns()) {
if (assign.getAttributeDefNameName() != null) {
if (assign.getAttributeDefNameName().equals(TRIO)) {
trios.add(assign.getOwnerGroupName());
} else if (assign.getAttributeDefNameName().equals(OPT_IN)) {
opts.add(assign.getOwnerGroupName());
}
}
}
// opts intersection trios
opts.retainAll(trios);
// excludes intersection opts
excludes.retainAll(opts);
// opts - (opts intersection groupPaths)
opts.removeAll(groupPaths);
// opts union excludes
opts.addAll(excludes);
}
// get rid of duplicates
List<String> groups = new ArrayList<>(new HashSet<>(opts));
return helperService.makeGroupings(groups);
}
Aggregations