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.product.bo;
17  
18  import java.math.BigDecimal;
19  import java.util.Collection;
20  import java.util.Iterator;
21  
22  import net.sf.oness.common.model.bo.AbstractBusinessObject;
23  
24  /***
25   * @hibernate.class table="price"
26   * 
27   * @author Carlos Sanchez
28   * @version $Revision: 1.5 $
29   */
30  public class Price extends AbstractBusinessObject {
31  
32      private BigDecimal amount;
33  
34      private Collection products;
35  
36      private Collection fares;
37  
38      /***
39       * @param amount
40       *            The amount to set.
41       */
42      public void setAmount(BigDecimal amount) {
43          this.amount = amount;
44      }
45  
46      /***
47       * @hibernate.property length="2"
48       * 
49       * @return Returns the amount.
50       */
51      public BigDecimal getAmount() {
52          return amount;
53      }
54  
55      /***
56       * @return Returns the the latest version of product.
57       */
58      public Product getProduct() {
59          Iterator iter = getProducts().iterator();
60          return iter.hasNext() ? (Product) iter.next() : null;
61      }
62  
63      /***
64       * @param products
65       *            The products to set.
66       */
67      public void setProducts(Collection products) {
68          this.products = products;
69      }
70  
71      /***
72       * @hibernate.bag table="product_price" lazy="true" order-by="product_id desc" 
73       * @hibernate.collection-key column="price_id"
74       * @hibernate.collection-many-to-many column="product_id" class="net.sf.oness.inventory.model.product.bo.Product"
75       * 
76       * @return Returns the products.
77       */
78      public Collection getProducts() {
79          return products;
80      }
81  
82      /***
83       * @return Returns the the latest version of fare.
84       */
85      public Fare getFare() {
86          Iterator iter = getFares().iterator();
87          return iter.hasNext() ? (Fare) iter.next() : null;
88      }
89  
90      /***
91       * @param fares
92       *            The fares to set.
93       */
94      public void setFares(Collection fares) {
95          this.fares = fares;
96      }
97  
98      /***
99       * @hibernate.bag table="fare_price" lazy="true" order-by="fare_id desc" 
100      * @hibernate.collection-key column="price_id"
101      * @hibernate.collection-many-to-many column="fare_id" class="net.sf.oness.inventory.model.product.bo.Fare"
102      * 
103      * @return Returns the fares.
104      */
105     public Collection getFares() {
106         return fares;
107     }
108 
109 }