1 23 24 package discRack.business.disc; 25 26 import discRack.spec.*; 27 import discRack.data.person.PersonDO; 28 import discRack.data.disc.DiscDO; 29 30 import discRack.business.DiscRackBusinessException; 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 37 40 public class DiscImpl implements Disc{ 41 44 protected DiscDO myDO = null; 45 46 49 public DiscImpl() throws DiscRackBusinessException { 50 try { 51 this.myDO = DiscDO.createVirgin(); 52 } catch(DatabaseManagerException ex) { 53 throw new DiscRackBusinessException("Error creating empty Disc", ex); 54 } catch(ObjectIdException ex) { 55 throw new DiscRackBusinessException("Error creating empty Disc", ex); 56 } 57 } 58 59 63 protected DiscImpl(DiscDO theDisc) 64 throws DiscRackBusinessException { 65 this.myDO = theDisc; 66 } 67 68 76 public String getHandle() 77 throws DiscRackBusinessException { 78 try { 79 return this.myDO.getHandle(); 80 } catch(DatabaseManagerException ex) { 81 throw new DiscRackBusinessException("Error getting disc's handle", ex); 82 } 83 } 84 85 93 public String getTitle() 94 throws DiscRackBusinessException { 95 try { 96 return myDO.getTitle(); 97 } catch(DataObjectException ex) { 98 throw new DiscRackBusinessException("Error getting disc's title", ex); 99 } 100 } 101 102 110 public String getArtist() 111 throws DiscRackBusinessException { 112 try { 113 return myDO.getArtist(); 114 } catch(DataObjectException ex) { 115 throw new DiscRackBusinessException("Error getting disc's artist", ex); 116 } 117 } 118 119 127 public String getGenre() 128 throws DiscRackBusinessException { 129 try { 130 return myDO.getGenre(); 131 } catch(DataObjectException ex) { 132 throw new DiscRackBusinessException("Error getting disc's genre", ex); 133 } 134 } 135 136 144 public boolean isLiked() 145 throws DiscRackBusinessException { 146 try { 147 return myDO.getIsLiked(); 148 } catch(DataObjectException ex) { 149 throw new DiscRackBusinessException("Error getting disc's likedness", ex); 150 } 151 } 152 153 161 public void setTitle(String title) 162 throws DiscRackBusinessException { 163 try { 164 this.myDO .setTitle(title); 165 } catch(DataObjectException ex) { 166 throw new DiscRackBusinessException("Error setting disc's title", ex); 167 } 168 } 169 170 178 public void setArtist(String artist) 179 throws DiscRackBusinessException { 180 try { 181 this.myDO.setArtist(artist); 182 } catch(DataObjectException ex) { 183 throw new DiscRackBusinessException("Error setting disc's artist", ex); 184 } 185 } 186 187 195 public void setGenre(String genre) 196 throws DiscRackBusinessException { 197 try { 198 this.myDO.setGenre(genre); 199 } catch(DataObjectException ex) { 200 throw new DiscRackBusinessException("Error setting disc's genre", ex); 201 } 202 } 203 204 212 public void setOwner(Person owner) 213 throws DiscRackException 214 { 215 try { 216 this.myDO.setOwner(PersonDO.createExisting(owner.getHandle())); 217 } catch(DataObjectException ex) { 218 throw new DiscRackBusinessException("Error setting disc's owner", ex); 219 } 220 } 221 222 230 public void setLiked(boolean isLiked) 231 throws DiscRackBusinessException { 232 try { 233 this.myDO.setIsLiked(isLiked); 234 } catch(DataObjectException ex) { 235 throw new DiscRackBusinessException("Error setting disc's likedness", ex); 236 } 237 } 238 239 240 247 public void save() 248 throws DiscRackBusinessException, AssertionDataObjectException { 249 try { 250 this.myDO.commit(); 251 } 252 catch (AssertionDataObjectException ex) { 253 throw new AssertionDataObjectException("Read-only table: DML operations not allowed", ex); 254 } 255 catch(Exception ex) { 256 throw new DiscRackBusinessException("Error saving disc", ex); 257 } 258 } 259 260 267 public void delete() 268 throws DiscRackBusinessException, AssertionDataObjectException { 269 try { 270 this.myDO.delete(); 271 } 272 catch (AssertionDataObjectException ex) { 273 throw new AssertionDataObjectException("Read-only table: DML operations not allowed", ex); 274 } 275 catch(Exception ex) { 276 throw new DiscRackBusinessException("Error deleting disc", ex); 277 } 278 } 279 } 280 | Popular Tags |