Search in sources :

Example 16 with Grouping

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

the class TestGroupingAssignmentService method groupingsToOptTest.

@Test
public void groupingsToOptTest() {
    GroupingAssignment groupingAssignment = groupingAssignmentService.getGroupingAssignment(username[0]);
    boolean canOptIn = false;
    for (Grouping grouping : groupingAssignment.getGroupingsToOptInTo()) {
        if (grouping.getPath().contains(GROUPING)) {
            canOptIn = true;
            break;
        }
    }
    assertFalse(canOptIn);
    boolean canOptOut = false;
    for (Grouping grouping : groupingAssignment.getGroupingsToOptOutOf()) {
        if (grouping.getPath().contains(GROUPING)) {
            canOptOut = true;
            break;
        }
    }
    assertTrue(canOptOut);
}
Also used : Grouping(edu.hawaii.its.api.type.Grouping) GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 17 with Grouping

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

the class GrouperFactoryServiceImplLocal method makeWsAddMemberResults.

@Override
public WsAddMemberResults makeWsAddMemberResults(String group, WsSubjectLookup lookup, Person personToAdd) {
    Person newGroupMember;
    WsAddMemberResults wsAddMemberResults = new WsAddMemberResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    wsAddMemberResults.setResultMetadata(wsResultMeta);
    Grouping grouping = groupingRepository.findByIncludePathOrExcludePathOrCompositePathOrOwnersPath(group, group, group, group);
    if (personToAdd.getUsername() != null) {
        newGroupMember = personRepository.findByUsername(personToAdd.getUsername());
    } else {
        newGroupMember = personRepository.findByUuid(personToAdd.getUuid());
    }
    if (grouping == null) {
        Group groupToAddTo = groupRepository.findByPath(group);
        addMember(groupToAddTo, newGroupMember);
    } else {
        boolean inBasis = grouping.getBasis().isMember(newGroupMember);
        boolean inExclude = grouping.getExclude().isMember(newGroupMember);
        boolean inInclude = grouping.getInclude().isMember(newGroupMember);
        if (group.endsWith(OWNERS)) {
            addMember(grouping.getOwners(), newGroupMember);
        } else if (group.endsWith(EXCLUDE)) {
            if (inBasis) {
                addMember(grouping.getExclude(), newGroupMember);
            } else if (inInclude) {
                deleteMember(grouping.getInclude(), newGroupMember);
            }
        } else if (group.endsWith(INCLUDE)) {
            if (inExclude) {
                deleteMember(grouping.getExclude(), newGroupMember);
            } else if (!inBasis) {
                addMember(grouping.getInclude(), newGroupMember);
            }
        }
        grouping = groupingRepository.findByPath(grouping.getPath());
        Group composite = buildComposite(grouping.getInclude(), grouping.getExclude(), grouping.getBasis(), grouping.getPath());
        groupRepository.save(composite);
    }
    return wsAddMemberResults;
}
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) Person(edu.hawaii.its.api.type.Person) WsAddMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)

Example 18 with Grouping

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

the class GroupingAssignmentServiceImpl method adminLists.

// returns an adminLists object containing the list of all admins and all groupings
@Override
public AdminListsHolder adminLists(String adminUsername) {
    AdminListsHolder info = new AdminListsHolder();
    List<Grouping> groupings;
    if (memberAttributeService.isSuperuser(adminUsername)) {
        WsGetAttributeAssignmentsResults attributeAssignmentsResults = grouperFS.makeWsGetAttributeAssignmentsResultsTrio(ASSIGN_TYPE_GROUP, TRIO);
        List<WsGroup> groups = new ArrayList<>(Arrays.asList(attributeAssignmentsResults.getWsGroups()));
        List<String> groupPaths = groups.stream().map(WsGroup::getName).collect(Collectors.toList());
        Group admin = getMembers(adminUsername, GROUPING_ADMINS);
        groupings = helperService.makeGroupings(groupPaths);
        info.setAdminGroup(admin);
        info.setAllGroupings(groupings);
    }
    return info;
}
Also used : AdminListsHolder(edu.hawaii.its.api.type.AdminListsHolder) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) ArrayList(java.util.ArrayList) WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) Grouping(edu.hawaii.its.api.type.Grouping) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup)

Example 19 with Grouping

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

the class GrouperFactoryServiceImplLocal method attributeAssignsOptIn.

private List<WsAttributeAssign> attributeAssignsOptIn() {
    List<WsAttributeAssign> attributeAssigns = new ArrayList<>();
    Iterable<Grouping> groupings = groupingRepository.findAll();
    for (Grouping grouping : groupings) {
        if (grouping.isOptInOn()) {
            WsAttributeAssign attributeAssign = new WsAttributeAssign();
            attributeAssign.setAttributeDefNameName(OPT_IN);
            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 20 with Grouping

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

the class GrouperFactoryServiceImplLocal method makeWsAssignAttributesResultsForGroup.

@Override
public WsAssignAttributesResults makeWsAssignAttributesResultsForGroup(String attributeAssignType, String attributeAssignOperation, String attributeDefNameName, String ownerGroupName) {
    WsAssignAttributesResults wsAssignAttributesResults = new WsAssignAttributesResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(FAILURE);
    Grouping grouping = groupingRepository.findByPath(ownerGroupName);
    if (attributeAssignOperation.equals(OPERATION_ASSIGN_ATTRIBUTE)) {
        if (setGroupingAttribute(grouping, attributeDefNameName, true)) {
            wsResultMeta.setResultCode(SUCCESS);
        }
    } else if (attributeAssignOperation.equals(OPERATION_REMOVE_ATTRIBUTE)) {
        if (setGroupingAttribute(grouping, attributeDefNameName, false)) {
            wsResultMeta.setResultCode(SUCCESS);
        }
    }
    wsAssignAttributesResults.setResultMetadata(wsResultMeta);
    return wsAssignAttributesResults;
}
Also used : WsAssignAttributesResults(edu.internet2.middleware.grouperClient.ws.beans.WsAssignAttributesResults) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Grouping(edu.hawaii.its.api.type.Grouping)

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