Search in sources :

Example 6 with KimTypeAttribute

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

the class RoleServiceBase method getAttributeNameToAttributeIdMappings.

/*
     * CU Customization: Create mappings from attribute names to attribute IDs.
     */
protected Map<String, String> getAttributeNameToAttributeIdMappings(Collection<String> roleIds, Map<String, String> qualification) {
    if (CollectionUtils.isEmpty(roleIds) || qualification == null || qualification.isEmpty()) {
        return Collections.emptyMap();
    }
    KimTypeInfoService typeInfoService = getKimTypeInfoService();
    Set<String> attributeNames = qualification.keySet();
    Map<String, String> validAttributeIds = new HashMap<>();
    roleIds.stream().map(this::getRoleLite).filter(ObjectUtils::isNotNull).map(RoleLite::getKimTypeId).distinct().map(typeInfoService::getKimType).filter(ObjectUtils::isNotNull).flatMap(kimType -> kimType.getAttributeDefinitions().stream()).map(KimTypeAttribute::getKimAttribute).filter(attribute -> ObjectUtils.isNotNull(attribute) && attributeNames.contains(attribute.getAttributeName())).forEach(attribute -> validAttributeIds.put(attribute.getAttributeName(), attribute.getId()));
    for (String attributeName : attributeNames) {
        validAttributeIds.computeIfAbsent(attributeName, this::getAttributeIdByName);
    }
    return validAttributeIds;
}
Also used : KimApiServiceLocator(org.kuali.kfs.kim.api.services.KimApiServiceLocator) KimAttribute(org.kuali.kfs.kim.impl.common.attribute.KimAttribute) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) KimTypeInfoService(org.kuali.kfs.kim.api.type.KimTypeInfoService) HashMap(java.util.HashMap) DelegationType(org.kuali.kfs.core.api.delegation.DelegationType) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) DelegateType(org.kuali.kfs.kim.impl.common.delegate.DelegateType) ResponsibilityInternalService(org.kuali.kfs.kim.impl.responsibility.ResponsibilityInternalService) KimType(org.kuali.kfs.kim.impl.type.KimType) Map(java.util.Map) LookupService(org.kuali.kfs.krad.service.LookupService) GroupService(org.kuali.kfs.kim.api.group.GroupService) MemberType(org.kuali.kfs.core.api.membership.MemberType) Group(org.kuali.kfs.kim.impl.group.Group) DelegateMember(org.kuali.kfs.kim.impl.common.delegate.DelegateMember) KRADServiceLocatorWeb(org.kuali.kfs.krad.service.KRADServiceLocatorWeb) Collection(java.util.Collection) KimConstants(org.kuali.kfs.kim.api.KimConstants) KRADServiceLocator(org.kuali.kfs.krad.service.KRADServiceLocator) Set(java.util.Set) KimImplServiceLocator(org.kuali.kfs.kim.impl.services.KimImplServiceLocator) KRADPropertyConstants(org.kuali.kfs.krad.util.KRADPropertyConstants) ObjectUtils(org.kuali.kfs.krad.util.ObjectUtils) IdentityService(org.kuali.kfs.kim.api.identity.IdentityService) List(java.util.List) Logger(org.apache.logging.log4j.Logger) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) Principal(org.kuali.kfs.kim.impl.identity.principal.Principal) RoleContract(org.kuali.kfs.kim.api.role.RoleContract) RoleTypeService(org.kuali.kfs.kim.framework.role.RoleTypeService) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) CriteriaLookupService(org.kuali.kfs.core.api.criteria.CriteriaLookupService) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) HashMap(java.util.HashMap) KimTypeInfoService(org.kuali.kfs.kim.api.type.KimTypeInfoService) ObjectUtils(org.kuali.kfs.krad.util.ObjectUtils)

Example 7 with KimTypeAttribute

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

the class RoleServiceBase method getAttributeIdFromKimType.

protected String getAttributeIdFromKimType(String kimTypeId, String attributeName) {
    KimType kimType = getKimTypeInfoService().getKimType(kimTypeId);
    if (ObjectUtils.isNull(kimType)) {
        return null;
    }
    KimTypeAttribute attribute = kimType.getAttributeDefinitionByName(attributeName);
    if (ObjectUtils.isNotNull(attribute) && ObjectUtils.isNotNull(attribute.getKimAttribute())) {
        return attribute.getKimAttribute().getId();
    } else {
        return null;
    }
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute)

Example 8 with KimTypeAttribute

use of org.kuali.kfs.kim.impl.type.KimTypeAttribute 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;
}
Also used : KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) SecurityRequestRoleQualification(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 9 with KimTypeAttribute

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

the class OrgReviewRole method getAttributeSetAsQualifierList.

public List<KfsKimDocumentAttributeData> getAttributeSetAsQualifierList(Map<String, String> qualifiers) {
    KimType kimTypeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(kimTypeId);
    List<KfsKimDocumentAttributeData> attributesList = new ArrayList<>();
    KfsKimDocumentAttributeData attribData;
    if (LOG.isDebugEnabled()) {
        LOG.debug("passed qualifiers: " + StringUtils.join(qualifiers.keySet(), ", "));
    }
    for (String key : qualifiers.keySet()) {
        KimTypeAttribute attribInfo = kimTypeInfo.getAttributeDefinitionByName(key);
        if (attribInfo == null) {
            LOG.debug("attribute info for qualifier " + key + " is null");
        }
        attribData = new KfsKimDocumentAttributeData();
        attribData.setKimAttribute(attribInfo.getKimAttribute());
        attribData.setKimTypId(kimTypeInfo.getId());
        attribData.setKimAttrDefnId(attribInfo.getId());
        // attribData.setAttrDataId(attrDataId) - Not Available
        attribData.setAttrVal(qualifiers.get(key));
        attributesList.add(attribData);
    }
    return attributesList;
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) ArrayList(java.util.ArrayList)

Example 10 with KimTypeAttribute

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

the class PersonInquirableImpl method buildRowsWithQualifierFields.

private List<Row> buildRowsWithQualifierFields(String sectionId, PersonImpl person, int memberIndex) {
    List<KimTypeAttribute> attributeDefinitions;
    List<KimAttributeData> attributeDetails;
    if (StringUtils.equals(sectionId, "rolesSection")) {
        attributeDefinitions = person.getRoleMembers().get(memberIndex).getRole().getKimType().getAttributeDefinitions();
        attributeDetails = new ArrayList<>(person.getRoleMembers().get(memberIndex).getAttributeDetails());
    } else {
        attributeDefinitions = person.getDelegateMembers().get(memberIndex).getRoleMember().getRole().getKimType().getAttributeDefinitions();
        attributeDetails = new ArrayList<>(person.getDelegateMembers().get(memberIndex).getAttributeDetails());
    }
    Map<String, Field> fieldsToAdd = new LinkedHashMap<>(buildQualifierAttributeFieldMap(attributeDefinitions));
    setFieldValuesForMember(attributeDetails, fieldsToAdd);
    List<Row> qualifierRows = fieldsToAdd.values().stream().map(Row::new).collect(Collectors.toList());
    if (!fieldsToAdd.isEmpty()) {
        qualifierRows.add(0, new Row(buildSeparatorField(SUB_SECTION_LABELS.get(sectionId))));
    }
    return qualifierRows;
}
Also used : Field(org.kuali.kfs.kns.web.ui.Field) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) KimAttributeData(org.kuali.kfs.kim.impl.common.attribute.KimAttributeData) Row(org.kuali.kfs.kns.web.ui.Row) LinkedHashMap(java.util.LinkedHashMap)

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