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 java.util.ArrayList;
37 import java.util.List;
38
39 import javax.validation.constraints.NotEmpty;
40 import javax.validation.constraints.Pattern;
41
42 import com.fasterxml.jackson.annotation.JsonIgnore;
43
44 import fr.paris.lutece.plugins.pluginwizard.util.Utils;
45
46
47
48
49 public class BusinessClass
50 {
51
52 private int _nIdBusinessClass;
53 @NotEmpty( message = "pluginwizard.error.businessClass.class.notEmpty" )
54 @Pattern( regexp = "[A-Z][a-zA-Z]*", message = "pluginwizard.error.businessClass.class.pattern" )
55 private String _strBusinessClass;
56 @NotEmpty( message = "pluginwizard.error.businessClass.tableName.notEmpty" )
57 @Pattern( regexp = "[a-z][a-z_]*", message = "pluginwizard.error.businessClass.tableName.pattern" )
58 private String _strBusinessTableName;
59 private List<Attribute> _listAttributes;
60 private String _strPrimaryAttributeName;
61
62
63
64
65 public BusinessClass( )
66 {
67 _listAttributes = new ArrayList<>( );
68 }
69
70
71
72
73
74
75 public int getId( )
76 {
77 return _nIdBusinessClass;
78 }
79
80
81
82
83
84
85
86 public void setId( int nIdBusinessClass )
87 {
88 _nIdBusinessClass = nIdBusinessClass;
89 }
90
91
92
93
94
95
96 public String getBusinessClass( )
97 {
98 return _strBusinessClass;
99 }
100
101
102
103
104
105
106
107 public void setBusinessClass( String strBusinessClass )
108 {
109 _strBusinessClass = strBusinessClass;
110 }
111
112
113
114
115
116
117 public String getBusinessTableName( )
118 {
119 return _strBusinessTableName;
120 }
121
122
123
124
125
126
127
128 public void setBusinessTableName( String strBusinessTableName )
129 {
130 _strBusinessTableName = strBusinessTableName;
131 }
132
133
134
135
136
137
138
139
140 public void setAttributes( List<Attribute> listAttributes )
141 {
142 if ( listAttributes != null )
143 {
144 _listAttributes = new ArrayList<>( listAttributes );
145 }
146 else
147 {
148 _listAttributes = null;
149 }
150 }
151
152
153
154
155
156
157 public List<Attribute> getAttributes( )
158 {
159 if ( _listAttributes != null )
160 {
161 return new ArrayList<>( _listAttributes );
162 }
163 else
164 {
165 return null;
166 }
167 }
168
169
170
171
172
173
174
175 public void setPrimaryKey( String strPrimaryAttributeName )
176 {
177 _strPrimaryAttributeName = strPrimaryAttributeName;
178 }
179
180
181
182
183
184
185 public String getPrimaryKey( )
186 {
187 return _strPrimaryAttributeName;
188 }
189
190
191
192
193
194
195
196
197
198 @JsonIgnore
199 public String getPrimaryKeyName( )
200 {
201 return Utils.getProperName( _strPrimaryAttributeName );
202 }
203
204
205
206
207
208
209 @JsonIgnore
210 public String getBusinessClassCapsFirst( )
211 {
212 char [ ] characters = _strBusinessClass.toCharArray( );
213 characters [0] = Character.toTitleCase( characters [0] );
214
215 return String.valueOf( characters );
216 }
217
218
219
220
221
222
223 @JsonIgnore
224 public String getInstanceName( )
225 {
226 return Utils.firstLowerCase( _strBusinessClass );
227 }
228
229 }