use of org.kuali.kfs.kns.web.ui.ResultRow in project cu-kfs by CU-CommunityApps.
the class BalanceInquiryLookupAction method selectAll.
/**
* @see org.kuali.rice.kns.web.struts.action.KualiMultipleValueLookupAction#selectAll(org.kuali.rice.kns.web.struts.form.MultipleValueLookupForm,
* int)
* <p>
* KRAD Conversion: Lookupable performs customization of the results.
* <p>
* Fields are in data dictionary for bo Balance.
*/
@Override
protected List<ResultRow> selectAll(MultipleValueLookupForm multipleValueLookupForm, int maxRowsPerPage) {
List<ResultRow> resultTable = null;
try {
LookupResultsService lookupResultsService = SpringContext.getBean(LookupResultsService.class);
String lookupResultsSequenceNumber = multipleValueLookupForm.getLookupResultsSequenceNumber();
resultTable = lookupResultsService.retrieveResultsTable(lookupResultsSequenceNumber, GlobalVariables.getUserSession().getPerson().getPrincipalId());
} catch (Exception e) {
LOG.error("error occured trying to export multiple lookup results", e);
throw new RuntimeException("error occured trying to export multiple lookup results");
}
Map<String, String> selectedObjectIds = this.getSelectedObjectIds(multipleValueLookupForm, resultTable);
multipleValueLookupForm.jumpToPage(multipleValueLookupForm.getViewedPageNumber(), resultTable.size(), maxRowsPerPage);
multipleValueLookupForm.setColumnToSortIndex(Integer.parseInt(multipleValueLookupForm.getPreviouslySortedColumnIndex()));
multipleValueLookupForm.setCompositeObjectIdMap(selectedObjectIds);
return resultTable;
}
use of org.kuali.kfs.kns.web.ui.ResultRow 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;
}
use of org.kuali.kfs.kns.web.ui.ResultRow in project cu-kfs by CU-CommunityApps.
the class BalanceInquiryLookupAction method search.
/**
* search - sets the values of the data entered on the form on the jsp into a map and then searches for the results.
* <p>
* KRAD Conversion: Lookupable performs customization of the results if
* balance inquiry. The result rows are added to a collection
* based on field's actual size if truncated is > 7.
* <p>
* Fields are in data dictionary for bo Balance.
*/
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
BalanceInquiryLookupForm lookupForm = (BalanceInquiryLookupForm) form;
Lookupable lookupable = lookupForm.getLookupable();
if (lookupable == null) {
LOG.error("Lookupable is null.");
throw new RuntimeException("Lookupable is null.");
}
lookupable.validateSearchParameters(lookupForm.getFields());
if (GlobalVariables.getMessageMap().getErrorCount() > 0) {
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
List<ResultRow> resultTable = new ArrayList<ResultRow>();
boolean bounded = true;
Collection displayList = performMultipleValueLookup(lookupForm, resultTable, getMaxRowsPerPage(lookupForm), bounded);
CollectionIncomplete incompleteDisplayList = (CollectionIncomplete) displayList;
Long totalSize = incompleteDisplayList.getActualSizeIfTruncated();
if (lookupable.isSearchUsingOnlyPrimaryKeyValues()) {
lookupForm.setSearchUsingOnlyPrimaryKeyValues(true);
lookupForm.setPrimaryKeyFieldLabels(lookupable.getPrimaryKeyFieldLabels());
} else {
lookupForm.setSearchUsingOnlyPrimaryKeyValues(false);
lookupForm.setPrimaryKeyFieldLabels(KFSConstants.EMPTY_STRING);
}
// TODO: use inheritance instead of this if statement
if (lookupable.getLookupableHelperService() instanceof AccountBalanceByConsolidationLookupableHelperServiceImpl) {
Object[] resultTableAsArray = resultTable.toArray();
Collection totalsTable = new ArrayList();
int arrayIndex = 0;
try {
for (int listIndex = 0; listIndex < incompleteDisplayList.size(); listIndex++) {
AccountBalance balance = (AccountBalance) incompleteDisplayList.get(listIndex);
boolean ok = ObjectHelper.isOneOf(balance.getTitle(), getTotalTitles());
if (ok) {
if (totalSize > 7) {
totalsTable.add(resultTableAsArray[arrayIndex]);
}
resultTable.remove(resultTableAsArray[arrayIndex]);
incompleteDisplayList.remove(balance);
}
arrayIndex++;
}
request.setAttribute(TOTALS_TABLE_KEY, totalsTable);
GlobalVariables.getUserSession().addObject(TOTALS_TABLE_KEY, totalsTable);
} catch (NumberFormatException e) {
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, KFSKeyConstants.ERROR_CUSTOM, new String[] { "Fiscal Year must be a four-digit number" });
} catch (Exception e) {
GlobalVariables.getMessageMap().putError(KFSConstants.DOCUMENT_ERRORS, KFSKeyConstants.ERROR_CUSTOM, new String[] { "Please report the server error." });
LOG.error("Application Errors", e);
}
}
request.setAttribute(KFSConstants.REQUEST_SEARCH_RESULTS_SIZE, totalSize);
request.setAttribute(KFSConstants.REQUEST_SEARCH_RESULTS, resultTable);
lookupForm.setResultsActualSize((int) totalSize.longValue());
lookupForm.setResultsLimitedSize(resultTable.size());
if (lookupForm.isSegmented()) {
LOG.debug("I'm segmented");
request.setAttribute(GeneralLedgerConstants.LookupableBeanKeys.SEGMENTED_LOOKUP_FLAG_NAME, Boolean.TRUE);
}
if (request.getParameter(KFSConstants.SEARCH_LIST_REQUEST_KEY) != null) {
GlobalVariables.getUserSession().removeObject(request.getParameter(KFSConstants.SEARCH_LIST_REQUEST_KEY));
request.setAttribute(KFSConstants.SEARCH_LIST_REQUEST_KEY, GlobalVariables.getUserSession().addObjectWithGeneratedKey(resultTable));
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Aggregations