@Override public List<SubAward> getLinkedSubAwards(Award award) { Map<String, Object> values = new HashMap<String, Object>(); values.put("awardId", award.getAwardId()); Collection<SubAwardFundingSource> subAwardFundingSources = businessObjectService.findMatching(SubAwardFundingSource.class, values); Set<String> subAwardSet = new TreeSet<String>(); for (SubAwardFundingSource subAwardFundingSource : subAwardFundingSources) { subAwardSet.add(subAwardFundingSource.getSubAward().getSubAwardCode()); } List<SubAward> subAwards = new ArrayList<SubAward>(); for (String subAwardCode : subAwardSet) { VersionHistory activeVersion = getVersionHistoryService().findActiveVersion(SubAward.class, subAwardCode); if (activeVersion == null) { VersionHistory pendingVersion = getVersionHistoryService().findPendingVersion(SubAward.class, subAwardCode); if (pendingVersion != null) { subAwards.add((SubAward) pendingVersion.getSequenceOwner()); } } else { subAwards.add((SubAward) activeVersion.getSequenceOwner()); } } return subAwards; }
public ActionForward openAwardReports( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String awardNumber = getSelectedAwardNumber(request); List<VersionHistory> versions = KraServiceLocator.getService(VersionHistoryService.class) .loadVersionHistory(Award.class, awardNumber); Award newest = null; for (VersionHistory version : versions) { if (newest == null || version.getSequenceOwnerSequenceNumber() > newest.getSequenceNumber() && version.getStatus() != VersionStatus.CANCELED) { newest = ((Award) version.getSequenceOwner()); } } String docNumber = newest.getAwardDocument().getDocumentNumber(); final AwardDocument awardDocument = (AwardDocument) getDocumentService().getByDocumentHeaderId(docNumber); String forwardUrl = buildForwardUrl(awardDocument.getDocumentHeader().getWorkflowDocument().getDocumentId()); return new ActionForward(forwardUrl, true); }
private ActionForward getReturnToAwardForward(BudgetForm budgetForm) throws Exception { assert budgetForm != null : "the form is null"; final DocumentService docService = KraServiceLocator.getService(DocumentService.class); Award award = ((AwardDocument) budgetForm.getBudgetDocument().getParentDocument()).getAward(); // find the newest, uncanceled award document to return to String docNumber = budgetForm.getBudgetDocument().getParentDocument().getDocumentNumber(); List<VersionHistory> versions = KraServiceLocator.getService(VersionHistoryService.class) .loadVersionHistory(Award.class, award.getAwardNumber()); for (VersionHistory version : versions) { if (version.getSequenceOwnerSequenceNumber() > award.getSequenceNumber() && version.getStatus() != VersionStatus.CANCELED) { docNumber = ((Award) version.getSequenceOwner()).getAwardDocument().getDocumentNumber(); } } final AwardDocument awardDocument = (AwardDocument) docService.getByDocumentHeaderId(docNumber); String forwardUrl = buildForwardUrl(awardDocument.getDocumentHeader().getWorkflowDocument().getRouteHeaderId()); if (budgetForm.isAuditActivated()) { forwardUrl = StringUtils.replace(forwardUrl, "Award.do?", "Actions.do?"); } // add showAllBudgetVersion to the url to persist that flag until they leave the document forwardUrl = StringUtils.replace( forwardUrl, ".do?", ".do?showAllBudgetVersions=" + budgetForm.isShowAllBudgetVersions() + "&"); return new ActionForward(forwardUrl, true); }
@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; }