1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.portal.business.right;
35
36 import fr.paris.lutece.portal.service.i18n.I18nService;
37 import fr.paris.lutece.portal.service.i18n.Localizable;
38
39 import java.io.Serializable;
40
41 import java.util.Locale;
42
43
44
45
46 public class Right implements Localizable, Comparable<Right>, Serializable
47 {
48 private static final long serialVersionUID = 4075896005615205007L;
49
50
51
52 private static final String EMPTY_STRING = "";
53 private String _strId;
54 private String _strNameKey;
55 private String _strDescriptionKey;
56 private int _nLevel;
57 private String _strUrl;
58 private String _strPluginName;
59 private String _strFeatureGroup;
60 private String _strIconUrl;
61 private String _strDocumentationUrl;
62 private Locale _locale;
63 private int _nIdOrder;
64 private boolean _bIsExternalFeature;
65
66
67
68
69
70
71
72 @Override
73 public void setLocale( Locale locale )
74 {
75 _locale = locale;
76 }
77
78
79
80
81
82
83 public String getId( )
84 {
85 return _strId;
86 }
87
88
89
90
91
92
93
94 public void setId( String strId )
95 {
96 _strId = strId;
97 }
98
99
100
101
102
103
104 public String getNameKey( )
105 {
106 return _strNameKey;
107 }
108
109
110
111
112
113
114 public String getName( )
115 {
116 String strReturn = I18nService.getLocalizedString( _strNameKey, _locale );
117 if ( !strReturn.equals( "" ) )
118 {
119 return I18nService.getLocalizedString( _strNameKey, _locale );
120 }
121 return _strNameKey;
122 }
123
124
125
126
127
128
129
130 public void setNameKey( String strNameKey )
131 {
132 _strNameKey = ( strNameKey == null ) ? EMPTY_STRING : strNameKey;
133 }
134
135
136
137
138
139
140 public int getLevel( )
141 {
142 return _nLevel;
143 }
144
145
146
147
148
149
150
151 public void setLevel( int nLevel )
152 {
153 _nLevel = nLevel;
154 }
155
156
157
158
159
160
161 public String getUrl( )
162 {
163 return _strUrl;
164 }
165
166
167
168
169
170
171
172 public void setUrl( String strUrl )
173 {
174 _strUrl = strUrl;
175 }
176
177
178
179
180
181
182 public String getDescriptionKey( )
183 {
184 return _strDescriptionKey;
185 }
186
187
188
189
190
191
192 public String getDescription( )
193 {
194 String strReturn = I18nService.getLocalizedString( _strDescriptionKey, _locale );
195 if ( !strReturn.equals( "" ) )
196 {
197 return I18nService.getLocalizedString( _strDescriptionKey, _locale );
198 }
199 return _strDescriptionKey;
200 }
201
202
203
204
205
206
207
208 public void setDescriptionKey( String strDescriptionKey )
209 {
210 _strDescriptionKey = ( strDescriptionKey == null ) ? EMPTY_STRING : strDescriptionKey;
211 }
212
213
214
215
216
217
218 public String getPluginName( )
219 {
220 return _strPluginName;
221 }
222
223
224
225
226
227
228
229 public void setPluginName( String strPluginName )
230 {
231 _strPluginName = ( strPluginName == null ) ? EMPTY_STRING : strPluginName;
232 }
233
234
235
236
237
238
239
240 public String getFeatureGroup( )
241 {
242 return _strFeatureGroup;
243 }
244
245
246
247
248
249
250
251
252 public void setFeatureGroup( String strFeatureGroup )
253 {
254 _strFeatureGroup = strFeatureGroup;
255 }
256
257
258
259
260
261
262 public String getIconUrl( )
263 {
264 return _strIconUrl;
265 }
266
267
268
269
270
271
272
273 public void setIconUrl( String strIconUrl )
274 {
275 _strIconUrl = strIconUrl;
276 }
277
278
279
280
281
282
283 public String getDocumentationUrl( )
284 {
285 return _strDocumentationUrl;
286 }
287
288
289
290
291
292
293
294 public void setDocumentationUrl( String strDocumentationUrl )
295 {
296 _strDocumentationUrl = strDocumentationUrl;
297 }
298
299
300
301
302
303
304 public int getOrder( )
305 {
306 return _nIdOrder;
307 }
308
309
310
311
312
313
314
315 public void setOrder( int nOrder )
316 {
317 this._nIdOrder = nOrder;
318 }
319
320
321
322
323
324
325 public boolean isExternalFeature( )
326 {
327 return _bIsExternalFeature;
328 }
329
330
331
332
333
334
335
336 public void setExternalFeature( boolean bExternalFeature )
337 {
338 this._bIsExternalFeature = bExternalFeature;
339 }
340
341
342
343
344
345
346
347
348 @Override
349 public int compareTo( Right o )
350 {
351 if ( this.getOrder( ) > o.getOrder( ) )
352 {
353 return 1;
354 }
355 else
356 if ( this.getOrder( ) < o.getOrder( ) )
357 {
358 return -1;
359 }
360 else
361 {
362 return this.getId( ).compareTo( o.getId( ) );
363 }
364 }
365
366
367
368
369 @Override
370 public boolean equals( Object o )
371 {
372 if ( !( o instanceof Right ) )
373 {
374 return false;
375 }
376
377 return compareTo( (Right) o ) == 0;
378 }
379
380
381
382
383 @Override
384 public int hashCode( )
385 {
386 int nIdHash = ( getId( ) == null ) ? 0 : getId( ).hashCode( );
387
388 return ( getOrder( ) * 100 ) + nIdHash;
389 }
390 }