use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method makeWsGetAttributeAssignmentsResultsForGroup.
@Override
public WsGetAttributeAssignmentsResults makeWsGetAttributeAssignmentsResultsForGroup(String assignType, String group) {
WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults = new WsGetAttributeAssignmentsResults();
Grouping grouping = groupingRepository.findByPath(group);
if (grouping.isListservOn()) {
wsGetAttributeAssignmentsResults = addAssignmentResults(wsGetAttributeAssignmentsResults, LISTSERV);
}
if (grouping.isOptInOn()) {
wsGetAttributeAssignmentsResults = addAssignmentResults(wsGetAttributeAssignmentsResults, OPT_IN);
}
if (grouping.isOptOutOn()) {
wsGetAttributeAssignmentsResults = addAssignmentResults(wsGetAttributeAssignmentsResults, OPT_OUT);
}
return wsGetAttributeAssignmentsResults;
}
use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method removeGroupsWithoutOptOut.
private WsGetAttributeAssignmentsResults removeGroupsWithoutOptOut(WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults) {
List<WsGroup> wsGroupList = Arrays.asList(wsGetAttributeAssignmentsResults.getWsGroups());
List<WsAttributeAssign> wsAttributeAssignList = Arrays.asList(wsGetAttributeAssignmentsResults.getWsAttributeAssigns());
List<WsGroup> newWsGroupList = new ArrayList<>();
List<WsAttributeAssign> newWsAttributeAssignList = new ArrayList<>();
for (WsGroup wsGroup : wsGroupList) {
Grouping grouping = groupingRepository.findByPath(wsGroup.getName());
if (grouping.isOptOutOn()) {
newWsGroupList.add(wsGroup);
}
}
for (WsAttributeAssign wsAttributeAssign : wsAttributeAssignList) {
Grouping grouping = groupingRepository.findByPath(wsAttributeAssign.getOwnerGroupName());
if (grouping.isOptOutOn()) {
newWsAttributeAssignList.add(wsAttributeAssign);
}
}
wsGetAttributeAssignmentsResults.setWsAttributeAssigns(newWsAttributeAssignList.toArray(new WsAttributeAssign[newWsAttributeAssignList.size()]));
wsGetAttributeAssignmentsResults.setWsGroups(newWsGroupList.toArray(new WsGroup[newWsGroupList.size()]));
return wsGetAttributeAssignmentsResults;
}
use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method makeWsAssignAttributesResults.
@Override
public WsAssignAttributesResults makeWsAssignAttributesResults(String attributeAssignType, String attributeAssignOperation, String ownerGroupName, String attributeDefNameName, String attributeAssignValueOperation, WsAttributeAssignValue value) {
WsAssignAttributesResults wsAssignAttributesResults = new WsAssignAttributesResults();
WsResultMeta wsResultMeta = new WsResultMeta();
wsResultMeta.setResultCode(SUCCESS);
wsAssignAttributesResults.setResultMetadata(wsResultMeta);
Grouping grouping = groupingRepository.findByPath(ownerGroupName);
Boolean onOrrOff = null;
if (attributeAssignOperation.equals(OPERATION_ASSIGN_ATTRIBUTE)) {
onOrrOff = true;
} else if (attributeAssignOperation.equals(OPERATION_REMOVE_ATTRIBUTE)) {
onOrrOff = false;
}
if (onOrrOff != null) {
if (attributeDefNameName.equals(LISTSERV)) {
grouping.setListservOn(onOrrOff);
} else if (attributeDefNameName.equals(OPT_IN)) {
grouping.setOptInOn(onOrrOff);
} else if (attributeDefNameName.equals(OPT_OUT)) {
grouping.setOptOutOn(onOrrOff);
}
}
return wsAssignAttributesResults;
}
use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceImpl method groupingsToOptInto.
// returns the list of groupings that the user is allowed to opt-in to
public List<Grouping> groupingsToOptInto(String optInUsername, List<String> groupPaths) {
logger.info("groupingsToOptInto; username: " + optInUsername + "; groupPaths : " + groupPaths + ";");
List<String> trios = new ArrayList<>();
List<String> opts = new ArrayList<>();
List<String> excludes = groupPaths.stream().map(group -> group + EXCLUDE).collect(Collectors.toList());
WsGetAttributeAssignmentsResults assignmentsResults = grouperFS.makeWsGetAttributeAssignmentsResultsTrio(ASSIGN_TYPE_GROUP, TRIO, OPT_IN);
if (assignmentsResults.getWsAttributeAssigns() != null) {
for (WsAttributeAssign assign : assignmentsResults.getWsAttributeAssigns()) {
if (assign.getAttributeDefNameName() != null) {
if (assign.getAttributeDefNameName().equals(TRIO)) {
trios.add(assign.getOwnerGroupName());
} else if (assign.getAttributeDefNameName().equals(OPT_IN)) {
opts.add(assign.getOwnerGroupName());
}
}
}
// opts intersection trios
opts.retainAll(trios);
// excludes intersection opts
excludes.retainAll(opts);
// opts - (opts intersection groupPaths)
opts.removeAll(groupPaths);
// opts union excludes
opts.addAll(excludes);
}
// get rid of duplicates
List<String> groups = new ArrayList<>(new HashSet<>(opts));
return helperService.makeGroupings(groups);
}
use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceImpl method getGrouping.
// fetch a grouping from Grouper or the database
@Override
public Grouping getGrouping(String groupingPath, String ownerUsername) {
logger.info("getGrouping; grouping: " + groupingPath + "; username: " + ownerUsername + ";");
Grouping compositeGrouping = new Grouping();
if (memberAttributeService.isOwner(groupingPath, ownerUsername) || memberAttributeService.isAdmin(ownerUsername)) {
compositeGrouping = new Grouping(groupingPath);
Group include = getMembers(ownerUsername, groupingPath + INCLUDE);
Group exclude = getMembers(ownerUsername, groupingPath + EXCLUDE);
Group basis = getMembers(ownerUsername, groupingPath + BASIS);
Group composite = getMembers(ownerUsername, groupingPath);
Group owners = getMembers(ownerUsername, groupingPath + OWNERS);
compositeGrouping = setGroupingAttributes(compositeGrouping);
compositeGrouping.setBasis(basis);
compositeGrouping.setExclude(exclude);
compositeGrouping.setInclude(include);
compositeGrouping.setComposite(composite);
compositeGrouping.setOwners(owners);
}
return compositeGrouping;
}
Aggregations