示例#1
0
 public ActionForward versions(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response) {
   BudgetForm budgetForm = (BudgetForm) form;
   BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
   BudgetParentDocument parentDocument = budgetDocument.getParentDocument();
   //        proposal.refreshReferenceObject("budgetDocumentVersions");
   budgetForm.setFinalBudgetVersion(
       getFinalBudgetVersion(parentDocument.getBudgetDocumentVersions()));
   setBudgetStatuses(parentDocument);
   return mapping.findForward(Constants.BUDGET_VERSIONS_PAGE);
 }
示例#2
0
  /**
   * This method sets additional document information in the document header of the budget form. If
   * the document contained in the budget form is null then empty values will be placed for the
   * additional information.
   *
   * @param budgetForm the budget form
   */
  private void setAdditionalDocumentHeaderInfo(final BudgetForm budgetForm) {
    assert budgetForm != null : "the budgetForm is null";

    final BudgetDocument budgetDocument = budgetForm.getDocument();
    Budget budget = budgetDocument.getBudget();
    BudgetParentDocument parentDocument = budgetDocument.getParentDocument();
    if (budget != null
        && parentDocument != null
        && parentDocument.getBudgetDocumentVersions() != null) {
      boolean setAdditionalInfo = false;
      for (final BudgetDocumentVersion budgetVersion : parentDocument.getBudgetDocumentVersions()) {
        if (budgetVersion
            .getBudgetVersionOverview()
            .getBudgetVersionNumber()
            .equals(budget.getBudgetVersionNumber())) {
          budgetForm
              .getDocInfo()
              .add(
                  new HeaderField(
                      BudgetForm.BUDGET_NAME_KEY,
                      budgetVersion.getBudgetVersionOverview().getDocumentDescription()));
          setAdditionalInfo = true;
          break;
        } else {
          budgetForm
              .getDocInfo()
              .add(new HeaderField(BudgetForm.BUDGET_NAME_KEY, Constants.EMPTY_STRING));
        }
      }
      if (!setAdditionalInfo) {
        budgetForm
            .getDocInfo()
            .add(new HeaderField(BudgetForm.BUDGET_NAME_KEY, Constants.EMPTY_STRING));
      }

      if (budget.getBudgetVersionNumber() != null) {
        budgetForm
            .getDocInfo()
            .add(
                new HeaderField(
                    BudgetForm.VERSION_NUMBER_KEY, budget.getBudgetVersionNumber().toString()));
      } else {
        budgetForm
            .getDocInfo()
            .add(new HeaderField(BudgetForm.VERSION_NUMBER_KEY, Constants.EMPTY_STRING));
      }
    }
  }
 /**
  * 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);
   }
 }
示例#4
0
 @Override
 public void processAfterRetrieve() {
   super.processAfterRetrieve();
   if (!isProposalDeleted()) {
     getProposalBudgetStatusService().loadBudgetStatus(this.getDevelopmentProposal());
     getDevelopmentProposal().updateProposalChangeHistory();
   }
 }
 /**
  * Gets the parentDocument attribute.
  *
  * @return Returns the parentDocument.
  */
 @Override
 public BudgetParentDocument<Award> getParentDocument() {
   if (newestBudgetParentDocument == null) {
     BudgetParentDocument<Award> parent = super.getParentDocument();
     if (parent == null) {
       return null;
     } else if (parent.getBudgetParent() == null) {
       return parent;
     } else {
       Award currentAward =
           getAwardBudgetService()
               .getActiveOrNewestAward(parent.getBudgetParent().getAwardNumber());
       newestBudgetParentDocument = currentAward.getAwardDocument();
     }
   }
   return newestBudgetParentDocument;
 }
示例#6
0
 @Override
 public void prepareForSave() {
   super.prepareForSave();
   if (!isProposalDeleted()) {
     getDevelopmentProposal().updateS2sOpportunity();
     getProposalBudgetStatusService().saveBudgetFinalVersionStatus(this);
     if (getBudgetDocumentVersions() != null) {
       updateDocumentDescriptions(getBudgetDocumentVersions());
     }
   }
 }
