1 19 20 package com.lutris.airsent.business.customer; 21 22 23 import com.lutris.airsent.spec.AirSentException; 24 25 import com.lutris.airsent.business.*; 26 27 import com.lutris.airsent.spec.customer.Customer; 28 29 import com.lutris.airsent.business.address.*; 30 31 import com.lutris.airsent.spec.address.Address; 32 33 34 import com.lutris.airsent.data.person.*; 35 import com.lutris.appserver.server.sql.DatabaseManagerException; 36 import com.lutris.appserver.server.sql.ObjectIdException; 37 import com.lutris.dods.builder.generator.query.DataObjectException; 38 39 40 43 public class CustomerImpl 44 implements Customer, java.io.Serializable { 45 46 CustomerDO customerDO = null; 47 PersonDO personDO = null; 48 49 54 CustomerImpl() 55 throws AirSentException { 56 try { 57 customerDO = CustomerDO.createVirgin(); 58 personDO = PersonDO.createVirgin(); 59 60 AddressManager af = HomeManagerImpl.getInstance().getAddressManager(); 61 62 AddressImpl addr = af.create(); 63 64 personDO.setAddressID(addr.getDataObject()); 65 customerDO.setPersonID(personDO); 66 } catch (Exception e) { 67 throw new AirSentException(e); 68 } 69 } 70 71 77 public CustomerImpl(CustomerDO customer) 78 throws AirSentException { 79 try { 80 customerDO = customer; 81 personDO = customerDO.getPersonID(); 82 } catch (Exception e) { 83 throw new AirSentException(e); 84 } 85 } 86 87 93 public String getHandle() 94 throws AirSentException { 95 try { 96 return customerDO.getHandle(); 97 } catch (Exception e) { 98 throw new AirSentException(e); 99 } 100 } 101 102 107 public String getFirstName() 108 throws AirSentException { 109 try { 110 return personDO.getFirstName(); 111 } catch (Exception e) { 112 throw new AirSentException(e); 113 } 114 } 115 116 121 public void setFirstName(String first) 122 throws AirSentException, AirSentBusinessException { 123 if (first.length() > Customer.MAX_FIRST_NAME) { 124 throw new AirSentBusinessException("Exceeds maximum size"); 125 } 126 try { 127 personDO.setFirstName(first); 128 } catch (Exception e) { 129 throw new AirSentException(e); 130 } 131 } 132 133 139 public String getLastName() 140 throws AirSentException { 141 try { 142 return personDO.getLastName(); 143 } catch (Exception e) { 144 throw new AirSentException(e); 145 } 146 } 147 148 154 public void setLastName(String last) 155 throws AirSentException, AirSentBusinessException { 156 if (last.length() > Customer.MAX_LAST_NAME) { 157 throw new AirSentBusinessException("Exceeds maximum size"); 158 } 159 try { 160 personDO.setLastName(last); 161 } catch (Exception e) { 162 throw new AirSentException(e); 163 } 164 } 165 166 172 public String getEmail() 173 throws AirSentException { 174 try { 175 return personDO.getEmail(); 176 } catch (Exception e) { 177 throw new AirSentException(e); 178 } 179 } 180 181 187 public void setEmail(String email) 188 throws AirSentException, AirSentBusinessException { 189 if (email.length() > Customer.MAX_EMAIL) { 190 throw new AirSentBusinessException("Exceeds maximum size"); 191 } 192 try { 193 personDO.setEmail(email); 194 } catch (Exception e) { 195 throw new AirSentException(e); 196 } 197 } 198 199 205 public Address getAddress() 206 throws AirSentException { 207 try { 208 AddressManager af = HomeManagerImpl.getInstance().getAddressManager(); 209 return af.create(personDO.getAddressID()); 210 } catch (Exception e) { 211 throw new AirSentException(e); 212 } 213 } 214 215 221 public String getBusiness() 222 throws AirSentException { 223 try { 224 return customerDO.getBusiness(); 225 } catch (Exception e) { 226 throw new AirSentException(e); 227 } 228 } 229 230 236 public void setBusiness(String business) 237 throws AirSentException, AirSentBusinessException { 238 if (business.length() > Customer.MAX_BUSINESS) { 239 throw new AirSentBusinessException("Exceeds maximum size"); 240 } 241 try { 242 customerDO.setBusiness(business); 243 } catch (Exception e) { 244 throw new AirSentException(e); 245 } 246 } 247 248 254 public String getLogin() 255 throws AirSentException { 256 try { 257 return customerDO.getLogin(); 258 } catch (Exception e) { 259 throw new AirSentException(e); 260 } 261 } 262 263 269 public void setLogin(String login) 270 throws AirSentException, AirSentBusinessException { 271 if (login.length() > Customer.MAX_LOGIN) { 272 throw new AirSentBusinessException("Exceeds maximum size"); 273 } 274 try { 275 customerDO.setLogin(login); 276 } catch (Exception e) { 277 throw new AirSentException(e); 278 } 279 } 280 281 287 public String getPassword() 288 throws AirSentException { 289 try { 290 return customerDO.getPassword(); 291 } catch (Exception e) { 292 throw new AirSentException(e); 293 } 294 } 295 296 302 public void setPassword(String password) 303 throws AirSentException, AirSentBusinessException { 304 if (password.length() > Customer.MAX_PASSWORD) { 305 throw new AirSentBusinessException("Exceeds maximum size"); 306 } 307 try { 308 customerDO.setPassword(password); 309 } catch (Exception e) { 310 throw new AirSentException(e); 311 } 312 } 313 314 319 public void save() 320 throws AirSentException { 321 try { 322 customerDO.commit(); 323 } catch (Exception e) { 324 throw new AirSentException(e); 325 } 326 } 327 328 333 public void delete() 334 throws AirSentException { 335 try { 336 customerDO.delete(); 337 } catch (Exception e) { 338 throw new AirSentException(e); 339 } 340 } 341 } 342 343 | Popular Tags |