View Javadoc
1   /*
2    * Copyright (c) 2002-2018, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.appointment.business.planning;
35  
36  import java.io.Serializable;
37  import java.sql.Time;
38  import java.time.LocalDateTime;
39  import java.time.LocalTime;
40  
41  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
42  
43  /**
44   * Business class of the time slot
45   * 
46   * @author Laurent Payen
47   *
48   */
49  @JsonIgnoreProperties( ignoreUnknown = true )
50  public final class TimeSlot implements Serializable
51  {
52  
53      /**
54       * Serial version UID
55       */
56      private static final long serialVersionUID = 3543470088706843432L;
57  
58      /**
59       * Id of the time slot
60       */
61      private int _nIdTimeSlot;
62  
63      /**
64       * Starting time of the slot
65       */
66      private LocalTime _startingTime;
67  
68      /**
69       * The starting time + date Need to have the date for the display
70       */
71      private LocalDateTime _startingDateTime;
72  
73      /**
74       * Ending time of the slot
75       */
76      private LocalTime _endingTime;
77  
78      /**
79       * The endind time + date need to have the date for the display
80       */
81      private LocalDateTime _endingDateTime;
82  
83      /**
84       * Indicate whether the time slot is open or not
85       */
86      private boolean _bIsOpen;
87  
88      /**
89       * Max capacity for this slot
90       */
91      private int _nMaxCapacity;
92      /**
93       * Working day id the time slot belongs to
94       */
95      private int _nIdWorkingDay;
96  
97      /**
98       * Get the id of the time slot
99       * 
100      * @return
101      */
102     public int getIdTimeSlot( )
103     {
104         return _nIdTimeSlot;
105     }
106 
107     /**
108      * Set the id of the time slot
109      * 
110      * @param nIdTimeSlot
111      *            the id to set
112      */
113     public void setIdTimeSlot( int nIdTimeSlot )
114     {
115         this._nIdTimeSlot = nIdTimeSlot;
116     }
117 
118     /**
119      * Get the starting time of the time slot
120      * 
121      * @return the starting time of the time slot
122      */
123     public LocalTime getStartingTime( )
124     {
125         return _startingTime;
126     }
127 
128     /**
129      * Get the starting time of the time slot (in sql time)
130      * 
131      * @return the starting time
132      */
133     public Time getStartingTimeSqlTime( )
134     {
135         Time time = null;
136         if ( _startingTime != null )
137         {
138             time = Time.valueOf( _startingTime );
139         }
140         return time;
141     }
142 
143     /**
144      * Set the starting time of the time slot
145      * 
146      * @param startingTime
147      *            the starting time to set
148      */
149     public void setStartingTime( LocalTime startingTime )
150     {
151         this._startingTime = startingTime;
152     }
153 
154     /**
155      * Set the starting time of the time slot
156      * 
157      * @param startingTime
158      *            the starting time (in sql time)
159      */
160     public void setSqlStartingTime( Time startingTime )
161     {
162         if ( startingTime != null )
163         {
164             this._startingTime = startingTime.toLocalTime( );
165         }
166     }
167 
168     /**
169      * Get the ending time of the time slot
170      * 
171      * @return the ending time of the time slot
172      */
173     public LocalTime getEndingTime( )
174     {
175         return _endingTime;
176     }
177 
178     /**
179      * Get the ending time in sql time
180      * 
181      * @return the ending time in sql time
182      */
183     public Time getEndingTimeSqlTime( )
184     {
185         Time time = null;
186         if ( this._endingTime != null )
187         {
188             time = Time.valueOf( _endingTime );
189         }
190         return time;
191     }
192 
193     /**
194      * Set the ending time of the time slot
195      * 
196      * @param endingTime
197      *            the ending time to set
198      */
199     public void setEndingTime( LocalTime endingTime )
200     {
201         this._endingTime = endingTime;
202     }
203 
204     /**
205      * Set the ending time of the time slot
206      * 
207      * @param endingTime
208      *            the ending time (in sql time format)
209      */
210     public void setSqlEndingTime( Time endingTime )
211     {
212         if ( endingTime != null )
213         {
214             this._endingTime = endingTime.toLocalTime( );
215         }
216     }
217 
218     /**
219      * Indicate whether the time slot is open or not
220      * 
221      * @return true if the time slot is open
222      */
223     public boolean getIsOpen( )
224     {
225         return _bIsOpen;
226     }
227 
228     /**
229      * Set the opening boolean value of the time slot
230      * 
231      * @param bIsOpen
232      *            the opening boolean value
233      */
234     public void setIsOpen( boolean bIsOpen )
235     {
236         this._bIsOpen = bIsOpen;
237     }
238 
239     /**
240      * Get the maximum capacity of the slot
241      * 
242      * @return the maximum capacity
243      */
244     public int getMaxCapacity( )
245     {
246         return _nMaxCapacity;
247     }
248 
249     /**
250      * Set the maximum capacity of the slot
251      * 
252      * @param nMaxCapacity
253      *            the maximum capacity
254      */
255     public void setMaxCapacity( int nMaxCapacity )
256     {
257         this._nMaxCapacity = nMaxCapacity;
258     }
259 
260     /**
261      * Get the working day id the time slot belongs to
262      * 
263      * @return the working day id the time slot belongs to
264      */
265     public int getIdWorkingDay( )
266     {
267         return _nIdWorkingDay;
268     }
269 
270     /**
271      * Set the working day id the time slot belongs to
272      * 
273      * @param nIdWorkingDay
274      *            the working day id to set
275      */
276     public void setIdWorkingDay( int nIdWorkingDay )
277     {
278         this._nIdWorkingDay = nIdWorkingDay;
279     }
280 
281     public LocalDateTime getStartingDateTime( )
282     {
283         return _startingDateTime;
284     }
285 
286     public void setStartingDateTime( LocalDateTime startingDateTime )
287     {
288         this._startingDateTime = startingDateTime;
289     }
290 
291     public LocalDateTime getEndingDateTime( )
292     {
293         return _endingDateTime;
294     }
295 
296     public void setEndingDateTime( LocalDateTime endingDateTime )
297     {
298         this._endingDateTime = endingDateTime;
299     }
300 
301 }