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