コード例 #1
0
ファイル: VacationService.java プロジェクト: itru/timesheet
  public List<Vacation> getVacationList(VacationsForm vacationsForm) {
    Integer divisionId = vacationsForm.getDivisionId();
    Integer employeeId = vacationsForm.getEmployeeId();
    Date dateFrom = DateTimeUtil.parseStringToDateForDB(vacationsForm.getCalFromDate());
    Date dateTo = DateTimeUtil.parseStringToDateForDB(vacationsForm.getCalToDate());
    Integer projectId = vacationsForm.getProjectId();
    Integer managerId = vacationsForm.getManagerId();
    List<Integer> regions = vacationsForm.getRegions();
    DictionaryItem vacationType =
        vacationsForm.getVacationType() != 0
            ? dictionaryItemService.find(vacationsForm.getVacationType())
            : null;

    List<Vacation> vacations = new ArrayList<Vacation>();
    if (employeeId != null && employeeId != ALL_VALUE) {
      vacations.addAll(findVacations(employeeId, dateFrom, dateTo, vacationType));
    } else {
      List<Employee> employees =
          employeeService.getEmployees(
              employeeService.createDivisionList(divisionId),
              employeeService.createManagerList(managerId),
              employeeService.createRegionsList(regions),
              employeeService.createProjectList(projectId),
              dateFrom,
              dateTo,
              true);
      vacations.addAll(findVacations(employees, dateFrom, dateTo, vacationType));
    }
    sortVacations(vacations);
    return vacations;
  }