/** * This method will remove all PO related transactions from display on GL results * * @see org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl#getSearchResults(java.util.Map) */ @Override public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) { // update status code from user input value to DB value. updateStatusCodeCriteria(fieldValues); List<? extends BusinessObject> searchResults = super.getSearchResults(fieldValues); if (searchResults == null || searchResults.isEmpty()) { return searchResults; } Integer searchResultsLimit = LookupUtils.getSearchResultsLimit(GeneralLedgerEntry.class); Long matchingResultsCount = null; List<GeneralLedgerEntry> newList = new ArrayList<GeneralLedgerEntry>(); for (BusinessObject businessObject : searchResults) { GeneralLedgerEntry entry = (GeneralLedgerEntry) businessObject; if (!CabConstants.PREQ.equals(entry.getFinancialDocumentTypeCode())) { if (!CabConstants.CM.equals(entry.getFinancialDocumentTypeCode())) { newList.add(entry); } else if (CabConstants.CM.equals(entry.getFinancialDocumentTypeCode())) { Map<String, String> cmKeys = new HashMap<String, String>(); cmKeys.put( CabPropertyConstants.PurchasingAccountsPayableDocument.DOCUMENT_NUMBER, entry.getDocumentNumber()); // check if CAB PO document exists, if not included Collection<PurchasingAccountsPayableDocument> matchingCreditMemos = businessObjectService.findMatching(PurchasingAccountsPayableDocument.class, cmKeys); if (matchingCreditMemos == null || matchingCreditMemos.isEmpty()) { newList.add(entry); } } } } matchingResultsCount = Long.valueOf(newList.size()); if (matchingResultsCount.intValue() <= searchResultsLimit.intValue()) { matchingResultsCount = new Long(0); } return new CollectionIncomplete(newList, matchingResultsCount); }
/** * @param dataObjectClass the dataobject class * @param formProperties the incoming lookup form properties * @param unbounded whether the search is unbounded * @param searchResultsLimit the searchResultsLimit; null implies use of default KNS value if set * for the class * @param <T> the data object type * @return collection of lookup results */ protected <T> Collection<T> performDataObjectServiceLookup( Class<T> dataObjectClass, Map<String, String> formProperties, boolean unbounded, boolean allPrimaryKeyValuesPresentAndNotWildcard, Integer searchResultsLimit) { if (!unbounded && searchResultsLimit == null) { // use KRAD LookupUtils.getSearchResultsLimit instead of KNS version. we have no LookupForm, // so pass null, only the class will be used // searchResultsLimit = LookupUtils.getSearchResultsLimit(example, null); searchResultsLimit = org.kuali.rice.kns.lookup.LookupUtils.getSearchResultsLimit(dataObjectClass); } QueryByCriteria.Builder query = lookupCriteriaGenerator.generateCriteria( dataObjectClass, formProperties, allPrimaryKeyValuesPresentAndNotWildcard); if (!unbounded && searchResultsLimit != null) { query.setMaxResults(searchResultsLimit); } Collection<T> results = dataObjectService.findMatching(dataObjectClass, query.build()).getResults(); return filterCurrentDataObjects(dataObjectClass, results, formProperties); }
@Override public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) { List<FunctionalFieldDescription> functionalFieldDescriptions = kfsBusinessObjectMetaDataService.findFunctionalFieldDescriptions( fieldValues.get(OLEPropertyConstants.NAMESPACE_CODE), fieldValues.get( OLEPropertyConstants .FUNCTIONAL_FIELD_DESCRIPTION_BUSINESS_OBJECT_PROPERTY_COMPONENT_LABEL), fieldValues.get( OLEPropertyConstants.FUNCTIONAL_FIELD_DESCRIPTION_BUSINESS_OBJECT_PROPERTY_LABEL), fieldValues.get(OLEPropertyConstants.FUNCTIONAL_FIELD_DESCRIPTION_DESCRIPTION), "Y"); List<BusinessObjectProperty> businessObjectProperties = kfsBusinessObjectMetaDataService.findBusinessObjectProperties( fieldValues.get(OLEPropertyConstants.NAMESPACE_CODE), fieldValues.get( OLEPropertyConstants .FUNCTIONAL_FIELD_DESCRIPTION_BUSINESS_OBJECT_PROPERTY_COMPONENT_LABEL), fieldValues.get( OLEPropertyConstants.FUNCTIONAL_FIELD_DESCRIPTION_BUSINESS_OBJECT_PROPERTY_LABEL)); Map<String, BusinessObject> matches = new HashMap<String, BusinessObject>(); for (FunctionalFieldDescription functionalFieldDescription : functionalFieldDescriptions) { if (kfsBusinessObjectMetaDataService.isMatch( functionalFieldDescription.getComponentClass(), functionalFieldDescription.getPropertyName(), fieldValues.get(OLEPropertyConstants.TABLE_NAME), fieldValues.get(OLEPropertyConstants.FIELD_NAME))) { matches.put( functionalFieldDescription.getComponentClass() + functionalFieldDescription.getPropertyName(), functionalFieldDescription); } } if (StringUtils.isBlank( fieldValues.get(OLEPropertyConstants.FUNCTIONAL_FIELD_DESCRIPTION_DESCRIPTION))) { for (BusinessObjectProperty businessObjectProperty : businessObjectProperties) { if (!matches.containsKey( businessObjectProperty.getComponentClass() + businessObjectProperty.getPropertyName()) && kfsBusinessObjectMetaDataService.isMatch( businessObjectProperty.getComponentClass(), businessObjectProperty.getPropertyName(), fieldValues.get(OLEPropertyConstants.TABLE_NAME), fieldValues.get(OLEPropertyConstants.FIELD_NAME))) { matches.put( businessObjectProperty.getComponentClass() + businessObjectProperty.getPropertyName(), businessObjectProperty); } } } Map<String, DataMappingFieldDefinition> dataMappingFieldDefinitions = new HashMap<String, DataMappingFieldDefinition>(); int searchResultsLimit = LookupUtils.getSearchResultsLimit(DataMappingFieldDefinition.class); int iterationCount = 0; for (BusinessObject businessObject : matches.values()) { if (++iterationCount <= searchResultsLimit) { if (businessObject instanceof FunctionalFieldDescription) { FunctionalFieldDescription functionalFieldDescription = (FunctionalFieldDescription) businessObject; dataMappingFieldDefinitions.put( functionalFieldDescription.getComponentClass() + functionalFieldDescription.getPropertyName(), kfsBusinessObjectMetaDataService.getDataMappingFieldDefinition( functionalFieldDescription)); } else { BusinessObjectProperty businessObjectProperty = (BusinessObjectProperty) businessObject; dataMappingFieldDefinitions.put( businessObjectProperty.getComponentClass() + businessObjectProperty.getPropertyName(), kfsBusinessObjectMetaDataService.getDataMappingFieldDefinition( businessObjectProperty.getComponentClass(), businessObjectProperty.getPropertyName())); } } else { break; } } List<DataMappingFieldDefinition> searchResults = null; if (matches.size() > searchResultsLimit) { searchResults = new CollectionIncomplete( dataMappingFieldDefinitions.values(), Long.valueOf(matches.size())); } else { searchResults = new CollectionIncomplete(dataMappingFieldDefinitions.values(), 0L); } Collections.sort(searchResults, new BeanPropertyComparator(getSortProperties(), true)); return searchResults; }