1 package projectmanagement.business.customer; 2 3 import projectmanagement.business.ProjectManagementBusinessException; 4 import projectmanagement.data.customer.*; 5 import com.lutris.appserver.server.sql.DatabaseManagerException; 6 import com.lutris.appserver.server.sql.ObjectId; 7 import com.lutris.appserver.server.sql.ObjectIdException; 8 import com.lutris.dods.builder.generator.query.*; 9 import com.lutris.appserver.server.Enhydra; 10 import com.lutris.logging.*; 11 12 import projectmanagement.spec.customer.*; 13 19 public class CustomerManagerImpl implements CustomerManager { 20 21 29 public Customer[] getAllCustomers() 30 throws ProjectManagementBusinessException { 31 try { 32 CustomerQuery query = new CustomerQuery(); 33 34 CustomerDO[] foundCustomers = query.getDOArray(); 35 if(foundCustomers.length != 0) { 36 CustomerImpl[] cs=new CustomerImpl[foundCustomers.length]; 37 for (int i=0; i<foundCustomers.length; i++) { 38 cs[i]=new CustomerImpl(foundCustomers[i]); 39 } 40 return cs; 41 } else { 42 return null; 43 } 44 } catch(NonUniqueQueryException ex) { 45 Enhydra.getLogChannel().write(Logger.DEBUG, 46 "Non-unique customer found in database: "+ex.getMessage()); 47 throw new ProjectManagementBusinessException("Non unique customer found"); 48 } catch(DataObjectException ex) { 49 throw new ProjectManagementBusinessException("Database error retrieving customers: ", ex); 50 } 53 } 54 55 68 public Customer findCustomerByID(String id) 69 throws ProjectManagementBusinessException { 70 CustomerImpl theCustomer = null; 71 72 try { 73 CustomerQuery query = new CustomerQuery(); 74 query.setQueryOId(new ObjectId(id)); 76 query.requireUniqueInstance(); 78 CustomerDO theCustomerDO = query.getNextDO(); 79 theCustomer = new CustomerImpl(theCustomerDO); 80 return theCustomer; 81 } catch(Exception ex) { 82 throw new ProjectManagementBusinessException("Exception in findCustomerByID()", ex); 83 } 84 } 85 86 public Customer getCustomer() 87 throws ProjectManagementBusinessException{ 88 return new CustomerImpl(); 89 } 90 } 91 92 | Popular Tags |