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.product;
35
36 import fr.paris.lutece.plugins.stock.business.StockEntityBean;
37 import fr.paris.lutece.plugins.stock.business.attribute.product.ProductAttribute;
38 import fr.paris.lutece.plugins.stock.business.attribute.product.ProductAttributeDate;
39 import fr.paris.lutece.plugins.stock.business.attribute.product.ProductAttributeNum;
40 import fr.paris.lutece.plugins.stock.business.category.Category;
41 import fr.paris.lutece.plugins.stock.business.provider.Provider;
42 import fr.paris.lutece.plugins.stock.utils.jpa.StockJPAUtils;
43
44 import java.util.HashSet;
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.Inheritance;
55 import javax.persistence.InheritanceType;
56 import javax.persistence.JoinColumn;
57 import javax.persistence.ManyToOne;
58 import javax.persistence.OneToMany;
59 import javax.persistence.Table;
60 import javax.persistence.TableGenerator;
61
62
63
64
65 @Entity
66 @Inheritance( strategy = InheritanceType.JOINED )
67 @Table( name = "stock_product" )
68 public class Product extends StockEntityBean<Product>
69 {
70
71
72
73
74 private static final long serialVersionUID = -2357849090898194150L;
75
76
77 private static final String JPA_SEQUENCE_NAME = "stock_product_sequence";
78
79
80 private static final String JPA_COLUMN_NAME = "stock_product_id";
81
82
83 private Integer _idProduct;
84
85
86 private String _strDescription;
87
88
89 private String _strName;
90
91
92 private Float _price;
93
94
95 private Category _category;
96
97
98 private Provider _provider;
99
100
101 private Set<ProductAttributeDate> _attributeDateList;
102
103
104 private Set<ProductAttributeNum> _attributeNumList;
105
106
107 private Set<ProductAttribute> _attributeList;
108
109
110
111
112 public Product( )
113 {
114 super( );
115 this._attributeDateList = new HashSet<>( );
116 this._attributeList = new HashSet<>( );
117 this._attributeNumList = new HashSet<>( );
118 this._provider = new Provider( );
119 this._category = new Category( );
120 }
121
122
123
124
125
126
127
128 public Product" href="../../../../../../../fr/paris/lutece/plugins/stock/business/product/Product.html#Product">Product( Product product )
129 {
130 _strName = product.getName( );
131 _strDescription = product.getDescription( );
132 _price = product.getPrice( );
133 _category = product.getCategory( );
134 _idProduct = product.getId( );
135 }
136
137
138
139
140
141
142 @TableGenerator( table = StockJPAUtils.SEQUENCE_TABLE_NAME, name = JPA_SEQUENCE_NAME, pkColumnValue = JPA_COLUMN_NAME, allocationSize = 1 )
143 @Id
144 @GeneratedValue( strategy = GenerationType.TABLE, generator = JPA_SEQUENCE_NAME )
145 @Column( name = "id_product" )
146 public Integer getId( )
147 {
148 return _idProduct;
149 }
150
151
152
153
154
155
156
157 public void setId( Integer idProduct )
158 {
159 _idProduct = idProduct;
160 }
161
162
163
164
165
166
167 @Column( name = "description" )
168 public String getDescription( )
169 {
170 return _strDescription;
171 }
172
173
174
175
176
177
178
179 public void setDescription( String description )
180 {
181 _strDescription = description;
182 }
183
184
185
186
187
188
189 @Column( name = "name" )
190 public String getName( )
191 {
192 return _strName;
193 }
194
195
196
197
198
199
200
201 public void setName( String name )
202 {
203 _strName = name;
204 }
205
206
207
208
209
210
211 @Column( name = "price" )
212 public Float getPrice( )
213 {
214 return _price;
215 }
216
217
218
219
220
221
222
223 public void setPrice( Float price )
224 {
225 _price = price;
226 }
227
228
229
230
231
232
233 @ManyToOne( fetch = FetchType.LAZY )
234 @JoinColumn( name = "category_id_category", nullable = true )
235 public Category getCategory( )
236 {
237 return _category;
238 }
239
240
241
242
243
244
245
246 public void setCategory( Category category )
247 {
248 _category = category;
249 }
250
251
252
253
254
255
256 @ManyToOne( fetch = FetchType.LAZY )
257 @JoinColumn( name = "provider_id_provider", nullable = true )
258 public Provider getProvider( )
259 {
260 return _provider;
261 }
262
263
264
265
266
267
268
269 public void setProvider( Provider provider )
270 {
271 _provider = provider;
272 }
273
274
275
276
277
278
279 @OneToMany( cascade = {
280 CascadeType.ALL
281 }, mappedBy = "owner", orphanRemoval = true, fetch = FetchType.EAGER )
282 public Set<ProductAttribute> getAttributeList( )
283 {
284 return _attributeList;
285 }
286
287
288
289
290
291
292
293 public void setAttributeList( Set<ProductAttribute> stringAttribute )
294 {
295 this._attributeList = stringAttribute;
296 }
297
298
299
300
301
302
303 @OneToMany( cascade = {
304 CascadeType.ALL
305 }, mappedBy = "owner", orphanRemoval = true, fetch = FetchType.EAGER )
306 public Set<ProductAttributeDate> getAttributeDateList( )
307 {
308 return _attributeDateList;
309 }
310
311
312
313
314
315
316
317 public void setAttributeDateList( Set<ProductAttributeDate> dateAttribute )
318 {
319 this._attributeDateList = dateAttribute;
320 }
321
322
323
324
325
326
327 @OneToMany( cascade = {
328 CascadeType.ALL
329 }, mappedBy = "owner", orphanRemoval = true, fetch = FetchType.EAGER )
330 public Set<ProductAttributeNum> getAttributeNumList( )
331 {
332 return _attributeNumList;
333 }
334
335
336
337
338
339
340
341 public void setAttributeNumList( Set<ProductAttributeNum> numAttribute )
342 {
343 this._attributeNumList = numAttribute;
344 }
345
346 }