use of org.kuali.kfs.krad.datadictionary.DataDictionaryEntry in project cu-kfs by CU-CommunityApps.
the class BatchFeedHelperServiceImpl method performForceUppercase.
/**
* @see com.rsmart.kuali.kfs.sys.batch.service.BatchFeedHelperService#performForceUppercase(java.lang.String, java.lang.Object)
*/
public void performForceUppercase(String entryName, Object businessObject) {
DataDictionary dataDictionary = dataDictionaryService.getDataDictionary();
DataDictionaryEntry entry = dataDictionary.getDictionaryObjectEntry(entryName);
if (entry == null) {
return;
}
List<AttributeDefinition> attributes = ((DataDictionaryEntryBase) entry).getAttributes();
for (AttributeDefinition attribute : attributes) {
try {
if (!attribute.getForceUppercase() || !PropertyUtils.isWriteable(businessObject, attribute.getName())) {
continue;
}
Object currentValue = ObjectUtils.getPropertyValue(businessObject, attribute.getName());
if (currentValue != null && String.class.isAssignableFrom(currentValue.getClass())) {
try {
ObjectUtils.setObjectProperty(businessObject, attribute.getName(), currentValue.toString().toUpperCase());
} catch (Exception e) {
LOG.error("cannot uppercase property " + attribute.getName() + " in bo class " + entryName, e);
throw new RuntimeException("cannot uppercase property " + attribute.getName() + " in bo class " + entryName, e);
}
}
} catch (Exception e) {
LOG.warn("cannot uppercase property: " + attribute.getName() + "; " + e.getMessage());
continue;
}
}
}
Aggregations