Esempio n. 1
0
  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 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 void setAwardAmountInfoDetails(
     AwardHierarchy awardHierarchy, ChildAwardType childAwardType) {
   awardHierarchy.refreshReferenceObject("award");
   Award childAward = awardHierarchy.getAward();
   AwardAmountInfo awardAmountInfo = childAward.getLastAwardAmountInfo();
   if (awardHierarchy.getAward().getAccountNumber() != null) {
     childAwardType.setAccountNumber(awardHierarchy.getAward().getAccountNumber());
   }
   if (awardAmountInfo.getAnticipatedTotalAmount() != null) {
     childAwardType.setAnticipatedTotalAmt(
         awardAmountInfo.getAnticipatedTotalAmount().bigDecimalValue());
   }
   if (awardAmountInfo.getFinalExpirationDate() != null) {
     Calendar finalExpDate = dateTimeService.getCalendar(awardAmountInfo.getFinalExpirationDate());
     childAwardType.setFinalExpirationDate(finalExpDate);
   }
   if (awardAmountInfo.getCurrentFundEffectiveDate() != null) {
     Calendar currentFundEffectiveDate =
         dateTimeService.getCalendar(awardAmountInfo.getCurrentFundEffectiveDate());
     childAwardType.setCurrentFundEffectiveDate(currentFundEffectiveDate);
   }
   if (awardAmountInfo.getAmountObligatedToDate() != null) {
     childAwardType.setAmtObligatedToDate(
         awardAmountInfo.getAmountObligatedToDate().bigDecimalValue());
   }
   if (awardAmountInfo.getObligationExpirationDate() != null) {
     Calendar obligationExpirationDate =
         dateTimeService.getCalendar(awardAmountInfo.getObligationExpirationDate());
     childAwardType.setObligationExpirationDate(obligationExpirationDate);
   }
   childAwardType.setPIName(childAward.getPrincipalInvestigator().getFullName());
 }
 public AwardHierarchyNode getRootAwardNode(Award award) {
   String awardNumber = award.getAwardNumber();
   AwardHierarchyNode awardNode =
       getAwardHierarchyNodes(awardNumber, awardNumber, award.getSequenceNumber().toString())
           .get(awardNumber);
   return awardNode;
 }
  private void addAwardSpecialReview(
      Award award,
      String protocolNumber,
      Date applicationDate,
      Date approvalDate,
      Date expirationDate,
      List<String> exemptionTypeCodes) {

    if (award != null) {
      Integer specialReviewNumber =
          award.getAwardDocument().getDocumentNextValue(Constants.SPECIAL_REVIEW_NUMBER);

      AwardSpecialReview specialReview = new AwardSpecialReview();
      specialReview.setSpecialReviewNumber(specialReviewNumber);
      specialReview.setSpecialReviewTypeCode(SpecialReviewType.HUMAN_SUBJECTS);
      specialReview.setApprovalTypeCode(SpecialReviewApprovalType.LINK_TO_IRB);
      specialReview.setProtocolNumber(protocolNumber);
      specialReview.setApplicationDate(applicationDate);
      specialReview.setApprovalDate(approvalDate);
      specialReview.setExpirationDate(expirationDate);
      for (String exemptionTypeCode : exemptionTypeCodes) {
        AwardSpecialReviewExemption specialReviewExemption = new AwardSpecialReviewExemption();
        specialReviewExemption.setAwardSpecialReview(specialReview);
        specialReviewExemption.setExemptionTypeCode(exemptionTypeCode);
        specialReview.getSpecialReviewExemptions().add(specialReviewExemption);
      }
      specialReview.setComments(NEW_SPECIAL_REVIEW_COMMENT);
      award.getSpecialReviews().add(specialReview);

      getBusinessObjectService().save(award);
    }
  }
 private void addApprovedEquipmentToAward(
     AwardApprovedEquipment equipmentItem1, AwardApprovedEquipment equipmentItem2) {
   equipmentItem1.setApprovedEquipmentId(1L);
   award.add(equipmentItem1);
   equipmentItem2.setApprovedEquipmentId(2L);
   award.add(equipmentItem2);
 }
