Search in sources :

Example 6 with SecurityRequestRoleQualification

use of edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification in project cu-kfs by CU-CommunityApps.

the class SecurityRequestPostProcessingServiceImpl method assignUpdatePrincipalRoleQualifications.

protected void assignUpdatePrincipalRoleQualifications(SecurityRequestRole requestRole, String principalId) {
    List<Map<String, String>> principalQualifications = getPrincipalsCurrentQualifications(requestRole, principalId);
    principalQualifications = new ArrayList<Map<String, String>>(principalQualifications);
    for (SecurityRequestRoleQualification roleQualification : requestRole.getRequestRoleQualifications()) {
        Map<String, String> requestedQualification = roleQualification.buildQualificationAttributeSet();
        boolean qualificationExists = findInQualificationsListAndRemove(principalQualifications, requestedQualification);
        if (!qualificationExists) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("assignUpdatePrincipalRoleQualifications() Assigning role: " + requestRole.getRoleId() + " to principal Id: " + principalId + " with qualifications: " + requestedQualification.toString());
            }
            getRoleService().assignPrincipalToRole(principalId, requestRole.getRoleInfo().getNamespaceCode(), requestRole.getRoleInfo().getName(), requestedQualification);
        }
    }
    for (Map<String, String> existingQualification : principalQualifications) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("assignUpdatePrincipalRoleQualifications() Removing assignment for role: " + requestRole.getRoleId() + " to principal Id: " + principalId + " with qualifications: " + existingQualification.toString());
        }
        getRoleService().removePrincipalFromRole(principalId, requestRole.getRoleInfo().getNamespaceCode(), requestRole.getRoleInfo().getName(), existingQualification);
    }
}
Also used : SecurityRequestRoleQualification(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with SecurityRequestRoleQualification

use of edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentAction method addQualificationLine.

public ActionForward addQualificationLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    SecurityRequestDocumentForm documentForm = (SecurityRequestDocumentForm) form;
    SecurityRequestDocument document = (SecurityRequestDocument) documentForm.getDocument();
    int roleRequestIndex = -1;
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName) && StringUtils.contains(parameterName, ".roleRequestIndex")) {
        String roleRequestIndexStr = StringUtils.substringBetween(parameterName, ".roleRequestIndex", ".");
        roleRequestIndex = Integer.parseInt(roleRequestIndexStr);
    } else {
        LOG.error("addQualificationLine() Unable to find role request index for new qualification line");
        throw new RuntimeException("Unable to find role request index for new qualification line");
    }
    SecurityRequestRole securityRequestRole = document.getSecurityRequestRoles().get(roleRequestIndex);
    if (securityRequestRole == null) {
        LOG.error("addQualificationLine() Security request role not found for index: " + roleRequestIndex);
        throw new RuntimeException("Security request role not found for index: " + roleRequestIndex);
    }
    String errorPath = "document.securityRequestRoles[" + roleRequestIndex + "].newRequestRoleQualification";
    boolean rulePassed = KRADServiceLocatorWeb.getKualiRuleService().applyRules(new AddQualificationLineEvent(errorPath, document, securityRequestRole.getNewRequestRoleQualification()));
    if (rulePassed) {
        securityRequestRole.getRequestRoleQualifications().add(securityRequestRole.getNewRequestRoleQualification());
        SecurityRequestRoleQualification newRequestRoleQualification = SpringContext.getBean(SecurityRequestDocumentService.class).buildRoleQualificationLine(securityRequestRole, null);
        securityRequestRole.setNewRequestRoleQualification(newRequestRoleQualification);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : SecurityRequestRoleQualification(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification) AddQualificationLineEvent(edu.cornell.kfs.ksr.document.validation.impl.AddQualificationLineEvent) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) SecurityRequestDocumentService(edu.cornell.kfs.ksr.service.SecurityRequestDocumentService) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Example 8 with SecurityRequestRoleQualification

use of edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification in project cu-kfs by CU-CommunityApps.

the class KSRUtil method isQualificationChangeRequested.

public static boolean isQualificationChangeRequested(SecurityRequestRole securityRequestRole) {
    boolean changeRequested = false;
    List<KimTypeAttribute> typeAttributes = getTypeAttributesForRoleRequest(securityRequestRole);
    List<Map<String, String>> requestedQualifications = new ArrayList<Map<String, String>>();
    for (SecurityRequestRoleQualification requestRoleQualification : securityRequestRole.getRequestRoleQualifications()) {
        requestedQualifications.add(requestRoleQualification.buildQualificationAttributeSet());
    }
    String qualificationsString = KSRUtil.buildQualificationString(requestedQualifications, typeAttributes);
    if (StringUtils.isBlank(qualificationsString)) {
        qualificationsString = null;
    }
    if (!StringUtils.equals(qualificationsString, securityRequestRole.getCurrentQualifications())) {
        changeRequested = true;
    }
    return changeRequested;
}
Also used : KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) SecurityRequestRoleQualification(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification) ArrayList(java.util.ArrayList) Map(java.util.Map)

Aggregations

SecurityRequestRoleQualification (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification)8 Map (java.util.Map)4 SecurityRequestRole (edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 SecurityRequestRoleQualificationDetail (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualificationDetail)2 SecurityRequestDocument (edu.cornell.kfs.ksr.document.SecurityRequestDocument)2 KimType (org.kuali.kfs.kim.impl.type.KimType)2 KimTypeAttribute (org.kuali.kfs.kim.impl.type.KimTypeAttribute)2 AddQualificationLineEvent (edu.cornell.kfs.ksr.document.validation.impl.AddQualificationLineEvent)1 SecurityRequestDocumentService (edu.cornell.kfs.ksr.service.SecurityRequestDocumentService)1 List (java.util.List)1 RoleMembership (org.kuali.kfs.kim.api.role.RoleMembership)1 RoleService (org.kuali.kfs.kim.api.role.RoleService)1