@Override public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) { // need to set backlocation & docformkey here. Otherwise, they are empty super.setBackLocationDocFormKey(fieldValues); if (this.getParameters().containsKey(USER_ID)) { fieldValues.put("projectPersons.personId", ((String[]) this.getParameters().get(USER_ID))[0]); } Map<String, String> formProps = new HashMap<String, String>(); if (!StringUtils.isEmpty(fieldValues.get("lookupOspAdministratorName"))) { formProps.put("fullName", fieldValues.get("lookupOspAdministratorName")); formProps.put("unitAdministratorTypeCode", "2"); } fieldValues.remove("lookupOspAdministratorName"); if (!formProps.isEmpty()) { List<Long> ids = new ArrayList<Long>(); Collection<AwardUnitContact> persons = getLookupService().findCollectionBySearch(AwardUnitContact.class, formProps); if (persons.isEmpty()) { return new ArrayList<Award>(); } for (AwardUnitContact person : persons) { ids.add(person.getAwardContactId()); } fieldValues.put("awardUnitContacts.awardContactId", StringUtils.join(ids, '|')); } List<Award> unboundedResults = (List<Award>) super.getSearchResultsUnbounded(fieldValues); List<Award> returnResults = new ArrayList<Award>(); try { returnResults = filterForActiveAwardsAndAwardWithActiveTimeAndMoney(unboundedResults); } catch (WorkflowException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<Award> filteredResults = new ArrayList<Award>(); filteredResults = (List<Award>) filterForPermissions(returnResults); return filteredResults; }
/** * This method fetches the Award Amount Info object that is to be displayed in UI for Award. The * rules are: 1)the Award Amount Infos awardNumber and versionNumber must match the Award BO 2)The * Award Amount Infos timeAndMoneyDocumentNumber must be null or from a T&M document that has been * finalized Users don't want this data to apply to Award until the T&M document has been * approved. * * @param award * @return * @throws WorkflowException * @throws WorkflowException */ @SuppressWarnings("unchecked") public AwardAmountInfo fetchLastAwardAmountInfoForAwardVersionAndFinalizedTandMDocumentNumber( Award award) { List<AwardAmountInfo> validAwardAmountInfos = new ArrayList<AwardAmountInfo>(); for (AwardAmountInfo aai : award.getAwardAmountInfos()) { // the aai needs to be added if it is created on initialization, or in the case of a root node // we add a new one for initial money transaction. // if an award has been versioned, the initial transaction will be the first index in list. if (aai.getTimeAndMoneyDocumentNumber() == null || (aai.getAwardNumber().endsWith("-00001") && award.getAwardAmountInfos().indexOf(aai) == 1)) { validAwardAmountInfos.add(aai); } else { Map<String, Object> fieldValues1 = new HashMap<String, Object>(); fieldValues1.put("documentNumber", aai.getTimeAndMoneyDocumentNumber()); List<TimeAndMoneyDocument> timeAndMoneyDocuments = (List<TimeAndMoneyDocument>) getBusinessObjectService().findMatching(TimeAndMoneyDocument.class, fieldValues1); try { TimeAndMoneyDocument timeAndMoneyDocument = (TimeAndMoneyDocument) getDocumentService() .getByDocumentHeaderId( timeAndMoneyDocuments.get(0).getDocumentHeader().getDocumentNumber()); if (timeAndMoneyDocument.getDocumentHeader().hasWorkflowDocument()) { if (timeAndMoneyDocument.getDocumentHeader().getWorkflowDocument().stateIsFinal()) { validAwardAmountInfos.add(aai); } } } catch (WorkflowException e) { LOG.error(e.getMessage(), e); } } } return validAwardAmountInfos.get(validAwardAmountInfos.size() - 1); }