KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > store > orders > CompositeOrderArchive


1 /*
2  * Created on Oct 3, 2005
3  */

4 package com.openedit.store.orders;
5
6 import java.util.ArrayList JavaDoc;
7 import java.util.HashMap JavaDoc;
8 import java.util.Iterator JavaDoc;
9 import java.util.List JavaDoc;
10 import java.util.Map JavaDoc;
11
12 import org.apache.commons.collections.map.ListOrderedMap;
13
14 import com.openedit.WebPageRequest;
15 import com.openedit.store.Order;
16 import com.openedit.store.OrderArchive;
17 import com.openedit.store.OrderState;
18 import com.openedit.store.Store;
19 import com.openedit.store.StoreException;
20
21 public class CompositeOrderArchive implements OrderArchive
22 {
23     protected List JavaDoc fieldOrderArchives;
24     
25
26     public void archiveOrderData(Store inStore) throws StoreException
27     {
28         for (Iterator JavaDoc iter = getOrderArchives().iterator(); iter.hasNext();)
29         {
30             OrderArchive oa = (OrderArchive) iter.next();
31             oa.archiveOrderData(inStore);
32         }
33     }
34
35     public void exportNewOrder(WebPageRequest inContext, Store inStore, Order inOrder)
36         throws StoreException
37     {
38         
39         for (Iterator JavaDoc iter = getOrderArchives().iterator(); iter.hasNext();)
40         {
41             OrderArchive oa = (OrderArchive) iter.next();
42             oa.exportNewOrder(inContext, inStore, inOrder);
43             if ( !inOrder.getOrderState().isOk() )
44             {
45                 return;
46             }
47         }
48         
49     }
50
51     public void changeOrderStatus(OrderState inState, Store inStore, Order inOrder) throws StoreException
52     {
53         for (Iterator JavaDoc iter = getOrderArchives().iterator(); iter.hasNext();)
54         {
55             OrderArchive oa = (OrderArchive) iter.next();
56             oa.changeOrderStatus(inState, inStore, inOrder);
57         }
58     }
59
60     public List JavaDoc getOrderArchives()
61     {
62         return fieldOrderArchives;
63     }
64
65     public void setOrderArchives(List JavaDoc inOrderArchives)
66     {
67         fieldOrderArchives = inOrderArchives;
68     }
69
70     public List JavaDoc listOrders(Store inStore, WebPageRequest inReq) throws StoreException
71     {
72         List JavaDoc orders = new ArrayList JavaDoc();
73         for (Iterator JavaDoc iter = getOrderArchives().iterator(); iter.hasNext();)
74         {
75             OrderArchive oa = (OrderArchive) iter.next();
76             List JavaDoc old = oa.listOrders(inStore, inReq);
77             if ( old != null )
78             {
79                 orders.addAll(old);
80             }
81         }
82         return orders;
83     }
84
85     public void captureOrder(WebPageRequest inContext, Store inStore, Order inOrder) throws StoreException
86     {
87         for (Iterator JavaDoc iter = getOrderArchives().iterator(); iter.hasNext();)
88         {
89             OrderArchive oa = (OrderArchive) iter.next();
90             oa.captureOrder(inContext, inStore, inOrder);
91         }
92     }
93
94     public Map JavaDoc getOrderStates()
95     {
96         Map JavaDoc all = ListOrderedMap.decorate(new HashMap JavaDoc());
97         for (Iterator JavaDoc iter = getOrderArchives().iterator(); iter.hasNext();)
98         {
99             OrderArchive oa = (OrderArchive) iter.next();
100             Map JavaDoc list = oa.getOrderStates();
101             if( list != null)
102             {
103                 all.putAll(list);
104             }
105         }
106
107         return all;
108     }
109
110 }
111
Popular Tags