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.stock.business.provider;
35
36 import fr.paris.lutece.plugins.stock.business.StockEntityBean;
37 import fr.paris.lutece.plugins.stock.business.attribute.provider.ProviderAttribute;
38 import fr.paris.lutece.plugins.stock.business.attribute.provider.ProviderAttributeDate;
39 import fr.paris.lutece.plugins.stock.business.attribute.provider.ProviderAttributeNum;
40 import fr.paris.lutece.plugins.stock.business.category.Category;
41 import fr.paris.lutece.plugins.stock.utils.jpa.StockJPAUtils;
42
43 import java.util.HashSet;
44 import java.util.List;
45 import java.util.Set;
46
47 import javax.persistence.CascadeType;
48 import javax.persistence.Column;
49 import javax.persistence.Entity;
50 import javax.persistence.FetchType;
51 import javax.persistence.GeneratedValue;
52 import javax.persistence.GenerationType;
53 import javax.persistence.Id;
54 import javax.persistence.OneToMany;
55 import javax.persistence.Table;
56 import javax.persistence.TableGenerator;
57
58
59
60
61
62
63 @Entity
64
65 @Table( name = "stock_provider" )
66 public class Provider extends StockEntityBean<Provider>
67 {
68
69
70
71 private static final long serialVersionUID = 4296244688535088812L;
72
73
74 private static final String JPA_SEQUENCE_NAME = "stock_provider_sequence";
75
76
77 private static final String JPA_COLUNM_NAME = "stock_provider_id";
78 private Integer _id;
79 private String _strName;
80 private String _strAddress;
81 private String _strContactName;
82 private String _strPhoneNumber;
83 private String _strMail;
84 private String _strComment;
85 private List<Category> _listProducts;
86 private Set<ProviderAttribute> _attributeList;
87 private Set<ProviderAttributeDate> _attributeDateList;
88 private Set<ProviderAttributeNum> _attributeNumList;
89
90
91
92
93 public Provider( )
94 {
95 this._attributeDateList = new HashSet<>( );
96 this._attributeList = new HashSet<>( );
97 this._attributeNumList = new HashSet<>( );
98 }
99
100
101
102
103
104
105
106 public Provider href="../../../../../../../fr/paris/lutece/plugins/stock/business/provider/Provider.html#Provider">Provider( Provider provider )
107 {
108 this._attributeDateList = new HashSet<>( );
109 this._attributeList = new HashSet<>( );
110 this._attributeNumList = new HashSet<>( );
111 copy( provider );
112 }
113
114
115
116
117
118
119
120 private void copy( Provider provider )
121 {
122 setId( provider.getId( ) );
123 setName( provider.getName( ) );
124 setAddress( provider.getAddress( ) );
125 setContactName( provider.getContactName( ) );
126 setPhoneNumber( provider.getPhoneNumber( ) );
127 setMail( provider.getMail( ) );
128 setComment( provider.getComment( ) );
129 setProducts( provider.getProducts( ) );
130 }
131
132
133
134
135
136
137 @TableGenerator( table = StockJPAUtils.SEQUENCE_TABLE_NAME, name = JPA_SEQUENCE_NAME, pkColumnValue = JPA_COLUNM_NAME, allocationSize = 1 )
138 @Id
139 @GeneratedValue( strategy = GenerationType.TABLE, generator = JPA_SEQUENCE_NAME )
140 @Column( name = "id_provider" )
141 public Integer getId( )
142 {
143 return _id;
144 }
145
146
147
148
149
150
151
152 public void setId( Integer idProvider )
153 {
154 _id = idProvider;
155 }
156
157
158
159
160
161
162 @Column( name = "phone_number" )
163 public String getPhoneNumber( )
164 {
165 return _strPhoneNumber;
166 }
167
168
169
170
171
172
173
174 public void setPhoneNumber( String strPhoneNumber )
175 {
176 _strPhoneNumber = strPhoneNumber;
177 }
178
179
180
181
182
183
184 @Column( name = "address" )
185 public String getAddress( )
186 {
187 return _strAddress;
188 }
189
190
191
192
193
194
195
196 public void setAddress( String address )
197 {
198 _strAddress = address;
199 }
200
201
202
203
204
205
206 @Column( name = "mail" )
207 public String getMail( )
208 {
209 return _strMail;
210 }
211
212
213
214
215
216
217
218 public void setMail( String mail )
219 {
220 _strMail = mail;
221 }
222
223
224
225
226
227
228 @Column( name = "name" )
229 public String getName( )
230 {
231 return this._strName;
232 }
233
234
235
236
237
238
239
240 public void setName( String name )
241 {
242 this._strName = name;
243 }
244
245
246
247
248
249
250 @OneToMany( cascade = CascadeType.ALL, fetch = FetchType.LAZY )
251 public List<Category> getProducts( )
252 {
253 return _listProducts;
254 }
255
256
257
258
259
260
261
262 public void setProducts( List<Category> products )
263 {
264 _listProducts = products;
265 }
266
267
268
269
270
271
272 public String getContactName( )
273 {
274 return _strContactName;
275 }
276
277
278
279
280
281
282
283 public void setContactName( String contactName )
284 {
285 this._strContactName = contactName;
286 }
287
288
289
290
291
292
293 public String getComment( )
294 {
295 return _strComment;
296 }
297
298
299
300
301
302
303
304 public void setComment( String comment )
305 {
306 this._strComment = comment;
307 }
308
309
310
311
312
313
314 @OneToMany( cascade = {
315 CascadeType.ALL
316 }, mappedBy = "owner", orphanRemoval = true, fetch = FetchType.EAGER )
317 public Set<ProviderAttribute> getAttributeList( )
318 {
319 return _attributeList;
320 }
321
322 public void setAttributeList( Set<ProviderAttribute> stringAttribute )
323 {
324 this._attributeList = stringAttribute;
325 }
326
327
328
329
330
331
332 @OneToMany( cascade = {
333 CascadeType.ALL
334 }, mappedBy = "owner", orphanRemoval = true, fetch = FetchType.EAGER )
335 public Set<ProviderAttributeDate> getAttributeDateList( )
336 {
337 return _attributeDateList;
338 }
339
340
341
342
343
344
345
346 public void setAttributeDateList( Set<ProviderAttributeDate> dateAttribute )
347 {
348 this._attributeDateList = dateAttribute;
349 }
350
351
352
353
354
355
356 @OneToMany( cascade = {
357 CascadeType.ALL
358 }, mappedBy = "owner", orphanRemoval = true, fetch = FetchType.EAGER )
359 public Set<ProviderAttributeNum> getAttributeNumList( )
360 {
361 return _attributeNumList;
362 }
363
364
365
366
367
368
369
370 public void setAttributeNumList( Set<ProviderAttributeNum> numAttribute )
371 {
372 this._attributeNumList = numAttribute;
373 }
374
375 }