Search in sources :

Example 11 with WsAttributeAssign

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);
}
Also used : WsGetGroupsResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult) Arrays(java.util.Arrays) GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment) WsAttributeDefName(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeDefName) Autowired(org.springframework.beans.factory.annotation.Autowired) WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) HashSet(java.util.HashSet) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) Service(org.springframework.stereotype.Service) Map(java.util.Map) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsStemLookup(edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults) Grouping(edu.hawaii.its.api.type.Grouping) AdminListsHolder(edu.hawaii.its.api.type.AdminListsHolder) Person(edu.hawaii.its.api.type.Person) Collectors(java.util.stream.Collectors) List(java.util.List) WsGetGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) StemScope(edu.internet2.middleware.grouperClient.ws.StemScope) ArrayList(java.util.ArrayList) WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)

Aggregations

WsAttributeAssign (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)11 ArrayList (java.util.ArrayList)8 Grouping (edu.hawaii.its.api.type.Grouping)5 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)5 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)3 WsAttributeDefName (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeDefName)2 AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)1 Group (edu.hawaii.its.api.type.Group)1 GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)1 Membership (edu.hawaii.its.api.type.Membership)1 Person (edu.hawaii.its.api.type.Person)1 GcGetAttributeAssignments (edu.internet2.middleware.grouperClient.api.GcGetAttributeAssignments)1 StemScope (edu.internet2.middleware.grouperClient.ws.StemScope)1 WsGetGroupsResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult)1 WsGetGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults)1 WsGetMembersResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults)1 WsGetMembershipsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembershipsResults)1 WsMembership (edu.internet2.middleware.grouperClient.ws.beans.WsMembership)1 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)1 WsStemLookup (edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup)1