use of org.kuali.kfs.kim.api.group.GroupService in project cu-kfs by CU-CommunityApps.
the class GroupServiceImpl method removeAllMembers.
@CacheEvict(value = { GroupMember.CACHE_NAME, Role.CACHE_NAME }, allEntries = true)
@Override
public void removeAllMembers(String groupId) throws IllegalArgumentException {
incomingParamCheck(groupId, "groupId");
GroupService groupService = KimApiServiceLocator.getGroupService();
List<String> memberPrincipalsBefore = groupService.getMemberPrincipalIds(groupId);
Collection<GroupMember> toDeactivate = getActiveGroupMembers(groupId, null, null);
Timestamp today = new Timestamp(System.currentTimeMillis());
// Set principals as inactive
for (GroupMember aToDeactivate : toDeactivate) {
aToDeactivate.setActiveToDateValue(today);
}
// Save
this.businessObjectService.save(new ArrayList<>(toDeactivate));
List<String> memberPrincipalsAfter = groupService.getMemberPrincipalIds(groupId);
if (!memberPrincipalsAfter.isEmpty()) {
// should never happen!
LOG.warn("after attempting removal of all members, group with id '" + groupId + "' still has principal members");
}
// do updates
KimImplServiceLocator.getGroupInternalService().updateForWorkgroupChange(groupId, memberPrincipalsBefore, memberPrincipalsAfter);
}
use of org.kuali.kfs.kim.api.group.GroupService in project cu-kfs by CU-CommunityApps.
the class ActionTakenServiceImpl method getPreviousAction.
public ActionTaken getPreviousAction(ActionRequest actionRequest, List<ActionTaken> simulatedActionsTaken) {
GroupService ims = KimApiServiceLocator.getGroupService();
ActionTaken foundActionTaken = null;
List<String> principalIds = new ArrayList<String>();
if (actionRequest.isGroupRequest()) {
principalIds.addAll(ims.getMemberPrincipalIds(actionRequest.getGroup().getId()));
} else if (actionRequest.isUserRequest()) {
principalIds.add(actionRequest.getPrincipalId());
}
for (String id : principalIds) {
List<ActionTaken> actionsTakenByUser = getActionTakenDAO().findByDocumentIdWorkflowId(actionRequest.getDocumentId(), id);
if (simulatedActionsTaken != null) {
for (ActionTaken simulatedAction : simulatedActionsTaken) {
if (id.equals(simulatedAction.getPrincipalId())) {
actionsTakenByUser.add(simulatedAction);
}
}
}
for (ActionTaken actionTaken : actionsTakenByUser) {
if (ActionRequest.compareActionCode(actionTaken.getActionTaken(), actionRequest.getActionRequested(), true) >= 0) {
foundActionTaken = actionTaken;
}
}
}
return foundActionTaken;
}
Aggregations