private String getDictionaryItemsInJson(List<DictionaryItem> items) {
    StringBuilder builder = new StringBuilder();
    builder.append("[");
    for (DictionaryItem item : items) {
      builder.append("{id:'");
      builder.append(item.getId().toString());
      builder.append("', value:'");
      builder.append(item.getValue());
      builder.append("'},");
    }
    if (builder.length() > 1) {
      builder.deleteCharAt(builder.length() - 1);
    }

    builder.append("]");
    return builder.toString();
  }
Beispiel #2
0
 public List<VacationInYear> getSummaryDaysCountByYearAndType(
     List<DictionaryItem> vacationTypes,
     int firstYear,
     int lastYear,
     Map<Vacation, Integer> calDays,
     Map<Vacation, Integer> workDays) {
   List<VacationInYear> result = new ArrayList<VacationInYear>();
   for (DictionaryItem vacationType : vacationTypes) {
     for (int year = firstYear; year <= lastYear; year++) {
       Map<Vacation, Integer> calDaysForYearByType =
           getDaysForYearByType(calDays, year, vacationType);
       Map<Vacation, Integer> workDaysForYearByType =
           getDaysForYearByType(workDays, year, vacationType);
       int summaryCalDays = getSummaryDaysCount(calDaysForYearByType);
       int summaryWorkDays = getSummaryDaysCount(workDaysForYearByType);
       result.add(
           new VacationInYear(vacationType.getValue(), year, summaryCalDays, summaryWorkDays));
     }
   }
   return result;
 }
Beispiel #3
0
  // возвращает список отпусков за год определенного типа с указанием количества календарных или
  // рабочих дней
  // в зависимости от того, какой список был передан
  private Map<Vacation, Integer> getDaysForYearByType(
      Map<Vacation, Integer> days, int year, DictionaryItem type) {
    Map<Vacation, Integer> daysForYearByType = new HashMap<Vacation, Integer>();
    for (Map.Entry<Vacation, Integer> entry : days.entrySet()) {
      Vacation vacation = entry.getKey();
      Integer calDaysInVacation = entry.getValue();

      if (vacationStatusInThisYear(vacation, year)
          && type.getId().equals(vacation.getType().getId())) {
        daysForYearByType.put(vacation, calDaysInVacation);
      }
    }
    return daysForYearByType;
  }