@Test
  public void testExample1WithLineItems() throws Exception {
    context.checking(
        new Expectations() {
          {
            one(sponsorHierarchyService).isSponsorNihMultiplePi(NIH_SPONSOR_CODE);
            will(returnValue(true));
          }
        });

    subAward.getBudgetSubAwardPeriodDetails().get(0).setDirectCost(new ScaleTwoDecimal(150000L));
    subAward.getBudgetSubAwardPeriodDetails().get(0).setIndirectCost(new ScaleTwoDecimal(75000L));
    subAward.getBudgetSubAwardPeriodDetails().get(1).setDirectCost(new ScaleTwoDecimal(150000L));
    subAward.getBudgetSubAwardPeriodDetails().get(1).setIndirectCost(new ScaleTwoDecimal(75000L));

    for (BudgetPeriod period : budget.getBudgetPeriods()) {
      BudgetLineItem newLineItem = new BudgetLineItem();
      newLineItem.setBudgetSubAward(subAward);
      newLineItem.setSubAwardNumber(subAward.getSubAwardNumber());
      newLineItem.setDirectCost(new ScaleTwoDecimal(100L));
      newLineItem.setCostSharingAmount(new ScaleTwoDecimal(100L));
      newLineItem.setCostElement(directLt);
      newLineItem.setLineItemNumber(1);
      period.getBudgetLineItems().add(newLineItem);
      newLineItem = (BudgetLineItem) org.kuali.rice.krad.util.ObjectUtils.deepCopy(newLineItem);
      newLineItem.setCostElement(directGt);
      newLineItem.setLineItemNumber(2);
      period.getBudgetLineItems().add(newLineItem);
      newLineItem = (BudgetLineItem) org.kuali.rice.krad.util.ObjectUtils.deepCopy(newLineItem);
      newLineItem.setCostElement(indirectLt);
      newLineItem.setLineItemNumber(3);
      period.getBudgetLineItems().add(newLineItem);
      newLineItem = (BudgetLineItem) org.kuali.rice.krad.util.ObjectUtils.deepCopy(newLineItem);
      newLineItem.setCostElement(indirectGt);
      newLineItem.setLineItemNumber(4);
      period.getBudgetLineItems().add(newLineItem);
    }

    List<Map<String, ScaleTwoDecimal>> expectedResults = new ArrayList<>();
    expectedResults.add(new HashMap<>());
    expectedResults.add(new HashMap<>());
    expectedResults.add(new HashMap<>());
    expectedResults.get(0).put(indirectGt, new ScaleTwoDecimal(75000L));
    expectedResults.get(0).put(indirectLt, ScaleTwoDecimal.ZERO);
    expectedResults.get(0).put(directGt, new ScaleTwoDecimal(125000L));
    expectedResults.get(0).put(directLt, new ScaleTwoDecimal(25000L));
    expectedResults.get(1).put(indirectGt, new ScaleTwoDecimal(75000L));
    expectedResults.get(1).put(indirectLt, ScaleTwoDecimal.ZERO);
    expectedResults.get(1).put(directGt, new ScaleTwoDecimal(150000L));
    expectedResults.get(1).put(directLt, ScaleTwoDecimal.ZERO);
    service.generateSubAwardLineItems(subAward, budget);
    assertExpectedResults(expectedResults);
    assertCostShare(0);
  }
  protected PersonnelAttachmentEventBase(
      String description,
      String errorPathPrefix,
      ProposalDevelopmentDocument document,
      ProposalPersonBiography proposalPersonBiography) {
    super(description, errorPathPrefix, document);

    if (proposalPersonBiography != null) {
      // by doing a deep copy, we are ensuring that the business rule class can't update
      // the original object by reference
      this.proposalPersonBiography =
          (ProposalPersonBiography) ObjectUtils.deepCopy(proposalPersonBiography);
      // personnelattachmentfile will be lost during deepcopy, so implement filename this way.
      if (proposalPersonBiography.getPersonnelAttachmentFile() != null) {
        this.proposalPersonBiography.setFileName(
            proposalPersonBiography.getPersonnelAttachmentFile().getFileName());
        this.proposalPersonBiography.setContentType(
            proposalPersonBiography.getPersonnelAttachmentFile().getContentType());
      }
    } else {
      // due to this rule requiring A proposal person biography, create one if null
      this.proposalPersonBiography = new ProposalPersonBiography();
    }
    logEvent();
  }
 /** TODO: remove this method once baseline accounting lines has been removed */
 protected List deepCopyAccountingLinesList(List originals) {
   if (originals == null) {
     return null;
   }
   List copiedLines = new ArrayList();
   for (int i = 0; i < originals.size(); i++) {
     copiedLines.add(ObjectUtils.deepCopy((AccountingLine) originals.get(i)));
   }
   return copiedLines;
 }
 /**
  * This method is a helper method that will return a source accounting line. The reason we're
  * making it protected in here is so that we can override this method in some of the modules.
  * PurchasingActionBase is one of the subclasses that will be overriding this, because in
  * PurchasingActionBase, we'll need to get the source accounting line using both an item index and
  * an account index.
  *
  * @param form
  * @param request
  * @param isSource
  * @return
  */
 protected SourceAccountingLine getSourceAccountingLine(
     ActionForm form, HttpServletRequest request) {
   int lineIndex = getSelectedLine(request);
   SourceAccountingLine line =
       (SourceAccountingLine)
           ObjectUtils.deepCopy(
               ((KualiAccountingDocumentFormBase) form)
                   .getFinancialDocument()
                   .getSourceAccountingLine(lineIndex));
   return line;
 }
Пример #5
0
  /**
   * Constructs a AwardFandaRateEventBase.java.
   *
   * @param description
   * @param errorPathPrefix
   * @param document
   * @param awardFandaRate
   */
  protected AwardFandaRateEvent(
      String description,
      String errorPathPrefix,
      AwardDocument document,
      AwardFandaRate awardFandaRate) {
    super(description, errorPathPrefix, document);

    // by doing a deep copy, we are ensuring that the business rule class can't update
    // the original object by reference
    this.awardFandaRate = (AwardFandaRate) ObjectUtils.deepCopy(awardFandaRate);
    logEvent();
  }
 public AddPersonDelegationMemberEvent(
     String errorPathPrefix, Document document, RoleDocumentDelegationMember member) {
   this(errorPathPrefix, (IdentityManagementPersonDocument) document);
   this.delegationMember = (RoleDocumentDelegationMember) ObjectUtils.deepCopy(member);
 }
 public AddDelegationEvent(
     String errorPathPrefix, Document document, RoleDocumentDelegation delegation) {
   this(errorPathPrefix, (IdentityManagementRoleDocument) document);
   this.delegation = (RoleDocumentDelegation) ObjectUtils.deepCopy(delegation);
 }