Search in sources :

Example 1 with KimTypeAttribute

use of org.kuali.kfs.kim.impl.type.KimTypeAttribute 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)

Example 2 with KimTypeAttribute

use of org.kuali.kfs.kim.impl.type.KimTypeAttribute 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 3 with KimTypeAttribute

use of org.kuali.kfs.kim.impl.type.KimTypeAttribute 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 4 with KimTypeAttribute

use of org.kuali.kfs.kim.impl.type.KimTypeAttribute 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 5 with KimTypeAttribute

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

the class SecurityRequestRoleQualificationDetail method getGenericAttributeEntry.

protected Map<String, Object> getGenericAttributeEntry() {
    Map<String, Object> attributeEntry = new HashMap<String, Object>();
    KimTypeAttribute attributeInfo = getKimType().getAttributeDefinitionById(attributeId);
    Map<String, Object> controlMap = new StringMap();
    TextControlDefinition textControl = new TextControlDefinition();
    textControl.setSize(15);
    controlMap.put("text", "true");
    controlMap.put("size", textControl.getSize().toString());
    controlMap.put("datePicker", Boolean.valueOf(textControl.isDatePicker()).toString());
    controlMap.put("ranged", Boolean.valueOf(textControl.isRanged()).toString());
    attributeEntry.put("control", controlMap);
    attributeEntry.put("name", attributeInfo.getKimAttribute().getAttributeName());
    String label = attributeInfo.getKimAttribute().getAttributeLabel();
    if (StringUtils.isBlank(label)) {
        label = attributeInfo.getKimAttribute().getAttributeName();
    }
    attributeEntry.put("label", label);
    attributeEntry.put("shortLabel", label);
    return attributeEntry;
}
Also used : TextControlDefinition(org.kuali.kfs.kns.datadictionary.control.TextControlDefinition) StringMap(org.kuali.kfs.krad.datadictionary.exporter.StringMap) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) HashMap(java.util.HashMap)

Aggregations

KimTypeAttribute (org.kuali.kfs.kim.impl.type.KimTypeAttribute)10 KimType (org.kuali.kfs.kim.impl.type.KimType)7 ArrayList (java.util.ArrayList)4 SecurityRequestRoleQualification (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 KimAttribute (org.kuali.kfs.kim.impl.common.attribute.KimAttribute)2 SecurityRequestRoleQualificationDetail (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualificationDetail)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1 CollectionUtils (org.apache.commons.collections4.CollectionUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 CriteriaLookupService (org.kuali.kfs.core.api.criteria.CriteriaLookupService)1 DelegationType (org.kuali.kfs.core.api.delegation.DelegationType)1