Source Code Cross Referenced for Disc.java in  » J2EE » enhydra » jtaDiscRack » business » disc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » enhydra » jtaDiscRack.business.disc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         *
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         *
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         *
019:         * Contributor(s):
020:         *
021:         * $Id: Disc.java,v 1.1 2006-06-27 12:03:06 sinisa Exp $
022:         */
023:
024:        package jtaDiscRack.business.disc;
025:
026:        import jtaDiscRack.business.JtaDiscRackBusinessException;
027:        import jtaDiscRack.business.XaTransactionSupport;
028:        import jtaDiscRack.business.person.Person;
029:        import jtaDiscRack.data.person.PersonDO;
030:        import jtaDiscRack.data.disc.DiscDO;
031:        import com.lutris.appserver.server.sql.DatabaseManagerException;
032:        import com.lutris.dods.builder.generator.query.DataObjectException;
033:        import org.enhydra.dods.exceptions.AssertionDataObjectException;
034:
035:        /**
036:         * Represents a disc.
037:         */
038:        public class Disc extends XaTransactionSupport {
039:
040:            private static int nextHandleNum = -1;
041:            /*
042:             * Disc attribures 
043:             */
044:            private String handle = null;
045:
046:            private String artist = null;
047:
048:            private String genre = null;
049:
050:            private String title = null;
051:
052:            private int version = -1;
053:
054:            private boolean isLiked = false;
055:
056:            private String owner = null;
057:
058:            /**
059:             * The public constructor.
060:             */
061:            public Disc() throws JtaDiscRackBusinessException {
062:                handle = String.valueOf(nextHandleNum);
063:                nextHandleNum--;
064:            }
065:
066:            /** The protected constructor
067:             *
068:             * @param theDisc. The data object of the disc.
069:             */
070:            protected Disc(DiscDO theDisc) throws JtaDiscRackBusinessException {
071:                try {
072:                    handle = theDisc.get_Handle();
073:                    title = theDisc.getTitle();
074:                    artist = theDisc.getArtist();
075:                    isLiked = theDisc.getIsLiked();
076:                    genre = theDisc.getGenre();
077:                    version = theDisc.getVersion();
078:                    owner = theDisc.getOwner().get_Handle();
079:                } catch (DatabaseManagerException dbme) {
080:                    dbme.printStackTrace();
081:                    throw new JtaDiscRackBusinessException(
082:                            "Error creating Disc", dbme);
083:                } catch (DataObjectException doe) {
084:                    doe.printStackTrace();
085:                    throw new JtaDiscRackBusinessException(
086:                            "Error creating Disc", doe);
087:                }
088:            }
089:
090:            /**
091:             * Gets the object id for the disc
092:             *
093:             * @return the object id.
094:             * @exception JtaDiscRackBusinessException if an error occurs
095:             *   retrieving data (usually due to an underlying data layer
096:             *   error).
097:             */
098:            public String getHandle() throws JtaDiscRackBusinessException {
099:                return handle;
100:            }
101:
102:            /**
103:             * Gets the status of DO
104:             *
105:             * @return is Do null.
106:             */
107:            public boolean isDONull() {
108:                return true;
109:            }
110:
111:            /**
112:             * Gets the title for the disc
113:             *
114:             * @return the title.
115:             * @exception JtaDiscRackBusinessException if an error occurs
116:             *   retrieving data (usually due to an underlying data layer
117:             *   error).
118:             */
119:            public String getTitle() throws JtaDiscRackBusinessException {
120:                return title;
121:            }
122:
123:            /**
124:             * Gets the version for the disc
125:             *
126:             * @return the version.
127:             * @exception JtaDiscRackBusinessException if an error occurs
128:             *   retrieving data (usually due to an underlying data layer
129:             *   error).
130:             */
131:            public int getVersion() throws JtaDiscRackBusinessException {
132:                return version;
133:            }
134:
135:            /**
136:             * Gets the artist for the disc
137:             *
138:             * @return the artist.
139:             * @exception JtaDiscRackBusinessException if an error occurs
140:             *   retrieving data (usually due to an underlying data layer
141:             *   error).
142:             */
143:            public String getArtist() throws JtaDiscRackBusinessException {
144:                return artist;
145:            }
146:
147:            /**
148:             * Gets the genre for the disc
149:             *
150:             * @return the genre.
151:             * @exception JtaDiscRackBusinessException if an error occurs
152:             *   retrieving data (usually due to an underlying data layer
153:             *   error).
154:             */
155:            public String getGenre() throws JtaDiscRackBusinessException {
156:                return genre;
157:            }
158:
159:            /**
160:             * Gets the preference for the disc
161:             *
162:             * @return true if like the disc, false if not
163:             * @exception JtaDiscRackBusinessException if an error occurs
164:             *   retrieving data (usually due to an underlying data layer
165:             *   error).
166:             */
167:            public boolean isLiked() throws JtaDiscRackBusinessException {
168:                return isLiked;
169:            }
170:
171:            /**
172:             * Sets the title for the disc.
173:             *
174:             * @param the title.
175:             * @exception JtaDiscRackBusinessException if an error occurs
176:             *   setting the data (usually due to an underlying data layer
177:             *   error).
178:             */
179:            public void setTitle(String title)
180:                    throws JtaDiscRackBusinessException {
181:                this .title = title;
182:            }
183:
184:            /**
185:             * Sets the artist for the disc.
186:             *
187:             * @param the artist.
188:             * @exception JtaDiscRackBusinessException if an error occurs
189:             *   setting the data (usually due to an underlying data layer
190:             *   error).
191:             */
192:            public void setArtist(String artist)
193:                    throws JtaDiscRackBusinessException {
194:                this .artist = artist;
195:            }
196:
197:            /**
198:             * Sets the genre for the disc.
199:             *
200:             * @param the genre.
201:             * @exception JtaDiscRackBusinessException if an error occurs
202:             *   setting the data (usually due to an underlying data layer
203:             *   error).
204:             */
205:            public void setGenre(String genre)
206:                    throws JtaDiscRackBusinessException {
207:                this .genre = genre;
208:            }
209:
210:            /**
211:             * Sets the owner for the disc.
212:             *
213:             * @param the owner.
214:             * @exception JtaDiscRackBusinessException if an error occurs
215:             *   setting the data (usually due to an underlying data layer
216:             *   error).
217:             */
218:            public void setOwner(Person owner)
219:                    throws JtaDiscRackBusinessException {
220:                this .owner = owner.getHandle();
221:            }
222:
223:            /**
224:             * Sets the preference for the disc.
225:             *
226:             * @param the preference.
227:             * @exception JtaDiscRackBusinessException if an error occurs
228:             *   setting the data (usually due to an underlying data layer
229:             *   error).
230:             */
231:            public void setLiked(boolean isLiked)
232:                    throws JtaDiscRackBusinessException {
233:                this .isLiked = isLiked;
234:            }
235:
236:            /**
237:             * Sets the version for the disc.
238:             *
239:             * @param the version.
240:             * @exception JtaDiscRackBusinessException if an error occurs
241:             *   setting the data (usually due to an underlying data layer
242:             *   error).
243:             */
244:            public void setVersion(int ver) throws JtaDiscRackBusinessException {
245:                this .version = ver;
246:            }
247:
248:            /**
249:             * Commits all changes to the database.
250:             *
251:             * @exception JtaDiscRackBusinessException if an error occurs
252:             *   retrieving data (usually due to an underlying data layer
253:             *   error). 
254:             */
255:            public void save() throws JtaDiscRackBusinessException,
256:                    AssertionDataObjectException {
257:
258:                initTransaction();
259:
260:                boolean doCommit = true;
261:
262:                DiscDO myDO = null;
263:
264:                try {
265:                    PersonDO personDO = PersonDO.createExisting(this .owner);
266:
267:                    if (personDO != null) {
268:                        myDO = DiscDO.createExisting(this .handle);
269:
270:                        if (myDO == null) {
271:                            // disc creation
272:                            myDO = DiscDO.createVirgin();
273:                        }
274:                        myDO.setTitle(this .title);
275:                        myDO.setArtist(this .artist);
276:                        myDO.setGenre(this .genre);
277:                        myDO.setIsLiked(this .isLiked);
278:                        myDO.setOwner(personDO);
279:                        myDO.save();
280:                    }
281:                } catch (AssertionDataObjectException ex) {
282:                    doCommit = false;
283:                    ex.printStackTrace();
284:                    throw new AssertionDataObjectException(
285:                            "Read-only cache: DML opertions not allowed.", ex);
286:                } catch (Exception ex) {
287:                    doCommit = false;
288:                    ex.printStackTrace();
289:                    throw new JtaDiscRackBusinessException("Error saving disc",
290:                            ex);
291:                } finally {
292:                    if (doCommit) {
293:                        commitTransaction();
294:                    } else {
295:                        rollbackTransaction();
296:                    }
297:                }
298:
299:                try {
300:                    if (myDO != null) {
301:                        this .handle = myDO.get_Handle();
302:                        this .version = myDO.get_Version();
303:                    }
304:                } catch (Exception ex) {
305:                    ex.printStackTrace();
306:                }
307:            }
308:
309:            /**
310:             * Deletes the disc from the database.
311:             *
312:             * @exception JtaDiscRackBusinessException if an error occurs
313:             *   deleting data (usually due to an underlying data layer
314:             *   error).
315:             */
316:            public void delete() throws JtaDiscRackBusinessException,
317:                    AssertionDataObjectException {
318:
319:                initTransaction();
320:
321:                boolean doCommit = true;
322:
323:                try {
324:                    DiscDO myDO = DiscDO.createExisting(this .handle);
325:                    if (myDO != null) {
326:                        myDO.delete();
327:                    }
328:                } catch (AssertionDataObjectException ex) {
329:                    doCommit = false;
330:                    throw new AssertionDataObjectException(
331:                            "DML opertions not allowed.", ex);
332:                } catch (Exception ex) {
333:                    doCommit = false;
334:                    throw new JtaDiscRackBusinessException(
335:                            "Error deleting disc", ex);
336:                } finally {
337:                    if (doCommit) {
338:                        commitTransaction();
339:                    } else {
340:                        rollbackTransaction();
341:                    }
342:                }
343:            }
344:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.