KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > trade > OfferPrice


1 /*
2  * Created on 04.11.2004
3  */

4 package com.nightlabs.ipanema.trade;
5
6 import java.util.Collection JavaDoc;
7 import java.util.Iterator JavaDoc;
8
9 /**
10  * @author Marco Schulze - marco at nightlabs dot de
11  * @author Alexander Bieber <alex[AT]nightlabs[DOT]de>
12  *
13  * @jdo.persistence-capable
14  * identity-type = "application"
15  * persistence-capable-superclass = "com.nightlabs.ipanema.accounting.Price"
16  * detachable = "true"
17  *
18  * @jdo.inheritance strategy = "new-table"
19  */

20 public class OfferPrice extends com.nightlabs.ipanema.accounting.Price
21 {
22     /**
23      * @jdo.field persistence-modifier="persistent"
24      */

25     private Offer offer;
26
27     public OfferPrice() { }
28
29     /**
30      * @param organisationID
31      * @param priceID
32      * @param currency
33      *
34      * @deprecated test
35      */

36     public OfferPrice(Offer offer, String JavaDoc organisationID, long priceConfigID, long priceID)
37     {
38         super(organisationID, priceConfigID, priceID, offer.getCurrency());
39         this.offer = offer;
40
41         calculatePrice();
42     }
43
44     protected void calculatePrice()
45     {
46         setAmount(0);
47         clearFragments();
48
49         for (int i = 0; i < 2; ++i) {
50             Collection JavaDoc items;
51             if (i == 0)
52                 items = offer.getItemsToSell();
53             else
54                 items = offer.getItemsToRefund();
55
56             for (Iterator JavaDoc it = items.iterator(); it.hasNext(); ) {
57                 OfferItem offerItem = (OfferItem)it.next();
58                 OfferItemPrice offerItemPrice = offerItem.getPrice();
59                 sumPrice(offerItemPrice);
60             }
61         }
62     }
63
64     /**
65      * @return Returns the offer.
66      */

67     protected Offer getOffer()
68     {
69         return offer;
70     }
71 }
72
Popular Tags