示例#7
0
  /** {@inheritDoc} */
  @Override
  public ActionForward reload(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final ActionForward forward = super.reload(mapping, form, request, response);
    final BudgetForm budgetForm = (BudgetForm) form;
    BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
    BudgetParentDocument parentDocument = budgetDocument.getParentDocument();

    budgetForm.setFinalBudgetVersion(
        getFinalBudgetVersion(parentDocument.getBudgetDocumentVersions()));
    setBudgetStatuses(budgetDocument.getParentDocument());

    final BudgetTDCValidator tdcValidator = new BudgetTDCValidator(request);
    tdcValidator.validateGeneratingWarnings(budgetDocument.getParentDocument());

    populateBudgetPrintForms(budgetDocument.getBudget());
    return forward;
  }
  /**
   * This method checks budget versions business rules.
   *
   * @param budgetParentDocument the document
   * @param runDatactionaryValidation if dd validation should be run
   * @return true if valid false if not
   * @throws NullPointerException if the proposalDevelopmentDocument is null
   */
  protected boolean processBudgetVersionsBusinessRule(
      final BudgetParentDocument budgetParentDocument, final boolean runDatactionaryValidation) {
    if (budgetParentDocument == null) {
      throw new NullPointerException("the parentDocument is null.");
    }

    boolean valid = true;
    final MessageMap errorMap = GlobalVariables.getMessageMap();
    boolean finalVersionFound = false;

    final DictionaryValidationService dictionaryValidationService =
        getKnsDictionaryValidationService();

    int index = 0;
    for (BudgetDocumentVersion budgetDocumentVersion :
        budgetParentDocument.getBudgetDocumentVersions()) {
      BudgetVersionOverview budgetVersion = budgetDocumentVersion.getBudgetVersionOverview();
      if (runDatactionaryValidation) {
        dictionaryValidationService.validateBusinessObject(budgetVersion, true);
      }
      if (budgetVersion.isFinalVersionFlag()) {
        if (finalVersionFound) {
          errorMap.putError("finalVersionFlag", KeyConstants.ERROR_MULTIPLE_FINAL_BUDGETS);
        } else {
          finalVersionFound = true;
        }
      }

      final String budgetStatusCompleteCode =
          getParameterService()
              .getParameterValueAsString(
                  BudgetDocument.class, Constants.BUDGET_STATUS_COMPLETE_CODE);

      if (budgetStatusCompleteCode.equalsIgnoreCase(budgetVersion.getBudgetStatus())) {
        if (!budgetVersion.isFinalVersionFlag()) {
          errorMap.putError(
              "budgetVersionOverview[" + index + "].budgetStatus",
              KeyConstants.ERROR_NO_FINAL_BUDGET);
          valid = false;
        }
      }
      index++;
    }

    return valid;
  }
示例#9
0
 @Override
 public void doRouteStatusChange(DocumentRouteStatusChange dto) {
   super.doRouteStatusChange(dto);
   String newStatus = dto.getNewRouteStatus();
   String oldStatus = dto.getOldRouteStatus();
   if (LOG.isDebugEnabled()) {
     LOG.debug(
         String.format(
             "Route Status change for document %s from %s to %s",
             this.getDocumentNumber(), oldStatus, newStatus));
   }
   if (!isProposalDeleted()) {
     DevelopmentProposal bp = this.getDevelopmentProposal();
     LOG.info(
         String.format(
             "Route status change for document %s - proposal number %s is moving from %s to %s",
             bp.getProposalDocument().getDocumentHeader().getDocumentNumber(),
             bp.getProposalNumber(),
             oldStatus,
             newStatus));
     if (bp.isParent()) {
       try {
         getProposalHierarchyService().routeHierarchyChildren(this, dto);
       } catch (ProposalHierarchyException e) {
         throw new RuntimeException(
             "ProposalHierarchyException thrown while routing children.", e);
       }
     } else if (!bp.isInHierarchy()) {
       try {
         getProposalHierarchyService().calculateAndSetProposalAppDocStatus(this, dto);
       } catch (ProposalHierarchyException pe) {
         throw new RuntimeException(
             String.format(
                 "ProposalHierarchyException thrown while updating app doc status for document %s",
                 getDocumentNumber()));
       }
     }
     bp.setProposalStateTypeCode(
         getProposalStateService().getProposalStateTypeCode(this, true, false));
   }
 }
