Search in sources :

Example 6 with SecurityRequestDocument

use of edu.cornell.kfs.ksr.document.SecurityRequestDocument in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentAction method deleteQualificationLine.

public ActionForward deleteQualificationLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    SecurityRequestDocumentForm documentForm = (SecurityRequestDocumentForm) form;
    SecurityRequestDocument document = (SecurityRequestDocument) documentForm.getDocument();
    int roleRequestIndex = -1;
    int qualificationIndex = -1;
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName) && StringUtils.contains(parameterName, ".roleRequestIndex") && StringUtils.contains(parameterName, ".qualificationIndex")) {
        String roleRequestIndexStr = StringUtils.substringBetween(parameterName, ".roleRequestIndex", ".");
        roleRequestIndex = Integer.parseInt(roleRequestIndexStr);
        String qualificationIndexStr = StringUtils.substringBetween(parameterName, ".qualificationIndex", ".");
        qualificationIndex = Integer.parseInt(qualificationIndexStr);
    } else {
        LOG.error("deleteQualificationLine() Unable to find qualification index for line to delete");
        throw new RuntimeException("Unable to find qualification index for line to delete");
    }
    SecurityRequestRole securityRequestRole = document.getSecurityRequestRoles().get(roleRequestIndex);
    if (securityRequestRole == null) {
        LOG.error("deleteQualificationLine() Security request role not found for index: " + roleRequestIndex);
        throw new RuntimeException("Security request role not found for index: " + roleRequestIndex);
    }
    securityRequestRole.getRequestRoleQualifications().remove(qualificationIndex);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Example 7 with SecurityRequestDocument

use of edu.cornell.kfs.ksr.document.SecurityRequestDocument in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentAction method createDocument.

@Override
protected void createDocument(KualiDocumentFormBase kualiDocumentFormBase) throws WorkflowException {
    SecurityRequestDocumentForm documentForm = (SecurityRequestDocumentForm) kualiDocumentFormBase;
    if (documentForm.getSecurityGroupId() == null) {
        LOG.error("createDocument() Security group id not given for new security request document request");
        throw new RuntimeException("Security group id not given for new security request document request");
    }
    super.createDocument(kualiDocumentFormBase);
    SecurityRequestDocument document = (SecurityRequestDocument) documentForm.getDocument();
    document.setSecurityGroupId(documentForm.getSecurityGroupId());
    documentForm.setCurrentPrincipalId(document.getPrincipalId());
    document.refreshReferenceObject(KSRPropertyConstants.SECURITY_GROUP);
}
Also used : SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Example 8 with SecurityRequestDocument

use of edu.cornell.kfs.ksr.document.SecurityRequestDocument in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentAction method refresh.

