Search in sources :

Example 1 with KimType

use of org.kuali.kfs.kim.impl.type.KimType in project cu-kfs by CU-CommunityApps.

the class SecurityRequestRoleQualification method getWrappedRoleQualificationDetails.

public List<WrappedRoleQualificationDetail> getWrappedRoleQualificationDetails() {
    KimType kimType = getKimTypeFromQualificationDetails();
    if (ObjectUtils.isNull(kimType)) {
        return Collections.emptyList();
    }
    Map<String, KimTypeAttribute> typeAttributes = KSRUtil.getTypeAttributesMappedByAttributeId(kimType);
    Stream.Builder<WrappedRoleQualificationDetail> wrappedDetails = Stream.builder();
    int i = 0;
    for (SecurityRequestRoleQualificationDetail roleQualificationDetail : roleQualificationDetails) {
        KimTypeAttribute typeAttribute = typeAttributes.get(roleQualificationDetail.getAttributeId());
        if (ObjectUtils.isNull(typeAttribute)) {
            throw new IllegalStateException("Could not find attribute " + roleQualificationDetail.getAttributeId() + " for KIM type " + kimType.getNamespaceCode() + " " + kimType.getName());
        }
        wrappedDetails.add(new WrappedRoleQualificationDetail(roleQualificationDetail, i, typeAttribute.getSortCode()));
        i++;
    }
    return wrappedDetails.build().sorted(Comparator.comparing(WrappedRoleQualificationDetail::getSortCode)).collect(Collectors.toUnmodifiableList());
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) Stream(java.util.stream.Stream)

Example 2 with KimType

use of org.kuali.kfs.kim.impl.type.KimType in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentRule method isDocumentAttributesValid.

@Override
public boolean isDocumentAttributesValid(Document document, boolean validateRequired) {
    boolean success = true;
    SecurityRequestDocument securityRequestDocument = (SecurityRequestDocument) document;
    for (int i = 0; i < securityRequestDocument.getSecurityRequestRoles().size(); i++) {
        SecurityRequestRole securityRequestRole = securityRequestDocument.getSecurityRequestRoles().get(i);
        KimType tempTypeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(securityRequestRole.getRoleInfo().getKimTypeId());
        if (!securityRequestRole.isActive()) {
            continue;
        } else if (!securityRequestRole.isQualifiedRole()) {
            continue;
        } else {
            String[] requiredQualifications = getRequiredQualificationsMap().get(tempTypeInfo.getServiceName());
            if (requiredQualifications != null && requiredQualifications.length > 0) {
                boolean qualsValid = true;
                boolean[] hasQuals = new boolean[requiredQualifications.length];
                for (SecurityRequestRoleQualification roleQualification : securityRequestRole.getRequestRoleQualifications()) {
                    Arrays.fill(hasQuals, false);
                    for (SecurityRequestRoleQualificationDetail qualDetail : roleQualification.getRoleQualificationDetails()) {
                        for (int j = requiredQualifications.length - 1; j >= 0; j--) {
                            if (requiredQualifications[j].equals(qualDetail.getAttributeName()) && StringUtils.isNotBlank(qualDetail.getAttributeValue())) {
                                hasQuals[j] = true;
                            }
                        }
                    }
                    for (boolean hasQual : hasQuals) {
                        qualsValid &= hasQual;
                    }
                }
                if (!qualsValid || securityRequestRole.getRequestRoleQualifications().size() == 0) {
                    success = false;
                    GlobalVariables.getMessageMap().putError(KSRPropertyConstants.SECURITY_REQUEST_DOC_REQUEST_ROLE + "[" + i + "].active", KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_QUALIFIER_MULTI_MISSING, new String[] { securityRequestRole.getRoleInfo().getName() });
                }
            } else if (securityRequestRole.getRequestRoleQualifications().size() == 0) {
                securityRequestRole.getRequestRoleQualifications().add(SpringContext.getBean(SecurityRequestDocumentService.class).buildRoleQualificationLine(securityRequestRole, null));
            }
        }
        for (int j = 0; j < securityRequestRole.getRequestRoleQualifications().size(); j++) {
            SecurityRequestRoleQualification requestRoleQualification = securityRequestRole.getRequestRoleQualifications().get(j);
            String typeId = securityRequestRole.getRoleInfo().getKimTypeId();
            KimType typeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(typeId);
            String fieldKeyPrefix = KSRPropertyConstants.SECURITY_REQUEST_DOC_REQUEST_ROLE + "[" + i + "]." + KSRPropertyConstants.SECURITY_REQUEST_DOC_ROLE_QUAL + "[" + j + "].";
            success &= validateQualification(typeInfo, requestRoleQualification, fieldKeyPrefix);
        }
    }
    return super.isDocumentAttributesValid(document, validateRequired) && success;
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) SecurityRequestRoleQualificationDetail(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualificationDetail) SecurityRequestRoleQualification(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Example 3 with KimType

use of org.kuali.kfs.kim.impl.type.KimType in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentServiceImpl method buildRoleQualificationLine.

public SecurityRequestRoleQualification buildRoleQualificationLine(SecurityRequestRole requestRole, Map<String, String> qualification) {
    SecurityRequestRoleQualification requestQualification = new SecurityRequestRoleQualification();
    requestQualification.setDocumentNumber(requestRole.getDocumentNumber());
    requestQualification.setRoleRequestId(requestRole.getRoleRequestId());
    KimType typeInfo = KSRUtil.getTypeInfoForRoleRequest(requestRole);
    List<KimTypeAttribute> typeAttributes = KSRUtil.getTypeAttributesForRoleRequest(requestRole);
    for (KimTypeAttribute attributeInfo : typeAttributes) {
        SecurityRequestRoleQualificationDetail requestQualificationDetail = new SecurityRequestRoleQualificationDetail();
        requestQualificationDetail.setDocumentNumber(requestRole.getDocumentNumber());
        requestQualificationDetail.setRoleRequestId(requestRole.getRoleRequestId());
        requestQualificationDetail.setQualificationId(requestRole.getNextQualificationId());
        requestQualificationDetail.setAttributeId(attributeInfo.getKimAttribute().getId());
        requestQualificationDetail.setRoleTypeId(typeInfo.getId());
        if ((qualification != null) && qualification.containsKey(attributeInfo.getKimAttribute().getAttributeName())) {
            requestQualificationDetail.setAttributeValue(qualification.get(attributeInfo.getKimAttribute().getAttributeName()));
        }
        requestQualification.getRoleQualificationDetails().add(requestQualificationDetail);
    }
    requestQualification.setQualificationId(requestRole.getNextQualificationId());
    requestRole.setNextQualificationId(requestRole.getNextQualificationId() + 1);
    return requestQualification;
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) SecurityRequestRoleQualificationDetail(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualificationDetail) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) SecurityRequestRoleQualification(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification)

