Class SchedulerController

java.lang.Object
org.cswteams.ms3.control.scheduler.SchedulerController
All Implemented Interfaces:
ISchedulerController

@Service public class SchedulerController extends Object implements ISchedulerController
  • Constructor Details

    • SchedulerController

      public SchedulerController()
  • Method Details

    • getAllSchedulesWithDates

      public Set<ShowScheduleToPlannerDTO> getAllSchedulesWithDates()
      Specified by:
      getAllSchedulesWithDates in interface ISchedulerController
    • createSchedule

      public Schedule createSchedule(LocalDate startDate, LocalDate endDate)
      Description copied from interface: ISchedulerController
      Proxy of the method createSchedule, when the DoctorUffaPriority list cannot be retrieved. This method creates a new shift schedule by specifying start date and end date.
      Specified by:
      createSchedule in interface ISchedulerController
      Parameters:
      startDate - First date of the shift schedule
      endDate - Last date of the shift schedule
      Returns:
      An instance of schedule if correctly created and saved in persistence, null otherwise
    • createSchedule

      public Schedule createSchedule(LocalDate startDate, LocalDate endDate, List<DoctorUffaPriority> doctorUffaPriorityList, List<DoctorUffaPrioritySnapshot> snapshot)
      Description copied from interface: ISchedulerController
      Creates a schedule valid for the specified period and saves it in the DB.
      Specified by:
      createSchedule in interface ISchedulerController
      Parameters:
      startDate - starting day of the schedule validity
      endDate - end day (inclusive) of the validity of the schedule
      Returns:
      the created schedule
    • recreateSchedule

      public boolean recreateSchedule(long id)
      Description copied from interface: ISchedulerController
      This method recreates an existing shift scheduling. It is not possible to recreate a schedule in the past.
      Specified by:
      recreateSchedule in interface ISchedulerController
      Parameters:
      id - An existing schedule ID
      Returns:
      Boolean that represents if the regeneration ended successfully
    • addConcreteShift

      public Schedule addConcreteShift(ConcreteShift concreteShift, boolean forced) throws IllegalScheduleException
      Description copied from interface: ISchedulerController
      This method adds a new concrete shift to an existing schedule. In particular, it looks for the schedule containing the date of the new concrete shift and passes it to ScheduleBuilder.
      Specified by:
      addConcreteShift in interface ISchedulerController
      Parameters:
      concreteShift - The new concrete shift to be added to the schedule
      forced - If true, the concrete shift will be added if it respects all the non-violable constraints; if false, the concrete shift will be added only if it respects all the existing constraints.
      Returns:
      An instance of the updated shift schedule
      Throws:
      IllegalScheduleException - Rised if the new concrete shift makes the schedule illegal
    • removeConcreteShiftFromSchedule

      public void removeConcreteShiftFromSchedule(ConcreteShift concreteShiftOld)
      Description copied from interface: ISchedulerController
      This method removes a concrete shift from a schedule but not from the database.
      Specified by:
      removeConcreteShiftFromSchedule in interface ISchedulerController
      Parameters:
      concreteShiftOld - Concrete shift to be removed
    • removeConcreteShift

      public boolean removeConcreteShift(Long concreteShiftId)
      Description copied from interface: ISchedulerController
      This method removes a concrete shift from the database.
      Specified by:
      removeConcreteShift in interface ISchedulerController
      Parameters:
      concreteShiftId - ID of the concrete shift to be removed
      Returns:
      Boolean that represents if the deletion was successful
    • addConcreteShift

      public Schedule addConcreteShift(RegisterConcreteShiftDTO registerConcreteShiftDTO, boolean forced) throws ConcreteShiftException, IllegalScheduleException
      Description copied from interface: ISchedulerController
      This method adds a new concrete shift to an existing schedule; the concrete shift is described by the DTO parameter.
      Specified by:
      addConcreteShift in interface ISchedulerController
      Parameters:
      registerConcreteShiftDTO - DTO class that describes the new concrete shift
      forced - If true, the concrete shift will be added if it respects all the non-violable constraints; if false, the concrete shift will be added only if it respects all the existing constraints.
      Returns:
      An instance of the updated shift schedule
      Throws:
      ConcreteShiftException - Rised if the DTO parameter describes a non-existing concrete shift
      IllegalScheduleException - Rised if the new concrete shift makes the schedule illegal
    • modifyConcreteShift

      public Schedule modifyConcreteShift(ModifyConcreteShiftDTO modifyConcreteShiftDTO) throws IllegalScheduleException
      Description copied from interface: ISchedulerController
      This method modifies an existing concrete shift. In particular, it removes the existing concrete shifts, checks if the new version of the concrete shift respects all the constraints and, if the checks succeed, then saves the new version of the concrete shift into the database. Instead, if there are some violated constraints, then the old version of the concrete shift is saved into the database again.
      Specified by:
      modifyConcreteShift in interface ISchedulerController
      Parameters:
      modifyConcreteShiftDTO - DTO instance representing the changes to make in an existing concrete shift
      Returns:
      An instance of the updated shift schedule containing the modified concrete shift
      Throws:
      IllegalScheduleException - Rised if the new concrete shift makes the schedule illegal
    • readSchedules

      public List<ScheduleDTO> readSchedules()
      Description copied from interface: ISchedulerController
      This method retrieves all the existing schedules from the database.
      Specified by:
      readSchedules in interface ISchedulerController
      Returns:
      List of DTO instances representing all the existing schedules to be delivered to the frontend
    • readIllegalSchedules

      public List<ScheduleDTO> readIllegalSchedules()
      Description copied from interface: ISchedulerController
      This method retrieves the illegal schedules from the database.
      Specified by:
      readIllegalSchedules in interface ISchedulerController
      Returns:
      List of DTO instances representing the illegal schedules to be delivered to the frontend
    • removeSchedule

      public boolean removeSchedule(long id)
      Description copied from interface: ISchedulerController
      This method removes an existing shift schedule. This operation can be performed correctly only if the schedule is in the future and not in the past.
      Specified by:
      removeSchedule in interface ISchedulerController
      Parameters:
      id - ID of the shift schedule to be removed
      Returns:
      Boolean that represents if the deletion was successful
    • check

      public boolean check(LocalDate startNewSchedule, LocalDate endNewSchedule)
      This method verifies the existence of a shift schedule for the dates we want to plan.
      Parameters:
      startNewSchedule - First date to be planned for a shift schedule
      endNewSchedule - Last date to be planned for a shift schedule
      Returns:
      False if there already exists a shift schedule for the dates we want to plan, true otherwise