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.form;
35  
36  import java.io.Serializable;
37  import java.sql.Date;
38  import java.time.LocalDate;
39  
40  import javax.validation.constraints.Size;
41  
42  import org.hibernate.validator.constraints.NotBlank;
43  
44  import com.fasterxml.jackson.annotation.JsonIgnore;
45  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
46  
47  import fr.paris.lutece.portal.service.rbac.RBACResource;
48  import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupResource;
49  
50  /**
51   * Business class of the Form
52   * 
53   * @author Laurent Payen
54   *
55   */
56  @JsonIgnoreProperties( ignoreUnknown = true )
57  public final class Form implements RBACResource, AdminWorkgroupResource, Serializable
58  {
59  
60      /**
61       * Serial version UID
62       */
63      private static final long serialVersionUID = 4742702767509625292L;
64  
65      /**
66       * Name of the resource type of Appointment Forms
67       */
68      @JsonIgnore
69      public static final String RESOURCE_TYPE = "APPOINTMENT_FORM";
70  
71      /**
72       * Form Id
73       */
74      private int _nIdForm;
75  
76      /**
77       * Title of the form
78       */
79      @NotBlank( message = "#i18n{appointment.validation.appointmentform.Title.notEmpty}" )
80      @Size( max = 255, message = "#i18n{appointment.validation.appointmentform.Title.size}" )
81      private String _strTitle;
82  
83      /**
84       * Description of the form
85       */
86      @NotBlank( message = "#i18n{appointment.validation.appointmentform.Description.notEmpty}" )
87      private String _strDescription;
88  
89      /**
90       * Reference of the form
91       */
92      private String _strReference;
93  
94      /**
95       * Category of the form
96       */
97      private Integer _nIdCategory;
98  
99      /**
100      * Starting validity date of the form
101      */
102     private LocalDate _startingValidityDate;
103 
104     /**
105      * Ending validity date of the form
106      */
107     private LocalDate _endingValidityDate;
108 
109     /**
110      * Indicate whether the form is active or not
111      */
112     private boolean _bIsActive;
113 
114     /**
115      * Workflow Id
116      */
117     private int _nIdWorkflow;
118 
119     /**
120      * Workgroup
121      */
122     private String _strWorkgroup;
123 
124     /**
125      * Get the form Id
126      * 
127      * @return the form Id
128      */
129     public int getIdForm( )
130     {
131         return _nIdForm;
132     }
133 
134     /**
135      * Set the form Id
136      * 
137      * @param nIdForm
138      *            the Id to set
139      */
140     public void setIdForm( int nIdForm )
141     {
142         this._nIdForm = nIdForm;
143     }
144 
145     /**
146      * Get the title of the form
147      * 
148      * @return the form title
149      */
150     public String getTitle( )
151     {
152         return _strTitle;
153     }
154 
155     /**
156      * Set the form title
157      * 
158      * @param title
159      *            the Title to set
160      */
161     public void setTitle( String strTitle )
162     {
163         this._strTitle = strTitle;
164     }
165 
166     /**
167      * Get the description of the form
168      * 
169      * @return the description of the form
170      */
171     public String getDescription( )
172     {
173         return _strDescription;
174     }
175 
176     /**
177      * Set the description of the form
178      * 
179      * @param description
180      *            the description to set
181      */
182     public void setDescription( String strDescription )
183     {
184         this._strDescription = strDescription;
185     }
186 
187     /**
188      * Get the reference of the form
189      * 
190      * @return the reference of the form
191      */
192     public String getReference( )
193     {
194         return _strReference;
195     }
196 
197     /**
198      * Set the reference of the form
199      * 
200      * @param reference
201      *            the reference to set
202      */
203     public void setReference( String strReference )
204     {
205         this._strReference = strReference;
206     }
207 
208     /**
209      * Get the category id of the form
210      * 
211      * @return the category id of the form
212      */
213     public Integer getIdCategory( )
214     {
215         return _nIdCategory;
216     }
217 
218     /**
219      * Set the category id of the form
220      * 
221      * @param nIdCategory
222      *            the category id to set
223      */
224     public void setIdCategory( Integer nIdCategory )
225     {
226         this._nIdCategory = nIdCategory;
227     }
228 
229     /**
230      * Get the starting validity date of the form (in LocalDate format)
231      * 
232      * @return the starting validity date of the form
233      */
234     public LocalDate getStartingValidityDate( )
235     {
236         return _startingValidityDate;
237     }
238 
239     /**
240      * Get the starting validity date of the form (in sql date format)
241      * 
242      * @return the starting validity date
243      */
244     public Date getStartingValiditySqlDate( )
245     {
246         Date date = null;
247         if ( _startingValidityDate != null )
248         {
249             date = Date.valueOf( _startingValidityDate );
250         }
251         return date;
252     }
253 
254     /**
255      * Set the starting date of the validity of the form
256      * 
257      * @param startValidity
258      *            the starting validity date to set
259      */
260     public void setStartingValidityDate( LocalDate startingValidityDate )
261     {
262         this._startingValidityDate = startingValidityDate;
263     }
264 
265     /**
266      * Set the starting validity date of the form
267      * 
268      * @param startingValidityDate
269      *            the starting validity date to set (in sql Date format)
270      */
271     public void setStartingValiditySqlDate( Date startingValidityDate )
272     {
273         if ( startingValidityDate != null )
274         {
275             this._startingValidityDate = startingValidityDate.toLocalDate( );
276         }
277         else
278         {
279             this._startingValidityDate = null;
280         }
281     }
282 
283     /**
284      * Get the end date of the validity of the form
285      * 
286      * @return the end validity date of the form
287      */
288     public LocalDate getEndingValidityDate( )
289     {
290         return _endingValidityDate;
291     }
292 
293     /**
294      * Get the ending validity date of the form (in sql date format)
295      * 
296      * @return the ending validity date
297      */
298     public Date getEndingValiditySqlDate( )
299     {
300         Date date = null;
301         if ( _endingValidityDate != null )
302         {
303             date = Date.valueOf( _endingValidityDate );
304         }
305         return date;
306     }
307 
308     /**
309      * Set the end date of the validity of the form
310      * 
311      * @param endValidity
312      *            the end validity date to set
313      */
314     public void setEndingValidityDate( LocalDate endingValidityDate )
315     {
316         this._endingValidityDate = endingValidityDate;
317     }
318 
319     /**
320      * Set the ending validity date of the form
321      * 
322      * @param endingValidityDate
323      *            the ending validity date to set (in sql Date format)
324      */
325     public void setEndingValiditySqlDate( Date endingValidityDate )
326     {
327         if ( endingValidityDate != null )
328         {
329             this._endingValidityDate = endingValidityDate.toLocalDate( );
330         }
331         else
332         {
333             this._endingValidityDate = null;
334         }
335     }
336 
337     /**
338      * Returns the IsActive
339      * 
340      * @return The IsActive
341      */
342     public boolean getIsActive( )
343     {
344         return _bIsActive;
345     }
346 
347     /**
348      * Set the active boolean value of the form
349      * 
350      * @param isActive
351      *            the boolean active value to set
352      */
353     public void setIsActive( boolean bIsActive )
354     {
355         this._bIsActive = bIsActive;
356     }
357 
358     /**
359      * Get the workflow id
360      * 
361      * @return the workflow id
362      */
363     public int getIdWorkflow( )
364     {
365         return _nIdWorkflow;
366     }
367 
368     /**
369      * Set the workflow Id
370      * 
371      * @param nIdWorkflow
372      *            the workflow id to set
373      */
374     public void setIdWorkflow( int nIdWorkflow )
375     {
376         this._nIdWorkflow = nIdWorkflow;
377     }
378 
379     @Override
380     public String getWorkgroup( )
381     {
382         return _strWorkgroup;
383     }
384 
385     /**
386      * Set the workgroup
387      * 
388      * @param strWorkgroup
389      *            the workgroup
390      */
391     public void setWorkgroup( String strWorkgroup )
392     {
393         this._strWorkgroup = strWorkgroup;
394     }
395 
396     @Override
397     public String getResourceTypeCode( )
398     {
399         return RESOURCE_TYPE;
400     }
401 
402     @Override
403     public String getResourceId( )
404     {
405         return Integer.toString( getIdForm( ) );
406     }
407 
408 }