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