コード例 #1
0
  /**
   * This method will iterate over salaryTypeVo List and set to xml bean SalaryType and sort the
   * List based on costElement
   *
   * @param salaryTypeVoList
   * @return list of SalaryType xml bean
   */
  protected List<SalaryType> getListOfSalaryTypeXmlObjects(List<SalaryTypeVO> salaryTypeVoList) {
    List<SalaryType> salaryTypeList = new ArrayList<SalaryType>();
    Map<Integer, ScaleTwoDecimal> budgetPeriodWiseTotalMap =
        new HashMap<Integer, ScaleTwoDecimal>();
    if (!salaryTypeVoList.isEmpty()) {
      for (SalaryTypeVO salaryTypeVO : salaryTypeVoList) {
        BudgetPeriodData[] budgetPeriodArray = null;
        List<BudgetDataPeriodVO> budgetDataPeriodVOs = salaryTypeVO.getBudgetPeriodVOs();
        if (budgetDataPeriodVOs != null) {
          ScaleTwoDecimal total = ScaleTwoDecimal.ZERO;
          budgetPeriodArray =
              getBudgetDataPeriodXmlObjects(budgetDataPeriodVOs, budgetPeriodWiseTotalMap);
          total = getTotalForCostElementOfAllPeriodsCost(budgetDataPeriodVOs);
          salaryTypeVO.setTotal(total);
        }

        salaryTypeList.add(
            getSalaryTypeXmlObject(
                salaryTypeVO.getCostElement(),
                salaryTypeVO.getCostElementCode(),
                salaryTypeVO.getName(),
                budgetPeriodArray,
                salaryTypeVO.getTotal()));
      }
      setTotalForPeriodWise(salaryTypeList, budgetPeriodWiseTotalMap);
    }
    Collections.sort(
        salaryTypeList,
        new Comparator<SalaryType>() {
          public int compare(SalaryType salaryType1, SalaryType salaryType2) {
            int i = 0;
            if (salaryType1.getCostElementCode() != null
                && salaryType2.getCostElementCode() != null) {
              i = salaryType1.getCostElementCode().compareTo(salaryType2.getCostElementCode());
            }
            return i;
          }
        });
    return salaryTypeList;
  }