use of org.kuali.kfs.kim.impl.common.attribute.KimAttribute 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;
}
use of org.kuali.kfs.kim.impl.common.attribute.KimAttribute in project cu-kfs by CU-CommunityApps.
the class AttributeValidationHelper method getAttributeDefinitionByName.
protected KimAttribute getAttributeDefinitionByName(String attributeName) {
CacheManager cm = CoreImplServiceLocator.getCacheManagerRegistry().getCacheManagerByCacheName(KimAttribute.CACHE_NAME);
Cache cache = cm.getCache(KimAttribute.CACHE_NAME);
// CU Customization (KFSPTS-23531): Build a more specific cache key
String cacheKey = MessageFormat.format(ATTRIBUTE_BY_NAME_CACHE_KEY_PATTERN, attributeName);
ValueWrapper valueWrapper = cache.get(cacheKey);
if (valueWrapper != null) {
return (KimAttribute) valueWrapper.get();
}
Map<String, String> criteria = new HashMap<>();
criteria.put(KRADPropertyConstants.ATTRIBUTE_NAME, attributeName);
List<KimAttribute> attributeImpls = (List<KimAttribute>) getBusinessObjectService().findMatching(KimAttribute.class, criteria);
KimAttribute attribute = null;
if (!attributeImpls.isEmpty()) {
attribute = attributeImpls.get(0);
}
cache.put(cacheKey, attribute);
return attribute;
}
use of org.kuali.kfs.kim.impl.common.attribute.KimAttribute in project cu-kfs by CU-CommunityApps.
the class AttributeValidationHelper method convertQualifiersToAttrIdxMap.
public Map<String, String> convertQualifiersToAttrIdxMap(List<? extends KimDocumentAttributeDataBusinessObjectBase> qualifiers) {
Map<String, String> m = new HashMap<>();
int i = 0;
for (KimDocumentAttributeDataBusinessObjectBase data : qualifiers) {
KimAttribute attrib = getAttributeDefinitionById(data.getKimAttrDefnId());
if (attrib != null) {
m.put(attrib.getAttributeName(), Integer.toString(i));
} else {
LOG.error("Unable to get attribute name for ID:" + data.getKimAttrDefnId());
}
i++;
}
return m;
}
use of org.kuali.kfs.kim.impl.common.attribute.KimAttribute in project cu-kfs by CU-CommunityApps.
the class AttributeValidationHelper method getAttributeDefinitionById.
protected KimAttribute getAttributeDefinitionById(String id) {
CacheManager cm = CoreImplServiceLocator.getCacheManagerRegistry().getCacheManagerByCacheName(KimAttribute.CACHE_NAME);
Cache cache = cm.getCache(KimAttribute.CACHE_NAME);
String cacheKey = "{" + KimAttribute.CACHE_NAME + "}id=" + id;
ValueWrapper valueWrapper = cache.get(cacheKey);
if (valueWrapper != null) {
return (KimAttribute) valueWrapper.get();
}
KimAttribute attribute = getBusinessObjectService().findBySinglePrimaryKey(KimAttribute.class, id);
cache.put(cacheKey, attribute);
return attribute;
}
use of org.kuali.kfs.kim.impl.common.attribute.KimAttribute in project cu-kfs by CU-CommunityApps.
the class AttributeValidationHelper method convertErrorsForMappedFields.
public List<AttributeError> convertErrorsForMappedFields(String errorPath, List<AttributeError> localErrors) {
List<AttributeError> errors = new ArrayList<>();
if (errorPath == null) {
errorPath = KFSConstants.EMPTY_STRING;
} else if (StringUtils.isNotEmpty(errorPath)) {
errorPath = errorPath + ".";
}
for (AttributeError error : localErrors) {
KimAttribute attribute = getAttributeDefinitionByName(error.getAttributeName());
String attributeDefnId = attribute == null ? "" : attribute.getId();
errors.add(AttributeError.Builder.create(errorPath + "qualifier(" + attributeDefnId + ").attrVal", error.getErrors()).build());
}
return errors;
}
Aggregations