1 23 package org.enhydra.barracuda.discRack.biz.disc; 24 25 import org.enhydra.barracuda.discRack.biz.DiscRackBusinessException; 26 import org.enhydra.barracuda.discRack.biz.person.Person; 27 import org.enhydra.barracuda.discRack.data.person.PersonDO; 28 import org.enhydra.barracuda.discRack.data.disc.DiscDO; 29 import com.lutris.appserver.server.sql.DatabaseManagerException; 30 import com.lutris.appserver.server.sql.ObjectIdException; 31 import com.lutris.dods.builder.generator.query.DataObjectException; 32 33 36 public class Disc { 37 40 protected DiscDO myDO = null; 41 42 45 public Disc() throws DiscRackBusinessException { 46 try { 47 this.myDO = DiscDO.createVirgin(); 48 } catch(DatabaseManagerException ex) { 49 throw new DiscRackBusinessException("Error creating empty Disc", ex); 50 } catch(ObjectIdException ex) { 51 throw new DiscRackBusinessException("Error creating empty Disc", ex); 52 } 53 } 54 55 59 protected Disc(DiscDO theDisc) 60 throws DiscRackBusinessException { 61 this.myDO = theDisc; 62 } 63 64 72 public String getHandle() 73 throws DiscRackBusinessException { 74 try { 75 return this.myDO.getHandle(); 76 } catch(DatabaseManagerException ex) { 77 throw new DiscRackBusinessException("Error getting disc's handle", ex); 78 } 79 } 80 81 89 public String getTitle() 90 throws DiscRackBusinessException { 91 try { 92 return myDO.getTitle(); 93 } catch(DataObjectException ex) { 94 throw new DiscRackBusinessException("Error getting disc's title", ex); 95 } 96 } 97 98 106 public String getArtist() 107 throws DiscRackBusinessException { 108 try { 109 return myDO.getArtist(); 110 } catch(DataObjectException ex) { 111 throw new DiscRackBusinessException("Error getting disc's artist", ex); 112 } 113 } 114 115 123 public String getGenre() 124 throws DiscRackBusinessException { 125 try { 126 return myDO.getGenre(); 127 } catch(DataObjectException ex) { 128 throw new DiscRackBusinessException("Error getting disc's genre", ex); 129 } 130 } 131 132 140 public boolean isLiked() 141 throws DiscRackBusinessException { 142 try { 143 return myDO.getIsLiked(); 144 } catch(DataObjectException ex) { 145 throw new DiscRackBusinessException("Error getting disc's likedness", ex); 146 } 147 } 148 149 157 public void setTitle(String title) 158 throws DiscRackBusinessException { 159 try { 160 this.myDO .setTitle(title); 161 } catch(DataObjectException ex) { 162 throw new DiscRackBusinessException("Error setting disc's title", ex); 163 } 164 } 165 166 174 public void setArtist(String artist) 175 throws DiscRackBusinessException { 176 try { 177 this.myDO.setArtist(artist); 178 } catch(DataObjectException ex) { 179 throw new DiscRackBusinessException("Error setting disc's artist", ex); 180 } 181 } 182 183 191 public void setGenre(String genre) 192 throws DiscRackBusinessException { 193 try { 194 this.myDO.setGenre(genre); 195 } catch(DataObjectException ex) { 196 throw new DiscRackBusinessException("Error setting disc's genre", ex); 197 } 198 } 199 200 208 public void setOwner(Person owner) 209 throws DiscRackBusinessException 210 { 211 try { 212 this.myDO.setOwner(PersonDO.createExisting(owner.getHandle())); 213 } catch(DataObjectException ex) { 214 throw new DiscRackBusinessException("Error setting disc's owner", ex); 215 } 216 } 217 218 226 public void setLiked(boolean isLiked) 227 throws DiscRackBusinessException { 228 try { 229 this.myDO.setIsLiked(isLiked); 230 } catch(DataObjectException ex) { 231 throw new DiscRackBusinessException("Error setting disc's likedness", ex); 232 } 233 } 234 235 236 243 public void save() 244 throws DiscRackBusinessException { 245 try { 246 this.myDO.commit(); 247 } catch(Exception ex) { 248 throw new DiscRackBusinessException("Error saving disc", ex); 249 } 250 } 251 252 259 public void delete() 260 throws DiscRackBusinessException { 261 try { 262 this.myDO.delete(); 263 } catch(Exception ex) { 264 throw new DiscRackBusinessException("Error deleting disc", ex); 265 } 266 } 267 } 268 | Popular Tags |