Search in sources :

Example 11 with WsGetAttributeAssignmentsResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method makeWsGetAttributeAssignmentsResultsForGroup.

@Override
public WsGetAttributeAssignmentsResults makeWsGetAttributeAssignmentsResultsForGroup(String assignType, String group) {
    WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults = new WsGetAttributeAssignmentsResults();
    Grouping grouping = groupingRepository.findByPath(group);
    if (grouping.isListservOn()) {
        wsGetAttributeAssignmentsResults = addAssignmentResults(wsGetAttributeAssignmentsResults, LISTSERV);
    }
    if (grouping.isOptInOn()) {
        wsGetAttributeAssignmentsResults = addAssignmentResults(wsGetAttributeAssignmentsResults, OPT_IN);
    }
    if (grouping.isOptOutOn()) {
        wsGetAttributeAssignmentsResults = addAssignmentResults(wsGetAttributeAssignmentsResults, OPT_OUT);
    }
    return wsGetAttributeAssignmentsResults;
}
Also used : WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) Grouping(edu.hawaii.its.api.type.Grouping)

Example 12 with WsGetAttributeAssignmentsResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method addAssignmentResults.

private WsGetAttributeAssignmentsResults addAssignmentResults(WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults, String attributeName) {
    List<WsAttributeDefName> wsAttributeDefNames = new ArrayList<>();
    List<WsAttributeAssign> wsAttributeAssigns = new ArrayList<>();
    if (wsGetAttributeAssignmentsResults.getWsAttributeAssigns() != null) {
        Collections.addAll(wsAttributeAssigns, wsGetAttributeAssignmentsResults.getWsAttributeAssigns());
    }
    if (wsGetAttributeAssignmentsResults.getWsAttributeDefNames() != null) {
        Collections.addAll(wsAttributeDefNames, wsGetAttributeAssignmentsResults.getWsAttributeDefNames());
    }
    WsAttributeAssign wsAttributeAssign = new WsAttributeAssign();
    WsAttributeDefName wsAttributeDefName = new WsAttributeDefName();
    wsAttributeDefName.setName(attributeName);
    wsAttributeAssign.setAttributeDefNameName(attributeName);
    wsAttributeAssigns.add(wsAttributeAssign);
    wsAttributeDefNames.add(wsAttributeDefName);
    wsGetAttributeAssignmentsResults.setWsAttributeDefNames(wsAttributeDefNames.toArray(new WsAttributeDefName[wsAttributeDefNames.size()]));
    wsGetAttributeAssignmentsResults.setWsAttributeAssigns(wsAttributeAssigns.toArray(new WsAttributeAssign[wsAttributeAssigns.size()]));
    return wsGetAttributeAssignmentsResults;
}
Also used : WsAttributeDefName(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeDefName) ArrayList(java.util.ArrayList) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)

Example 13 with WsGetAttributeAssignmentsResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method removeGroupsWithoutOptOut.

private WsGetAttributeAssignmentsResults removeGroupsWithoutOptOut(WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults) {
    List<WsGroup> wsGroupList = Arrays.asList(wsGetAttributeAssignmentsResults.getWsGroups());
    List<WsAttributeAssign> wsAttributeAssignList = Arrays.asList(wsGetAttributeAssignmentsResults.getWsAttributeAssigns());
    List<WsGroup> newWsGroupList = new ArrayList<>();
    List<WsAttributeAssign> newWsAttributeAssignList = new ArrayList<>();
    for (WsGroup wsGroup : wsGroupList) {
        Grouping grouping = groupingRepository.findByPath(wsGroup.getName());
        if (grouping.isOptOutOn()) {
            newWsGroupList.add(wsGroup);
        }
    }
    for (WsAttributeAssign wsAttributeAssign : wsAttributeAssignList) {
        Grouping grouping = groupingRepository.findByPath(wsAttributeAssign.getOwnerGroupName());
        if (grouping.isOptOutOn()) {
            newWsAttributeAssignList.add(wsAttributeAssign);
        }
    }
    wsGetAttributeAssignmentsResults.setWsAttributeAssigns(newWsAttributeAssignList.toArray(new WsAttributeAssign[newWsAttributeAssignList.size()]));
    wsGetAttributeAssignmentsResults.setWsGroups(newWsGroupList.toArray(new WsGroup[newWsGroupList.size()]));
    return wsGetAttributeAssignmentsResults;
}
Also used : ArrayList(java.util.ArrayList) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign) Grouping(edu.hawaii.its.api.type.Grouping)

Example 14 with WsGetAttributeAssignmentsResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method makeWsGetAttributeAssignmentsResultsForMembership.

@Override
public WsGetAttributeAssignmentsResults makeWsGetAttributeAssignmentsResultsForMembership(String assignType, String attributeDefNameName, String membershipId) {
    Membership membership = membershipRepository.findById(membershipId);
    WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults = new WsGetAttributeAssignmentsResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    WsAttributeAssign[] wsAttributeAssigns = new WsAttributeAssign[1];
    WsAttributeAssign wsAttributeAssign = new WsAttributeAssign();
    if (membership.isSelfOpted()) {
        wsAttributeAssign.setAttributeDefNameName(SELF_OPTED);
    }
    wsAttributeAssigns[0] = wsAttributeAssign;
    wsGetAttributeAssignmentsResults.setResultMetadata(wsResultMeta);
    wsGetAttributeAssignmentsResults.setWsAttributeAssigns(wsAttributeAssigns);
    return wsGetAttributeAssignmentsResults;
}
Also used : Membership(edu.hawaii.its.api.type.Membership) WsMembership(edu.internet2.middleware.grouperClient.ws.beans.WsMembership) WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)

Example 15 with WsGetAttributeAssignmentsResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults 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

WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)13 ArrayList (java.util.ArrayList)10 WsAttributeAssign (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)8 Grouping (edu.hawaii.its.api.type.Grouping)5 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)5 WsAttributeDefName (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeDefName)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)2 Group (edu.hawaii.its.api.type.Group)2 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)2 GcGetAttributeAssignments (edu.internet2.middleware.grouperClient.api.GcGetAttributeAssignments)2 GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)1 Membership (edu.hawaii.its.api.type.Membership)1 Person (edu.hawaii.its.api.type.Person)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 WsMembership (edu.internet2.middleware.grouperClient.ws.beans.WsMembership)1