Search in sources :

Example 1 with DataDictionaryEntryBase

use of org.kuali.kfs.krad.datadictionary.DataDictionaryEntryBase 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;
        }
    }
}
Also used : DataDictionaryEntry(org.kuali.kfs.krad.datadictionary.DataDictionaryEntry) DataDictionaryEntryBase(org.kuali.kfs.krad.datadictionary.DataDictionaryEntryBase) AttributeDefinition(org.kuali.kfs.krad.datadictionary.AttributeDefinition) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) DataDictionary(org.kuali.kfs.krad.datadictionary.DataDictionary) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ParseException(org.kuali.kfs.sys.exception.ParseException)

Example 2 with DataDictionaryEntryBase

use of org.kuali.kfs.krad.datadictionary.DataDictionaryEntryBase in project cu-kfs by CU-CommunityApps.

the class WebUtils method getPartiallyMaskedValue.

public static String getPartiallyMaskedValue(String className, String fieldName, Object formObject, String propertyName) {
    String displayMaskValue = null;
    Object propertyValue = ObjectUtils.getPropertyValue(formObject, propertyName);
    DataDictionaryEntryBase entry = (DataDictionaryEntryBase) KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDictionaryObjectEntry(className);
    AttributeDefinition a = entry.getAttributeDefinition(fieldName);
    AttributeSecurity attributeSecurity = a.getAttributeSecurity();
    if (attributeSecurity != null && attributeSecurity.isPartialMask()) {
        MaskFormatter partialMaskFormatter = attributeSecurity.getPartialMaskFormatter();
        displayMaskValue = partialMaskFormatter.maskValue(propertyValue);
    }
    return displayMaskValue;
}
Also used : DataDictionaryEntryBase(org.kuali.kfs.krad.datadictionary.DataDictionaryEntryBase) AttributeDefinition(org.kuali.kfs.krad.datadictionary.AttributeDefinition) MaskFormatter(org.kuali.kfs.krad.datadictionary.mask.MaskFormatter) AttributeSecurity(org.kuali.kfs.krad.datadictionary.AttributeSecurity)

Example 3 with DataDictionaryEntryBase

use of org.kuali.kfs.krad.datadictionary.DataDictionaryEntryBase in project cu-kfs by CU-CommunityApps.

the class WebUtils method getFullyMaskedValue.

public static String getFullyMaskedValue(String className, String fieldName, Object formObject, String propertyName) {
    String displayMaskValue = null;
    Object propertyValue = ObjectUtils.getPropertyValue(formObject, propertyName);
    DataDictionaryEntryBase entry = (DataDictionaryEntryBase) KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDictionaryObjectEntry(className);
    AttributeDefinition a = entry.getAttributeDefinition(fieldName);
    AttributeSecurity attributeSecurity = a.getAttributeSecurity();
    if (attributeSecurity != null && attributeSecurity.isMask()) {
        MaskFormatter maskFormatter = attributeSecurity.getMaskFormatter();
        displayMaskValue = maskFormatter.maskValue(propertyValue);
    }
    return displayMaskValue;
}
Also used : DataDictionaryEntryBase(org.kuali.kfs.krad.datadictionary.DataDictionaryEntryBase) AttributeDefinition(org.kuali.kfs.krad.datadictionary.AttributeDefinition) MaskFormatter(org.kuali.kfs.krad.datadictionary.mask.MaskFormatter) AttributeSecurity(org.kuali.kfs.krad.datadictionary.AttributeSecurity)

Aggregations

AttributeDefinition (org.kuali.kfs.krad.datadictionary.AttributeDefinition)3 DataDictionaryEntryBase (org.kuali.kfs.krad.datadictionary.DataDictionaryEntryBase)3 AttributeSecurity (org.kuali.kfs.krad.datadictionary.AttributeSecurity)2 MaskFormatter (org.kuali.kfs.krad.datadictionary.mask.MaskFormatter)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)1 DataDictionary (org.kuali.kfs.krad.datadictionary.DataDictionary)1 DataDictionaryEntry (org.kuali.kfs.krad.datadictionary.DataDictionaryEntry)1 ParseException (org.kuali.kfs.sys.exception.ParseException)1