View Javadoc
1   /*
2    * Copyright (c) 2002-2017, 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.document.modules.export.dto.exportdocument;
35  
36  import fr.paris.lutece.plugins.document.business.Document;
37  
38  import java.text.SimpleDateFormat;
39  
40  
41  /**
42   * A document's DTO
43   */
44  public class ExportUserDocumentDTO
45  {
46      public static final String RESOURCE_TYPE = "DOCUMENT_EXPORT";
47      private static final String DATE_FORMAT = "dd/MM/yyyy";
48      private static final String EMPTY_STRING = "";
49      private int _nIdDocument;
50      private String _strTitle;
51      private String _strType;
52      private String _strState;
53      private String _strDateValidityBegin;
54      private String _strDateValidityEnd;
55      private String _strDateCreation;
56      private String _strDateModification;
57      private String _strSpacePath;
58  
59      /**
60       * Contructor from Document
61       * @param document the document
62       */
63      public ExportUserDocumentDTO( Document document )
64      {
65          this._nIdDocument = document.getId(  );
66          this._strTitle = document.getTitle(  );
67          this._strType = document.getType(  );
68          this._strState = document.getState(  );
69          this.setDateValidityBegin( document.getDateValidityBegin(  ) );
70          this.setDateValidityEnd( document.getDateValidityEnd(  ) );
71          this.setDateCreation( document.getDateCreation(  ) );
72          this.setDateModification( document.getDateModification(  ) );
73      }
74  
75      /**
76       * provides the parameters of the class in String array
77       * @return String array
78       */
79      public String[] toTabString(  )
80      {
81          String[] tabStrTemp = 
82              {
83                  String.valueOf( this.getId(  ) ), this.getTitle(  ), this.getType(  ), this.getState(  ),
84                  this.getDateValidityBegin(  ), this.getDateValidityEnd(  ), this.getDateCreation(  ),
85                  this.getDateModification(  ), this.getSpacePath(  ),
86              };
87  
88          return tabStrTemp;
89      }
90  
91      /**
92       * Returns the IdDocument
93       *
94       * @return The IdDocument
95       */
96      public int getId(  )
97      {
98          return _nIdDocument;
99      }
100 
101     /**
102      * Sets the IdDocument
103      *
104      * @param nIdDocument The IdDocument
105      */
106     public void setId( int nIdDocument )
107     {
108         _nIdDocument = nIdDocument;
109     }
110 
111     /**
112      * Returns the Title
113      *
114      * @return The Title
115      */
116     public String getTitle(  )
117     {
118         return _strTitle;
119     }
120 
121     /**
122      * Sets the Title
123      *
124      * @param strTitle The Title
125      */
126     public void setTitle( String strTitle )
127     {
128         _strTitle = strTitle;
129     }
130 
131     /**
132      * Returns the DateCreation
133      *
134      * @return The DateCreation
135      */
136     public String getDateCreation(  )
137     {
138         return _strDateCreation;
139     }
140 
141     /**
142      * Sets the DateCreation
143      *
144      * @param dateCreation The DateCreation
145      */
146     public void setDateCreation( String dateCreation )
147     {
148         _strDateCreation = dateCreation;
149     }
150 
151     /**
152      * Sets the DateCreation
153      *
154      * @param dateCreation The DateCreation
155      */
156     public final void setDateCreation( java.sql.Timestamp dateCreation )
157     {
158         if ( dateCreation == null )
159         {
160             _strDateCreation = EMPTY_STRING;
161         }
162         else
163         {
164             _strDateCreation = new SimpleDateFormat( DATE_FORMAT ).format( dateCreation );
165         }
166     }
167 
168     /**
169      * Returns the Date of the last Modification
170      *
171      * @return The Date of the last Modification
172      */
173     public String getDateModification(  )
174     {
175         return _strDateModification;
176     }
177 
178     /**
179      * Sets the Date of the last Modification
180      *
181      * @param dateModification The Date of the last Modification
182      */
183     public void setDateModification( String dateModification )
184     {
185         _strDateModification = dateModification;
186     }
187 
188     /**
189      * Sets the Date of the last Modification
190      *
191      * @param dateModification The Date of the last Modification
192      */
193     public final void setDateModification( java.sql.Timestamp dateModification )
194     {
195         if ( dateModification == null )
196         {
197             _strDateModification = EMPTY_STRING;
198         }
199         else
200         {
201             _strDateModification = new SimpleDateFormat( DATE_FORMAT ).format( dateModification );
202         }
203     }
204 
205     /**
206      * Returns the begining Date of the validity period of the document
207      *
208      * @return The begining Date of the validity period of the document
209      */
210     public String getDateValidityBegin(  )
211     {
212         return _strDateValidityBegin;
213     }
214 
215     /**
216      * Sets the begining Date of the validity period of the document
217      *
218      * @param dateValidityBegin The begining Date of the validity period of the document
219      */
220     public void setDateValidityBegin( String dateValidityBegin )
221     {
222         _strDateValidityBegin = dateValidityBegin;
223     }
224 
225     /**
226      * Sets the begining Date of the validity period of the document
227      *
228      * @param dateValidityBegin The begining Date of the validity period of the document
229      */
230     public final void setDateValidityBegin( java.sql.Timestamp dateValidityBegin )
231     {
232         if ( dateValidityBegin == null )
233         {
234             _strDateValidityBegin = EMPTY_STRING;
235         }
236         else
237         {
238             _strDateValidityBegin = new SimpleDateFormat( DATE_FORMAT ).format( dateValidityBegin );
239         }
240     }
241 
242     /**
243      * Returns the end Date of the validity period of the document
244      *
245      * @return The end Date of the validity period of the document
246      */
247     public String getDateValidityEnd(  )
248     {
249         return _strDateValidityEnd;
250     }
251 
252     /**
253      * Sets the end Date of the validity period of the document
254      *
255      * @param dateValidityEnd The end Date of the validity period of the document
256      */
257     public void setDateValidityEnd( String dateValidityEnd )
258     {
259         _strDateValidityEnd = dateValidityEnd;
260     }
261 
262     /**
263      * Sets the end Date of the validity period of the document
264      *
265      * @param dateValidityEnd The end Date of the validity period of the document
266      */
267     public final void setDateValidityEnd( java.sql.Timestamp dateValidityEnd )
268     {
269         if ( dateValidityEnd == null )
270         {
271             _strDateValidityEnd = EMPTY_STRING;
272         }
273         else
274         {
275             _strDateValidityEnd = new SimpleDateFormat( DATE_FORMAT ).format( dateValidityEnd );
276         }
277     }
278 
279     /**
280      * Returns the State
281      *
282      * @return The State
283      */
284     public String getStateKey(  )
285     {
286         return _strState;
287     }
288 
289     /**
290      * Returns the State
291      *
292      * @return The State
293      */
294     public String getState(  )
295     {
296         return _strState;
297     }
298 
299     /**
300      * Sets the State
301      *
302      * @param strState The State
303      */
304     public void setStateKey( String strState )
305     {
306         _strState = strState;
307     }
308 
309     /**
310      * Returns the Type
311      *
312      * @return The Type
313      */
314     public String getType(  )
315     {
316         return _strType;
317     }
318 
319     /**
320      * Sets the Type
321      *
322      * @param strType The Type
323      */
324     public void setType( String strType )
325     {
326         _strType = strType;
327     }
328 
329     /**
330      * Returns the Space Path
331      *
332      * @return The Space Path
333      */
334     public String getSpacePath(  )
335     {
336         return _strSpacePath;
337     }
338 
339     /**
340      * Sets the Space Path
341      *
342      * @param strSpacePath The Space Path
343      */
344     public void setSpacePath( String strSpacePath )
345     {
346         _strSpacePath = strSpacePath;
347     }
348 }