View Javadoc
1   /*
2    * Copyright (c) 2002-2019, 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.directories.business;
35  
36  import java.io.Serializable;
37  import java.sql.Timestamp;
38  import java.util.ArrayList;
39  import java.util.List;
40  import fr.paris.lutece.plugins.genericattributes.business.Response;
41  import fr.paris.lutece.portal.business.user.AdminUser;
42  import fr.paris.lutece.portal.business.user.AdminUserHome;
43  
44  /**
45   * This is the business class for the object DirectoryEntity
46   */
47  public class DirectoryEntity implements Serializable
48  {
49      private static final long serialVersionUID = 1L;
50      // Variables declarations
51      private int _nId;
52      private int _nIdDirectory;
53      private List<Response> _listResponses;
54      private int _nIdCreator;
55      private String _strCreator = "";
56      private Timestamp _dateCreation;
57      private int _nIdModificator;
58      private String _strModificator = "";
59      private Timestamp _dateUpdate;
60      private String _strTitle;
61  
62      /**
63       * Returns the Id
64       * 
65       * @return The Id
66       */
67      public int getId( )
68      {
69          return _nId;
70      }
71  
72      /**
73       * Sets the Id
74       * 
75       * @param nId
76       *            The Id
77       */
78      public void setId( int nId )
79      {
80          _nId = nId;
81      }
82  
83      /**
84       * Returns the IdDirectory
85       * 
86       * @return The IdDirectory
87       */
88      public int getIdDirectory( )
89      {
90          return _nIdDirectory;
91      }
92  
93      /**
94       * Sets the IdDirectory
95       * 
96       * @param nIdDirectory
97       *            The IdDirectory
98       */
99      public void setIdDirectory( int nIdDirectory )
100     {
101         _nIdDirectory = nIdDirectory;
102     }
103 
104     /**
105      * Returns responses
106      * 
107      * @return The IdDirectory
108      */
109     public List<Response> getResponses( )
110     {
111         return new ArrayList<>( _listResponses );
112     }
113 
114     /**
115      * Sets responses
116      * 
117      * @param listResponses
118      *            Entity Responses
119      */
120     public void setResponses( List<Response> listResponses )
121     {
122         _listResponses = new ArrayList<>( listResponses );
123     }
124 
125     /**
126      * @return the _dateCreation
127      */
128     public Timestamp getCreation( )
129     {
130         return (Timestamp) _dateCreation.clone( );
131     }
132 
133     /**
134      * @param dateCreation
135      *            the dateCreation to set
136      */
137     public void setDateCreation( Timestamp dateCreation )
138     {
139         this._dateCreation = (Timestamp) dateCreation.clone( );
140     }
141 
142     /**
143      * @return the _dateUpdate
144      */
145     public Timestamp getUpdate( )
146     {
147         return _dateUpdate != null ? (Timestamp) _dateUpdate.clone( ) : null;
148     }
149 
150     /**
151      * @param dateUpdate
152      *            the dateUpdate to set
153      */
154     public void setUpdate( Timestamp dateUpdate )
155     {
156         this._dateUpdate = dateUpdate != null ? (Timestamp) dateUpdate.clone( ) : null;
157     }
158 
159     /**
160      * Returns the _nIdCreator
161      * 
162      * @return The _nIdCreator
163      */
164     public int getIdCreator( )
165     {
166         return _nIdCreator;
167     }
168 
169     /**
170      * Sets the _nIdCreator
171      * 
172      * @param nIdCreator
173      *            The Id Creator
174      */
175     public void setIdCreator( int nIdCreator )
176     {
177         _nIdCreator = nIdCreator;
178     }
179 
180     /**
181      * Returns the _nIdModificator
182      * 
183      * @return The _nIdModificator
184      */
185     public int getIdModificator( )
186     {
187         return _nIdModificator;
188     }
189 
190     /**
191      * Sets the _nIdModificator
192      * 
193      * @param nIdModificator
194      *            The Id Modificator
195      */
196     public void setIdModificator( int nIdModificator )
197     {
198         _nIdModificator = nIdModificator;
199     }
200 
201     /**
202      * Returns the _strCreator
203      * 
204      * @return The _strCreator
205      */
206     public String getCreator( )
207     {
208         return _strCreator;
209     }
210 
211     /**
212      * Sets the _strCreator
213      * 
214      * @param nIdCreator
215      *            The Id Creator
216      */
217     public void setCreator( int nIdCreator )
218     {
219         _strCreator = getUserAdmin( nIdCreator );
220     }
221 
222     /**
223      * Returns the _strModificator
224      * 
225      * @return The _strModificator
226      */
227     public String getModificator( )
228     {
229         return _strModificator;
230     }
231 
232     /**
233      * Sets the _strModificator
234      * 
235      * @param nIdModificator
236      *            The Id Modificator
237      */
238     public void setModificator( int nIdModificator )
239     {
240         _strModificator = getUserAdmin( nIdModificator );
241     }
242 
243     /**
244      * get the Admin user
245      * 
246      * @param nUserId
247      *            The Id Admin User
248      */
249     private String getUserAdmin( int nUserId )
250     {
251         AdminUser adminUser = AdminUserHome.findByPrimaryKey( nUserId );
252         String name = "";
253         if ( adminUser != null )
254         {
255             name = adminUser.getLastName( ) + " " + adminUser.getFirstName( );
256         }
257         return name;
258     }
259 
260     /**
261      * Returns the title
262      * 
263      * @return The title
264      */
265     public String getTitle( )
266     {
267         return _strTitle;
268     }
269 
270     /**
271      * Sets the title
272      * 
273      * @param strTitle
274      *            The title
275      */
276     public void setTitle( String strTitle )
277     {
278         _strTitle = strTitle;
279     }
280 }