fr.paris.lutece.plugins.appointment.service
Class AppointmentService

java.lang.Object
  extended by fr.paris.lutece.plugins.appointment.service.AppointmentService

public class AppointmentService
extends Object

Service to manage calendars


Field Summary
static String BEAN_NAME
          Name of the bean of the service
 
Constructor Summary
AppointmentService()
           
 
Method Summary
 void checkFormDays(AppointmentForm form)
          Check that a form has every days created for its coming weeks
 List<AppointmentDay> computeDayList(AppointmentForm form)
          Compute the list of days with the list of slots for a given form and a given week.
 List<AppointmentSlot> computeDaySlots(AppointmentDay day)
          Get the list of appointment slots for a given day
 List<AppointmentSlot> computeDaySlots(AppointmentDay day, int nDayOfWeek)
          Get the list of appointment slots for a given day
 String computeRefAppointment(Appointment appointment)
          Compute the unique reference of an appointment
 List<AppointmentDay> findAndComputeDayList(AppointmentForm form, int nOffsetWeeks, boolean bLoadSlotsFromDb)
          Find a list of days with the list of slots for a given form and a given week, and compute missing data.
 AppointmentDay getAppointmentDayFromForm(AppointmentForm appointmentForm)
          Get an appointment day from an appointment form.
 Date getDateLastMonday()
          Get the date of the last Monday.
 Date getDateMonday(int nOffsetWeek)
          Get the date of a Monday.
 List<AppointmentDay> getDayListForCalendar(AppointmentForm form, int nOffsetWeeks, boolean bIsForFront)
          Get the list of days of a form to display them in a calendar.
 int getDayOfWeek(Date date)
          Get the day of the week of a date.
 String getFormatedStringTime(int nHour, int nMinute)
          Get a string that describe a given time
 List<String> getListAppointmentTimes(int nAppointmentDuration, int nOpeningHour, int nOpeningMinutes, int nClosingHour, int nClosingMinutes)
          Get a list of string that describes times of appointments available in for a day
static String[] getListDaysOfWeek()
          Get a string array containing a list of i118n keys of days of week
 int getListTimeBegin(List<AppointmentDay> listDays, AppointmentForm form, List<String> listTimeBegin)
          Get the list of begin times for a given list of days
 int getRefSizeRandomPart()
          Get the size of the random part of the reference of appointments
static AppointmentService getService()
          Get an instance of the service
 int parseInt(String strNumber)
          Parse a string representing a positive or negative integer
 void resetFormDays(AppointmentForm form)
          Reset days and slots of a form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEAN_NAME

public static final String BEAN_NAME
Name of the bean of the service

See Also:
Constant Field Values
Constructor Detail

AppointmentService

public AppointmentService()
Method Detail

getService

public static AppointmentService getService()
Get an instance of the service

Returns:
An instance of the service

getListDaysOfWeek

public static String[] getListDaysOfWeek()
Get a string array containing a list of i118n keys of days of week

Returns:
A string array containing a list of i118n keys of days of week

computeDayList

public List<AppointmentDay> computeDayList(AppointmentForm form)
Compute the list of days with the list of slots for a given form and a given week. The number of free places of slots are initialized to the number of available places.

Parameters:
form - The form to get days of. Opening and closing hour of the form are updated by this method
Returns:
The list of days

findAndComputeDayList

public List<AppointmentDay> findAndComputeDayList(AppointmentForm form,
                                                  int nOffsetWeeks,
                                                  boolean bLoadSlotsFromDb)
Find a list of days with the list of slots for a given form and a given week, and compute missing data. The number of free places of slots are initialized to the number of available places.

Parameters:
form - The form to get days of. Opening and closing hour of the form are updated by this method
nOffsetWeeks - The offset of the week to get
bLoadSlotsFromDb - True if slots should be loaded from the database, false if they should be computed
Returns:
The list of days

getDayListForCalendar

public List<AppointmentDay> getDayListForCalendar(AppointmentForm form,
                                                  int nOffsetWeeks,
                                                  boolean bIsForFront)
