1 4 package com.openedit.store.orders; 5 6 import java.util.ArrayList ; 7 import java.util.HashMap ; 8 import java.util.Iterator ; 9 import java.util.List ; 10 import java.util.Map ; 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 fieldOrderArchives; 24 25 26 public void archiveOrderData(Store inStore) throws StoreException 27 { 28 for (Iterator 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 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 iter = getOrderArchives().iterator(); iter.hasNext();) 54 { 55 OrderArchive oa = (OrderArchive) iter.next(); 56 oa.changeOrderStatus(inState, inStore, inOrder); 57 } 58 } 59 60 public List getOrderArchives() 61 { 62 return fieldOrderArchives; 63 } 64 65 public void setOrderArchives(List inOrderArchives) 66 { 67 fieldOrderArchives = inOrderArchives; 68 } 69 70 public List listOrders(Store inStore, WebPageRequest inReq) throws StoreException 71 { 72 List orders = new ArrayList (); 73 for (Iterator iter = getOrderArchives().iterator(); iter.hasNext();) 74 { 75 OrderArchive oa = (OrderArchive) iter.next(); 76 List 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 iter = getOrderArchives().iterator(); iter.hasNext();) 88 { 89 OrderArchive oa = (OrderArchive) iter.next(); 90 oa.captureOrder(inContext, inStore, inOrder); 91 } 92 } 93 94 public Map getOrderStates() 95 { 96 Map all = ListOrderedMap.decorate(new HashMap ()); 97 for (Iterator iter = getOrderArchives().iterator(); iter.hasNext();) 98 { 99 OrderArchive oa = (OrderArchive) iter.next(); 100 Map list = oa.getOrderStates(); 101 if( list != null) 102 { 103 all.putAll(list); 104 } 105 } 106 107 return all; 108 } 109 110 } 111 | Popular Tags |