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