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.portal.business.right;
35  
36  import fr.paris.lutece.portal.service.i18n.I18nService;
37  
38  import java.util.ArrayList;
39  import java.util.Collection;
40  import java.util.Locale;
41  
42  
43  /**
44   * This class represents business objects feature group
45   */
46  public class FeatureGroup
47  {
48      /////////////////////////////////////////////////////////////////////////////////
49      // Constants
50      private static final String EMPTY_STRING = "";
51  
52      /////////////////////////////////////////////////////////////////////////////////
53      // Variables
54      private String _strId;
55      private String _strDescriptionKey;
56      private String _strLabelKey;
57      private int _nOrder;
58      private Collection<Right> _aFeaturesList = new ArrayList<Right>(  );
59      private Locale _locale;
60  
61      /**
62       * Sets the locale to use
63       *
64       * @param locale the locale to use
65       */
66      public void setLocale( Locale locale )
67      {
68          _locale = locale;
69      }
70  
71      /**
72       * Returns the identifier of this feature group
73       *
74       * @return the identifier of this feature group
75       */
76      public String getId(  )
77      {
78          return _strId;
79      }
80  
81      /**
82       * Sets the identifier of the feature group to the specified string.
83       *
84       * @param strId the new identifier
85       */
86      public void setId( String strId )
87      {
88          _strId = strId;
89      }
90  
91      /**
92       * Returns the label of this feature group.
93       *
94       * @return the feature group label
95       */
96      public String getLabelKey(  )
97      {
98          return _strLabelKey;
99      }
100 
101     /**
102      * Returns the label of this feature group.
103      * @return the feature group label
104      */
105     public String getLabel(  )
106     {
107         return I18nService.getLocalizedString( _strLabelKey, _locale );
108     }
109 
110     /**
111      * Sets the label of the feature group to the specified string.
112      *
113      * @param strLabelKey the new label
114      */
115     public void setLabelKey( String strLabelKey )
116     {
117         _strLabelKey = ( strLabelKey == null ) ? EMPTY_STRING : strLabelKey;
118     }
119 
120     /**
121      * Returns the order of this feature group.
122      *
123      * @return the feature group order
124      */
125     public int getOrder(  )
126     {
127         return _nOrder;
128     }
129 
130     /**
131      * Sets the order of the feature group to the specified int.
132      *
133      * @param nOrder the new level
134      */
135     public void setOrder( int nOrder )
136     {
137         _nOrder = nOrder;
138     }
139 
140     /**
141      * Returns the description of this feature group.
142      *
143      * @return the feature group description
144      */
145     public String getDescriptionKey(  )
146     {
147         return _strDescriptionKey;
148     }
149 
150     /**
151      * Returns the description of this feature group.
152      *
153      * @return the feature group description
154      */
155     public String getDescription(  )
156     {
157         return I18nService.getLocalizedString( _strDescriptionKey, _locale );
158     }
159 
160     /**
161      * Sets the description of the feature group to the specified string.
162      *
163      * @param strDescriptionKey the new description
164      */
165     public void setDescriptionKey( String strDescriptionKey )
166     {
167         _strDescriptionKey = ( strDescriptionKey == null ) ? EMPTY_STRING : strDescriptionKey;
168     }
169 
170     /**
171      * Add a feature to the group
172      * @param right The feature to add
173      */
174     public void addFeature( Right right )
175     {
176         _aFeaturesList.add( right );
177     }
178 
179     /**
180      * Tells whether or not the feature list is empty
181      * @return _aFeaturesList
182      */
183     public boolean isEmpty(  )
184     {
185         return _aFeaturesList.isEmpty(  );
186     }
187 
188     /**
189      * Returns all features affected to the group
190      * @return a collection
191      */
192     public Collection<Right> getFeatures(  )
193     {
194         return _aFeaturesList;
195     }
196 }