Class WeekDefinitionService


  • public final class WeekDefinitionService
    extends java.lang.Object
    Service class of a week definition
    Author:
    Laurent Payen
    • Method Detail

      • createWeekDefinition

        public static WeekDefinition createWeekDefinition​(int nIdReservationRule,
                                                          java.time.LocalDate dateOfApply,
                                                          java.time.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,
                                                java.time.LocalDate dateOfApply,
                                                java.time.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 java.util.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 java.util.List<WeekDefinition> findWeekDefinitionByDateOfApply​(int nIdForm,
                                                                                     java.time.LocalDate startingDate,
                                                                                     java.time.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,
                                                                                       java.time.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,
                                                                              java.time.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,
                                                            java.time.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 java.util.HashMap<java.time.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 java.time.LocalTime getMinStartingTimeOfAListOfWeekDefinition​(java.util.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 java.time.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 java.time.LocalTime getMaxEndingTimeOfAListOfWeekDefinition​(java.util.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 java.time.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​(java.util.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 java.util.Set<java.lang.String> getSetDaysOfWeekOfAListOfWeekDefinitionForFullCalendar​(java.util.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 java.util.Set<java.lang.Integer> getOpenDaysOfWeek​(java.util.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 java.util.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