Search in sources :

Example 21 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method makeWsDeleteMemberResults.

@Override
public WsDeleteMemberResults makeWsDeleteMemberResults(String group, WsSubjectLookup lookup, Person personToDelete) {
    WsDeleteMemberResults wsDeleteMemberResults = new WsDeleteMemberResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    wsDeleteMemberResults.setResultMetadata(wsResultMeta);
    Grouping grouping = groupingRepository.findByIncludePathOrExcludePathOrCompositePathOrOwnersPath(group, group, group, group);
    if (personToDelete.getUsername() != null) {
        personToDelete = personRepository.findByUsername(personToDelete.getUsername());
    } else if (personToDelete.getUuid() != null) {
        personToDelete = personRepository.findByUuid(personToDelete.getUuid());
    }
    if (grouping == null) {
        Group groupToDeleteFrom = groupRepository.findByPath(group);
        deleteMember(groupToDeleteFrom, personToDelete);
    } else {
        if (group.endsWith(OWNERS)) {
            deleteMember(grouping.getOwners(), personToDelete);
        } else if (group.endsWith(EXCLUDE)) {
            deleteMember(grouping.getExclude(), personToDelete);
        } else if (group.endsWith(INCLUDE)) {
            deleteMember(grouping.getInclude(), personToDelete);
        }
        grouping = groupingRepository.findByPath(grouping.getPath());
        grouping = groupingRepository.findByPath(grouping.getPath());
        Group composite = buildComposite(grouping.getInclude(), grouping.getExclude(), grouping.getBasis(), grouping.getPath());
        groupRepository.save(composite);
    }
    return wsDeleteMemberResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Grouping(edu.hawaii.its.api.type.Grouping) WsDeleteMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)

Example 22 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method attributeAssignsOptOut.

private List<WsAttributeAssign> attributeAssignsOptOut() {
    List<WsAttributeAssign> attributeAssigns = new ArrayList<>();
    Iterable<Grouping> groupings = groupingRepository.findAll();
    for (Grouping grouping : groupings) {
        if (grouping.isOptOutOn()) {
            WsAttributeAssign attributeAssign = new WsAttributeAssign();
            attributeAssign.setAttributeDefNameName(OPT_OUT);
            attributeAssign.setOwnerGroupName(grouping.getPath());
            attributeAssigns.add(attributeAssign);
        }
    }
    return attributeAssigns;
}
Also used : ArrayList(java.util.ArrayList) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign) Grouping(edu.hawaii.its.api.type.Grouping)

Example 23 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method removeGroupsWithoutOptIn.

private WsGetAttributeAssignmentsResults removeGroupsWithoutOptIn(WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults) {
    List<WsGroup> wsGroupList = Arrays.asList(wsGetAttributeAssignmentsResults.getWsGroups());
    List<WsGroup> wsGroupsWithOptIn = new ArrayList<>();
    List<WsAttributeAssign> wsAttributeAssignList = Arrays.asList(wsGetAttributeAssignmentsResults.getWsAttributeAssigns());
    List<WsAttributeAssign> wsAttributeAssignsWithOptIn = new ArrayList<>();
    for (WsGroup wsGroup : wsGroupList) {
        Grouping grouping = groupingRepository.findByPath(wsGroup.getName());
        if (grouping.isOptInOn()) {
            wsGroupsWithOptIn.add(wsGroup);
        }
    }
    for (WsAttributeAssign wsAttributeAssign : wsAttributeAssignList) {
        Grouping grouping = groupingRepository.findByPath(wsAttributeAssign.getOwnerGroupName());
        if (grouping.isOptInOn()) {
            wsAttributeAssignsWithOptIn.add(wsAttributeAssign);
        }
    }
    wsGetAttributeAssignmentsResults.setWsAttributeAssigns(wsAttributeAssignsWithOptIn.toArray(new WsAttributeAssign[wsAttributeAssignsWithOptIn.size()]));
    wsGetAttributeAssignmentsResults.setWsGroups(wsGroupsWithOptIn.toArray(new WsGroup[wsGroupsWithOptIn.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 24 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method grouping.

// Test data.
private Grouping grouping() {
    Grouping grouping = new Grouping("test:ing:me:bob");
    Group basisGroup = new Group();
    basisGroup.addMember(new Person("b0-name", "b0-uuid", "b0-username"));
    basisGroup.addMember(new Person("b1-name", "b1-uuid", "b1-username"));
    basisGroup.addMember(new Person("b2-name", "b2-uuid", "b2-username"));
    grouping.setBasis(basisGroup);
    Group exclude = new Group();
    exclude.addMember(new Person("e0-name", "e0-uuid", "e0-username"));
    grouping.setExclude(exclude);
    Group include = new Group();
    include.addMember(new Person("i0-name", "i0-uuid", "i0-username"));
    include.addMember(new Person("i1-name", "i1-uuid", "i1-username"));
    grouping.setInclude(include);
    Group owners = new Group();
    owners.addMember(new Person("o0-name", "o0-uuid", "o0-username"));
    owners.addMember(new Person("o1-name", "o1-uuid", "o1-username"));
    owners.addMember(new Person("o2-name", "o2-uuid", "o2-username"));
    owners.addMember(new Person("o3-name", "o3-uuid", "o3-username"));
    grouping.setOwners(owners);
    grouping.setListservOn(true);
    return grouping;
}
Also used : Group(edu.hawaii.its.api.type.Group) Grouping(edu.hawaii.its.api.type.Grouping) Person(edu.hawaii.its.api.type.Person)

Example 25 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method myGroupings.

// Test data.
private GroupingAssignment myGroupings() {
    GroupingAssignment mg = new GroupingAssignment();
    List<Grouping> groupings = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        groupings.add(grouping());
        groupings.get(i).setPath("grouping" + i);
    }
    mg.setGroupingsIn(groupings);
    mg.setGroupingsOwned(groupings);
    mg.setGroupingsOptedOutOf(groupings);
    mg.setGroupingsOptedInTo(groupings);
    mg.setGroupingsToOptOutOf(groupings);
    mg.setGroupingsToOptInTo(groupings);
    return mg;
}
Also used : ArrayList(java.util.ArrayList) Grouping(edu.hawaii.its.api.type.Grouping) GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment)

Aggregations

Grouping (edu.hawaii.its.api.type.Grouping)45 Test (org.junit.Test)28 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)28 ArrayList (java.util.ArrayList)14 Group (edu.hawaii.its.api.type.Group)13 GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)11 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)11 WithMockUhUser (edu.hawaii.its.groupings.controller.WithMockUhUser)9 Person (edu.hawaii.its.api.type.Person)8 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)6 GroupingsServiceResultException (edu.hawaii.its.api.type.GroupingsServiceResultException)6 WsAttributeAssign (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)5 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)5 WsAssignAttributesResults (edu.internet2.middleware.grouperClient.ws.beans.WsAssignAttributesResults)3 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)3 AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Membership (edu.hawaii.its.api.type.Membership)1 StemScope (edu.internet2.middleware.grouperClient.ws.StemScope)1 WsAddMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)1