Search in sources :

Example 1 with Membership

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

the class DatabaseSetup method setUpMemberships.

private void setUpMemberships() {
    Person grouperAll = new Person();
    grouperAll.setUsername("GrouperAll");
    personRepository.save(grouperAll);
    Iterable<Group> groups = groupRepository.findAll();
    for (Group group : groups) {
        group.addMember(grouperAll);
        groupRepository.save(group);
        for (Person person : group.getMembers()) {
            Membership membership = new Membership(person, group);
            membershipRepository.save(membership);
        }
    }
    Iterable<Grouping> groupings = groupingRepository.findAll();
    for (Grouping grouping : groupings) {
        Membership allExclude = membershipRepository.findByPersonAndGroup(grouperAll, grouping.getExclude());
        Membership allInclude = membershipRepository.findByPersonAndGroup(grouperAll, grouping.getInclude());
        Membership allComposite = membershipRepository.findByPersonAndGroup(grouperAll, grouping.getComposite());
        if (grouping.isOptOutOn()) {
            allComposite.setOptOutEnabled(true);
            allExclude.setOptInEnabled(true);
            allExclude.setOptOutEnabled(true);
        }
        if (grouping.isOptInOn()) {
            allComposite.setOptInEnabled(true);
            allInclude.setOptInEnabled(true);
            allInclude.setOptOutEnabled(true);
        }
        membershipRepository.save(allComposite);
        membershipRepository.save(allExclude);
        membershipRepository.save(allInclude);
    }
}
Also used : Group(edu.hawaii.its.api.type.Group) Membership(edu.hawaii.its.api.type.Membership) Grouping(edu.hawaii.its.api.type.Grouping) Person(edu.hawaii.its.api.type.Person)

Example 2 with Membership

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

the class MemberAttributeServiceTest method checkSelfOptedTest.

@Test
public void checkSelfOptedTest() {
    // user is not in group
    boolean selfOpted = memberAttributeService.isSelfOpted(GROUPING_0_INCLUDE_PATH, users.get(2).getUsername());
    assertFalse(selfOpted);
    // user has not self opted
    selfOpted = memberAttributeService.isSelfOpted(GROUPING_0_INCLUDE_PATH, users.get(5).getUsername());
    assertFalse(selfOpted);
    // user has self opted
    Person person = personRepository.findByUsername(users.get(5).getUsername());
    Group group = groupRepository.findByPath(GROUPING_0_INCLUDE_PATH);
    Membership membership = membershipRepository.findByPersonAndGroup(person, group);
    membership.setSelfOpted(true);
    membershipRepository.save(membership);
    selfOpted = memberAttributeService.isSelfOpted(GROUPING_0_INCLUDE_PATH, users.get(5).getUsername());
    assertTrue(selfOpted);
}
Also used : Group(edu.hawaii.its.api.type.Group) Membership(edu.hawaii.its.api.type.Membership) Person(edu.hawaii.its.api.type.Person) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with Membership

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

the class GrouperFactoryServiceImplLocal method makeWsAssignAttributesResultsForMembership.

@Override
public WsAssignAttributesResults makeWsAssignAttributesResultsForMembership(String attributeAssignType, String attributeAssignOperation, String attributeDefNameName, String ownerMembershipId) {
    WsAssignAttributesResults wsAssignAttributesResults = new WsAssignAttributesResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    wsAssignAttributesResults.setResultMetadata(wsResultMeta);
    Membership membership = membershipRepository.findById(ownerMembershipId);
    if (attributeAssignOperation.equals(OPERATION_ASSIGN_ATTRIBUTE)) {
        membership.setSelfOpted(true);
    } else if (attributeAssignOperation.equals(OPERATION_REMOVE_ATTRIBUTE)) {
        membership.setSelfOpted(false);
    }
    membershipRepository.save(membership);
    return wsAssignAttributesResults;
}
Also used : WsAssignAttributesResults(edu.internet2.middleware.grouperClient.ws.beans.WsAssignAttributesResults) Membership(edu.hawaii.its.api.type.Membership) WsMembership(edu.internet2.middleware.grouperClient.ws.beans.WsMembership) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)

Example 4 with Membership

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

the class GrouperFactoryServiceImplLocal method addMember.

private void addMember(Group group, Person person) {
    Membership membership = membershipRepository.findByPersonAndGroup(person, group);
    if (membership == null) {
        group.getMembers().add(person);
        membership = new Membership(person, group);
        groupRepository.save(group);
        membershipRepository.save(membership);
    }
}
Also used : Membership(edu.hawaii.its.api.type.Membership) WsMembership(edu.internet2.middleware.grouperClient.ws.beans.WsMembership)

Example 5 with Membership

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

the class MembershipServiceTest method removeSelfOptedTest.

@Test
public void removeSelfOptedTest() {
    Group group = groupRepository.findByPath(GROUPING_4_EXCLUDE_PATH);
    GroupingsServiceResult gsr;
    try {
        // member is not in group
        gsr = membershipService.removeSelfOpted(GROUPING_4_EXCLUDE_PATH, users.get(5).getUsername());
    } catch (GroupingsServiceResultException gsre) {
        gsr = gsre.getGsr();
    }
    assertTrue(gsr.getResultCode().startsWith(FAILURE));
    // member is not self-opted
    gsr = membershipService.removeSelfOpted(GROUPING_4_EXCLUDE_PATH, users.get(4).getUsername());
    assertTrue(gsr.getResultCode().startsWith(SUCCESS));
    // make member self-opted
    Membership membership = membershipRepository.findByPersonAndGroup(users.get(4), group);
    membership.setSelfOpted(true);
    membershipRepository.save(membership);
    // member is self-opted
    gsr = membershipService.removeSelfOpted(GROUPING_4_EXCLUDE_PATH, users.get(4).getUsername());
    assertTrue(gsr.getResultCode().startsWith(SUCCESS));
}
Also used : Group(edu.hawaii.its.api.type.Group) GroupingsServiceResultException(edu.hawaii.its.api.type.GroupingsServiceResultException) GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) Membership(edu.hawaii.its.api.type.Membership) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Membership (edu.hawaii.its.api.type.Membership)10 WsMembership (edu.internet2.middleware.grouperClient.ws.beans.WsMembership)7 Group (edu.hawaii.its.api.type.Group)6 Person (edu.hawaii.its.api.type.Person)5 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)5 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)3 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Grouping (edu.hawaii.its.api.type.Grouping)1 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)1 GroupingsServiceResultException (edu.hawaii.its.api.type.GroupingsServiceResultException)1 WsAssignAttributesResults (edu.internet2.middleware.grouperClient.ws.beans.WsAssignAttributesResults)1 WsAssignGrouperPrivilegesLiteResult (edu.internet2.middleware.grouperClient.ws.beans.WsAssignGrouperPrivilegesLiteResult)1 WsAttributeAssign (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)1 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)1 WsGetGrouperPrivilegesLiteResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetGrouperPrivilegesLiteResult)1 WsGetMembershipsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembershipsResults)1