/** * Creates an instance of BudgetCommonService by looking at the classname. * * @return */ public static BudgetCommonService createInstance(BudgetParentDocument parentBudgetDocument) { if (parentBudgetDocument.getClass().equals(AwardDocument.class)) { return KraServiceLocator.getService(AwardBudgetService.class); } else { return KraServiceLocator.getService(ProposalBudgetService.class); } }
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); }
public void populateProposalPerson_Investigator( Protocol protocol, ProposalDevelopmentDocument proposalDocument) { ProposalPerson proposalPerson = new ProposalPerson(); proposalPerson.setPersonId(protocol.getPrincipalInvestigatorId()); PersonEditableService personEditableService = KraServiceLocator.getService(PersonEditableService.class); personEditableService.populateContactFieldsFromPersonId(proposalPerson); proposalPerson.setProposalPersonRoleId(Constants.PRINCIPAL_INVESTIGATOR_ROLE); proposalPerson.setDevelopmentProposal(proposalDocument.getDevelopmentProposal()); proposalPerson.setProposalNumber(proposalDocument.getDevelopmentProposal().getProposalNumber()); proposalPerson.setProposalPersonNumber(new Integer(1)); proposalPerson.setOptInUnitStatus("Y"); proposalPerson.setOptInCertificationStatus("Y"); proposalDocument.getDevelopmentProposal().getProposalPersons().add(proposalPerson); KeyPersonnelService keyPersonnelService = (KeyPersonnelServiceImpl) KraServiceLocator.getService(KeyPersonnelService.class); keyPersonnelService.populateProposalPerson(proposalPerson, proposalDocument); keyPersonnelService.assignLeadUnit( proposalPerson, proposalDocument.getDevelopmentProposal().getOwnedByUnitNumber()); }
@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; }
/** * Need to suppress buttons here when 'Totals' tab is clicked. * * @see * org.kuali.core.web.struts.action.KualiDocumentActionBase#execute(org.apache.struts.action.ActionMapping, * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final BudgetForm budgetForm = (BudgetForm) form; if (budgetForm.getMethodToCall().equals("close")) { setupDocumentExit(); } ActionForward actionForward = null; actionForward = super.execute(mapping, budgetForm, request, response); if (actionForward != null) { if ("summaryTotals".equals(actionForward.getName())) { budgetForm.suppressButtonsForTotalPage(); } } // check if audit rule check is done from PD if (budgetForm.isAuditActivated() && !"route".equals(((KualiForm) form).getMethodToCall())) { KraServiceLocator.getService(KualiRuleService.class) .applyRules(new DocumentAuditEvent(budgetForm.getDocument())); } return actionForward; }
@Override public ActionForward reload( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BudgetForm budgetForm = (BudgetForm) form; // setBudgetPersonDefaultPeriodTypeCode(budgetForm); ActionForward actionForward = super.reload(mapping, form, request, response); BusinessObjectService bos = KraServiceLocator.getService(BusinessObjectService.class); BudgetDocument budgetDocument = budgetForm.getBudgetDocument(); Budget budget = budgetDocument.getBudget(); Map queryMap = new HashMap(); queryMap.put("budgetId", budget.getBudgetId()); Collection budgetPersons = bos.findMatching(BudgetPerson.class, queryMap); budget.setBudgetPersons(budgetPersons == null ? new ArrayList() : (List) budgetPersons); BudgetCategoryTypeValuesFinder budgetCategoryTypeValuesFinder = new BudgetCategoryTypeValuesFinder(); List<KeyValue> budgetCategoryTypes = new ArrayList<KeyValue>(); budgetCategoryTypes = budgetCategoryTypeValuesFinder.getKeyValues(); for (int i = 0; i < budgetCategoryTypes.size(); i++) { budgetForm.getNewBudgetLineItems().add(budget.getNewBudgetLineItem()); } budget.setBudgetCategoryTypeCodes(budgetCategoryTypes); return actionForward; }
/** * . This is the Getter Method for RequisitionerUnit * * @return Returns the requisitionerUnit. */ public String getRequisitionerUnit() { if (this.requisitionerUnit != null) { UnitService unitService = KraServiceLocator.getService(UnitService.class); this.unit = unitService.getUnit(requisitionerUnit); } return requisitionerUnit; }
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); }
/** * This method... * * @param budget */ private void populateBudgetPrintForms(Budget budget) { if (budget.getBudgetPrintForms().isEmpty()) { BudgetPrintService budgetPrintService = KraServiceLocator.getService(BudgetPrintService.class); budgetPrintService.populateBudgetPrintForms(budget); } }
/** * Added mthod to enable change of status when the document changes KEW status. * * @see * org.kuali.rice.kns.document.DocumentBase#doRouteStatusChange(org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO) */ public void doRouteStatusChange(DocumentRouteStatusChangeDTO dto) { super.doRouteStatusChange(dto); String newStatus = dto.getNewRouteStatus(); String oldStatus = dto.getOldRouteStatus(); boolean changeStatus = false; this.setCurrentAward(getParentDocument().getBudgetParent()); if (LOG.isDebugEnabled()) LOG.debug( String.format( "Route status change on AwardBudgetDocument #%s from %s to %s.", getDocumentNumber(), oldStatus, newStatus)); // Only know what to do with disapproved right now, left the if (StringUtils.equals(newStatus, KEWConstants.ROUTE_HEADER_DISAPPROVED_CD)) { getAwardBudget().setAwardBudgetStatusCode(Constants.BUDGET_STATUS_CODE_DISAPPROVED); } else if (StringUtils.equals(newStatus, KEWConstants.ROUTE_HEADER_CANCEL_CD)) { getAwardBudget().setAwardBudgetStatusCode(Constants.BUDGET_STATUS_CODE_CANCELLED); } else if (StringUtils.equals(newStatus, KEWConstants.ROUTE_HEADER_FINAL_CD)) { getAwardBudget().setAwardBudgetStatusCode(Constants.BUDGET_STATUS_CODE_TO_BE_POSTED); changeStatus = true; } if (changeStatus) { try { KraServiceLocator.getService(DocumentService.class).saveDocument(this); } catch (WorkflowException e) { throw new RuntimeException("Could not save award document on action taken."); } } }
/** * . This is the Getter Method for subAwardAmountReleasedList * * @return Returns the subAwardAmountReleasedList. */ public List<SubAwardAmountReleased> getSubAwardAmountReleasedList() { Map<String, Object> values = new HashMap<String, Object>(); values.put("subAwardCode", this.getSubAwardCode()); return (List<SubAwardAmountReleased>) KraServiceLocator.getService(BusinessObjectService.class) .findMatchingOrderBy(SubAwardAmountReleased.class, values, "createdDate", false); }
@SuppressWarnings("unchecked") public PersonService getPersonService() { if (personService == null) { personService = KraServiceLocator.getService(PersonService.class); } return personService; }
private static String getCodeValue(String paramName) { return KraServiceLocator.getService(ParameterService.class) .getParameterValueAsString( InstitutionalProposalConstants.INSTITUTIONAL_PROPOSAL_NAMESPACE, ParameterConstants.DOCUMENT_COMPONENT, paramName); }
/** * Gets the KC Person Service. * * @return KC Person Service. */ protected KcPersonService getKcPersonService() { if (this.kcPersonService == null) { this.kcPersonService = KraServiceLocator.getService(KcPersonService.class); } return this.kcPersonService; }
/* * This method will set the values to award amount info xml object * attributes. */ private AwardAmountInfo getAwardAmountInfo(Award award) { AmountInfoType amountInfoType = null; AwardAmountInfo awardAmountInfo = AwardAmountInfo.Factory.newInstance(); List<AmountInfoType> amountInfoTypes = new ArrayList<AmountInfoType>(); AwardHierarchy branchNode = award.getAwardHierarchyService().loadFullHierarchyFromAnyNode(award.getParentNumber()); org.kuali.kra.award.home.AwardAmountInfo awardAmount = award.getLastAwardAmountInfo(); BusinessObjectService businessObjectService = KraServiceLocator.getService(BusinessObjectService.class); Collection<Award> awards = businessObjectService.findAll(Award.class); Award parentAward = null; for (Award awardParent : awards) { if (awardParent.getAwardNumber().equals(branchNode.getAwardNumber())) { parentAward = awardParent; break; } } if (branchNode != null) { amountInfoType = setAwardAmountInfo(parentAward, parentAward.getLastAwardAmountInfo()); amountInfoTypes = recurseTree(branchNode, amountInfoTypes); amountInfoTypes.add(0, amountInfoType); awardAmountInfo.setAmountInfoArray(amountInfoTypes.toArray(new AmountInfoType[0])); } return awardAmountInfo; }
/** * Takes a routeHeaderId for a particular document and constructs the URL to forward to that * document Copied from KraTransactionalDocument as this does not extend from that. * * @param routeHeaderId * @return String */ protected String buildForwardUrl(String routeHeaderId) { ResearchDocumentService researchDocumentService = KraServiceLocator.getService(ResearchDocumentService.class); String forward = researchDocumentService.getDocHandlerUrl(routeHeaderId); // forward = forward.replaceFirst(DEFAULT_TAB, ALTERNATE_OPEN_TAB); if (forward.indexOf("?") == -1) { forward += "?"; } else { forward += "&"; } forward += KewApiConstants.DOCUMENT_ID_PARAMETER + "=" + routeHeaderId; forward += "&" + KewApiConstants.COMMAND_PARAMETER + "=" + NotificationConstants.NOTIFICATION_DETAIL_VIEWS.DOC_SEARCH_VIEW; if (GlobalVariables.getUserSession().isBackdoorInUse()) { forward += "&" + KewApiConstants.BACKDOOR_ID_PARAMETER + "=" + GlobalVariables.getUserSession().getPrincipalName(); } return forward; }
public boolean isValidStatus(String disclosureStatus, Integer dispositionStatus) { boolean isValid = true; if (StringUtils.isBlank(disclosureStatus)) { GlobalVariables.getMessageMap() .putError(ADMIN_ERRORS, KeyConstants.ERROR_COI_DISCLOSURE_STATUS_REQUIRED); isValid = false; } if (dispositionStatus == null) { GlobalVariables.getMessageMap() .putError(ADMIN_ERRORS, KeyConstants.ERROR_COI_DISPOSITON_STATUS_REQUIRED); isValid = false; } CoiDispositionStatus disposition = KraServiceLocator.getService(BusinessObjectService.class) .findBySinglePrimaryKey(CoiDispositionStatus.class, dispositionStatus); if (disposition == null) { GlobalVariables.getMessageMap() .putError(ADMIN_ERRORS, KeyConstants.ERROR_COI_DISPOSITON_STATUS_REQUIRED); isValid = false; } // if the disposition requires disapproval, then the disclosureStatus must be disapproved. if (StringUtils.equals( disposition.getCoiDisclosureStatusCode(), CoiDisclosureStatus.DISAPPROVED) && !StringUtils.equals(disclosureStatus, CoiDisclosureStatus.DISAPPROVED)) { GlobalVariables.getMessageMap() .putError(ADMIN_ERRORS, KeyConstants.ERROR_COI_DISCLOSURE_STATUS_INVALID); isValid = false; } return isValid; }
/* * ensure the uniqueness of award type/basis of payment */ private boolean validateUniqueueCodes( final AwardType awardType, final AwardBasisOfPayment basisOfPayment) { boolean valid = true; if (awardType != null && basisOfPayment != null && StringUtils.isNotBlank(awardType.getAwardTypeCode().toString()) && StringUtils.isNotBlank(basisOfPayment.getBasisOfPaymentCode())) { final Map<String, String> pkMap = new HashMap<String, String>(); pkMap.put("awardTypeCode", awardType.getAwardTypeCode().toString()); pkMap.put("basisOfPaymentCode", basisOfPayment.getBasisOfPaymentCode()); final int matchingCount = KraServiceLocator.getService(BusinessObjectService.class) .countMatching(ValidAwardBasisPayment.class, pkMap); if (matchingCount > 0) { final MessageMap errorMap = GlobalVariables.getMessageMap(); errorMap.putError( "document.newMaintainableObject.awardTypeCode", KeyConstants.ERROR_AWARD_BASIS_EXIST, new String[] {awardType.getDescription(), basisOfPayment.getDescription()}); valid = false; } } return valid; }
private synchronized ProposalDevelopmentS2sQuestionnaireService getProposalDevelopmentS2sQuestionnaireService() { if (proposalDevelopmentS2sQuestionnaireService == null) { proposalDevelopmentS2sQuestionnaireService = KraServiceLocator.getService(ProposalDevelopmentS2sQuestionnaireService.class); } return proposalDevelopmentS2sQuestionnaireService; }
public List<HeaderNavigation> getBudgetHeaderNavigatorList() { DataDictionaryService dataDictionaryService = (DataDictionaryService) KraServiceLocator.getService(Constants.DATA_DICTIONARY_SERVICE_NAME); DocumentEntry docEntry = dataDictionaryService.getDataDictionary().getDocumentEntry(BudgetDocument.class.getName()); return docEntry.getHeaderNavigationList(); }
public KcPerson getRequisitioner() { if (requisitionerId != null) { return KraServiceLocator.getService(KcPersonService.class) .getKcPersonByPersonId(requisitionerId); } else { return null; } }
/** @see org.kuali.kra.budget.document.BudgetDocument#documentHasBeenRejected(java.lang.String) */ @Override public void documentHasBeenRejected(String reason) { this.getAwardBudget().setAwardBudgetStatusCode(Constants.BUDGET_STATUS_CODE_REJECTED); try { KraServiceLocator.getService(DocumentService.class).saveDocument(this); } catch (WorkflowException e) { throw new RuntimeException("Could not save award document on action taken."); } }
@Override protected String getProjectEndDateNumberOfYearsHook() { if (parameterService == null) { parameterService = KraServiceLocator.getService(ParameterService.class); } String parameter = parameterService.getParameterValueAsString( IacucProtocolDocument.class, IACUC_PROJECT_END_DATE_NUMBER_OF_YEARS); return parameter; }
/** * Constructs the list of Proposal Narrative Statuses. Each entry in the list is a <key, * value> pair, where the "key" is the unique status code and the "value" is the textual * description that is viewed by a user. The list is obtained from the NARRATIVE_STATUS database * table via the "KeyValueFinderService". * * @return the list of <key, value> pairs of abstract types. The first entry is always * <"", "select:">. * @see org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder#getKeyValues() */ public List<KeyLabelPair> getKeyValues() { KeyValuesService keyValuesService = (KeyValuesService) KraServiceLocator.getService("keyValuesService"); Collection<NarrativeStatus> statuses = keyValuesService.findAll(NarrativeStatus.class); List<KeyLabelPair> keyValues = new ArrayList<KeyLabelPair>(); for (NarrativeStatus status : statuses) { keyValues.add(new KeyLabelPair(status.getNarrativeStatusCode(), status.getDescription())); } return keyValues; }
@Override public void afterInsert(PersistenceBroker persistenceBroker) { // this will update the associated temporary log to indicate that it was // merged with the current permanent log if (getMergedWith() != null) { super.afterInsert(persistenceBroker); KraServiceLocator.getService(ProposalLogService.class) .updateMergedTempLog(getMergedWith(), getProposalNumber()); } return; }
/** {@inheritDoc} */ @Override public void prepareForSave() { // force ojb to precache the budget as an AwardBudgetExt. // without this it caches the budget as a Budget which causes problems // when assuming it must be an awardbudgetext for an awardbudgetdocument if (this.getBudget() != null) { AwardBudgetExt budget = KraServiceLocator.getService(BusinessObjectService.class) .findBySinglePrimaryKey(AwardBudgetExt.class, this.getBudget().getBudgetId()); } super.prepareForSave(); }
public ActionForward modularBudget( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { BudgetForm budgetForm = (BudgetForm) form; BudgetModularService budgetModularService = KraServiceLocator.getService(BudgetModularService.class); budgetForm.setBudgetModularSummary( budgetModularService.generateModularSummary(budgetForm.getDocument().getBudget())); return mapping.findForward(Constants.BUDGET_MODULAR_PAGE); }
public ActionForward distributionAndIncome( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { BudgetDistributionAndIncomeService budgetDistributionAndIncomeService = KraServiceLocator.getService(BudgetDistributionAndIncomeService.class); budgetDistributionAndIncomeService.initializeCollectionDefaults( ((BudgetForm) form).getDocument().getBudget()); return mapping.findForward(Constants.BUDGET_DIST_AND_INCOME_PAGE); }
public ActionForward budgetActions( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { BudgetForm budgetForm = (BudgetForm) form; BudgetDocument budgetDocument = budgetForm.getDocument(); Budget budget = budgetDocument.getBudget(); populateBudgetPrintForms(budget); KraServiceLocator.getService(BudgetSubAwardService.class) .populateBudgetSubAwardAttachments(budget); return mapping.findForward(Constants.BUDGET_ACTIONS_PAGE); }
/** * . This is the Setter Method for siteInvestigator * * @param siteInvestigator The siteInvestigator to set. */ public void setSiteInvestigator(Integer siteInvestigator) { if (siteInvestigator != null) { BusinessObjectService businessObjectService = KraServiceLocator.getService(BusinessObjectService.class); this.rolodex = (NonOrganizationalRolodex) businessObjectService.findByPrimaryKey( NonOrganizationalRolodex.class, getIdentifierMap(ROLODEX_ID_FIELD_NAME, siteInvestigator)); this.siteInvestigatorId = rolodex.getRolodexId().toString(); } this.siteInvestigator = siteInvestigator; }