Esempio n. 7
0
  /**
   * route the document using the document service
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   * @throws Exception
   */
  @Override
  public ActionForward route(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    AwardBudgetDocument awardBudgetDocument = ((AwardBudgetForm) form).getAwardBudgetDocument();
    Award currentAward =
        getAwardBudgetService()
            .getActiveOrNewestAward(
                ((AwardDocument) awardBudgetDocument.getBudget().getBudgetParent().getDocument())
                    .getAward()
                    .getAwardNumber());
    ScaleTwoDecimal newCostLimit = getAwardBudgetService().getTotalCostLimit(currentAward);
    if (!newCostLimit.equals(awardBudgetDocument.getBudget().getTotalCostLimit())
        || !getAwardBudgetService()
            .limitsMatch(
                currentAward.getAwardBudgetLimits(),
                awardBudgetDocument.getAwardBudget().getAwardBudgetLimits())) {
      Object question = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME);
      Object buttonClicked = request.getParameter(KRADConstants.QUESTION_CLICKED_BUTTON);
      String methodToCall = ((KualiForm) form).getMethodToCall();
      if (question == null) {
        ConfigurationService kualiConfiguration =
            CoreApiServiceLocator.getKualiConfigurationService();
        return confirm(
            buildParameterizedConfirmationQuestion(
                mapping,
                form,
                request,
                response,
                UPDATE_COST_LIMITS_QUESTION,
                KeyConstants.QUESTION_TOTALCOSTLIMIT_CHANGED),
            methodToCall,
            methodToCall);
      } else if (UPDATE_COST_LIMITS_QUESTION.equals(question)
          && ConfirmationQuestion.YES.equals(buttonClicked)) {
        getAwardBudgetService().setBudgetLimits(awardBudgetDocument, currentAward);
        return mapping.findForward(Constants.MAPPING_AWARD_BASIC);
      } else {
        // do nothing and continue with route
      }
    }
    ((AwardBudgetForm) form).setAuditActivated(true);
    ValidationState state =
        KcServiceLocator.getService(AuditHelper.class)
            .isValidSubmission((AwardBudgetForm) form, true);
    if (state != ValidationState.ERROR) {
      getAwardBudgetService().processSubmision(awardBudgetDocument);
      return super.route(mapping, form, request, response);
    } else {
      GlobalVariables.getMessageMap().clearErrorMessages();
      GlobalVariables.getMessageMap()
          .putError("datavalidation", KeyConstants.ERROR_WORKFLOW_SUBMISSION, new String[] {});

      return mapping.findForward(Constants.MAPPING_AWARD_BASIC);
    }
  }
 /*
  * This method initializes the awardDocument ,award and awardAamountInfo
  * reference variables
  */
 private void initialize(Award award) {
   this.awardDocument = award.getAwardDocument();
   this.award = award;
   List<AwardAmountInfo> awardAmountInfos = award.getAwardAmountInfos();
   if (awardAmountInfos != null && !awardAmountInfos.isEmpty()) {
     awardAmountInfo = awardAmountInfos.get(0);
   }
 }
Esempio n. 9
0
  public boolean isAuthorized(String userId, AwardTask task) {

    AwardDocument doc = task.getAward().getAwardDocument();
    Award award = task.getAward();
    return award.isNew()
        ? canUserCreateAward(userId, award)
        : canUserModifyAward(userId, award, doc);
  }
 private boolean isAwardInAwardList(String awardNumber, List<Award> awardList) {
   boolean returnVal = false;
   for (Award award : awardList) {
     if (award.getAwardNumber().equals(awardNumber)) {
       returnVal = true;
     }
   }
   return returnVal;
 }
 @Override
 public void initialize() {
   Award award = getParentDocument().getBudgetParent();
   this.setCurrentAward(award);
   AwardBudgetExt awardBudget = getAwardBudget();
   awardBudget.setObligatedTotal(
       new BudgetDecimal(award.getBudgetTotalCostLimit().bigDecimalValue()));
   List<BudgetRate> budgetRates = awardBudget.getBudgetRates();
   populateBudgetRateTypes(awardBudget, budgetRates);
 }
  /**
   * @see
   *     org.kuali.kra.service.AwardHierarchyUIService#getAwardRecord(org.kuali.kra.award.home.Award)
   */
  public String getAwardRecord(Award award) throws ParseException {

    String awardNumber = award.getAwardNumber();
    return buildCompleteRecord(
        awardNumber,
        getAwardHierarchyNodes(
                award.getAwardNumber(),
                award.getAwardNumber(),
                award.getSequenceNumber().toString())
            .get(awardNumber));
  }
