/**
   * Generate Query object for GeneralLedgerEntry search.
   *
   * @param fieldValues
   * @return
   */
  protected ReportQueryByCriteria getGeneralLedgerReportQuery(Map fieldValues) {
    Collection docTypeCodes = getDocumentType(fieldValues);
    Collection activityStatusCodes = getActivityStatusCode(fieldValues);

    Criteria criteria = OJBUtility.buildCriteriaFromMap(fieldValues, new GeneralLedgerEntry());

    // set document type code criteria
    if (!docTypeCodes.isEmpty()) {
      criteria.addIn(
          CabPropertyConstants.GeneralLedgerEntry.FINANCIAL_DOCUMENT_TYPE_CODE, docTypeCodes);
    }
    // set activity status code criteria
    if (!activityStatusCodes.isEmpty()) {
      criteria.addIn(
          CabPropertyConstants.GeneralLedgerEntry.ACTIVITY_STATUS_CODE, activityStatusCodes);
    }
    ReportQueryByCriteria query = QueryFactory.newReportQuery(GeneralLedgerEntry.class, criteria);

    List attributeList = buildAttributeList(false);

    // set the selection attributes
    String[] attributes = (String[]) attributeList.toArray(new String[attributeList.size()]);
    query.setAttributes(attributes);
    return query;
  }
 /**
  * @see
  *     org.kuali.kfs.module.cab.dataaccess.PurchasingAccountsPayableReportDao#findPurchasingAccountsPayableDocuments(java.util.Map)
  */
 @Override
 public Collection findPurchasingAccountsPayableDocuments(Map fieldValues) {
   Criteria criteria =
       OJBUtility.buildCriteriaFromMap(fieldValues, new PurchasingAccountsPayableDocument());
   QueryByCriteria query =
       QueryFactory.newQuery(PurchasingAccountsPayableDocument.class, criteria);
   return getPersistenceBrokerTemplate().getCollectionByQuery(query);
 }
  /**
   * Generates the list of search results for this inquiry
   *
   * @param fieldValues the field values of the query to carry out
   * @return List the search results returned by the lookup
   * @see org.kuali.rice.kns.lookup.Lookupable#getSearchResults(java.util.Map)
   *     <p>KRAD Conversion: Lookupable modifies the search results based on the fields
   *     consolidated. But all field definitions are in data dictionary.
   */
  @Override
  public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
    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 = this.getSelectedPendingEntryOption(fieldValues);

    // KFSMI-410: need to get this before getting isConsolidated because this value will be removed.
    String consolidationOption =
        (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.CONSOLIDATION_OPTION);

    // test if the consolidation option is selected or not
    boolean isConsolidated = isConsolidationSelected(fieldValues);

    // KFSMI-410: added one more node for consolidationOption
    if (consolidationOption.equals(Constant.EXCLUDE_SUBACCOUNTS)) {
      fieldValues.put(Constant.SUB_ACCOUNT_OPTION, KFSConstants.getDashSubAccountNumber());
      isConsolidated = false;
    }

    // get Amount View Option and determine if the results has to be accumulated
    String amountViewOption = getSelectedAmountViewOption(fieldValues);
    boolean isAccumulated = amountViewOption.equals(Constant.ACCUMULATE);

    // get the search result collection
    Iterator balanceIterator = balanceService.findBalance(fieldValues, isConsolidated);
    Collection searchResultsCollection =
        this.buildBalanceCollection(balanceIterator, isConsolidated, pendingEntryOption);

    // update search results according to the selected pending entry option
    updateByPendingLedgerEntry(
        searchResultsCollection, fieldValues, pendingEntryOption, isConsolidated, false);

    // perform the accumulation of the amounts
    this.accumulate(searchResultsCollection, isAccumulated);

    // get the actual size of all qualified search results
    Integer recordCount = balanceService.getBalanceRecordCount(fieldValues, isConsolidated);
    Long actualSize =
        OJBUtility.getResultActualSize(
            searchResultsCollection, recordCount, fieldValues, new Balance());

    return this.buildSearchResultList(searchResultsCollection, actualSize);
  }