/* * This method will calculate the total for cost element of all periods * period cost. */ private ScaleTwoDecimal getTotalForCostElementOfAllPeriodsCost( List<BudgetDataPeriodVO> budgetDataPeriodVOs) { ScaleTwoDecimal total = ScaleTwoDecimal.ZERO; for (BudgetDataPeriodVO budgetDataPeriodVO : budgetDataPeriodVOs) { total = total.add(budgetDataPeriodVO.getPeriodCost()); } return total; }
/* * This method will set the values to budget data period xml object and * finally return the set of budget data period xml objects. */ private BudgetPeriodData[] getBudgetDataPeriodXmlObjects( List<BudgetDataPeriodVO> budgetDataPeriods, Map<Integer, ScaleTwoDecimal> budgetPeriodWiseTotalMap) { List<BudgetPeriodData> budgetPeriodList = null; budgetPeriodList = new ArrayList<BudgetPeriodData>(); for (BudgetDataPeriodVO budgetPeriodVO : budgetDataPeriods) { BudgetPeriodData budgetPeriodData = BudgetPeriodData.Factory.newInstance(); int budgetPeriodId = budgetPeriodVO.getBudgetPeriodId(); budgetPeriodData.setBudgetPeriodID(budgetPeriodId); ScaleTwoDecimal periodCost = budgetPeriodVO.getPeriodCost(); budgetPeriodData.setPeriodCost(periodCost.bigDecimalValue()); if (budgetPeriodWiseTotalMap.containsKey(budgetPeriodId)) { ScaleTwoDecimal periodTotal = budgetPeriodWiseTotalMap.get(budgetPeriodId); periodTotal = periodTotal.add(periodCost); budgetPeriodWiseTotalMap.put(budgetPeriodId, periodTotal); } else { budgetPeriodWiseTotalMap.put(budgetPeriodId, periodCost); } budgetPeriodList.add(budgetPeriodData); } BudgetPeriodData[] budgetPeriodArray = budgetPeriodList.toArray(new BudgetPeriodData[0]); return budgetPeriodArray; }