Search in sources :

Example 1 with GroupService

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);
}
Also used : GroupService(org.kuali.kfs.kim.api.group.GroupService) Timestamp(java.sql.Timestamp) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 2 with GroupService

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;
}
Also used : ArrayList(java.util.ArrayList) GroupService(org.kuali.kfs.kim.api.group.GroupService) ActionTaken(org.kuali.kfs.kew.actiontaken.ActionTaken)

Aggregations

GroupService (org.kuali.kfs.kim.api.group.GroupService)2 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 ActionTaken (org.kuali.kfs.kew.actiontaken.ActionTaken)1 CacheEvict (org.springframework.cache.annotation.CacheEvict)1