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);
}
}
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);
}
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;
}
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);
}
}
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));
}
Aggregations