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.plugins.pluginwizard.business.model;
35
36 import fr.paris.lutece.plugins.pluginwizard.service.ModelService;
37 import fr.paris.lutece.plugins.pluginwizard.util.Utils;
38
39 import com.fasterxml.jackson.annotation.JsonIgnore;
40
41 import java.io.Serializable;
42
43 import javax.validation.constraints.NotEmpty;
44 import javax.validation.constraints.Pattern;
45
46
47
48
49 public class Attribute implements Serializable
50 {
51
52
53
54 private static final long serialVersionUID = 1L;
55
56 private int _nIdAttribute;
57 private int _nAttributeTypeId;
58 @NotEmpty( message = "pluginwizard.error.attribute.name.notEmpty" )
59 @Pattern( regexp = "[a-z_]*", message = "pluginwizard.error.attribute.name.pattern" )
60 private String _strAttributeName;
61 private int _nMaxLength;
62 private boolean _bNotNull;
63
64
65
66
67
68
69 public int getId( )
70 {
71 return _nIdAttribute;
72 }
73
74
75
76
77
78
79
80 public void setId( int nIdAttribute )
81 {
82 _nIdAttribute = nIdAttribute;
83 }
84
85
86
87
88
89
90 public int getAttributeTypeId( )
91 {
92 return _nAttributeTypeId;
93 }
94
95
96
97
98
99
100
101 public void setAttributeTypeId( int nAttributeTypeId )
102 {
103 _nAttributeTypeId = nAttributeTypeId;
104 }
105
106
107
108
109
110
111 public String getAttributeName( )
112 {
113 return _strAttributeName;
114 }
115
116
117
118
119
120
121
122 public void setAttributeName( String strAttributeName )
123 {
124 _strAttributeName = strAttributeName;
125 }
126
127
128
129
130
131
132 @JsonIgnore
133 public String getType( )
134 {
135 return ModelService.getAttributeType( _nAttributeTypeId );
136 }
137
138
139
140
141
142
143 @JsonIgnore
144 public String getName( )
145 {
146 return Utils.getProperName( _strAttributeName );
147 }
148
149
150
151
152
153
154 @JsonIgnore
155 public String getLabelName( )
156 {
157 return _strAttributeName.substring( 0, 1 ).toUpperCase( ) + _strAttributeName.substring( 1 ).replace( "_", " " );
158 }
159
160
161
162
163
164
165 @JsonIgnore
166 public String getVariableName( )
167 {
168 return ModelService.getAttributePrefix( _nAttributeTypeId ) + Utils.getProperName( _strAttributeName );
169 }
170
171
172
173
174
175
176 @JsonIgnore
177 public String getTypeDescription( )
178 {
179 return ModelService.getAttributeTypeDescription( _nAttributeTypeId );
180 }
181
182
183
184
185
186
187 @JsonIgnore
188 public String getParamName( )
189 {
190 return _strAttributeName.toLowerCase( );
191 }
192
193
194
195
196
197
198 @JsonIgnore
199 public String getJavaName( )
200 {
201 return Utils.getProperName( _strAttributeName ).substring( 0, 1 ).toLowerCase( ) + Utils.getProperName( _strAttributeName ).substring( 1 );
202 }
203
204
205
206
207 public int getMaxLength( )
208 {
209 return _nMaxLength;
210 }
211
212
213
214
215
216 public void setMaxLength( int maxLength )
217 {
218 _nMaxLength = maxLength;
219 }
220
221
222
223
224
225
226 public boolean getNotNull( )
227 {
228 return _bNotNull;
229 }
230
231
232
233
234
235
236
237 public void setNotNull( boolean bNotNull )
238 {
239 _bNotNull = bNotNull;
240 }
241
242
243
244
245
246
247 @JsonIgnore
248 public String getConstraint( )
249 {
250 return ModelService.getAttributeConstraint( _nAttributeTypeId );
251 }
252 }