1 37 38 package com.sun.j2ee.blueprints.processmanager.ejb; 39 40 import java.util.Collection ; 41 42 import javax.naming.InitialContext ; 43 import javax.naming.NamingException ; 44 import javax.ejb.SessionBean ; 45 import javax.ejb.SessionContext ; 46 import javax.ejb.EJBException ; 47 import javax.ejb.FinderException ; 48 import javax.ejb.CreateException ; 49 import javax.ejb.RemoveException ; 50 import javax.ejb.DuplicateKeyException ; 51 52 import com.sun.j2ee.blueprints.processmanager.manager.ejb.ManagerLocal; 53 import com.sun.j2ee.blueprints.processmanager.manager.ejb.ManagerLocalHome; 54 55 import com.sun.j2ee.blueprints.servicelocator.*; 56 import com.sun.j2ee.blueprints.servicelocator.ejb.*; 57 58 public class ProcessManagerBean implements SessionBean { 59 60 public static final String MANAGER_HOME_ENV_NAME = 61 "java:comp/env/ejb/local/processmanager/Manager"; 62 63 private ManagerLocalHome mlh; 64 65 69 public void createManager(String orderId, String status, 70 String actyOrderStatus, 71 String airlineOrderStatus, 72 String lodgOrderStatus) 73 throws CreateException { 74 ManagerLocal manager = mlh.create(orderId, status, actyOrderStatus, 75 airlineOrderStatus, lodgOrderStatus, 76 false); 77 } 78 79 82 83 public void updateStatus(String orderId, String status) 84 throws FinderException { 85 ManagerLocal manager = mlh.findByPrimaryKey(orderId); 86 manager.setStatus(status); 87 } 88 89 public void updateOrderErrorStatus(String orderId, boolean error) 90 throws FinderException { 91 ManagerLocal manager = mlh.findByPrimaryKey(orderId); 92 manager.setOrderError(error); 93 } 94 95 public void updateActivityOrderStatus(String orderId, String status) 96 throws FinderException { 97 ManagerLocal manager = mlh.findByPrimaryKey(orderId); 98 manager.setActivityOrderStatus(status); 99 } 100 101 public void updateAirlineOrderStatus(String orderId, String status) 102 throws FinderException { 103 ManagerLocal manager = mlh.findByPrimaryKey(orderId); 104 manager.setAirlineOrderStatus(status); 105 } 106 107 public void updateLodgingOrderStatus(String orderId, String status) 108 throws FinderException { 109 ManagerLocal manager = mlh.findByPrimaryKey(orderId); 110 manager.setLodgingOrderStatus(status); 111 } 112 113 public void updateStatusToCompleted(String orderId) throws FinderException { 114 117 if ( (getActivityOrderStatus(orderId).equalsIgnoreCase(OrderStatusNames.COMPLETED)) && 118 (getAirlineOrderStatus(orderId).equalsIgnoreCase(OrderStatusNames.COMPLETED)) && 119 (getLodgingOrderStatus(orderId).equalsIgnoreCase(OrderStatusNames.COMPLETED))) { 120 ManagerLocal manager = mlh.findByPrimaryKey(orderId); 121 manager.setStatus("COMPLETED"); 122 } 123 } 124 125 126 129 public String getOrderStatus(String orderId) throws FinderException { 130 ManagerLocal manager = mlh.findByPrimaryKey(orderId); 131 return manager.getStatus(); 132 } 133 134 private String getActivityOrderStatus(String orderId) 135 throws FinderException { 136 ManagerLocal manager = mlh.findByPrimaryKey(orderId); 137 return manager.getActivityOrderStatus(); 138 } 139 140 private String getAirlineOrderStatus(String orderId) 141 throws FinderException { 142 ManagerLocal manager = mlh.findByPrimaryKey(orderId); 143 return manager.getAirlineOrderStatus(); 144 } 145 146 private String getLodgingOrderStatus(String orderId) 147 throws FinderException { 148 ManagerLocal manager = mlh.findByPrimaryKey(orderId); 149 return manager.getLodgingOrderStatus(); 150 } 151 152 153 154 157 public Collection getOrdersByStatus (String status) throws FinderException { 158 return mlh.findOrdersByStatus(status); 159 } 160 161 public void ejbCreate() throws CreateException { 162 try { 163 ServiceLocator sl = new ServiceLocator(); 164 mlh = (ManagerLocalHome) sl.getLocalHome(MANAGER_HOME_ENV_NAME); 165 } catch (ServiceLocatorException se) { 166 throw new EJBException ("Got service locator exception! " + 167 se.getMessage()); 168 } 169 } 170 171 public void ejbActivate() { } 175 176 public void ejbPassivate() { } 178 179 public void setSessionContext(SessionContext c) { } 180 public void ejbRemove() { } 181 182 } 183 | Popular Tags |