/* * This method calculates the total period cost of entire budget period * irrespective of cost element. */ private void setTotalForPeriodWise( List<SalaryType> salaryTypeList, Map<Integer, ScaleTwoDecimal> budgetPeriodWiseTotalMap) { BudgetPeriodData[] budgetPeriodArray = null; ScaleTwoDecimal budgetSalaryTotal = ScaleTwoDecimal.ZERO; if (!budgetPeriodWiseTotalMap.isEmpty()) { List<BudgetPeriodData> budgetPeriodList = new ArrayList<BudgetPeriodData>(); for (Integer periodId : budgetPeriodWiseTotalMap.keySet()) { BudgetPeriodData budgetPeriodData = BudgetPeriodData.Factory.newInstance(); budgetPeriodData.setBudgetPeriodID(periodId); ScaleTwoDecimal periodCost = budgetPeriodWiseTotalMap.get(periodId); budgetPeriodData.setPeriodCost(periodCost.bigDecimalValue()); budgetSalaryTotal = budgetSalaryTotal.add(periodCost); budgetPeriodList.add(budgetPeriodData); } budgetPeriodArray = budgetPeriodList.toArray(new BudgetPeriodData[0]); } salaryTypeList.add( getSalaryTypeXmlObject( null, null, PERIOD_COST_TOTAL, budgetPeriodArray, budgetSalaryTotal)); }
/* * 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; }