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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassignWeekDefinition(int nIdForm, WeekDefinition newWeek)Assign a week to the calendarstatic WeekDefinitioncreateWeekDefinition(int nIdReservationRule, LocalDate dateOfApply, LocalDate endingDateOfApply)Create a week definition in databasestatic voidfillInWeekDefinition(WeekDefinition weekDefinition, int nIdReservationRule, LocalDate dateOfApply, LocalDate endingDateOfApply)Fill the week definition object with the given parametersstatic fr.paris.lutece.util.ReferenceListfindAllDateOfWeekDefinition(int nIdForm)Build a reference list of all the week definitions of a formstatic HashMap<LocalDate,WeekDefinition>findAllWeekDefinition(int nIdForm)Find all the week definition of a formstatic List<WeekDefinition>findByReservationRule(int nIdReservationRule)Get the week definitions of a form for reservation rulestatic List<WeekDefinition>findListWeekDefinition(int nIdForm)Fin all the week definition of a formstatic WeekDefinitionfindNextWeekDefinition(int nIdForm, LocalDate previousDateOfApply)Return, if it exists, the next week definition after a given datestatic List<WeekDefinition>findWeekDefinitionByDateOfApply(int nIdForm, LocalDate startingDate, LocalDate endingDate)Find a week definition of a form by date of applystatic WeekDefinitionfindWeekDefinitionById(int nIdWeekDefinition)Find a week definition by its primary key and set its working daysstatic WeekDefinitionfindWeekDefinitionByIdFormAndClosestToDateOfApply(int nIdForm, LocalDate dateOfApply)Find a week definition of a form and a date of applystatic WeekDefinitionfindWeekDefinitionByIdFormAndDateOfApply(int nIdForm, LocalDate dateOfApply)Find the weekdefinition of a form on a specific datestatic WeekDefinitionfindWeekDefinitionLightById(int nIdWeekDefinition)Find a week definition with its primary keystatic LocalTimegetMaxEndingTimeOfAListOfWeekDefinition(List<ReservationRule> listReservationRules)Return the max ending time of a list of week definitionsstatic LocalTimegetMaxEndingTimeOfAWeekDefinition(ReservationRule reservationRule)Get the max ending time of a week definitionstatic intgetMinDurationTimeSlotOfAListOfWeekDefinition(List<ReservationRule> listReservationRules)Get the min duration of a time slot of a list of week definitionstatic intgetMinDurationTimeSlotOfAWeekDefinition(ReservationRule reservationRule)Get the min duration of a time slot of a week definitionstatic LocalTimegetMinStartingTimeOfAListOfWeekDefinition(List<ReservationRule> listReservationRules)Return the min starting time of a list of week definitionsstatic LocalTimegetMinStartingTimeOfAWeekDefinition(ReservationRule reservationRule)Return the min starting time of a week definitionstatic Set<Integer>getOpenDaysOfWeek(List<ReservationRule> listReservationRules)Get the set of the open days of all the week definitonsstatic Set<String>getSetDaysOfWeekOfAListOfWeekDefinitionForFullCalendar(List<ReservationRule> listReservationRules)Get the working days integer enum values of a list of week definitionsstatic voidremoveWeekDefinition(WeekDefinition weekDefinition)Remove the weekdefinition (and by cascade the working days and the time slots)static WeekDefinitionsaveWeekDefinition(WeekDefinition weekDefinition)Save a week definition
-
-
-
Method Detail
-
createWeekDefinition
public static WeekDefinition createWeekDefinition(int nIdReservationRule, LocalDate dateOfApply, LocalDate endingDateOfApply)
Create a week definition in database- Parameters:
nIdReservationRule- the nIdReservationRuledateOfApply- 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 innIdForm- the form iddateOfApply- 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 formstartingDate- the starting dateendingDate- 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 IddateOfApply- 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 IddateOfApply- 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 idpreviousDateOfApply- 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 fromnewWeek- the week to assign
-
-