1 /*
2 * Copyright (c) 2002-2021, City of 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.announce.business;
35
36 import fr.paris.lutece.portal.service.rbac.RBACResource;
37 import fr.paris.lutece.portal.service.util.AppLogService;
38
39 import java.io.Serializable;
40
41 /**
42 * Business class for category
43 */
44 public class Category implements RBACResource, Serializable, Cloneable
45 {
46 /**
47 * The resource type of categories
48 */
49 public static final String RESOURCE_TYPE = "CATEGORY";
50
51 /**
52 * Serial version UID
53 */
54 private static final long serialVersionUID = -5333528106051789202L;
55
56 // ///////////////////////////////////////////////////////////////////////////////
57 // Constants
58 private int _nId;
59 private int _nIdSector;
60 private String _strLabel;
61 private int _nNumberAnnounces;
62 private int _nAnnouncesValidation;
63 private boolean _bDisplayPrice;
64 private boolean _bPriceMandatory;
65 private int _nIdMailingList;
66 private String _strTags;
67 private String _strLabelSector;
68 private int _nIdWorkflow;
69 private boolean _bDisplayCaptcha;
70
71 /**
72 * gets the id of category
73 *
74 * @return the id of category
75 */
76 public int getId( )
77 {
78 return _nId;
79 }
80
81 /**
82 * sets the id of category
83 *
84 * @param nId
85 * the id of category
86 */
87 public void setId( int nId )
88 {
89 _nId = nId;
90 }
91
92 /**
93 * gets the id of category sector
94 *
95 * @return the id of category sector
96 */
97 public int getIdSector( )
98 {
99 return _nIdSector;
100 }
101
102 /**
103 * sets the id of category sector
104 *
105 * @param nIdSector
106 * the id of category sector
107 */
108 public void setIdSector( int nIdSector )
109 {
110 _nIdSector = nIdSector;
111 }
112
113 /**
114 * gets the label
115 *
116 * @return the label
117 */
118 public String getLabel( )
119 {
120 return _strLabel;
121 }
122
123 /**
124 * sets the label
125 *
126 * @param strLabel
127 * the label
128 */
129 public void setLabel( String strLabel )
130 {
131 _strLabel = strLabel;
132 }
133
134 /**
135 * gets the number of announces
136 *
137 * @return the number of announces
138 */
139 public int getNumberAnnounces( )
140 {
141 return _nNumberAnnounces;
142 }
143
144 /**
145 * sets the number of announces
146 *
147 * @param nNumberAnnounces
148 * the number of announces
149 */
150 public void setNumberAnnounces( int nNumberAnnounces )
151 {
152 _nNumberAnnounces = nNumberAnnounces;
153 }
154
155 /**
156 * weather or not the announces must be moderated before publishing
157 *
158 * @return weather or not the announces must be moderated before publishing
159 */
160 public int getAnnouncesValidation( )
161 {
162 return _nAnnouncesValidation;
163 }
164
165 /**
166 * sets weather or not the announces must be moderated before publishing
167 *
168 * @param nAnnouncesValidation
169 * weather or not the announces must be moderated before publishing
170 */
171 public void setAnnouncesValidation( int nAnnouncesValidation )
172 {
173 _nAnnouncesValidation = nAnnouncesValidation;
174 }
175
176 /**
177 * {@inheritDoc}
178 */
179 @Override
180 public String getResourceId( )
181 {
182 return Integer.toString( getId( ) );
183 }
184
185 /**
186 * {@inheritDoc}
187 */
188 @Override
189 public String getResourceTypeCode( )
190 {
191 return RESOURCE_TYPE;
192 }
193
194 /**
195 * weather or not the category must display the price of announce
196 *
197 * @return weather or not the category must display the price of announce
198 */
199 public boolean getDisplayPrice( )
200 {
201 return _bDisplayPrice;
202 }
203
204 /**
205 * sets weather or not the category must display the price of announce
206 *
207 * @param displayPrice
208 * weather or not the category must display the price of announce
209 */
210 public void setDisplayPrice( boolean displayPrice )
211 {
212 this._bDisplayPrice = displayPrice;
213 }
214
215 /**
216 * Check if the price attribute is mandatory or not
217 *
218 * @return True if the price attribute is mandatory, false otherwise
219 */
220 public boolean getPriceMandatory( )
221 {
222 return _bPriceMandatory;
223 }
224
225 /**
226 * Set the price attribute mandatory or not
227 *
228 * @param bPriceMandatory
229 * True if the price attribute is mandatory, false otherwise
230 */
231 public void setPriceMandatory( boolean bPriceMandatory )
232 {
233 this._bPriceMandatory = bPriceMandatory;
234 }
235
236 /**
237 * Get the id of the mailing list associated with this category
238 *
239 * @return The id of the mailing list associated with this category
240 */
241 public int getIdMailingList( )
242 {
243 return _nIdMailingList;
244 }
245
246 /**
247 * Set the id of the mailing list associated with this category
248 *
249 * @param nIdMailingList
250 * The id of the mailing list associated with this category
251 */
252 public void setIdMailingList( int nIdMailingList )
253 {
254 this._nIdMailingList = nIdMailingList;
255 }
256
257 /**
258 * gets the tags of category
259 *
260 * @return gets the tags of category
261 */
262 public String getTags( )
263 {
264 return _strTags;
265 }
266
267 /**
268 * sets the Tags of category
269 *
270 * @param strTags
271 * the Tags of category
272 */
273 public void setTags( String strTags )
274 {
275 _strTags = strTags;
276 }
277
278 /**
279 * @return the _strLabelSector
280 */
281 public String getLabelSector( )
282 {
283 return _strLabelSector;
284 }
285
286 /**
287 * @param strLabelSector
288 * the _strLabelSector to set
289 */
290 public void setLabelSector( String strLabelSector )
291 {
292 this._strLabelSector = strLabelSector;
293 }
294
295 /**
296 * Get the id of the associated workflow
297 *
298 * @return The id of the associated workflow
299 */
300 public int getIdWorkflow( )
301 {
302 return _nIdWorkflow;
303 }
304
305 /**
306 * Set the id of the associated workflow
307 *
308 * @param nIdWorkflow
309 * The id of the associated workflow
310 */
311 public void setIdWorkflow( int nIdWorkflow )
312 {
313 this._nIdWorkflow = nIdWorkflow;
314 }
315
316 /**
317 * Check if a captcha should be displayed when creating an announce
318 *
319 * @return True if a captcha should be displayed when creating an announce, false otherwise
320 */
321 public boolean getDisplayCaptcha( )
322 {
323 return _bDisplayCaptcha;
324 }
325
326 /**
327 * Set whether a captcha should be displayed when creating an announce
328 *
329 * @param bDisplayCaptcha
330 * True if a captcha should be displayed when creating an announce, false otherwise
331 */
332 public void setDisplayCaptcha( boolean bDisplayCaptcha )
333 {
334 this._bDisplayCaptcha = bDisplayCaptcha;
335 }
336
337 /**
338 * {@inheritDoc}
339 */
340 @Override
341 public Object clone( )
342 {
343 try
344 {
345 return super.clone( );
346 }
347 catch( CloneNotSupportedException e )
348 {
349 AppLogService.error( e.getMessage( ), e );
350 }
351
352 return this;
353 }
354 }