Search in sources :

Example 1 with AddQualificationLineEvent

use of edu.cornell.kfs.ksr.document.validation.impl.AddQualificationLineEvent 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)

Aggregations

SecurityRequestRole (edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)1 SecurityRequestRoleQualification (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification)1 SecurityRequestDocument (edu.cornell.kfs.ksr.document.SecurityRequestDocument)1 AddQualificationLineEvent (edu.cornell.kfs.ksr.document.validation.impl.AddQualificationLineEvent)1 SecurityRequestDocumentService (edu.cornell.kfs.ksr.service.SecurityRequestDocumentService)1