1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.oness.inventory.model.warehouse.bo;
17
18 import java.math.BigDecimal;
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.Collection;
22
23 import net.sf.oness.common.model.bo.AbstractBusinessObject;
24 import net.sf.oness.inventory.model.product.bo.Product;
25
26 /***
27 * @hibernate.class table="stock"
28 *
29 * @author Carlos Sanchez
30 * @version $Revision: 1.5 $
31 */
32 public class Stock extends AbstractBusinessObject {
33
34 private BigDecimal quantity;
35
36 private Collection warehouses = new ArrayList();
37
38 private Collection products = new ArrayList();
39
40 /***
41 * @param quantity
42 * The quantity to set.
43 */
44 public void setQuantity(BigDecimal quantity) {
45 this.quantity = quantity;
46 }
47
48 /***
49 * @hibernate.property length="2"
50 *
51 * @return Returns the quantity.
52 */
53 public BigDecimal getQuantity() {
54 return quantity;
55 }
56
57 /***
58 * @return Returns the the latest version of warehouse.
59 */
60 public Warehouse getWarehouse() {
61 Iterator iter = getWarehouses().iterator();
62 return iter.hasNext() ? (Warehouse) iter.next() : null;
63 }
64
65 /***
66 * @param warehouses
67 * The warehouses to set.
68 */
69 public void setWarehouses(Collection warehouses) {
70 this.warehouses = warehouses;
71 }
72
73 /***
74 * @hibernate.bag table="warehouse_stock" lazy="true" inverse="true" order-by="warehouse_id desc"
75 * @hibernate.collection-key column="stock_id"
76 * @hibernate.collection-many-to-many column="warehouse_id" class="net.sf.oness.inventory.model.warehouse.bo.Warehouse"
77 *
78 * @return Returns the warehouses.
79 */
80 public Collection getWarehouses() {
81 return warehouses;
82 }
83
84 /***
85 * @return Returns the the latest version of product.
86 */
87 public Product getProduct() {
88 Iterator iter = getProducts().iterator();
89 return iter.hasNext() ? (Product) iter.next() : null;
90 }
91
92 /***
93 * @param products
94 * The products to set.
95 */
96 public void setProducts(Collection products) {
97 this.products = products;
98 }
99
100 /***
101 * @hibernate.bag table="product_stock" lazy="false" inverse="true" order-by="product_id desc"
102 * @hibernate.collection-key column="stock_id"
103 * @hibernate.collection-many-to-many column="product_id" class="net.sf.oness.inventory.model.product.bo.Product"
104 *
105 * @return Returns the products.
106 */
107 public Collection getProducts() {
108 return products;
109 }
110
111 }