1 23 24 package transactionsDiscRack.business.disc; 25 26 27 import transactionsDiscRack.data.disc.*; 28 import transactionsDiscRack.spec.*; 29 import transactionsDiscRack.business.TransactionsDiscRackBusinessException; 30 import transactionsDiscRack.data.person.PersonDO; 31 32 import com.lutris.dods.builder.generator.query.*; 33 import com.lutris.appserver.server.sql.ObjectId; 34 import org.enhydra.dods.exceptions.AssertionDataObjectException; 35 import com.lutris.appserver.server.sql.DBTransaction; 36 import org.enhydra.dods.*; 37 40 public class DiscGeneratorImpl implements DiscGenerator { 41 42 54 public Disc[] findDiscsForPerson(Person owner) 55 throws TransactionsDiscRackBusinessException { 56 DiscImpl[] theDiscArray = null; 57 DBTransaction trans = null; 58 59 try { 60 try{ 61 trans = DODS.getDatabaseManager().createTransaction(); 62 }catch(Exception ex){ 63 throw new TransactionsDiscRackBusinessException("Error creating transaction!", ex); 64 } 65 DiscQuery query = new DiscQuery(trans); 66 query.setQueryOwner(PersonDO.createExisting(owner.getHandle(),trans)); 68 query.addOrderByArtist(); 70 DiscDO[] DOarray = query.getDOArray(); 71 theDiscArray = new DiscImpl[ DOarray.length ]; 72 for ( int i = 0; i < DOarray.length; i++ ) 73 theDiscArray[i] = new DiscImpl(DOarray[i]); 74 if (DOarray.length == 0) 75 trans.release(); 76 }catch(Exception ex) { 77 if (trans != null) 78 trans.release(); 79 throw new TransactionsDiscRackBusinessException("Exception in findDiscsForPerson()", ex); 80 } 81 82 return theDiscArray; 83 } 84 85 98 public Disc findDiscByID(String id) 99 throws TransactionsDiscRackBusinessException { 100 DiscImpl theDisc = null; 101 DBTransaction trans = null; 102 103 try { 104 try{ 105 trans = DODS.getDatabaseManager().createTransaction(); 106 }catch(Exception ex){ 107 throw new TransactionsDiscRackBusinessException("Error creating transaction!", ex); 108 } 109 DiscQuery query = new DiscQuery(trans); 110 query.setQueryOId(new ObjectId(id)); 112 query.requireUniqueInstance(); 114 DiscDO theDiscDO = query.getNextDO(); 115 theDisc = new DiscImpl(theDiscDO); 116 return theDisc; 117 }catch(Exception ex) { 118 if (trans != null) 119 trans.release(); 120 throw new TransactionsDiscRackBusinessException("Exception in findDiscsByID()", ex); 121 } 122 } 123 124 125 126 } 127 128 | Popular Tags |