1 37 38 package com.sun.j2ee.blueprints.activitysupplier.purchaseorder.ejb; 39 40 import javax.ejb.*; 41 import java.util.*; 42 43 import com.sun.j2ee.blueprints.activitysupplier.powebservice.*; 44 import com.sun.j2ee.blueprints.activitysupplier.*; 45 import com.sun.j2ee.blueprints.servicelocator.*; 46 import com.sun.j2ee.blueprints.servicelocator.ejb.*; 47 48 54 55 public abstract class ActivityPurchaseOrderBean implements EntityBean { 56 57 private EntityContext entityContext = null; 58 59 public String ejbCreate(ActivityOrder po) throws CreateException { 60 setPoId(po.getOrderId()); 61 return null; 62 } 63 64 public void ejbPostCreate(ActivityOrder po) throws CreateException { 65 66 try { 67 ServiceLocator sl = new ServiceLocator(); 68 69 if(po != null){ 71 ActivityDetailsLocalHome alh = (ActivityDetailsLocalHome) 72 sl.getLocalHome(JNDINames.ACTIVITY_DETAILS_EJB); 73 ArrayList activities = po.getActivities(); 74 for(int i=0; i < activities.size(); i++) { 75 ActivityDetails act = (ActivityDetails) activities.get(i); 76 ActivityDetailsLocal al = (ActivityDetailsLocal) 77 alh.create(act.getActivityId(), act.getStartDate(), 78 act.getEndDate(), act.getHeadCount()); 79 addActivity(al); 80 } 81 } 82 } catch (ServiceLocatorException se) { 83 throw new CreateException("Exception saving Activity PO:" + 84 se.getMessage()); 85 } 86 } 87 88 public abstract void setPoId(String poId); 90 91 public abstract String getPoId(); 92 93 public abstract void setActivities(Collection activities); 94 95 public abstract Collection getActivities(); 96 97 public void addActivity(ActivityDetailsLocal activity) { 98 getActivities().add(activity); 99 } 100 101 public void ejbRemove() throws RemoveException {} 102 103 public void ejbLoad() {} 104 105 public void ejbStore() {} 106 107 public void ejbActivate() {} 108 109 public void ejbPassivate() {} 110 111 public void unsetEntityContext() { 112 this.entityContext = null; 113 } 114 115 public void setEntityContext(EntityContext entityContext) { 116 this.entityContext = entityContext; 117 } 118 } 119 | Popular Tags |