1 23 24 package discRack.business.disc; 25 26 import discRack.business.DiscRackBusinessException; 27 import discRack.business.person.Person; 28 import discRack.data.person.PersonDO; 29 import discRack.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 import org.enhydra.dods.exceptions.AssertionDataObjectException; 34 35 38 public class Disc { 39 42 protected DiscDO myDO = null; 43 44 47 public Disc() throws DiscRackBusinessException { 48 try { 49 this.myDO = DiscDO.createVirgin(); 50 } catch(DatabaseManagerException ex) { 51 throw new DiscRackBusinessException("Error creating empty Disc", ex); 52 } catch(ObjectIdException ex) { 53 throw new DiscRackBusinessException("Error creating empty Disc", ex); 54 } 55 } 56 57 61 protected Disc(DiscDO theDisc) 62 throws DiscRackBusinessException { 63 this.myDO = theDisc; 64 } 65 66 74 public String getHandle() 75 throws DiscRackBusinessException { 76 try { 77 return this.myDO.getHandle(); 78 } catch(DatabaseManagerException ex) { 79 throw new DiscRackBusinessException("Error getting disc's handle", ex); 80 } 81 } 82 83 84 85 90 public boolean isDONull(){ 91 return myDO==null; 92 } 93 94 95 96 97 105 public String getTitle() throws DiscRackBusinessException { 106 try { 107 return myDO.getTitle(); 108 } catch(DataObjectException ex) { 109 throw new DiscRackBusinessException("Error getting disc's title", ex); 110 } 111 } 112 113 114 122 public int getVersion() throws DiscRackBusinessException { 123 try { 124 return myDO.getVersion(); 125 }catch(Exception ex) { 126 throw new DiscRackBusinessException("Error getting disc's version", ex); 127 } 128 } 129 130 131 132 140 public String getArtist() throws DiscRackBusinessException { 141 try { 142 return myDO.getArtist(); 143 } catch(DataObjectException ex) { 144 throw new DiscRackBusinessException("Error getting disc's artist", ex); 145 } 146 } 147 148 156 public String getGenre() throws DiscRackBusinessException { 157 try { 158 return myDO.getGenre(); 159 } catch(DataObjectException ex) { 160 throw new DiscRackBusinessException("Error getting disc's genre", ex); 161 } 162 } 163 164 172 public boolean isLiked() throws DiscRackBusinessException { 173 try { 174 return myDO.getIsLiked(); 175 } catch(DataObjectException ex) { 176 throw new DiscRackBusinessException("Error getting disc's likedness", ex); 177 } 178 } 179 180 188 public void setTitle(String title) 189 throws DiscRackBusinessException { 190 try { 191 this.myDO .setTitle(title); 192 } catch(DataObjectException ex) { 193 throw new DiscRackBusinessException("Error setting disc's title", ex); 194 } 195 } 196 197 205 public void setArtist(String artist) 206 throws DiscRackBusinessException { 207 try { 208 this.myDO.setArtist(artist); 209 } catch(DataObjectException ex) { 210 throw new DiscRackBusinessException("Error setting disc's artist", ex); 211 } 212 } 213 214 222 public void setGenre(String genre) throws DiscRackBusinessException { 223 try { 224 this.myDO.setGenre(genre); 225 } catch(DataObjectException ex) { 226 throw new DiscRackBusinessException("Error setting disc's genre", ex); 227 } 228 } 229 230 238 public void setOwner(Person owner) throws DiscRackBusinessException { 239 try { 240 this.myDO.setOwner(PersonDO.createExisting(owner.getHandle())); 241 } catch(DataObjectException ex) { 242 throw new DiscRackBusinessException("Error setting disc's owner", ex); 243 } 244 } 245 246 254 public void setLiked(boolean isLiked) throws DiscRackBusinessException { 255 try { 256 this.myDO.setIsLiked(isLiked); 257 } catch(DataObjectException ex) { 258 throw new DiscRackBusinessException("Error setting disc's likedness", ex); 259 } 260 } 261 262 263 264 272 public void setVersion(int ver) throws DiscRackBusinessException { 273 try { 274 this.myDO.setVersion(ver); 275 } catch(Exception ex) { 276 throw new DiscRackBusinessException("Error setting disc's likedness", ex); 277 } 278 } 279 280 281 282 283 290 public void save() throws DiscRackBusinessException,AssertionDataObjectException { 291 try { 292 this.myDO.save(); 294 } catch(AssertionDataObjectException ex) { 295 throw new AssertionDataObjectException("Read-only cache: DML opertions not allowed.", ex); 296 } catch(Exception ex) { 297 throw new DiscRackBusinessException("Error saving disc", ex); 298 } 299 } 300 301 308 public void delete() throws DiscRackBusinessException, AssertionDataObjectException { 309 try { 310 this.myDO.delete(); 311 } catch(AssertionDataObjectException ex) { 312 throw new AssertionDataObjectException("DML opertions not allowed.", ex); 313 } catch(Exception ex) { 314 throw new DiscRackBusinessException("Error deleting disc", ex); 315 } 316 } 317 } 318 | Popular Tags |