View Javadoc
1   /*
2    * Copyright (c) 2002-2014, 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.form.business;
35  
36  import fr.paris.lutece.portal.service.rbac.RBACResource;
37  import fr.paris.lutece.portal.service.regularexpression.RegularExpressionRemovalListenerService;
38  import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupResource;
39  import fr.paris.lutece.portal.service.workgroup.WorkgroupRemovalListenerService;
40  
41  import java.sql.Timestamp;
42  
43  import java.util.Date;
44  import java.util.List;
45  
46  
47  /**
48   *
49   * Class form
50   *
51   */
52  public class Form implements AdminWorkgroupResource, RBACResource
53  {
54      public static final String RESOURCE_TYPE = "FORM_FORM_TYPE";
55      public static final int STATE_ENABLE = 1;
56      public static final int STATE_DISABLE = 0;
57      private static FormWorkgroupRemovalListener _listenerWorkgroup;
58      private static FormRegularExpressionRemovalListener _listenerRegularExpression;
59      private int _nIdForm;
60      private String _strTitle;
61      private String _strDescription;
62      private String _strWelcomeMessage;
63      private String _strUnavailabilityMessage;
64      private String _strRequirement;
65      private String _strWorkgroup;
66      private int _nIdMailingList;
67      private boolean _bActiveCaptcha;
68      private boolean _bActiveStoreAdresse;
69      private boolean _bLimitNumberResponse;
70      private boolean _bActiveRequirement;
71      private boolean _bSupportHTTPS;
72      private String _strLibelleValidateButton;
73      private String _strLibelleResetButton;
74      private Date _tDateBeginDisponibility;
75      private Date _tDateEndDisponibility;
76      private Timestamp _tDateCreation;
77      private boolean _nActive;
78      private boolean _bAutoPublicationActive;
79      private Recap _recap;
80      private List<FormAction> _listActions;
81      private int _nFormPageId;
82      private String _strInfoComplementary1;
83      private String _strInfoComplementary2;
84      private String _strInfoComplementary3;
85      private String _strInfoComplementary4;
86      private String _strInfoComplementary5;
87  
88      /**
89       * Initialize the Form
90       */
91      public static void init(  )
92      {
93          // Create removal listeners and register them
94          if ( _listenerWorkgroup == null )
95          {
96              _listenerWorkgroup = new FormWorkgroupRemovalListener(  );
97              WorkgroupRemovalListenerService.getService(  ).registerListener( _listenerWorkgroup );
98          }
99  
100         if ( _listenerRegularExpression == null )
101         {
102             _listenerRegularExpression = new FormRegularExpressionRemovalListener(  );
103             RegularExpressionRemovalListenerService.getService(  ).registerListener( _listenerRegularExpression );
104         }
105     }
106 
107     /**
108      *
109      * @return the id of the mailing list associate to the form
110      */
111     public int getIdMailingList(  )
112     {
113         return _nIdMailingList;
114     }
115 
116     /**
117      * set the id of the mailing list associate to the form
118      * @param mailingListId the id of the mailing list associate to the form
119      */
120     public void setIdMailingList( int mailingListId )
121     {
122         _nIdMailingList = mailingListId;
123     }
124 
125     /**
126      *
127      * @return true if the form contain a captcha
128      */
129     public boolean isActiveCaptcha(  )
130     {
131         return _bActiveCaptcha;
132     }
133 
134     /**
135      * set true if the form contain a captcha
136      * @param activeCaptcha true if the form contain a captcha
137      */
138     public void setActiveCaptcha( boolean activeCaptcha )
139     {
140         _bActiveCaptcha = activeCaptcha;
141     }
142 
143     /**
144      * true if the  ip adresse of the user must be store
145      * @return true if the  ip adresse of the user must be store
146      */
147     public boolean isActiveStoreAdresse(  )
148     {
149         return _bActiveStoreAdresse;
150     }
151 
152     /**
153      * set true if the  ip adresse of the user must be store
154      * @param activeStoreAdrese true if the  ip adresse of the user must be store
155      */
156     public void setActiveStoreAdresse( boolean activeStoreAdrese )
157     {
158         _bActiveStoreAdresse = activeStoreAdrese;
159     }
160 
161     /**
162     *
163     * @return true if the requirement must be activate
164     */
165     public boolean isActiveRequirement(  )
166     {
167         return _bActiveRequirement;
168     }
169 
170     /**
171      * set  true if the requirement must be activate
172      * @param activeRequirement true if the form contain requirement
173      */
174     public void setActiveRequirement( boolean activeRequirement )
175     {
176         _bActiveRequirement = activeRequirement;
177     }
178 
179     /**
180      *
181      * @return the libelle of the validate button
182      */
183     public String getLibelleValidateButton(  )
184     {
185         return _strLibelleValidateButton;
186     }
187 
188     /**
189      * set the libelle of the validate button
190      * @param libelleValidateButton the libelle of the validate button
191      */
192     public void setLibelleValidateButton( String libelleValidateButton )
193     {
194         _strLibelleValidateButton = libelleValidateButton;
195     }
196 
197     /**
198      *
199      * @return the date of end diosponibility
200      */
201     public Date getDateEndDisponibility(  )
202     {
203         return _tDateEndDisponibility;
204     }
205 
206     /**
207      * set the date of end disponibility
208      * @param dateEndDisponibility the date of end disponibility
209      */
210     public void setDateEndDisponibility( Date dateEndDisponibility )
211     {
212         _tDateEndDisponibility = dateEndDisponibility;
213     }
214 
215     /**
216      *
217      * @return the requirement of the form
218      */
219     public String getRequirement(  )
220     {
221         return _strRequirement;
222     }
223 
224     /**
225      * set the requirement of the form
226      * @param requirement the requierement of the form
227      */
228     public void setRequirement( String requirement )
229     {
230         _strRequirement = requirement;
231     }
232 
233     /**
234      *
235      * @return the title of the form
236      */
237     public String getTitle(  )
238     {
239         return _strTitle;
240     }
241 
242     /**
243      * set the title of the form
244      * @param strTitle the title of the form
245      */
246     public void setTitle( String strTitle )
247     {
248         this._strTitle = strTitle;
249     }
250 
251     /**
252      *
253      * @return the description of the form
254      */
255     public String getDescription(  )
256     {
257         return _strDescription;
258     }
259 
260     /**
261      * set the description of the form
262      * @param description the description of the form
263      */
264     public void setDescription( String description )
265     {
266         this._strDescription = description;
267     }
268 
269     /**
270      *
271      * @return the welcome message of the form
272      */
273     public String getWelcomeMessage(  )
274     {
275         return _strWelcomeMessage;
276     }
277 
278     /**
279      * set the welcome message of the form
280      * @param strWelcomeMessage the welcome message of the form
281      */
282     public void setWelcomeMessage( String strWelcomeMessage )
283     {
284         this._strWelcomeMessage = strWelcomeMessage;
285     }
286 
287     /**
288      *
289      * @return the unavailability message of the form
290      */
291     public String getUnavailabilityMessage(  )
292     {
293         return _strUnavailabilityMessage;
294     }
295 
296     /**
297      * set the unavailability message of the form
298      * @param unavailabilityMessage the unavailability message of the form
299      */
300     public void setUnavailabilityMessage( String unavailabilityMessage )
301     {
302         _strUnavailabilityMessage = unavailabilityMessage;
303     }
304 
305     /**
306      *
307      * @return the work group associate to the form
308      */
309     public String getWorkgroup(  )
310     {
311         return _strWorkgroup;
312     }
313 
314     /**
315      * set  the work group associate to the form
316      * @param workGroup  the work group associate to the form
317      */
318     public void setWorkgroup( String workGroup )
319     {
320         _strWorkgroup = workGroup;
321     }
322 
323     /**
324      *
325      * @return the id of the form
326      */
327     public int getIdForm(  )
328     {
329         return _nIdForm;
330     }
331 
332     /**
333      * set the id of the form
334      * @param idForm the id of the form
335      */
336     public void setIdForm( int idForm )
337     {
338         _nIdForm = idForm;
339     }
340 
341     /**
342      *
343      * @return true if the form is active
344      */
345     public boolean isActive(  )
346     {
347         return _nActive;
348     }
349 
350     /**
351      * set true if the form is active
352      * @param active true if the form is active
353      */
354     public void setActive( boolean active )
355     {
356         _nActive = active;
357     }
358 
359     /**
360      *
361      * @return true if the user can submit just one  form
362      */
363     public boolean isLimitNumberResponse(  )
364     {
365         return _bLimitNumberResponse;
366     }
367 
368     /**
369      * set true if the user can submit just one  form
370      * @param numberResponse true if the user can submit just one  form
371      */
372     public void setLimitNumberResponse( boolean numberResponse )
373     {
374         _bLimitNumberResponse = numberResponse;
375     }
376 
377     /**
378      *
379      * @return the creation date
380      */
381     public Timestamp getDateCreation(  )
382     {
383         return _tDateCreation;
384     }
385 
386     /**
387      * set the creation date
388      * @param dateCreation the creation date
389      */
390     public void setDateCreation( Timestamp dateCreation )
391     {
392         _tDateCreation = dateCreation;
393     }
394 
395     /**
396      *
397      * @return the recap associate to the form
398      */
399     public Recap getRecap(  )
400     {
401         return _recap;
402     }
403 
404     /**
405      * set  the recap associate to the form
406      * @param recap  the recap associate to the form
407      */
408     public void setRecap( Recap recap )
409     {
410         this._recap = recap;
411     }
412 
413     /**
414     * RBAC resource implmentation
415     * @return The resource type code
416     */
417     public String getResourceTypeCode(  )
418     {
419         return RESOURCE_TYPE;
420     }
421 
422     /**
423      * RBAC resource implmentation
424      * @return The resourceId
425      */
426     public String getResourceId(  )
427     {
428         return "" + _nIdForm;
429     }
430 
431     /**
432      *
433      * @return a list of action can be use for the form
434      */
435     public List<FormAction> getActions(  )
436     {
437         return _listActions;
438     }
439 
440     /**
441      * set a list of action can be use for the form
442      * @param formActions a list of action must be use for the form
443      */
444     public void setActions( List<FormAction> formActions )
445     {
446         _listActions = formActions;
447     }
448 
449     /**
450      *
451      * @return the id of the  page which contain the form
452      */
453     public int getFormPageId(  )
454     {
455         return _nFormPageId;
456     }
457 
458     /**
459      * set  the id of the  page which contain the form
460      * @param formPageId  the id of the  page which contain the form
461      */
462     public void setFormPageId( int formPageId )
463     {
464         _nFormPageId = formPageId;
465     }
466 
467     /**
468      * Define the date begin of the publication
469      * @param _tDateBeginDisponibility The date begin of the publication
470      */
471     public void setDateBeginDisponibility( Date _tDateBeginDisponibility )
472     {
473         this._tDateBeginDisponibility = _tDateBeginDisponibility;
474     }
475 
476     /**
477      * Return the date begin of the publication
478      * @return The date begin of the publication
479      */
480     public Date getDateBeginDisponibility(  )
481     {
482         return _tDateBeginDisponibility;
483     }
484 
485     /**
486      * Set if Auto publication is effectively active
487      * @param _bAutoPublicationActive
488      */
489     public void setAutoPublicationActive( boolean _bAutoPublicationActive )
490     {
491         this._bAutoPublicationActive = _bAutoPublicationActive;
492     }
493 
494     /**
495      * Return true if auto publication is effectively active
496      * @return true of false
497      */
498     public boolean isAutoPublicationActive(  )
499     {
500         return _bAutoPublicationActive;
501     }
502 
503     /**
504      * Return true if the form is in auto publication mode, false else
505      * @return true if the form is auto published
506      */
507     public boolean isAutoPublished(  )
508     {
509         return ( getDateBeginDisponibility(  ) != null ) || ( getDateEndDisponibility(  ) != null );
510     }
511 
512     /**
513      * The label to display for the Reset button
514      * @param _strLibelleResetButton The label
515      */
516     public void setLibelleResetButton( String _strLibelleResetButton )
517     {
518         this._strLibelleResetButton = _strLibelleResetButton;
519     }
520 
521     /**
522      * The label to display for the Reset button
523      * @return the Reset button name
524      */
525     public String getLibelleResetButton(  )
526     {
527         return _strLibelleResetButton;
528     }
529 
530     /**
531     *
532     * @return the Information Complementary 1
533     */
534     public String getInfoComplementary1(  )
535     {
536         return _strInfoComplementary1;
537     }
538 
539     /**
540      * set the Information Complementary 1
541      * @param strInfoComplementary1 the Information Complementary 1
542      */
543     public void setInfoComplementary1( String strInfoComplementary1 )
544     {
545         _strInfoComplementary1 = strInfoComplementary1;
546     }
547 
548     /**
549     *
550     * @return the Information Complementary 1
551     */
552     public String getInfoComplementary2(  )
553     {
554         return _strInfoComplementary2;
555     }
556 
557     /**
558      * set the Information Complementary 2
559      * @param strInfoComplementary2 the Information Complementary 2
560      */
561     public void setInfoComplementary2( String strInfoComplementary2 )
562     {
563         _strInfoComplementary2 = strInfoComplementary2;
564     }
565 
566     /**
567      *
568      * @return the Information Complementary 3
569      */
570     public String getInfoComplementary3(  )
571     {
572         return _strInfoComplementary3;
573     }
574 
575     /**
576      * set the Information Complementary 3
577      * @param strInfoComplementary3 the Information Complementary 3
578      */
579     public void setInfoComplementary3( String strInfoComplementary3 )
580     {
581         _strInfoComplementary3 = strInfoComplementary3;
582     }
583 
584     /**
585      *
586      * @return the Information Complementary 4
587      */
588     public String getInfoComplementary4(  )
589     {
590         return _strInfoComplementary4;
591     }
592 
593     /**
594      * set the Information Complementary 4
595      * @param strInfoComplementary4 the Information Complementary 4
596      */
597     public void setInfoComplementary4( String strInfoComplementary4 )
598     {
599         _strInfoComplementary4 = strInfoComplementary4;
600     }
601 
602     /**
603      *
604      * @return the Information Complementary 5
605      */
606     public String getInfoComplementary5(  )
607     {
608         return _strInfoComplementary5;
609     }
610 
611     /**
612      * set the Information Complementary 5
613      * @param strInfoComplementary5 the Information Complementary 5
614      */
615     public void setInfoComplementary5( String strInfoComplementary5 )
616     {
617         _strInfoComplementary5 = strInfoComplementary5;
618     }
619 
620     /**
621      * Set to <b>true</b> if the form support HTTPS, <b>false</b> otherwise 
622      * @param _bSupportHTTPS the support value
623      */
624 	public void setSupportHTTPS( boolean bSupportHTTPS )
625 	{
626 		this._bSupportHTTPS = bSupportHTTPS;
627 	}
628 
629 	/**
630 	 * Returns <b>true</b> if the form support HTTPS, <b>false</b> otherwise
631 	 * @return <b>true</b> if the form support HTTPS, <b>false</b> otherwise
632 	 */
633 	public boolean isSupportHTTPS(  )
634 	{
635 		return _bSupportHTTPS;
636 	}
637 }