/** * @param campusCode * @return true if campus code is a valid campus */ private boolean isValidCampus(String campusCode) { boolean valid = true; if (StringUtils.isBlank(campusCode)) { return valid; } BusinessObjectService boService = KNSServiceLocator.getBusinessObjectService(); Campus campus = boService.findBySinglePrimaryKey(CampusImpl.class, campusCode); if (campus == null || !campus.isActive()) { valid = false; } return valid; }
@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; }
/** * This method returns LobbyingActivitiesDisclosureDocument object based on proposal development * document which contains the LobbyingActivitiesDisclosureDocument informations * FederalActionType,FederalActionStatus,ReportType,ReportEntity,FederalAgencyDepartment, * FederalProgramName,LobbyingRegistrant,IndividualsPerformingServices,SignatureBlock and * LobbyingActivitiesDisclosure for a particular proposal * * @return lobbyingADDocument {@link XmlObject} of type LobbyingActivitiesDisclosureDocument. */ private LobbyingActivitiesDisclosureDocument getLobbyingActivitiesDisclosure() { LobbyingActivitiesDisclosureDocument lobbyingADDocument = LobbyingActivitiesDisclosureDocument.Factory.newInstance(); LobbyingActivitiesDisclosure lobbyingDisclosure = LobbyingActivitiesDisclosure.Factory.newInstance(); lobbyingDisclosure.setFormVersion(S2SConstants.FORMVERSION_1_0); lobbyingDisclosure.setFederalActionType(FederalActionType.GRANT); lobbyingDisclosure.setFederalActionStatus(FederalActionStatus.BID_OFFER); lobbyingDisclosure.setReportType(ReportDataType.INITIAL_FILING); lobbyingDisclosure.setReportEntity(getReportEntity()); lobbyingDisclosure.setFederalAgencyDepartment(""); Sponsor sponsor = pdDoc.getDevelopmentProposal().getSponsor(); if (sponsor != null) { if (sponsor.getSponsorName() != null) { if (sponsor.getSponsorName().length() > SPONSOR_NAME_MAX_LENGTH) { lobbyingDisclosure.setFederalAgencyDepartment( sponsor.getSponsorName().substring(0, SPONSOR_NAME_MAX_LENGTH)); } else { lobbyingDisclosure.setFederalAgencyDepartment(sponsor.getSponsorName()); } } } else { String primeSponsorCode = pdDoc.getDevelopmentProposal().getPrimeSponsorCode(); if (primeSponsorCode != null) { BusinessObjectService businessObjectService = KraServiceLocator.getService(BusinessObjectService.class); Map<String, String> sponsorMap = new HashMap<String, String>(); sponsorMap.put(KEY_SPONSOR_CODE, primeSponsorCode); Sponsor primeSponsor = (Sponsor) businessObjectService.findByPrimaryKey(Sponsor.class, sponsorMap); if (primeSponsor.getSponsorName() != null) { if (primeSponsor.getSponsorName().length() > SPONSOR_NAME_MAX_LENGTH) { lobbyingDisclosure.setFederalAgencyDepartment( primeSponsor.getSponsorName().substring(0, SPONSOR_NAME_MAX_LENGTH)); } else { lobbyingDisclosure.setFederalAgencyDepartment(primeSponsor.getSponsorName()); } } } } lobbyingDisclosure.setFederalProgramName(getFedProgramName()); lobbyingDisclosure.setLobbyingRegistrant(getLobbyingRegistrant()); lobbyingDisclosure.setIndividualsPerformingServices(getIndividualsPerformingServices()); lobbyingDisclosure.setSignatureBlock(getSignatureBlock()); lobbyingADDocument.setLobbyingActivitiesDisclosure(lobbyingDisclosure); return lobbyingADDocument; }
/* * 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; }
/** @see org.kuali.kfs.module.bc.service.PayrateImportService#importFile(java.io.InputStream) */ @Transactional public boolean importFile( InputStream fileImportStream, List<ExternalizedMessageWrapper> messageList, String principalId) { Map payRateHoldingPersonUniversalIdentifierKey = new HashMap(); payRateHoldingPersonUniversalIdentifierKey.put( KFSPropertyConstants.PERSON_UNIVERSAL_IDENTIFIER, principalId); this.businessObjectService.deleteMatching( BudgetConstructionPayRateHolding.class, payRateHoldingPersonUniversalIdentifierKey); BufferedReader fileReader = new BufferedReader(new InputStreamReader(fileImportStream)); this.importCount = 0; try { while (fileReader.ready()) { BudgetConstructionPayRateHolding budgetConstructionPayRateHolding = new BudgetConstructionPayRateHolding(); String line = fileReader.readLine(); ObjectUtil.convertLineToBusinessObject( budgetConstructionPayRateHolding, line, DefaultImportFileFormat.fieldLengths, Arrays.asList(DefaultImportFileFormat.fieldNames)); budgetConstructionPayRateHolding.setPrincipalId(principalId); budgetConstructionPayRateHolding.setAppointmentRequestedPayRate( budgetConstructionPayRateHolding.getAppointmentRequestedPayRate().movePointLeft(2)); businessObjectService.save(budgetConstructionPayRateHolding); this.importCount++; } } catch (Exception e) { this.businessObjectService.deleteMatching( BudgetConstructionPayRateHolding.class, payRateHoldingPersonUniversalIdentifierKey); messageList.add(new ExternalizedMessageWrapper(BCKeyConstants.ERROR_PAYRATE_IMPORT_ABORTED)); return false; } if (importCount == 0) messageList.add( new ExternalizedMessageWrapper(BCKeyConstants.MSG_PAYRATE_IMPORT_NO_IMPORT_RECORDS)); else messageList.add( new ExternalizedMessageWrapper( BCKeyConstants.MSG_PAYRATE_IMPORT_COUNT, String.valueOf(importCount))); return true; }
/* * This method will get the AwardAmountTransaction for given * timeAndMoneyDocument Number */ private AwardAmountTransaction getAwardAmountTransaction(String timeAndMoneyDocNumber) { AwardAmountTransaction awardAmountTransaction = null; Map<String, String> timeAndMoneyMap = new HashMap<String, String>(); // TODO Time Money Doc number - to be fixed timeAndMoneyMap.put(DOCUMENT_NUMBER, timeAndMoneyDocNumber); List<TimeAndMoneyDocument> timeAndMoneyDocs = (List<TimeAndMoneyDocument>) businessObjectService.findMatching(TimeAndMoneyDocument.class, timeAndMoneyMap); if (timeAndMoneyDocs != null && !timeAndMoneyDocs.isEmpty()) { TimeAndMoneyDocument timeAndMoneyDocument = timeAndMoneyDocs.get(0); List<AwardAmountTransaction> awardAmountTransactionList = timeAndMoneyDocument.getAwardAmountTransactions(); if (awardAmountTransactionList != null && !awardAmountTransactionList.isEmpty()) { awardAmountTransaction = awardAmountTransactionList.get(0); } } return awardAmountTransaction; }