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());
 }
  /*
   * 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;
  }
  /*
   * This method will set the values to ChildAwardDetails attributes and
   * finally returns ChildAwardDetails Xml object
   */
  private ChildAwardDetails getChildAwardDetails() {
    ChildAwardDetails childAwardDetails = ChildAwardDetails.Factory.newInstance();

    AwardHierarchy awardHierarchy =
        getAwardHierarchyService().loadAwardHierarchyBranch(award.getAwardNumber());
    List<AwardHierarchy> children = awardHierarchy.getChildren();
    for (AwardHierarchy awardHierarchy2 : children) {
      setAwardHierarchy(awardHierarchy2, childAwardDetails);
    }
    return childAwardDetails;
  }
 private void setAwardHierarchy(
     AwardHierarchy awardHierarchy, ChildAwardDetails childAwardDetails) {
   if (awardHierarchy != null) {
     ChildAwardType childAwardType = childAwardDetails.addNewChildAward();
     AwardHierarchyType hierarchyType = childAwardType.addNewAwardHierarchy();
     hierarchyType.setAwardNumber(awardHierarchy.getAwardNumber());
     hierarchyType.setParentAwardNumber(awardHierarchy.getParentAwardNumber());
     hierarchyType.setRootAwardNumber(awardHierarchy.getRootAwardNumber());
     setAwardAmountInfoDetails(awardHierarchy, childAwardType);
     List<AwardHierarchy> children = awardHierarchy.getChildren();
     for (AwardHierarchy awardHierarchy2 : children) {
       setAwardHierarchy(awardHierarchy2, childAwardDetails);
     }
   }
 }
 public String getSubAwardHierarchiesForTreeView(
     String awardNumber, String currentAwardNumber, String currentSequenceNumber)
     throws ParseException {
   String awardHierarchy = TAG_H3_START;
   for (AwardHierarchy ah : getChildrenNodes(awardNumber)) {
     AwardHierarchyNode aNode =
         getAwardHierarchyNodes(awardNumber, currentAwardNumber, currentSequenceNumber)
             .get(ah.getAwardNumber());
     awardHierarchy =
         awardHierarchy
             + buildCompleteRecord(ah.getAwardNumber(), aNode)
             + TAG_H3_END
             + TAG_H3_START;
   }
   awardHierarchy = awardHierarchy.substring(0, awardHierarchy.length() - 4);
   return awardHierarchy;
 }
  private List<AmountInfoType> recurseTree(
      AwardHierarchy branchNode, List<AmountInfoType> amountInfoTypes) {

    Map<String, Object> criteria =
        ServiceHelper.getInstance()
            .buildCriteriaMap(
                new String[] {"parentAwardNumber", "active"},
                new Object[] {branchNode.getAwardNumber(), Boolean.TRUE});
    Collection c =
        businessObjectService.findMatchingOrderBy(
            AwardHierarchy.class, criteria, AwardHierarchy.UNIQUE_IDENTIFIER_FIELD, true);
    branchNode.setChildren(new ArrayList<AwardHierarchy>(c));
    if (branchNode.hasChildren()) {
      for (AwardHierarchy childNode : branchNode.getChildren()) {
        org.kuali.kra.award.home.AwardAmountInfo awardAmount =
            childNode.getAward().getLastAwardAmountInfo();
        amountInfoTypes.add(setAwardAmountInfo(childNode.getAward(), awardAmount));
        childNode.setParent(branchNode);
        childNode.setRoot(branchNode.getRoot());
        recurseTree(childNode, amountInfoTypes);
      }
    }
    return amountInfoTypes;
  }