Get the list of days of a form to display them in a calendar. Days and slots are not computed by this method but loaded from the database. The number of free places of each slot is also loaded. Pasted days are marked as closed.

Parameters:
form - The form the get days of.
nOffsetWeeks - The offset of weeks (0 for the current week, 1 for the next, ...).
bIsForFront - True if the calendar is for Front Office, false if it is for Back Office. If the calendar is for Front Office, then the n next days will be closed (n is set by the AppointmentForm.getMinDaysBeforeAppointment() attribute).
Returns:
The list of days found

computeDaySlots

public List<AppointmentSlot> computeDaySlots(AppointmentDay day)
Get the list of appointment slots for a given day

Parameters:
day - the day to initialize
Returns:
The list of slots computed from the day

computeDaySlots

public List<AppointmentSlot> computeDaySlots(AppointmentDay day,
                                             int nDayOfWeek)
Get the list of appointment slots for a given day

Parameters:
day - the day to initialize. The date of the day will NOT be used
nDayOfWeek - The day of the week of the day
Returns:
The list of slots computed from the day

getListAppointmentTimes

public List<String> getListAppointmentTimes(int nAppointmentDuration,
                                            int nOpeningHour,
                                            int nOpeningMinutes,
                                            int nClosingHour,
                                            int nClosingMinutes)
Get a list of string that describes times of appointments available in for a day

Parameters:
nAppointmentDuration - The appointment duration
nOpeningHour - The opening hour of the day
nOpeningMinutes - The opening minutes of the day
nClosingHour - The closing hour of the day
nClosingMinutes - The closing minutes of the day
Returns:
The list of times of appointments formatted as HHhMM. The closing time is not included in the list.

getFormatedStringTime

public String getFormatedStringTime(int nHour,
                                    int nMinute)
Get a string that describe a given time

Parameters:
nHour - The hour of the time to describe
nMinute - The minute of the time to describe
Returns:
The string describing the given time. the returned string match the pattern HHhMM

getAppointmentDayFromForm

public AppointmentDay getAppointmentDayFromForm(AppointmentForm appointmentForm)
Get an appointment day from an appointment form. The date of the day and its opening are not initialized.

Parameters:
appointmentForm - The form
Returns:
The day

getDayOfWeek

public int getDayOfWeek(Date date)
Get the day of the week of a date.

Parameters:
date - The date to get the day of the week of
Returns:
1 for Monday, 2 for Tuesday, ..., 7 for Sunday

checkFormDays

public void checkFormDays(AppointmentForm form)
Check that a form has every days created for its coming weeks

Parameters:
form - The form to check

getDateLastMonday

public Date getDateLastMonday()
Get the date of the last Monday.

Returns:
The date of the last Monday

getDateMonday

public Date getDateMonday(int nOffsetWeek)
Get the date of a Monday.

Parameters:
nOffsetWeek - The offset of the week (0 for the current week, 1 for the next one, ...)
Returns:
The date of the Monday of the requested week

resetFormDays

public void resetFormDays(AppointmentForm form)
Reset days and slots of a form. Each day and each associated slot of the form that are associated with a future date are removed and re-created

Parameters:
form - The form to rest days of

getListTimeBegin

public int getListTimeBegin(List<AppointmentDay> listDays,
                            AppointmentForm form,
                            List<String> listTimeBegin)
Get the list of begin times for a given list of days

Parameters:
listDays - The list of days to consider
form - The form associated with the given days
listTimeBegin - The list to insert begin times in
Returns:
The minimum duration of appointments

getRefSizeRandomPart

public int getRefSizeRandomPart()
Get the size of the random part of the reference of appointments

Returns:
The size of the random part of the reference of appointments

computeRefAppointment

public String computeRefAppointment(Appointment appointment)
Compute the unique reference of an appointment

Parameters:
appointment - The appointment
Returns:
The unique reference of an appointment

parseInt

public int parseInt(String strNumber)
Parse a string representing a positive or negative integer

Parameters:
strNumber - The string to parse
Returns:
The integer value of the number represented by the string, or 0 if the string could not be parsed


Copyright © 2014 Mairie de Paris. All Rights Reserved.