@Override
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    SecurityRequestDocumentForm documentForm = (SecurityRequestDocumentForm) form;
    SecurityRequestDocument document = (SecurityRequestDocument) documentForm.getDocument();
    super.refresh(mapping, form, request, response);
    if (StringUtils.isNotBlank(request.getParameter("document.principalId"))) {
        if (StringUtils.isNotBlank(document.getPrincipalId()) && ObjectUtils.isNotNull(document.getRequestPerson())) {
            if (!StringUtils.equals(document.getPrincipalId(), documentForm.getCurrentPrincipalId())) {
                SpringContext.getBean(SecurityRequestDocumentService.class).initiateSecurityRequestDocument(document, GlobalVariables.getUserSession().getPerson());
                documentForm.setTabRoleIndexes(buildTabRoleIndexes(document));
                documentForm.setCurrentPrincipalId(document.getPrincipalId());
            }
        }
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : SecurityRequestDocumentService(edu.cornell.kfs.ksr.service.SecurityRequestDocumentService) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Example 9 with SecurityRequestDocument

use of edu.cornell.kfs.ksr.document.SecurityRequestDocument 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 10 with SecurityRequestDocument

use of edu.cornell.kfs.ksr.document.SecurityRequestDocument in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentRule method processCustomRouteDocumentBusinessRules.

@Override
protected boolean processCustomRouteDocumentBusinessRules(Document document) {
    boolean success = true;
    SecurityRequestDocument securityRequestDocument = (SecurityRequestDocument) document;
    if (!isDocumentChanged(securityRequestDocument)) {
        success = false;
        String input = KRADConstants.DOCUMENT_PROPERTY_NAME + "." + KRADConstants.DOCUMENT_HEADER_PROPERTY_NAME;
        GlobalVariables.getMessageMap().putError(input, KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_CHANGE_MISSING);
    } else {
        List<SecurityRequestRole> activeRoles = new ArrayList<SecurityRequestRole>();
        Map<String, String> indexes = new HashMap<String, String>();
        for (int i = 0; i < securityRequestDocument.getSecurityRequestRoles().size(); i++) {
            SecurityRequestRole securityRequestRole = securityRequestDocument.getSecurityRequestRoles().get(i);
            indexes.put(securityRequestRole.getRoleId(), Integer.toString(i));
            if (securityRequestRole.isActive()) {
                activeRoles.add(securityRequestRole);
            }
        }
        for (int i = 0; i < activeRoles.size(); i++) {
            List<String> rolesNeeded = new ArrayList<String>();
            SecurityRequestRole securityRequestRole = activeRoles.get(i);
            Map<String, Object> hashMap = new HashMap<String, Object>();
            hashMap.put(KSRPropertyConstants.PROVISIONING_ROLE_ID, securityRequestRole.getRoleId());
            hashMap.put(KSRPropertyConstants.SECURITY_GROUP_ID, securityRequestDocument.getSecurityGroupId());
            hashMap.put(KSRPropertyConstants.SECURITY_GROUP_ACTIVE_INDICATOR, Boolean.TRUE);
            List<SecurityProvisioningGroup> objList = (List<SecurityProvisioningGroup>) KRADServiceLocator.getBusinessObjectService().findMatching(SecurityProvisioningGroup.class, hashMap);
            SecurityProvisioningGroup securityProvisioningGroup = null;
            if ((objList != null) && (objList.size() != 0)) {
                securityProvisioningGroup = objList.get(0);
            }
            if (securityProvisioningGroup != null) {
                for (int j = 0; j < securityProvisioningGroup.getDependentRoles().size(); j++) {
                    SecurityProvisioningGroupDependentRoles dependentRole = securityProvisioningGroup.getDependentRoles().get(j);
                    if (!dependentRole.isActive()) {
                        continue;
                    }
                    boolean found = false;
                    for (int k = 0; k < activeRoles.size(); k++) {
                        if (activeRoles.get(k).getRoleId().equals(dependentRole.getRoleId())) {
                            found = true;
                        }
                    }
                    if (!found) {
                        String index = indexes.get(dependentRole.getRoleId());
                        String input = KSRPropertyConstants.SECURITY_REQUEST_DOC_REQUEST_ROLE + "[" + index + "].active";
                        GlobalVariables.getMessageMap().putError(input, KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_DEPENDENT_ROLE_MISSING, new String[] { securityRequestRole.getRoleInfo().getName(), dependentRole.getRole().getName() });
                        rolesNeeded.add(dependentRole.getRole().getName());
                        success = false;
                    }
                }
            }
        }
    }
    return super.processCustomRouteDocumentBusinessRules(document) && success;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SecurityProvisioningGroupDependentRoles(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles) SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) ArrayList(java.util.ArrayList) List(java.util.List) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Aggregations

SecurityRequestDocument (edu.cornell.kfs.ksr.document.SecurityRequestDocument)10 SecurityRequestRole (edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)6 SecurityRequestDocumentService (edu.cornell.kfs.ksr.service.SecurityRequestDocumentService)3 SecurityRequestRoleQualification (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification)2 ArrayList (java.util.ArrayList)2 SecurityProvisioningGroup (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup)1 SecurityProvisioningGroupDependentRoles (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles)1 SecurityRequestRoleQualificationDetail (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualificationDetail)1 AddQualificationLineEvent (edu.cornell.kfs.ksr.document.validation.impl.AddQualificationLineEvent)1 HashMap (java.util.HashMap)1 List (java.util.List)1 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)1 RoleMembership (org.kuali.kfs.kim.api.role.RoleMembership)1 KimType (org.kuali.kfs.kim.impl.type.KimType)1