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.slot;
35  
36  import java.io.Serializable;
37  import java.sql.Timestamp;
38  import java.time.LocalDate;
39  import java.time.LocalDateTime;
40  import java.time.LocalTime;
41  
42  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
43  
44  /**
45   * The business class of the slot
46   * 
47   * @author Laurent Payen
48   *
49   */
50  @JsonIgnoreProperties( ignoreUnknown = true )
51  public final class Slot implements Serializable
52  {
53  
54      /**
55       * Serial version UID
56       */
57      private static final long serialVersionUID = 9054234926836931062L;
58  
59      /**
60       * Id of the slot
61       */
62      private int _nIdSlot;
63  
64      /**
65       * Date of the slot
66       */
67      private LocalDate _date;
68  
69      /**
70       * Starting Time of The Slot
71       */
72      private LocalTime _startingTime;
73  
74      /**
75       * Ending Time Of The Slot
76       */
77      private LocalTime _endingTime;
78  
79      /**
80       * Starting date (Date + Time) of the slot
81       */
82      private LocalDateTime _startingDateTime;
83  
84      /**
85       * Ending date (Date + Time) of the slot
86       */
87      private LocalDateTime _endingDateTime;
88  
89      /**
90       * Indicate whether the slot is open or not
91       */
92      private boolean _bIsOpen;
93  
94      /**
95       * Indicate whether the slot has been created with the specific week configuration
96       */
97      private boolean _bIsSpecific;
98  
99      /**
100      * Indicate whether the slot is passed or not
101      */
102     private boolean _bIsPassed = Boolean.FALSE;
103 
104     /**
105      * Max Capacity of the Slot
106      */
107     private int _nMaxCapacity;
108 
109     /**
110      * Nb Remaining Places of the slot
111      */
112     private int _nNbRemainingPlaces;
113 
114     /**
115      * Nb Potential Remaining Places of the slot
116      */
117     private int _nNbPotentialRemainingPlaces;
118 
119     /**
120      * Nb Places Taken
121      */
122     private int _nNbPlacesTaken;
123 
124     /**
125      * Form Id the slot belongs to (foreign key)
126      */
127     private int _nIdForm;
128 
129     /**
130      * Get the id of the slot
131      * 
132      * @return the id of the slot
133      */
134     public int getIdSlot( )
135     {
136         return _nIdSlot;
137     }
138 
139     /**
140      * Get the date of the slot
141      * 
142      * @return the date of the slot
143      */
144     public LocalDate getDate( )
145     {
146         return _date;
147     }
148 
149     /**
150      * Set the date of the slot
151      * 
152      * @param date
153      *            the date to set
154      */
155     public void setDate( LocalDate date )
156     {
157         this._date = date;
158     }
159 
160     /**
161      * Get the starting time of the slot
162      * 
163      * @return the starting time of the slot
164      */
165     public LocalTime getStartingTime( )
166     {
167         return _startingTime;
168     }
169 
170     /**
171      * Set the starting time of the slot
172      * 
173      * @param startingTime
174      *            the starting time to set
175      */
176     public void setStartingTime( LocalTime startingTime )
177     {
178         this._startingTime = startingTime;
179     }
180 
181     /**
182      * Get the ending time of the slot
183      * 
184      * @return the ending time of the slot
185      */
186     public LocalTime getEndingTime( )
187     {
188         return _endingTime;
189     }
190 
191     /**
192      * Set the ending time of the slot
193      * 
194      * @param endingTime
195      *            the ending time to set
196      */
197     public void setEndingTime( LocalTime endingTime )
198     {
199         this._endingTime = endingTime;
200     }
201 
202     /**
203      * Set the id of the slot
204      * 
205      * @param nIdSlot
206      *            the id to set
207      */
208     public void setIdSlot( int nIdSlot )
209     {
210         this._nIdSlot = nIdSlot;
211     }
212 
213     /**
214      * Get the starting date of the slot
215      * 
216      * @return the starting date of the slot
217      */
218     public LocalDateTime getStartingDateTime( )
219     {
220         return _startingDateTime;
221     }
222 
223     /**
224      * Get the starting date of the slot
225      * 
226      * @return the starting date of the slot (in Sql Timestamp format)
227      */
228     public Timestamp getStartingTimestampDate( )
229     {
230         Timestamp timestamp = null;
231         if ( this._startingDateTime != null )
232         {
233             timestamp = Timestamp.valueOf( this._startingDateTime );
234         }
235         return timestamp;
236     }
237 
238     /**
239      * Set the starting date of the slot
240      * 
241      * @param startingDateTime
242      *            the starting date to set
243      */
244     public void setStartingDateTime( LocalDateTime startingDateTime )
245     {
246         this._startingDateTime = startingDateTime;
247     }
248 
249     /**
250      * Set the starting date of the slot
251      * 
252      * @param startingTimeStampDate
253      *            the starting date to set (in Timestamp format)
254      */
255     public void setStartingTimeStampDate( Timestamp startingTimeStampDate )
256     {
257         if ( startingTimeStampDate != null )
258         {
259             this._startingDateTime = startingTimeStampDate.toLocalDateTime( );
260         }
261     }
262 
263     /**
264      * Get the ending date of the slot
265      * 
266      * @return the ending date of the slot
267      */
268     public LocalDateTime getEndingDateTime( )
269     {
270         return _endingDateTime;
271     }
272 
273     /**
274      * Get the ending date of the slot
275      * 
276      * @return the ending date of the slot (in Sql Timestamp format)
277      */
278     public Timestamp getEndingTimestampDate( )
279     {
280         Timestamp timestamp = null;
281         if ( this._endingDateTime != null )
282         {
283             timestamp = Timestamp.valueOf( _endingDateTime );
284         }
285         return timestamp;
286     }
287 
288     /**
289      * Set the ending date of the slot
290      * 
291      * @param endingDateTime
292      *            the ending date of the slot (in LocalDateTime format)
293      */
294     public void setEndingDateTime( LocalDateTime endingDateTime )
295     {
296         this._endingDateTime = endingDateTime;
297     }
298 
299     /**
300      * Set the ending date of the slot
301      * 
302      * @param endingTimeStampDate
303      *            the ending date of the slot (in Timestamp format)
304      */
305     public void setEndingTimeStampDate( Timestamp endingTimeStampDate )
306     {
307         if ( endingTimeStampDate != null )
308         {
309             this._endingDateTime = endingTimeStampDate.toLocalDateTime( );
310         }
311     }
312 
313     /**
314      * Indicate if the slot is open or not
315      * 
316      * @return true if the slot is open
317      */
318     public boolean getIsOpen( )
319     {
320         return _bIsOpen;
321     }
322 
323     /**
324      * Set the boolean open value of the slot
325      * 
326      * @param bIsOpen
327      *            the boolean open value to set
328      */
329     public void setIsOpen( boolean bIsOpen )
330     {
331         this._bIsOpen = bIsOpen;
332     }
333 
334     /**
335      * Indicate if the slot is specific or not
336      * 
337      * @return true if the slot is specific
338      */
339     public boolean getIsSpecific( )
340     {
341         return _bIsSpecific;
342     }
343 
344     /**
345      * Set the boolean specific value of the slot
346      * 
347      * @param bIsSpecific
348      *            the boolean open value to set
349      */
350     public void setIsSpecific( boolean bIsSpecific )
351     {
352         this._bIsSpecific = bIsSpecific;
353     }
354 
355     /**
356      * Indicate if the slot is passed or not
357      * 
358      * @return true if the slot is specific
359      */
360     public boolean getIsPassed( )
361     {
362         return _bIsPassed;
363     }
364 
365     /**
366      * Set the boolean passed value of the slot
367      * 
368      * @param bIsSpecific
369      *            the boolean open value to set
370      */
371     public void setIsPassed( boolean bIsPassed )
372     {
373         this._bIsPassed = bIsPassed;
374     }
375 
376     /**
377      * Get number of remaining places of the slot
378      * 
379      * @return the number of remaining places of the slot
380      */
381     public int getNbRemainingPlaces( )
382     {
383         return _nNbRemainingPlaces;
384     }
385 
386     /**
387      * Set the number of remaining places of the slot
388      * 
389      * @param nNbRemainingPlaces
390      *            the number of remaining places
391      */
392     public void setNbRemainingPlaces( int nNbRemainingPlaces )
393     {
394         this._nNbRemainingPlaces = nNbRemainingPlaces;
395     }
396 
397     /**
398      * Get the potential remaining places on the slot
399      * 
400      * @return the number of potential ramaining places
401      */
402     public int getNbPotentialRemainingPlaces( )
403     {
404         return _nNbPotentialRemainingPlaces;
405     }
406 
407     /**
408      * Set the potential number of remaining places on the slot
409      * 
410      * @param nNbPotentialRemainingPlaces
411      *            the number to set
412      */
413     public void setNbPotentialRemainingPlaces( int nNbPotentialRemainingPlaces )
414     {
415         this._nNbPotentialRemainingPlaces = nNbPotentialRemainingPlaces;
416     }
417 
418     /**
419      * Get the nb places taken on the slot
420      * 
421      * @return the number of places taken
422      */
423     public int getNbPlacesTaken( )
424     {
425         return _nNbPlacesTaken;
426     }
427 
428     /**
429      * Set the number of places taken on the slot
430      * 
431      * @param nNbPlacesTaken
432      *            the number to set
433      */
434     public void setNbPlacestaken( int nNbPlacestaken )
435     {
436         this._nNbPlacesTaken = nNbPlacestaken;
437     }
438 
439     /**
440      * Get the maximum capacity of the slot
441      * 
442      * @return the maximum capacity
443      */
444     public int getMaxCapacity( )
445     {
446         return _nMaxCapacity;
447     }
448 
449     /**
450      * Set the maximum capacity of the slot
451      * 
452      * @param nMaxCapacity
453      *            the maximum capacity to set
454      */
455     public void setMaxCapacity( int nMaxCapacity )
456     {
457         this._nMaxCapacity = nMaxCapacity;
458     }
459 
460     /**
461      * Get the Form Id the slot belongs to
462      * 
463      * @return the FOrm Id
464      */
465     public int getIdForm( )
466     {
467         return _nIdForm;
468     }
469 
470     /**
471      * Set the Form Id the Slot belongs to
472      * 
473      * @param nIdForm
474      *            the Form Id to set
475      */
476     public void setIdForm( int nIdForm )
477     {
478         this._nIdForm = nIdForm;
479     }
480 
481 }