Esempio n. 13
0
 /**
  * Make sure the lead unit of the award still matches the lead unit of the person, if the person
  * is a PI.
  *
  * @param award
  * @param person
  */
 protected void fixLeadUnit(Award award, AwardPerson person) {
   if (person.isPrincipalInvestigator()) {
     for (AwardPersonUnit unit : person.getUnits()) {
       if (unit.isLeadUnit()) {
         if (!StringUtils.equals(award.getLeadUnit().getUnitNumber(), unit.getUnitNumber())) {
           award.setLeadUnit(unit.getUnit());
         }
       }
     }
   }
 }
 /**
  * This method filters results based so that the person doing the lookup only gets back the
  * documents he has permission view.
  *
  * @param results
  * @return
  */
 public List<Award> filterForPermissions(List<Award> results) {
   Person user = UserSession.getAuthenticatedUser().getPerson();
   AwardDocumentAuthorizer authorizer = new AwardDocumentAuthorizer();
   List<Award> filteredResults = new ArrayList<Award>();
   // if the user has permission.
   for (Award award : results) {
     if (authorizer.canOpen(award.getAwardDocument(), user)) {
       filteredResults.add(award);
     }
   }
   return filteredResults;
 }
 @Before
 public void setUp() throws Exception {
   approvedEquipmentRule = prepareTestReadyAwardApprovedEquipmentRule();
   award = new Award();
   award.setAwardId(1L);
   award.setAwardNumber("X1000");
   award.setSequenceNumber(1);
   String requirement = EquipmentCapitalizationMinimumLoader.INSTITUTION_REQUIREMENT;
   minimumCapitalizationInfo =
       new MinimumCapitalizationInfo(requirement, AMOUNT2, AMOUNT1, AMOUNT2);
   GlobalVariables.setMessageMap(new MessageMap());
 }
  @Test
  public void testCheckForUnitDetailsNotRequired_KP() {
    Assert.assertTrue(
        MISSING_UNIT_DETAILS_NOT_IDENTIFIED,
        rule.checkForRequiredUnitDetails(award.getProjectPersons()));

    kpPerson.getUnits().clear();
    Assert.assertTrue(
        MISSING_UNIT_DETAILS_NOT_IDENTIFIED,
        rule.checkForRequiredUnitDetails(award.getProjectPersons()));
    Assert.assertEquals(0, GlobalVariables.getMessageMap().getErrorCount());
  }
 @Test
 public void testCheckForExistingPI() {
   Assert.assertTrue(
       "PI not found or more than one found",
       rule.checkForOnePrincipalInvestigator(award.getProjectPersons()));
   award.getProjectPersons().remove(0);
   Assert.assertFalse(
       "PI existence check failed",
       rule.checkForOnePrincipalInvestigator(award.getProjectPersons()));
   checkErrorState(
       AwardProjectPersonsSaveRule.AWARD_PROJECT_PERSON_LIST_ERROR_KEY,
       AwardProjectPersonsSaveRule.ERROR_AWARD_PROJECT_PERSON_NO_PI);
 }
  @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;
  }
  @Test
  public void testCheckForLeadUnit_NoneFound() {
    Assert.assertTrue(
        "No lead unit was found", rule.checkForLeadUnitForPI(award.getProjectPersons()));

    piPerson.getUnit(0).setLeadUnit(false);
    Assert.assertFalse(
        "No lead unit should have been found",
        rule.checkForLeadUnitForPI(award.getProjectPersons()));

    checkErrorState(
        AwardProjectPersonsSaveRule.AWARD_PROJECT_PERSON_LIST_ERROR_KEY,
        AwardProjectPersonsSaveRule.ERROR_AWARD_PROJECT_PERSON_LEAD_UNIT_REQUIRED);
  }
  @Test
  public void testCheckForMultiplePIs() {
    AwardPerson newPerson =
        new AwardPerson(
            KcPersonFixtureFactory.createKcPerson(KP_PERSON_ID), ContactRoleFixtureFactory.MOCK_PI);
    newPerson.setPropAwardPersonRoleService(roleService);
    award.add(newPerson);
    Assert.assertFalse(
        "Multiple PIs not detected",
        rule.checkForOnePrincipalInvestigator(award.getProjectPersons()));

    checkErrorState(
        AwardProjectPersonsSaveRule.AWARD_PROJECT_PERSON_LIST_ERROR_KEY,
        AwardProjectPersonsSaveRule.ERROR_AWARD_PROJECT_PERSON_MULTIPLE_PI_EXISTS);
  }
  @Test
  public void testCheckForRequiredUnitDetails_COI() {
    Assert.assertTrue(
        MISSING_UNIT_DETAILS_NOT_IDENTIFIED,
        rule.checkForRequiredUnitDetails(award.getProjectPersons()));

    coiPerson.getUnits().clear();
    Assert.assertFalse(
        MISSING_UNIT_DETAILS_NOT_IDENTIFIED,
        rule.checkForRequiredUnitDetails(award.getProjectPersons()));

    checkErrorState(
        AwardProjectPersonsSaveRule.AWARD_PROJECT_PERSON_LIST_ERROR_KEY,
        AwardProjectPersonsSaveRule.ERROR_AWARD_PROJECT_PERSON_UNIT_DETAILS_REQUIRED);
  }
  protected AnchorHtmlData getCopyLink(Award award, Boolean readOnly) {
    AnchorHtmlData htmlData = new AnchorHtmlData();
    htmlData.setDisplayText("copy");
    Properties parameters = new Properties();
    parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, "awardActions");
    parameters.put(KNSConstants.PARAMETER_COMMAND, KEWConstants.DOCSEARCH_COMMAND);
    parameters.put(KNSConstants.DOCUMENT_TYPE_NAME, getDocumentTypeName());
    parameters.put("viewDocument", readOnly.toString());
    parameters.put("docId", award.getAwardDocument().getDocumentNumber());
    parameters.put("docOpenedFromAwardSearch", "true");
    parameters.put("placeHolderAwardId", award.getAwardId().toString());
    String href = UrlFactory.parameterizeUrl("../" + getHtmlAction(), parameters);

    htmlData.setHref(href);
    return htmlData;
  }
