Search in sources :

Example 1 with SegmentedBusinessObject

use of org.kuali.kfs.integration.ld.SegmentedBusinessObject in project cu-kfs by CU-CommunityApps.

the class BalanceInquiryLookupAction method getSelectedObjectIds.

/**
 * put all enties into select object map. This implmentation only deals with the money amount objects.
 *
 * @param multipleValueLookupForm the given struts form
 * @param resultTable             the given result table that holds all data being presented
 * @return the map containing all entries available for selection
 * <p>
 * KRAD Conversion: Performs customization of the results. Prepares
 * <p>
 * There is no use of data dictionary for fields.
 */
private Map<String, String> getSelectedObjectIds(MultipleValueLookupForm multipleValueLookupForm, List<ResultRow> resultTable) {
    String businessObjectClassName = multipleValueLookupForm.getBusinessObjectClassName();
    SegmentedBusinessObject segmentedBusinessObject;
    try {
        segmentedBusinessObject = (SegmentedBusinessObject) Class.forName(multipleValueLookupForm.getBusinessObjectClassName()).newInstance();
    } catch (Exception e) {
        throw new RuntimeException("Fail to create an object of " + businessObjectClassName + e);
    }
    Map<String, String> selectedObjectIds = new HashMap<String, String>();
    Collection<String> segmentedPropertyNames = segmentedBusinessObject.getSegmentedPropertyNames();
    for (ResultRow row : resultTable) {
        for (Column column : row.getColumns()) {
            String propertyName = column.getPropertyName();
            if (segmentedPropertyNames.contains(propertyName)) {
                String propertyValue = StringUtils.replace(column.getPropertyValue(), ",", "");
                // If there is a negative value, we need to convert it from (##.##) to -##.##
                if (StringUtils.contains(propertyValue, "(")) {
                    propertyValue = StringUtils.replace(propertyValue, "(", "-");
                    propertyValue = StringUtils.replace(propertyValue, ")", "");
                }
                KualiDecimal amount = new KualiDecimal(propertyValue);
                if (amount.isNonZero()) {
                    String objectId = row.getObjectId() + "." + propertyName + "." + KRADUtils.convertDecimalIntoInteger(amount);
                    selectedObjectIds.put(objectId, objectId);
                }
            }
        }
    }
    return selectedObjectIds;
}
Also used : ResultRow(org.kuali.kfs.kns.web.ui.ResultRow) HashMap(java.util.HashMap) Column(org.kuali.kfs.kns.web.ui.Column) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) SegmentedBusinessObject(org.kuali.kfs.integration.ld.SegmentedBusinessObject)

Aggregations

HashMap (java.util.HashMap)1 SegmentedBusinessObject (org.kuali.kfs.integration.ld.SegmentedBusinessObject)1 Column (org.kuali.kfs.kns.web.ui.Column)1 ResultRow (org.kuali.kfs.kns.web.ui.ResultRow)1 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)1