KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Created on 07.11.2004
3  */

4 package com.nightlabs.ipanema.trade;
5
6 import java.io.Serializable JavaDoc;
7 import java.util.HashMap JavaDoc;
8 import java.util.Map JavaDoc;
9
10 /**
11  * One instance of OfferRequirement exists for each Offer on the side of the vendor.
12  * The OfferRequirement bundles all other offers that the vendor needs to create to
13  * fulfill its own offer.
14  *
15  * @author Marco Schulze - marco at nightlabs dot de
16  *
17  * @jdo.persistence-capable
18  * identity-type = "application"
19  * objectid-class = "com.nightlabs.ipanema.trade.id.OfferRequirementID"
20  * detachable = "true"
21  *
22  * @jdo.inheritance strategy = "new-table"
23  */

24 public class OfferRequirement
25     implements Serializable JavaDoc
26 {
27     /**
28      * @jdo.field primary-key="true"
29      * @jdo.column length="100"
30      */

31     private String JavaDoc organisationID;
32
33     /**
34      * @jdo.field primary-key="true"
35      */

36     private long offerID;
37     
38     private Trader trader;
39
40     private Offer offer;
41     
42     /**
43      * key: String anchorPK (of the vendor LegalEntity)<br/>
44      * value: Offer offer
45      * <br/><br/>
46      *
47      * @jdo.field
48      * persistence-modifier="persistent"
49      * collection-type="map"
50      * key-type="java.lang.String"
51      * value-type="Offer"
52      *
53      * @jdo.join
54      */

55     private Map JavaDoc offersByVendor = new HashMap JavaDoc();
56
57     public OfferRequirement() { }
58
59     public OfferRequirement(Trader trader, Offer offer)
60     {
61         if (trader == null)
62             throw new NullPointerException JavaDoc("trader");
63         
64         if (offer == null)
65             throw new NullPointerException JavaDoc("offer");
66
67         this.trader = trader;
68         this.offer = offer;
69         this.organisationID = offer.getOrganisationID();
70         this.offerID = offer.getOfferID();
71     }
72     
73     public void addOffer(Offer offer) {
74         OrganisationLegalEntity vendor = offer.getOrder().getVendor();
75         offersByVendor.put(vendor.getPrimaryKey(), vendor);
76     }
77     
78     /**
79      * Returns the Offer for this vendor or null.
80      * @param vendor
81      */

82     public Offer getOfferByVendor(OrganisationLegalEntity vendor) {
83         return (Offer)offersByVendor.get(vendor.getPrimaryKey());
84     }
85     
86     /**
87      *
88      * @return The associated Offer.
89      */

90     public Offer getOffer() {
91         return offer;
92     }
93     
94
95 }
96
Popular Tags