Class WeekDefinitionService

java.lang.Object
fr.paris.lutece.plugins.appointment.service.WeekDefinitionService

public final class WeekDefinitionService extends Object
Service class of a week definition
Author:
Laurent Payen
  • Method Details

    • createWeekDefinition

      public static WeekDefinition createWeekDefinition(int nIdReservationRule, LocalDate dateOfApply, LocalDate endingDateOfApply)
      Create a week definition in database
      Parameters:
      nIdReservationRule - the nIdReservationRule
      dateOfApply - the date of the week definition
      Returns:
      the week definition created
    • removeWeekDefinition

      public static void removeWeekDefinition(WeekDefinition weekDefinition)
      Remove the weekdefinition (and by cascade the working days and the time slots)
      Parameters:
      nIdWeekDefinition - the id of the week definition to delete
    • saveWeekDefinition

      public static WeekDefinition saveWeekDefinition(WeekDefinition weekDefinition)
      Save a week definition
      Parameters:
      weekDefinition - the week definition to save
      Returns:
      the week definition saved
    • fillInWeekDefinition

      public static void fillInWeekDefinition(WeekDefinition weekDefinition, int nIdReservationRule, LocalDate dateOfApply, LocalDate endingDateOfApply)
      Fill the week definition object with the given parameters
      Parameters:
      weekDefinition - the week definition to fill in
      nIdForm - the form id
      dateOfApply - the date of the week definition
    • findListWeekDefinition

      public static List<WeekDefinition> findListWeekDefinition(int nIdForm)
      Fin all the week definition of a form
      Parameters:
      nIdForm - the form Id
      Returns:
      the list of all the week definition of the form
    • findWeekDefinitionByDateOfApply

      public static List<WeekDefinition> findWeekDefinitionByDateOfApply(int nIdForm, LocalDate startingDate, LocalDate endingDate)
      Find a week definition of a form by date of apply
      Parameters:
      nIdForm - the id form
      startingDate - the starting date
      endingDate - the ending date
      Returns:
      the list of week definition
    • findWeekDefinitionByIdFormAndClosestToDateOfApply

      public static WeekDefinition findWeekDefinitionByIdFormAndClosestToDateOfApply(int nIdForm, LocalDate dateOfApply)
      Find a week definition of a form and a date of apply
      Parameters:
      nIdForm - the form Id
      dateOfApply - the date of apply of the week definition
      Returns:
      the week definition with the closest date of apply
    • findWeekDefinitionByIdFormAndDateOfApply

      public static WeekDefinition findWeekDefinitionByIdFormAndDateOfApply(int nIdForm, LocalDate dateOfApply)
      Find the weekdefinition of a form on a specific date
      Parameters:
      nIdForm - the form Id
      dateOfApply - the date of the weekdefinition
      Returns:
      the weekdefinition object
    • findNextWeekDefinition

      public static WeekDefinition findNextWeekDefinition(int nIdForm, LocalDate previousDateOfApply)
      Return, if it exists, the next week definition after a given date
      Parameters:
      nIdForm - the form id
      previousDateOfApply - the previous date of the previous week definition
      Returns:
      the next week definition if it exists, null otherwise
    • findWeekDefinitionLightById

      public static WeekDefinition findWeekDefinitionLightById(int nIdWeekDefinition)
      Find a week definition with its primary key
      Parameters:
      nIdWeekDefinition - the week definition id
      Returns:
      the week definition found
    • findWeekDefinitionById

      public static WeekDefinition findWeekDefinitionById(int nIdWeekDefinition)
      Find a week definition by its primary key and set its working days
      Parameters:
      nIdWeekDefinition - the week definition id
      Returns:
      the week definition and its working days
    • findAllDateOfWeekDefinition

      public static fr.paris.lutece.util.ReferenceList findAllDateOfWeekDefinition(int nIdForm)
      Build a reference list of all the week definitions of a form
      Parameters:
      nIdForm - the form Id
      Returns:
      a reference list of all the week definitions of a form (Id of the week definition / date of apply of the week definition
    • findAllWeekDefinition

      public static HashMap<LocalDate,WeekDefinition> findAllWeekDefinition(int nIdForm)
      Find all the week definition of a form
      Parameters:
      nIdForm - the form id
      Returns:
      a HashMap with the date of apply in key and the week definition in value
    • getMinStartingTimeOfAListOfWeekDefinition

      public static LocalTime getMinStartingTimeOfAListOfWeekDefinition(List<ReservationRule> listReservationRules)
      Return the min starting time of a list of week definitions
      Parameters:
      listWeekDefinition - the list of week definitions
      Returns:
      the mini starting time
    • getMinStartingTimeOfAWeekDefinition

      public static LocalTime getMinStartingTimeOfAWeekDefinition(ReservationRule reservationRule)
      Return the min starting time of a week definition
      Parameters:
      weekDefinition - the week definition
      Returns:
      the min starting time of the week definition
    • getMaxEndingTimeOfAListOfWeekDefinition

      public static LocalTime getMaxEndingTimeOfAListOfWeekDefinition(List<ReservationRule> listReservationRules)
      Return the max ending time of a list of week definitions
      Parameters:
      listWeekDefinition - the list of week definitions
      Returns:
      the max ending time of the list of week definitions
    • getMaxEndingTimeOfAWeekDefinition

      public static LocalTime getMaxEndingTimeOfAWeekDefinition(ReservationRule reservationRule)
      Get the max ending time of a week definition
      Parameters:
      weekDefinition - the week definition
      Returns:
      the max ending time of the week definition
    • getMinDurationTimeSlotOfAListOfWeekDefinition

      public static int getMinDurationTimeSlotOfAListOfWeekDefinition(List<ReservationRule> listReservationRules)
      Get the min duration of a time slot of a list of week definition
      Parameters:
      listWeekDefinition - the list of the week definitions
      Returns:
      the min duration time slot
    • getMinDurationTimeSlotOfAWeekDefinition

      public static int getMinDurationTimeSlotOfAWeekDefinition(ReservationRule reservationRule)
      Get the min duration of a time slot of a week definition
      Parameters:
      weekDefinition - the week definition
      Returns:
      the min duration time slot
    • getSetDaysOfWeekOfAListOfWeekDefinitionForFullCalendar

      public static Set<String> getSetDaysOfWeekOfAListOfWeekDefinitionForFullCalendar(List<ReservationRule> listReservationRules)
      Get the working days integer enum values of a list of week definitions
      Parameters:
      listWeekDefinition - the list of week definitions
      Returns:
      a set of the working days (integer value in a week : 1-> Monday ...) // The fullCalendar library is zero-base (Sunday=0)
    • getOpenDaysOfWeek

      public static Set<Integer> getOpenDaysOfWeek(List<ReservationRule> listReservationRules)
      Get the set of the open days of all the week definitons
      Parameters:
      listWeekDefinition - the list of week definitions
      Returns:
      the set of the open days
    • findByReservationRule

      public static List<WeekDefinition> findByReservationRule(int nIdReservationRule)
      Get the week definitions of a form for reservation rule
      Parameters:
      nIdReservationRule -
      Returns:
      list of week definition
    • assignWeekDefinition

      public static void assignWeekDefinition(int nIdForm, WeekDefinition newWeek)
      Assign a week to the calendar
      Parameters:
      nIdForm - the id from
      newWeek - the week to assign