@Override public Capacity getCapacityAt(Days day) { if (getBaseCalendar() == null) { return Capacity.zero(); } return getBaseCalendar().getCapacityConsideringCalendarDatasOn( selectedDate, day); }
/** * Makes a map of capacities with a list of {@link CalendarDayHoursDTO}. * * @param hoursPerDays * List<CalendarDayHoursDTO> to extract data from. * @return Map<Integer, Capacity> with the data that we want. * @throws ValidationException */ private Map<Integer, Capacity> getCapacitiesPerDays(List<CalendarDayHoursDTO> hoursPerDays) { Map<Integer, Capacity> result = new HashMap<>(); if (hoursPerDays != null) { for (CalendarDayHoursDTO hoursPerDayDTO : hoursPerDays) { try { if (hoursPerDayDTO.type == CalendarTypeDayDTO.DEFAULT) { continue; } Integer day = CalendarData.Days.valueOf(hoursPerDayDTO.day.toString()).ordinal(); Capacity capacity = Capacity.zero(); if (hoursPerDayDTO.type == CalendarTypeDayDTO.WORKING) { capacity = Capacity.create( EffortDuration.hours(hoursPerDayDTO.hours)).overAssignableWithoutLimit(); } else if (hoursPerDayDTO.type == CalendarTypeDayDTO.NOT_WORKING) { capacity = Capacity.create(EffortDuration.hours(hoursPerDayDTO.hours)); } result.put(day, capacity); } catch (IllegalArgumentException e) { throw new ValidationException("a day is not valid"); } catch (NullPointerException e) { throw new ValidationException("a day is null"); } } } return result; }