예제 #1
0
  protected void populatePersonnelCategoryTypeCodes(BudgetForm budgetForm) {
    BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
    Budget budget = budgetDocument.getBudget();

    BudgetCategoryTypeValuesFinder budgetCategoryTypeValuesFinder =
        new BudgetCategoryTypeValuesFinder();
    List<KeyLabelPair> budgetCategoryTypes = new ArrayList<KeyLabelPair>();
    String personnelBudgetCategoryTypeCode = getPersonnelBudgetCategoryTypeCode();

    for (KeyLabelPair budgetCategoryType : budgetCategoryTypeValuesFinder.getKeyValues()) {
      String budgetCategoryTypeCode = (String) budgetCategoryType.getKey();
      if (StringUtils.isNotBlank(budgetCategoryTypeCode)
          && StringUtils.equalsIgnoreCase(
              budgetCategoryTypeCode, personnelBudgetCategoryTypeCode)) {
        budgetCategoryTypes.add(budgetCategoryType);
        BudgetLineItem newBudgetLineItem = budget.getNewBudgetLineItem();
        if (budgetForm.getNewBudgetLineItems() == null) {
          budgetForm.setNewBudgetLineItems(new ArrayList<BudgetLineItem>());
        }
        budgetForm.getNewBudgetLineItems().add(newBudgetLineItem);
      }
    }
    budget.setBudgetCategoryTypeCodes(budgetCategoryTypes);
  }