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);
}
Aggregations