protected BudgetPeriod findBudgetPeriod(BudgetSubAwardPeriodDetail detail, Budget budget) { for (BudgetPeriod period : budget.getBudgetPeriods()) { if (ObjectUtils.equals(detail.getBudgetPeriod(), period.getBudgetPeriod())) { return period; } } return null; }
public void prepareBudgetSubAwards(Budget budget) { populateBudgetSubAwardAttachments(budget); for (BudgetSubAwards subAward : budget.getBudgetSubAwards()) { for (BudgetPeriod period : budget.getBudgetPeriods()) { BudgetSubAwardPeriodDetail detail = null; for (BudgetSubAwardPeriodDetail curDetail : subAward.getBudgetSubAwardPeriodDetails()) { if (ObjectUtils.equals(curDetail.getBudgetPeriod(), period.getBudgetPeriod())) { detail = curDetail; break; } } if (detail == null) { subAward .getBudgetSubAwardPeriodDetails() .add(new BudgetSubAwardPeriodDetail(subAward, period)); } } } }
/** * First find a budget period that matches the start and end date. If that is found, find a * subaward period detail with the same budget period number. * * @param budget * @param budgetSubAward * @param startDate * @param endDate * @return */ protected BudgetSubAwardPeriodDetail findBudgetSubAwardPeriodDetail( Budget budget, BudgetSubAwards budgetSubAward, Date startDate, Date endDate) { BudgetPeriod matchingPeriod = null; BudgetSubAwardPeriodDetail matchingDetail = null; for (BudgetPeriod period : budget.getBudgetPeriods()) { if (startDate.getTime() == period.getStartDate().getTime() && endDate.getTime() == period.getEndDate().getTime()) { matchingPeriod = period; break; } } if (matchingPeriod != null) { for (BudgetSubAwardPeriodDetail detail : budgetSubAward.getBudgetSubAwardPeriodDetails()) { if (ObjectUtils.equals(detail.getBudgetPeriod(), matchingPeriod.getBudgetPeriod())) { matchingDetail = detail; break; } } } return matchingDetail; }