1 package projectmanagement.business.project; 2 3 import projectmanagement.business.customer.*; 4 import projectmanagement.business.ProjectManagementBusinessException; 5 import projectmanagement.data.project.*; 6 import com.lutris.appserver.server.sql.DatabaseManagerException; 7 import com.lutris.appserver.server.sql.ObjectIdException; 8 import com.lutris.dods.builder.generator.query.DataObjectException; 9 10 import projectmanagement.spec.project.*; 11 import projectmanagement.spec.customer.*; 12 18 public class ProjectImpl implements Project { 19 22 protected ProjectDO myDO = null; 23 24 27 public ProjectImpl() throws ProjectManagementBusinessException { 28 try { 29 this.myDO = ProjectDO.createVirgin(); 30 } catch(DatabaseManagerException ex) { 31 throw new ProjectManagementBusinessException("Error creating empty project", ex); 32 } catch(ObjectIdException ex) { 33 throw new ProjectManagementBusinessException("Error creating object ID for project", ex); 34 } 35 } 36 37 41 public ProjectImpl(ProjectDO theProject) { 42 this.myDO = theProject; 43 } 44 45 52 public ProjectDO getDO() 53 throws ProjectManagementBusinessException { 54 if (this.myDO!=null) { 55 return this.myDO; 56 } else { 57 throw new ProjectManagementBusinessException("Error getting DO object for project"); 58 } 59 } 60 61 69 public String getHandle() 70 throws ProjectManagementBusinessException { 71 try { 72 return this.myDO.getHandle(); 73 } catch(DatabaseManagerException ex) { 74 throw new ProjectManagementBusinessException("Error getting handle for project", ex); 75 } 76 } 77 78 86 public void setName(String name) 87 throws ProjectManagementBusinessException { 88 try { 89 myDO.setName(name); 90 } catch(DataObjectException ex) { 91 throw new ProjectManagementBusinessException("Error setting project name", ex); 92 } 93 } 94 95 103 public String getName () 104 throws ProjectManagementBusinessException { 105 try { 106 return myDO.getName(); 107 } catch(DataObjectException ex) { 108 throw new ProjectManagementBusinessException("Error getting project name", ex); 109 } 110 } 111 112 120 public void setMoneyPerHour(double moneyPerHour) 121 throws ProjectManagementBusinessException { 122 try { 123 myDO.setMoneyPerHour(moneyPerHour); 124 } catch(DataObjectException ex) { 125 throw new ProjectManagementBusinessException("Error setting money per hour", ex); 126 } 127 } 128 129 137 public double getMoneyPerHour () 138 throws ProjectManagementBusinessException { 139 try { 140 return myDO.getMoneyPerHour(); 141 } catch(DataObjectException ex) { 142 throw new ProjectManagementBusinessException("Error getting money per hour", ex); 143 } 144 } 145 146 154 public void setCustomer(Customer customer) 155 throws ProjectManagementBusinessException { 156 try { 157 myDO.setCustomer(((CustomerImpl)customer).getDO()); 158 } catch(DataObjectException ex) { 159 throw new ProjectManagementBusinessException("Error setting customer", ex); 160 } 161 } 162 163 171 public Customer getCustomer() 172 throws ProjectManagementBusinessException { 173 try { 174 return new CustomerImpl(myDO.getCustomer()); 175 } catch(DataObjectException ex) { 176 throw new ProjectManagementBusinessException("Error getting customer", ex); 177 } 178 } 179 180 187 public void save() throws ProjectManagementBusinessException { 188 try { 189 this.myDO.save(); 190 } catch(Exception ex) { 191 throw new ProjectManagementBusinessException("Error saving project", ex); 192 } 193 } 194 195 202 public void delete() throws ProjectManagementBusinessException { 203 try { 204 this.myDO.delete(); 205 } catch(Exception ex) { 206 throw new ProjectManagementBusinessException("Error deleting project", ex); 207 } 208 } 209 210 } 211 | Popular Tags |