Esempio n. 23
0
 @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;
 }
Esempio n. 24
0
 @SuppressWarnings("unchecked")
 @Override
 public void applySyncChange(Award award, AwardSyncChange change)
     throws NoSuchFieldException, IllegalAccessException, InvocationTargetException,
         ClassNotFoundException, NoSuchMethodException, InstantiationException,
         AwardSyncException {
   Collection awardPersons = award.getProjectPersons();
   AwardSyncXmlExport unitExport =
       (AwardSyncXmlExport) change.getXmlExport().getValues().get("units");
   AwardPerson person =
       (AwardPerson)
           getAwardSyncUtilityService()
               .findMatchingBo(awardPersons, change.getXmlExport().getKeys());
   if (StringUtils.equals(change.getSyncType(), AwardSyncType.ADD_SYNC.getSyncValue())) {
     if (person != null) {
       checkAndFixLeadUnit(person, unitExport);
       setValuesOnSyncable(person, change.getXmlExport().getValues(), change);
       fixLeadUnit(award, person);
     } else {
       throw new AwardSyncException(Constants.AWARD_SYNC_NOT_APPLICABLE, true);
     }
   } else {
     if (person != null) {
       AwardPersonUnit unit =
           (AwardPersonUnit)
               getAwardSyncUtilityService()
                   .findMatchingBo((Collection) person.getUnits(), unitExport.getKeys());
       if (unit != null) {
         person.getUnits().remove(unit);
       }
     } else {
       throw new AwardSyncException(Constants.AWARD_SYNC_NOT_APPLICABLE, true);
     }
   }
 }
  /** Create the mock services and insert them into the protocol auth service. */
  @Before
  public void setUp() throws Exception {
    fundingSponsorSourceType = new FundingSourceType();
    fundingSponsorSourceType.setFundingSourceTypeCode(FundingSourceType.SPONSOR);
    fundingSponsorSourceType.setFundingSourceTypeFlag(true);
    fundingSponsorSourceType.setDescription("Sponsor");
    fundingUnitSourceType = new FundingSourceType();
    fundingUnitSourceType.setFundingSourceTypeCode(FundingSourceType.UNIT);
    fundingUnitSourceType.setFundingSourceTypeFlag(true);
    fundingUnitSourceType.setDescription("Unit");
    fundingOtherSourceType = new FundingSourceType();
    fundingOtherSourceType.setFundingSourceTypeCode(FundingSourceType.OTHER);
    fundingOtherSourceType.setFundingSourceTypeFlag(true);
    fundingOtherSourceType.setDescription("Other");
    fundingDevProposalSourceType = new FundingSourceType();
    fundingDevProposalSourceType.setFundingSourceTypeCode(FundingSourceType.PROPOSAL_DEVELOPMENT);
    fundingDevProposalSourceType.setFundingSourceTypeFlag(true);
    fundingDevProposalSourceType.setDescription("Proposal Development");
    fundingInstProposalSourceType = new FundingSourceType();
    fundingInstProposalSourceType.setFundingSourceTypeCode(
        FundingSourceType.INSTITUTIONAL_PROPOSAL);
    fundingInstProposalSourceType.setFundingSourceTypeFlag(true);
    fundingInstProposalSourceType.setDescription("Institutional Proposal");
    fundingAwardSourceType = new FundingSourceType();
    fundingAwardSourceType.setFundingSourceTypeCode(FundingSourceType.AWARD);
    fundingAwardSourceType.setFundingSourceTypeFlag(true);
    fundingAwardSourceType.setDescription("Award");

    // sponsorGood = new Sponsor();
    // sponsorGood.setSponsorName(sponsorNameAirForce);
    // sponsorGood.setSponsorCode(SPONSOR_NUMBER_AIR_FORCE);
    sponsorGood =
        KcServiceLocator.getService(SponsorService.class).getSponsor(SPONSOR_NUMBER_AIR_FORCE);
    sponsorNameAirForce = sponsorGood.getSponsorName();

    devProposalGood = new DevelopmentProposal();
    devProposalGood.setTitle(DEV_PROPOSAL_TITLE_GOOD);
    devProposalGood.setSponsorCode(sponsorGood.getSponsorCode());

    instProposalGood = new InstitutionalProposal();
    instProposalGood.setTitle(INST_PROPOSAL_TITLE_GOOD);
    instProposalGood.setSponsorCode(sponsorGood.getSponsorCode());

    awardGood = new Award();
    awardGood.setTitle(AWARD_TITLE_GOOD);
    awardGood.setSponsorCode(sponsorGood.getSponsorCode());
  }
 /**
  * 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;
 }
  /*
   * 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;
  }
  @Test
  public void testProjectRolesChanges() {
    // when a coi is changed to key person
    coiPerson.setContactRole(ContactRoleFixtureFactory.MOCK_KEY_PERSON);
    Assert.assertFalse(
        "Key Person Role not checked for",
        rule.checkForKeyPersonProjectRoles(award.getProjectPersons()));
    coiPerson.setKeyPersonRole("fromCOI");
    Assert.assertTrue(
        "Key Person Role not checked for",
        rule.checkForKeyPersonProjectRoles(award.getProjectPersons()));

    // when a key person is changed to coi
    kpPerson.setContactRole(ContactRoleFixtureFactory.MOCK_COI);
    Assert.assertTrue(
        "rule should return true",
        rule.processSaveAwardProjectPersonsBusinessRules(award.getProjectPersons()));
  }
 @Override
 public boolean processRunAuditBusinessRules(Document document) {
   boolean valid = true;
   AwardDocument awardDocument = (AwardDocument) document;
   List<AuditError> auditErrors = new ArrayList<AuditError>();
   Award award = awardDocument.getAward();
   if (award.getMethodOfPaymentCode() == null) {
     valid &= false;
     addErrorToAuditErrors(auditErrors, METHOD_OF_PAYMENT_AUDIT_KEY, PAYMENT_METHOD);
   }
   if (award.getBasisOfPaymentCode() == null) {
     valid &= false;
     addErrorToAuditErrors(auditErrors, BASIS_OF_PAYMENT_AUDIT_KEY, PAYMENT_BASIS);
   }
   valid &= checkAwardBasisOfPayment(awardDocument, auditErrors);
   valid &= checkAwardBasisAndMethodOfPayment(awardDocument, auditErrors);
   reportAndCreateAuditCluster(auditErrors);
   return valid;
 }
  public AwardAmountInfo fetchLastAwardAmountInfoForDocNum(Award award, String docNum) {
    List<AwardAmountInfo> validAwardAmountInfos = new ArrayList<AwardAmountInfo>();
    int docNumIntValue = Integer.parseInt(docNum.trim());

    for (AwardAmountInfo aai : award.getAwardAmountInfos()) {
      if (aai.getTimeAndMoneyDocumentNumber() == null
          || (aai.getAwardNumber().endsWith("-00001")
              && award.getAwardAmountInfos().indexOf(aai) == 1)) {
        validAwardAmountInfos.add(aai);
      } else {
        if (Integer.parseInt(aai.getTimeAndMoneyDocumentNumber().trim()) > docNumIntValue) {
          break;
        } else {
          validAwardAmountInfos.add(aai);
        }
      }
    }
    return validAwardAmountInfos.get(validAwardAmountInfos.size() - 1);
  }