예제 #1
0
  /**
   * Validates credit splits of all investigators in a <code>{@link ProposalDevelopmentDocument}
   * </code>. Takes a <code>{@link Collection}</code> of investigators for a given credit type, and
   * validates credit splits for each investigator as well as iterating and validating credit splits
   * for each unit belonging to an investigator.
   *
   * @param investigators
   * @param creditTypeCode
   * @return true if the investigator collection is valid for the credit type, and false if it's
   *     invalid
   */
  public boolean validate(
      Collection<ProposalPerson> investigators, InvestigatorCreditType creditType) {
    boolean retval = true;

    DecimalHolder investigatorCreditTotal = new DecimalHolder(KualiDecimal.ZERO);

    if (!validateCreditSplitable(investigators.iterator(), creditType, investigatorCreditTotal)) {
      addAuditError(ERROR_TOTAL_CREDIT_SPLIT_UPBOUND, creditType.getDescription());
      retval = false;
    }

    info(INV_VALIDATION_MESSAGE, retval);

    for (ProposalPerson investigator : investigators) {
      DecimalHolder unitCreditTotal = new DecimalHolder(KualiDecimal.ZERO);

      if (!validateCreditSplitable(
          investigator.getUnits().iterator(), creditType, unitCreditTotal)) {
        addAuditError(
            ERROR_CREDIT_SPLIT_UPBOUND,
            creditType.getDescription(),
            getCreditSplitableName(investigator));
        retval = false;
      }

      info(UNIT_VALIDATION_MESSAGE, retval);
    }

    return retval;
  }
예제 #2
0
  /**
   * Validates the credit splits of an entire document by traversing it. If the Investigator is
   * instead a Principal Investigator, the units should all add up to 100.0.
   *
   * @param document The document to validate the credit splits of
   * @return boolean
   */
  public boolean validate(ProposalDevelopmentDocument document) {
    Collection<InvestigatorCreditType> creditTypes =
        getKeyPersonnelService().getInvestigatorCreditTypes();
    boolean retval = true;

    for (InvestigatorCreditType creditType : creditTypes) {
      info(VALIDATING_CT_MESSAGE, creditType.getDescription());
      if (creditType.addsToHundred()) {
        retval &= validate(document.getDevelopmentProposal().getInvestigators(), creditType);
      }
    }

    return retval;
  }