1 23 24 package transactionsDiscRack.business.person; 25 26 27 import transactionsDiscRack.data.person.*; 28 import transactionsDiscRack.data.disc.DiscDO; 29 import transactionsDiscRack.spec.Person; 30 import transactionsDiscRack.business.TransactionsDiscRackBusinessException; 31 32 import com.lutris.appserver.server.sql.DatabaseManagerException; 33 import com.lutris.appserver.server.sql.ObjectIdException; 34 import com.lutris.dods.builder.generator.query.DataObjectException; 35 import org.enhydra.dods.exceptions.AssertionDataObjectException; 36 import com.lutris.appserver.server.sql.DBTransaction; 37 import org.enhydra.dods.*; 38 39 42 public class PersonImpl implements Person,java.io.Serializable { 43 46 protected PersonDO myDO = null; 47 48 51 public PersonImpl() throws TransactionsDiscRackBusinessException { 52 DBTransaction trans = null; 53 try { 54 try{ 55 trans = DODS.getDatabaseManager().createTransaction(); 56 }catch(Exception ex){ 57 throw new DatabaseManagerException("Error creating transaction!", ex); 58 } 59 prep(trans); 60 this.myDO = PersonDO.createVirgin(trans); 61 } catch(DatabaseManagerException ex) { 62 throw new TransactionsDiscRackBusinessException("Error creating empty person", ex); 63 } catch(ObjectIdException ex) { 64 throw new TransactionsDiscRackBusinessException("Error creating object ID for person", ex); 65 } 66 } 67 68 72 public PersonImpl(PersonDO thePerson) { 73 this.myDO = thePerson; 74 } 75 76 84 public String getHandle() 85 throws TransactionsDiscRackBusinessException { 86 try { 87 return this.myDO.getHandle(); 88 } catch(DatabaseManagerException ex) { 89 throw new TransactionsDiscRackBusinessException("Error getting handle for person", ex); 90 } 91 } 92 93 101 public String getLogin() 102 throws TransactionsDiscRackBusinessException { 103 try { 104 return myDO.getLogin(); 105 } catch(DataObjectException ex) { 106 throw new TransactionsDiscRackBusinessException("Error getting user's login name", ex); 107 } 108 } 109 110 118 public String getPassword() 119 throws TransactionsDiscRackBusinessException { 120 try { 121 return myDO.getPassword(); 122 } catch(DataObjectException ex) { 123 throw new TransactionsDiscRackBusinessException("Error getting user's password", ex); 124 } 125 } 126 127 135 public String getFirstname() 136 throws TransactionsDiscRackBusinessException { 137 try { 138 return myDO.getFirstname(); 139 } catch(DataObjectException ex) { 140 throw new TransactionsDiscRackBusinessException("Error getting user's first name", ex); 141 } 142 } 143 144 152 public String getLastname() 153 throws TransactionsDiscRackBusinessException { 154 try { 155 return myDO.getLastname(); 156 } catch(DataObjectException ex) { 157 throw new TransactionsDiscRackBusinessException("Error getting user's last name", ex); 158 } 159 } 160 161 169 public void setLogin(String login) 170 throws TransactionsDiscRackBusinessException { 171 try { 172 myDO.setLogin(login); 173 } catch(DataObjectException ex) { 174 throw new TransactionsDiscRackBusinessException("Error setting user's login name", ex); 175 } 176 } 177 178 186 public void setPassword(String password) 187 throws TransactionsDiscRackBusinessException { 188 try { 189 myDO.setPassword(password); 190 } catch(DataObjectException ex) { 191 throw new TransactionsDiscRackBusinessException("Error setting user's password", ex); 192 } 193 } 194 195 203 public void setFirstname(String firstname) 204 throws TransactionsDiscRackBusinessException { 205 try { 206 myDO.setFirstname(firstname); 207 } catch(DataObjectException ex) { 208 throw new TransactionsDiscRackBusinessException("Error setting user's first name", ex); 209 } 210 } 211 212 220 public void setLastname(String lastname) 221 throws TransactionsDiscRackBusinessException { 222 try { 223 myDO.setLastname(lastname); 224 } catch(DataObjectException ex) { 225 throw new TransactionsDiscRackBusinessException("Error setting user's last name", ex); 226 } 227 } 228 229 private void prep(DBTransaction trans) { 230 try { 231 PersonQuery query = new PersonQuery(trans); 232 query.setQueryHandle("0"); 233 query.requireUniqueInstance(); 234 query.getNextDO(); 235 } catch (Exception exc){} 236 } 237 244 public void save() throws TransactionsDiscRackBusinessException, AssertionDataObjectException { 245 try { 246 this.myDO.save(); 247 this.myDO.get_transaction().commit(); 248 } 249 catch (AssertionDataObjectException ex) { 250 throw new AssertionDataObjectException("Read-only table: DML operations not allowed", ex); 251 } 252 catch(Exception ex) { 253 throw new TransactionsDiscRackBusinessException("Error saving person", ex); 254 } 255 } 256 public void dbtRelease() { 257 myDO.get_transaction().release(); 258 } 259 } 260 | Popular Tags |