use of org.kuali.kfs.kim.api.type.KimTypeInfoService 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;
}
Aggregations