示例#10
0
 @Override
 public void doActionTaken(ActionTakenEvent event) {
   super.doActionTaken(event);
   ActionTaken actionTaken = event.getActionTaken();
   if (LOG.isDebugEnabled()) {
     LOG.debug(
         String.format(
             "Action taken on document %s: event code %s, action taken is %s",
             getDocumentNumber(),
             event.getDocumentEventCode(),
             actionTaken.getActionTaken().getCode()));
   }
   if (!isProposalDeleted()) {
     if (StringUtils.equals(
         KewApiConstants.ACTION_TAKEN_APPROVED_CD, actionTaken.getActionTaken().getCode())) {
       try {
         if (getKcDocumentRejectionService().isDocumentOnInitialNode(this)) {
           DocumentRouteStatusChange dto =
               new DocumentRouteStatusChange(
                   getDocumentHeader().getWorkflowDocument().getDocumentId(),
                   getDocumentNumber(),
                   KewApiConstants.ROUTE_HEADER_ENROUTE_CD,
                   KewApiConstants.ROUTE_HEADER_ENROUTE_CD);
           // DocumentRouteStatusChange.documentEventCode is always returned as rt_status_change
           // dto.setDocumentEventCode("REJECTED_APPROVED");
           if (getDevelopmentProposal().isParent()) {
             getProposalHierarchyService().routeHierarchyChildren(this, dto);
             getProposalHierarchyService().calculateAndSetProposalAppDocStatus(this, dto);
           }
           if (!getDevelopmentProposal().isInHierarchy())
             getProposalHierarchyService().calculateAndSetProposalAppDocStatus(this, dto);
         }
       } catch (ProposalHierarchyException pe) {
         throw new RuntimeException(
             String.format(
                 "ProposalHeierachyException encountered trying to re-submit rejected parent document:%s",
                 getDocumentNumber()),
             pe);
       } catch (Exception we) {
         throw new RuntimeException(
             String.format(
                 "Exception trying to re-submit rejected parent:%s", getDocumentNumber()),
             we);
       }
     }
     String pCode = getDevelopmentProposal().getProposalStateTypeCode();
     getDevelopmentProposal()
         .setProposalStateTypeCode(
             getProposalStateService()
                 .getProposalStateTypeCode(
                     this, false, getKcDocumentRejectionService().isDocumentOnInitialNode(this)));
     if (!StringUtils.equals(pCode, getDevelopmentProposal().getProposalStateTypeCode())) {
       getDevelopmentProposal().refresh();
       getDataObjectService().save(getDevelopmentProposal());
     }
     if (getDevelopmentProposal().isChild()
         && StringUtils.equals(
             KewApiConstants.ACTION_TAKEN_CANCELED_CD, actionTaken.getActionTaken().getCode())) {
       try {
         getProposalHierarchyService().removeFromHierarchy(this.getDevelopmentProposal());
       } catch (ProposalHierarchyException e) {
         throw new RuntimeException(
             String.format(
                 "COULD NOT REMOVE CHILD:%s", this.getDevelopmentProposal().getProposalNumber()));
       }
     }
     if (isLastSubmitterApprovalAction(event.getActionTaken())
         && shouldAutogenerateInstitutionalProposal()) {
       String proposalNumber =
           getInstitutionalProposalService()
               .createInstitutionalProposal(
                   this.getDevelopmentProposal(), this.getFinalBudgetForThisProposal());
       this.setInstitutionalProposalNumber(proposalNumber);
     }
   }
 }
示例#11
0
 @Override
 public void initialize() {
   super.initialize();
   getDevelopmentProposal().initializeOwnedByUnitNumber();
 }