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