/* * call businessobjectservice to get a list of children award nodes 'awardNumber' */ protected List<AwardHierarchy> getChildrenNodes(String awardNumber) { List<AwardHierarchy> awardHierarchyList = new ArrayList<AwardHierarchy>(); Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put(FIELD_NAME_PARENT_AWARD_NUMBER, awardNumber); fieldValues.put("active", Boolean.TRUE); awardHierarchyList.addAll( businessObjectService.findMatchingOrderBy( AwardHierarchy.class, fieldValues, FIELD_NAME_AWARD_NUMBER, true)); return awardHierarchyList; }
@SuppressWarnings("unchecked") protected List<Award> filterForActiveAwardsAndAwardWithActiveTimeAndMoney( Collection<Award> collectionByQuery) throws WorkflowException { BusinessObjectService businessObjectService = KraServiceLocator.getService(BusinessObjectService.class); DocumentService documentService = KraServiceLocator.getService(DocumentService.class); Set<String> awardNumbers = new TreeSet<String>(); for (Award award : collectionByQuery) { awardNumbers.add(award.getAwardNumber()); } // get submitted docs List<Award> activeAwards = new ArrayList<Award>(); for (String versionName : awardNumbers) { VersionHistory versionHistory = versionHistoryService.findActiveVersion(Award.class, versionName); if (versionHistory != null) { Award activeAward = (Award) versionHistory.getSequenceOwner(); if (activeAward != null) { activeAwards.add(activeAward); } } } // get awards that have associated final T&M doc. for (Award award : collectionByQuery) { Map<String, Object> fieldValues = new HashMap<String, Object>(); String[] splitAwardNumber = award.getAwardNumber().split("-"); StringBuilder rootAwardNumberBuilder = new StringBuilder(12); rootAwardNumberBuilder.append(splitAwardNumber[0]); rootAwardNumberBuilder.append("-00001"); String rootAwardNumber = rootAwardNumberBuilder.toString(); fieldValues.put("rootAwardNumber", rootAwardNumber); List<TimeAndMoneyDocument> timeAndMoneyDocuments = (List<TimeAndMoneyDocument>) businessObjectService.findMatchingOrderBy( TimeAndMoneyDocument.class, fieldValues, "documentNumber", true); if (!(timeAndMoneyDocuments.size() == 0)) { TimeAndMoneyDocument t = timeAndMoneyDocuments.get(0); TimeAndMoneyDocument timeAndMoneyDocument = (TimeAndMoneyDocument) documentService.getByDocumentHeaderId(t.getDocumentNumber()); if (timeAndMoneyDocument.getDocumentHeader().getWorkflowDocument().stateIsFinal() && !(isAwardInAwardList(award.getAwardNumber(), activeAwards))) { activeAwards.add(award); } } } return activeAwards; }