KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > barracuda > Disc


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: Disc.java,v 1.4 2004/12/03 14:12:34 slobodan Exp $
22  */

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 /**
35  * Represents a disc.
36  */

37 public class Disc {
38     /**
39      * The DO of the disc.
40      */

41     protected DiscDO myDO = null;
42
43     /**
44      * The public constructor.
45      */

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     /** The protected constructor
57      *
58      * @param theDisc. The data object of the disc.
59      */

60     protected Disc(DiscDO theDisc)
61         throws DiscRackBusinessException {
62         this.myDO = theDisc;
63     }
64
65     /**
66      * Gets the object id for the disc
67      *
68      * @return the object id.
69      * @exception DiscRackBusinessException if an error occurs
70      * retrieving data (usually due to an underlying data layer
71      * error).
72      */

73     public String JavaDoc 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     /**
83      * Gets the title for the disc
84      *
85      * @return the title.
86      * @exception DiscRackBusinessException if an error occurs
87      * retrieving data (usually due to an underlying data layer
88      * error).
89      */

90     public String JavaDoc 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     /**
100      * Gets the artist for the disc
101      *
102      * @return the artist.
103      * @exception DiscRackBusinessException if an error occurs
104      * retrieving data (usually due to an underlying data layer
105      * error).
106      */

107     public String JavaDoc 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     /**
117      * Gets the genre for the disc
118      *
119      * @return the genre.
120      * @exception DiscRackBusinessException if an error occurs
121      * retrieving data (usually due to an underlying data layer
122      * error).
123      */

124     public String JavaDoc 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     /**
134      * Gets the preference for the disc
135      *
136      * @return true if like the disc, false if not
137      * @exception DiscRackBusinessException if an error occurs
138      * retrieving data (usually due to an underlying data layer
139      * error).
140      */

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     /**
151      * Sets the title for the disc.
152      *
153      * @param the title.
154      * @exception DiscRackBusinessException if an error occurs
155      * setting the data (usually due to an underlying data layer
156      * error).
157      */

158     public void setTitle(String JavaDoc 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     /**
168      * Sets the artist for the disc.
169      *
170      * @param the artist.
171      * @exception DiscRackBusinessException if an error occurs
172      * setting the data (usually due to an underlying data layer
173      * error).
174      */

175     public void setArtist(String JavaDoc 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     /**
185      * Sets the genre for the disc.
186      *
187      * @param the genre.
188      * @exception DiscRackBusinessException if an error occurs
189      * setting the data (usually due to an underlying data layer
190      * error).
191      */

192     public void setGenre(String JavaDoc 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     /**
202      * Sets the owner for the disc.
203      *
204      * @param the owner.
205      * @exception DiscRackBusinessException if an error occurs
206      * setting the data (usually due to an underlying data layer
207      * error).
208      */

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     /**
220      * Sets the preference for the disc.
221      *
222      * @param the preference.
223      * @exception DiscRackBusinessException if an error occurs
224      * setting the data (usually due to an underlying data layer
225      * error).
226      */

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     /**
238      * Commits all changes to the database.
239      *
240      * @exception DiscRackBusinessException if an error occurs
241      * retrieving data (usually due to an underlying data layer
242      * error).
243      */

244     public void save()
245         throws DiscRackBusinessException {
246         try {
247             this.myDO.commit();
248         } catch(Exception JavaDoc ex) {
249             throw new DiscRackBusinessException("Error saving disc", ex);
250         }
251     }
252     
253     /**
254      * Deletes the disc from the database.
255      *
256      * @exception DiscRackBusinessException if an error occurs
257      * deleting data (usually due to an underlying data layer
258      * error).
259      */

260     public void delete()
261         throws DiscRackBusinessException {
262         try {
263             this.myDO.delete();
264         } catch(Exception JavaDoc ex) {
265             throw new DiscRackBusinessException("Error deleting disc", ex);
266         }
267     }
268 }
269
Popular Tags