View Javadoc

1   /*
2    * Copyright 2004 Carlos Sanchez.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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 }