use of org.kuali.kfs.krad.lookup.CollectionIncomplete in project cu-kfs by CU-CommunityApps.
the class CurrentFundsLookupableHelperServiceImpl method getSearchResults.
/**
* Gets a list with the fields that will be displayed on page
*
* @param fieldValues list of fields that are used as a key to filter out data
* @see org.kuali.kfs.kns.lookup.Lookupable#getSearchResults(java.util.Map)
*/
@Override
public List getSearchResults(Map fieldValues) {
LOG.info("getSearchResults() - Entry");
boolean unbounded = false;
Long actualCountIfTruncated = new Long(0);
setBackLocation((String) fieldValues.get(KFSConstants.BACK_LOCATION));
setDocFormKey((String) fieldValues.get(KFSConstants.DOC_FORM_KEY));
// get the pending entry option. This method must be prior to the get search results
String pendingEntryOption = laborInquiryOptionsService.getSelectedPendingEntryOption(fieldValues);
// get the consolidation option
boolean isConsolidated = laborInquiryOptionsService.isConsolidationSelected(fieldValues, (Collection<Row>) getRows());
String searchObjectCodeVal = (String) fieldValues.get(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
// Check for a valid labor object code for this inquiry
if (StringUtils.isNotBlank(searchObjectCodeVal)) {
Map objectCodeFieldValues = new HashMap();
objectCodeFieldValues.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, fieldValues.get(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR));
objectCodeFieldValues.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, fieldValues.get(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE));
objectCodeFieldValues.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, searchObjectCodeVal);
LaborLedgerObject foundObjectCode = (LaborLedgerObject) businessObjectService.findByPrimaryKey(LaborObject.class, objectCodeFieldValues);
if (foundObjectCode == null) {
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, LaborKeyConstants.ERROR_INVALID_LABOR_OBJECT_CODE, "2");
return new CollectionIncomplete(new ArrayList(), actualCountIfTruncated);
}
}
// Parse the map and call the DAO to process the inquiry
Collection<AccountStatusCurrentFunds> searchResultsCollection = buildCurrentFundsCollection(toList(laborDao.getCurrentFunds(fieldValues, isConsolidated)), isConsolidated, pendingEntryOption);
// update search results according to the selected pending entry option
laborInquiryOptionsService.updateCurrentFundsByPendingLedgerEntry(searchResultsCollection, fieldValues, pendingEntryOption, isConsolidated);
// gets the July1st budget amount column.
Collection<July1PositionFunding> july1PositionFundings = laborDao.getJuly1(fieldValues);
this.updateJuly1BalanceAmount(searchResultsCollection, july1PositionFundings, isConsolidated);
// sort list if default sort column given
List searchResults = (List) searchResultsCollection;
List defaultSortColumns = getDefaultSortColumns();
if (defaultSortColumns.size() > 0) {
Collections.sort(searchResults, new BeanPropertyComparator(defaultSortColumns, true));
}
return new CollectionIncomplete(searchResults, actualCountIfTruncated);
}
use of org.kuali.kfs.krad.lookup.CollectionIncomplete 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);
}
use of org.kuali.kfs.krad.lookup.CollectionIncomplete in project cu-kfs by CU-CommunityApps.
the class CuVendorDaoOjb method getSearchResults.
public List<BusinessObject> getSearchResults(Map<String, String> fieldValues) {
List results = new ArrayList();
Map<String, VendorDetail> nonDupResults = new HashMap<String, VendorDetail>();
RemovalAwareCollection rac = new RemovalAwareCollection();
Criteria header = new Criteria();
Criteria detail = new Criteria();
Criteria taxNum = new Criteria();
Criteria name = new Criteria();
Criteria alias = new Criteria();
Criteria active = new Criteria();
Criteria type = new Criteria();
Criteria state = new Criteria();
Criteria commodityCode = new Criteria();
Criteria supplierDiversity = new Criteria();
Criteria vendorOwnershipCode = new Criteria();
Criteria vendorSupplierDiversityExpirationDate = new Criteria();
String headerVal = fieldValues.get(VendorPropertyConstants.VENDOR_HEADER_GENERATED_ID);
String detailVal = fieldValues.get(VendorPropertyConstants.VENDOR_DETAIL_ASSIGNED_ID);
String taxNumVal = fieldValues.get(VendorPropertyConstants.VENDOR_TAX_NUMBER);
String activeVal = fieldValues.get(ACTIVE_INDICATOR);
String nameVal = fieldValues.get(VendorPropertyConstants.VENDOR_NAME);
String typeVal = fieldValues.get(VendorPropertyConstants.VENDOR_TYPE_CODE);
String stateVal = fieldValues.get(VendorPropertyConstants.VENDOR_ADDRESS + "." + VendorPropertyConstants.VENDOR_ADDRESS_STATE);
String supplierDiversityVal = fieldValues.get(VendorPropertyConstants.VENDOR_HEADER_PREFIX + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITY_CODE);
String vendorOwnershipCodeVal = fieldValues.get(VendorPropertyConstants.VENDOR_OWNERSHIP_CODE);
String commodityCodeVal = fieldValues.get(VendorPropertyConstants.VENDOR_COMMODITIES_CODE_PURCHASING_COMMODITY_CODE);
String vendorSupplierDiversityExpirationDateVal = fieldValues.get(VendorPropertyConstants.VENDOR_HEADER_PREFIX + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION);
// KFSPTS-1891
String defaultPaymentMethod = fieldValues.get("extension.defaultB2BPaymentMethodCode");
if (StringUtils.isNotBlank(headerVal)) {
//
header.addEqualTo("vendorHeaderGeneratedIdentifier", headerVal);
}
if (StringUtils.isNotBlank(detailVal)) {
detail.addEqualTo("vendorDetailAssignedIdentifier", detailVal);
header.addAndCriteria(detail);
}
if (StringUtils.isNotBlank(taxNumVal)) {
// THIS IS ENCRYPTED IN THE DB, COMES OFF HDR TABLE
taxNum.addEqualTo("vendorHeader.vendorTaxNumber", taxNumVal);
header.addAndCriteria(taxNum);
}
if (StringUtils.isNotBlank(activeVal)) {
// VNDR_DTL
active.addEqualTo(ACTIVE_INDICATOR, activeVal);
header.addAndCriteria(active);
}
if (StringUtils.isNotBlank(nameVal) && nameVal.contains("*")) {
String upperVendorName = getDbPlatform().getUpperCaseFunction() + "( vendorName )";
String upperNameVal = nameVal.toUpperCase();
name.addLike(upperVendorName, upperNameVal);
alias.addLike(getDbPlatform().getUpperCaseFunction() + "( " + VendorPropertyConstants.VENDOR_ALIAS_NAME_FULL_PATH + " )", upperNameVal);
alias.addEqualTo(VendorPropertyConstants.VENDOR_ALIAS_ACTIVE, "Y");
Criteria t = new Criteria();
t.addOrCriteria(name);
t.addOrCriteria(alias);
header.addAndCriteria(t);
}
if (StringUtils.isNotBlank(nameVal) && !nameVal.contains("*")) {
name.addEqualTo(VendorPropertyConstants.VENDOR_NAME, nameVal);
alias.addEqualTo(VendorPropertyConstants.VENDOR_ALIAS_NAME_FULL_PATH, nameVal);
alias.addEqualTo(VendorPropertyConstants.VENDOR_ALIAS_ACTIVE, "Y");
Criteria t = new Criteria();
t.addOrCriteria(name);
t.addOrCriteria(alias);
header.addAndCriteria(t);
}
if (StringUtils.isNotBlank(typeVal)) {
// VNDR_HDR
type.addEqualTo(VendorPropertyConstants.VENDOR_TYPE_CODE, typeVal);
header.addAndCriteria(type);
}
if (StringUtils.isNotBlank(stateVal)) {
// THIS COMES OUT OF PUR_VND_ADDR_T
state.addEqualTo(VendorPropertyConstants.VENDOR_ADDRESS_STATE_CODE, stateVal);
header.addAndCriteria(state);
}
if (StringUtils.isNotBlank(commodityCodeVal)) {
// THIS COMES OUT OF PUR_VNDR_COMM_T
commodityCode.addEqualTo(VendorPropertyConstants.VENDOR_COMMODITIES_CODE_PURCHASING_COMMODITY_CODE, commodityCodeVal);
header.addAndCriteria(commodityCode);
}
if (StringUtils.isNotBlank(supplierDiversityVal)) {
// THIS COMES OUT OF PUR_VNDR_SUPP_DVRST_T
supplierDiversity.addEqualTo(CUVendorPropertyConstants.VENDOR_HEADER_SUPPLIER_DIVERSITY_CODE, supplierDiversityVal);
header.addAndCriteria(supplierDiversity);
}
if (StringUtils.isNotBlank(vendorOwnershipCodeVal)) {
// VNDR_HDR
vendorOwnershipCode.addEqualTo(VendorPropertyConstants.VENDOR_OWNERSHIP_CODE, vendorOwnershipCodeVal);
header.addAndCriteria(vendorOwnershipCode);
}
if (StringUtils.isNotBlank(vendorSupplierDiversityExpirationDateVal)) {
try {
Date date = new java.sql.Date(new SimpleDateFormat("MM/dd/yyyy").parse(vendorSupplierDiversityExpirationDateVal).getTime());
vendorSupplierDiversityExpirationDate.addGreaterOrEqualThan(VendorPropertyConstants.VENDOR_HEADER_PREFIX + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION, date);
header.addAndCriteria(vendorSupplierDiversityExpirationDate);
} catch (ParseException e) {
LOG.error("unable to parse date");
}
}
// KFSPTS-1891
if (StringUtils.isNotBlank(defaultPaymentMethod)) {
//
header.addEqualTo("extension.defaultB2BPaymentMethodCode", defaultPaymentMethod);
}
Long val = new Long(getPersistenceBrokerTemplate().getCount(QueryFactory.newQuery(VendorDetail.class, header)));
Integer searchResultsLimit = LookupUtils.getSearchResultsLimit(VendorDetail.class);
if (val.intValue() > searchResultsLimit.intValue()) {
LookupUtils.applySearchResultsLimit(VendorDetail.class, header, getDbPlatform());
}
QueryByCriteria qbc = new QueryByCriteria(VendorDetail.class, header);
rac = (RemovalAwareCollection) getPersistenceBrokerTemplate().getCollectionByQuery(qbc);
Criteria children = new Criteria();
Iterator it = rac.iterator();
while (it.hasNext()) {
VendorDetail vd = (VendorDetail) it.next();
String key = vd.getVendorNumber();
if (!nonDupResults.containsKey(key)) {
Criteria c = new Criteria();
c.addEqualTo("vendorHeaderGeneratedIdentifier", vd.getVendorHeaderGeneratedIdentifier());
children.addOrCriteria(c);
nonDupResults.put(key, vd);
results.add(vd);
}
}
// THE CHILDREN OF ANY MATCHING VENDOR DETAIL OBJECT MUST BE FOUND AND ADDED TO THE RESULTS LIST
if (nonDupResults.size() > 0) {
qbc = new QueryByCriteria(VendorDetail.class, children);
rac = (RemovalAwareCollection) getPersistenceBrokerTemplate().getCollectionByQuery(qbc);
it = rac.iterator();
while (it.hasNext()) {
VendorDetail vd = (VendorDetail) it.next();
String key = vd.getVendorNumber();
if (!nonDupResults.containsKey(key)) {
nonDupResults.put(key, vd);
results.add(vd);
}
}
}
CollectionIncomplete resultsTruncated = new CollectionIncomplete((Collection) results, new Long(results.size()));
if (val.intValue() > searchResultsLimit.intValue()) {
resultsTruncated.setActualSizeIfTruncated(new Long(-1));
}
return resultsTruncated;
}
use of org.kuali.kfs.krad.lookup.CollectionIncomplete in project cu-kfs by CU-CommunityApps.
the class CuAssetLookupableHelperServiceImplTest method testGetSearchResultsHelper.
public void testGetSearchResultsHelper() {
try {
// argument types for getSearchResultsHelper
Class[] args_getSearchResultsHelper = new Class[2];
args_getSearchResultsHelper[0] = Map.class;
args_getSearchResultsHelper[1] = boolean.class;
// values to use as method parameters for getSearchResultsHelper
Object[] vals_getSearchResultsHelper = new Object[2];
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("createDate", ">=01/01/2013");
Boolean unbounded = new Boolean(false);
Boolean bounded = new Boolean(true);
vals_getSearchResultsHelper[0] = hm;
vals_getSearchResultsHelper[1] = bounded;
Method m_getSearchResultsHelper = cuAssetLookupableHelperServiceImplClass.getDeclaredMethod("getSearchResultsHelper", args_getSearchResultsHelper);
Object result = m_getSearchResultsHelper.invoke(cuAssetLookupableHelperServiceImpl, vals_getSearchResultsHelper);
CollectionIncomplete resultArray = (CollectionIncomplete) result;
assertTrue("size of array should be greater than zero", 0 != resultArray.size());
LOG.info("Array size (bounded = true): " + resultArray.size());
vals_getSearchResultsHelper[1] = unbounded;
result = m_getSearchResultsHelper.invoke(cuAssetLookupableHelperServiceImpl, vals_getSearchResultsHelper);
resultArray = (CollectionIncomplete) result;
LOG.info("Array size (bounded = false): " + resultArray.size());
assertTrue("size of array should be greater than zero", 0 != resultArray.size());
hm.clear();
hm.put("createDate", ">=01/01/2014");
vals_getSearchResultsHelper[0] = hm;
vals_getSearchResultsHelper[1] = unbounded;
Object unfilteredResult = m_getSearchResultsHelper.invoke(cuAssetLookupableHelperServiceImpl, vals_getSearchResultsHelper);
CollectionIncomplete unfilteredArray = (CollectionIncomplete) unfilteredResult;
// using this value in the search criteria results in the excludeBlankOffCampusLocations method being invoked
hm.put("assetLocations.assetLocationTypeCode", "O");
vals_getSearchResultsHelper[0] = hm;
vals_getSearchResultsHelper[1] = unbounded;
Object filteredResult = m_getSearchResultsHelper.invoke(cuAssetLookupableHelperServiceImpl, vals_getSearchResultsHelper);
ArrayList filteredArray = (ArrayList) filteredResult;
LOG.info("unfiltered array size: " + unfilteredArray.size());
LOG.info("filtered array size: " + filteredArray.size());
assertTrue("Array of results excluding blank off campus locations is smaller than the array not excluding them", filteredArray.size() < unfilteredArray.size());
} catch (NoSuchMethodException nmse) {
nmse.printStackTrace();
} catch (InvocationTargetException ite) {
ite.printStackTrace();
} catch (IllegalAccessException iae) {
iae.printStackTrace();
}
}
use of org.kuali.kfs.krad.lookup.CollectionIncomplete in project cu-kfs by CU-CommunityApps.
the class CuACHPayeeLookupableHelperServiceImpl method getSearchResults.
/**
* Overridden to only search for employee or entity payees when principal name is specified.
*
* @see org.kuali.kfs.pdp.businessobject.lookup.ACHPayeeLookupableHelperServiceImpl#getSearchResults(java.util.Map)
*/
@SuppressWarnings({ "deprecation", "rawtypes", "unchecked" })
@Override
public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
/*
* This is mostly a copy of the superclass's method, but has been tweaked to account for principal name
* and to conform to our line formatting standards.
*/
List<DisbursementPayee> searchResults = new ArrayList<DisbursementPayee>();
String payeeTypeCode = fieldValues.get(KFSPropertyConstants.PAYEE_TYPE_CODE);
if (StringUtils.isBlank(payeeTypeCode)) {
GlobalVariables.getMessageMap().putInfo(KFSPropertyConstants.PAYEE_TYPE_CODE, PdpKeyConstants.MESSAGE_PDP_ACH_PAYEE_LOOKUP_NO_PAYEE_TYPE);
}
// CU Customization: Updated "else if" to restrict results to people if principal name is given.
if (StringUtils.isNotBlank(fieldValues.get(KFSPropertyConstants.VENDOR_NUMBER)) || StringUtils.isNotBlank(fieldValues.get(KFSPropertyConstants.VENDOR_NAME)) || (StringUtils.isNotBlank(payeeTypeCode) && PdpConstants.PayeeIdTypeCodes.VENDOR_ID.equals(payeeTypeCode))) {
searchResults.addAll(this.getVendorsAsPayees(fieldValues));
} else if (StringUtils.isNotBlank(fieldValues.get(KIMPropertyConstants.Person.EMPLOYEE_ID)) || StringUtils.isNotBlank(fieldValues.get(KIMPropertyConstants.Person.ENTITY_ID)) || StringUtils.isNotBlank(fieldValues.get(KIMPropertyConstants.Person.PRINCIPAL_NAME)) || (StringUtils.isNotBlank(payeeTypeCode) && (PdpConstants.PayeeIdTypeCodes.EMPLOYEE.equals(payeeTypeCode) || PdpConstants.PayeeIdTypeCodes.ENTITY.equals(payeeTypeCode)))) {
searchResults.addAll(this.getPersonAsPayees(fieldValues));
} else {
searchResults.addAll(this.getVendorsAsPayees(fieldValues));
searchResults.addAll(this.getPersonAsPayees(fieldValues));
}
CollectionIncomplete results = new CollectionIncomplete(searchResults, Long.valueOf(searchResults.size()));
// sort list if default sort column given
List<String> defaultSortColumns = getDefaultSortColumns();
if (defaultSortColumns.size() > 0) {
Collections.sort(results, new BeanPropertyComparator(getDefaultSortColumns(), true));
}
return results;
}
Aggregations