Example 4 with KimType

use of org.kuali.kfs.kim.impl.type.KimType in project cu-kfs by CU-CommunityApps.

the class KSRUtil method getTypeAttributesForRoleRequest.

@SuppressWarnings("unchecked")
public static List<KimTypeAttribute> getTypeAttributesForRoleRequest(SecurityRequestRole requestRole) {
    List<KimTypeAttribute> typeAttributes = new ArrayList<KimTypeAttribute>();
    KimType typeInfo = getTypeInfoForRoleRequest(requestRole);
    if (requestRole.isQualifiedRole()) {
        typeAttributes.addAll(typeInfo.getAttributeDefinitions());
        List<String> typeSort = new ArrayList<String>();
        typeSort.add("sortCode");
        Collections.<KimTypeAttribute>sort(typeAttributes, new BeanPropertyComparator(typeSort));
    }
    return typeAttributes;
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) BeanPropertyComparator(org.kuali.kfs.krad.util.BeanPropertyComparator) ArrayList(java.util.ArrayList)

Example 5 with KimType

use of org.kuali.kfs.kim.impl.type.KimType in project cu-kfs by CU-CommunityApps.

the class OrgReviewRoleServiceImpl method getAttributeDefinition.

protected KimAttribute getAttributeDefinition(String kimTypeId, String attributeName) {
    // attempt to pull from cache
    Map<String, KimAttribute> typeAttributes = ATTRIBUTE_CACHE.get(kimTypeId);
    // if type has not been loaded, init
    if (typeAttributes == null) {
        KimType kimType = KimApiServiceLocator.getKimTypeInfoService().getKimType(kimTypeId);
        if (kimType != null) {
            List<KimTypeAttribute> attributes = kimType.getAttributeDefinitions();
            typeAttributes = new HashMap<>();
            if (attributes != null) {
                // build the map and put it into the cache
                for (KimTypeAttribute att : attributes) {
                    typeAttributes.put(att.getKimAttribute().getAttributeName(), att.getKimAttribute());
                }
            }
            synchronized (ATTRIBUTE_CACHE) {
                ATTRIBUTE_CACHE.put(kimTypeId, typeAttributes);
            }
        }
    }
    // now, see if the attribute is in there
    if (typeAttributes != null) {
        return typeAttributes.get(attributeName);
    }
    return null;
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) KimAttribute(org.kuali.kfs.kim.impl.common.attribute.KimAttribute)

Aggregations

KimType (org.kuali.kfs.kim.impl.type.KimType)13 KimTypeAttribute (org.kuali.kfs.kim.impl.type.KimTypeAttribute)7 ArrayList (java.util.ArrayList)3 SecurityRequestRoleQualification (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification)2 SecurityRequestRoleQualificationDetail (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualificationDetail)2 HashMap (java.util.HashMap)2 RoleTypeService (org.kuali.kfs.kim.framework.role.RoleTypeService)2 KimTypeService (org.kuali.kfs.kim.framework.type.KimTypeService)2 KimAttribute (org.kuali.kfs.kim.impl.common.attribute.KimAttribute)2 DelegateType (org.kuali.kfs.kim.impl.common.delegate.DelegateType)2 SecurityProvisioning (edu.cornell.kfs.ksr.businessobject.SecurityProvisioning)1 SecurityProvisioningGroup (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup)1 SecurityRequestRole (edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)1 SecurityRequestDocument (edu.cornell.kfs.ksr.document.SecurityRequestDocument)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1