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.mylutece.business.attribute;
35
36 import fr.paris.lutece.portal.service.plugin.Plugin;
37
38 import java.util.List;
39 import java.util.Locale;
40
41 import javax.servlet.http.HttpServletRequest;
42
43 /**
44 * IAttribute
45 */
46 public interface IAttribute
47 {
48 /**
49 * Get ID Attribute
50 *
51 * @return ID attribute
52 */
53 int getIdAttribute( );
54
55 /**
56 * Set ID Attribute
57 *
58 * @param nIdAttribute
59 * ID Attribute
60 */
61 void setIdAttribute( int nIdAttribute );
62
63 /**
64 * Get Mandatory
65 *
66 * @return true if it's mandatory, false otherwise
67 */
68 boolean isMandatory( );
69
70 /**
71 * Set mandatory
72 *
73 * @param bMandatory
74 * true if it's mandatory, false otherwise
75 */
76 void setMandatory( boolean bMandatory );
77
78 /**
79 * Get list fields
80 *
81 * @return list fields
82 */
83 List<AttributeField> getListAttributeFields( );
84
85 /**
86 * Set list fields
87 *
88 * @param listAttributeFields
89 * list fields
90 */
91 void setListAttributeFields( List<AttributeField> listAttributeFields );
92
93 /**
94 * Get title
95 *
96 * @return title
97 */
98 String getTitle( );
99
100 /**
101 * Set title
102 *
103 * @param strTitle
104 * title
105 */
106 void setTitle( String strTitle );
107
108 /**
109 * Get help Message
110 *
111 * @return help message
112 */
113 String getHelpMessage( );
114
115 /**
116 * Set help message
117 *
118 * @param strHelpMessage
119 * help message
120 */
121 void setHelpMessage( String strHelpMessage );
122
123 /**
124 * Get position
125 *
126 * @return position
127 */
128 int getPosition( );
129
130 /**
131 * Set position
132 *
133 * @param nPosition
134 * position
135 */
136 void setPosition( int nPosition );
137
138 /**
139 * Get attribute type
140 *
141 * @return attribute type
142 */
143 AttributeType getAttributeType( );
144
145 /**
146 * Set attribute Type
147 *
148 * @param attributeType
149 * attribute type
150 */
151 void setAttributeType( AttributeType attributeType );
152
153 /**
154 * Get plugin
155 *
156 * @return plugin
157 */
158 Plugin getPlugin( );
159
160 /**
161 * Set plugin
162 *
163 * @param plugin
164 * plugin
165 */
166 void setPlugin( Plugin plugin );
167
168 /**
169 * Get the anonymize status of the attribute
170 *
171 * @return True if the attribute should be anonymize, false otherwise.
172 */
173 boolean getAnonymize( );
174
175 /**
176 * Set the anonymize status of the attribute
177 *
178 * @param bAnonymize
179 * New anonymize status. True if the attribute should be anonymize, false otherwise.
180 */
181 void setAnonymize( boolean bAnonymize );
182
183 /**
184 * Check if the attribute is shown in search
185 *
186 * @return true if it is, false otherwise
187 */
188 boolean isShownInSearch( );
189
190 /**
191 * Set isShownInSearch
192 *
193 * @param bIsShownInSearch
194 * shown in search
195 */
196 void setShownInSearch( boolean bIsShownInSearch );
197
198 /**
199 * Get the data of the user fields
200 *
201 * @param request
202 * HttpServletRequest
203 * @param nIdUser
204 * Id of the user
205 * @return user field data
206 */
207 List<MyLuteceUserField> getUserFieldsData( HttpServletRequest request, int nIdUser );
208
209 /**
210 * Set attribute type
211 *
212 * @param locale
213 * locale
214 */
215 void setAttributeType( Locale locale );
216
217 /**
218 * Get page title for create page
219 *
220 * @return page title
221 */
222 String getPropertyCreatePageTitle( );
223
224 /**
225 * Get page title for modify page
226 *
227 * @return page title
228 */
229 String getPropertyModifyPageTitle( );
230
231 /**
232 * Get the template create an attribute
233 *
234 * @return The URL of the template
235 */
236 String getTemplateCreateAttribute( );
237
238 /**
239 * Get the template modify an attribute
240 *
241 * @return The URL of the template
242 */
243 String getTemplateModifyAttribute( );
244
245 /**
246 * Get the template html form attribute
247 *
248 * @return the template
249 */
250 String getTemplateHtmlFormAttribute( );
251
252 /**
253 * Get the template html form search attribute
254 *
255 * @return the template
256 */
257 String getTemplateHtmlFormSearchAttribute( );
258
259 /**
260 * Set the data of the attribute
261 *
262 * @param request
263 * HttpServletRequest
264 * @return null if there are no errors
265 */
266 String setAttributeData( HttpServletRequest request );
267
268 /**
269 * Get whether the attribute is anonymizable.
270 *
271 * @return True if the attribute can be anonymized, false otherwise.
272 */
273 boolean isAnonymizable( );
274
275 /**
276 * Get user fields objects from values
277 *
278 * @param values
279 * The values of user fields. May contain either the value of the user field or its title
280 * @param nIdUser
281 * The id of the user
282 * @return The user fields
283 */
284 List<MyLuteceUserField> getUserFieldsData( String [ ] values, int nIdUser );
285 }