Source Code Cross Referenced for BaseReport.java in  » Issue-Tracking » scarab-0.21 » org » tigris » scarab » om » 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 » Issue Tracking » scarab 0.21 » org.tigris.scarab.om 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.tigris.scarab.om;
002:
003:        import java.math.BigDecimal;
004:        import java.sql.Connection;
005:        import java.util.ArrayList;
006:        import java.util.Collections;
007:        import java.util.Date;
008:        import java.util.List;
009:
010:        import org.apache.commons.lang.ObjectUtils;
011:        import org.apache.fulcrum.intake.Retrievable;
012:        import org.apache.torque.TorqueException;
013:        import org.apache.torque.om.BaseObject;
014:        import org.apache.torque.om.ComboKey;
015:        import org.apache.torque.om.DateKey;
016:        import org.apache.torque.om.NumberKey;
017:        import org.apache.torque.om.ObjectKey;
018:        import org.apache.torque.om.SimpleKey;
019:        import org.apache.torque.om.StringKey;
020:        import org.apache.torque.om.Persistent;
021:        import org.apache.torque.util.Criteria;
022:        import org.apache.torque.util.Transaction;
023:
024:        /**
025:         * You should not use this class directly.  It should not even be
026:         * extended all references should be to Report
027:         */
028:        public abstract class BaseReport extends BaseObject implements 
029:                org.apache.fulcrum.intake.Retrievable {
030:            /** The Peer class */
031:            private static final ReportPeer peer = new ReportPeer();
032:
033:            /** The value for the reportId field */
034:            private Integer reportId;
035:
036:            /** The value for the userId field */
037:            private Integer userId;
038:
039:            /** The value for the moduleId field */
040:            private Integer moduleId;
041:
042:            /** The value for the issueTypeId field */
043:            private Integer issueTypeId;
044:
045:            /** The value for the name field */
046:            private String name;
047:
048:            /** The value for the description field */
049:            private String description;
050:
051:            /** The value for the queryString field */
052:            private String queryString;
053:
054:            /** The value for the scopeId field */
055:            private Integer scopeId;
056:
057:            /** The value for the deleted field */
058:            private boolean deleted = false;
059:
060:            /** The value for the createdDate field */
061:            private Date createdDate;
062:
063:            /**
064:             * Get the ReportId
065:             *
066:             * @return Integer
067:             */
068:            public Integer getReportId() {
069:                return reportId;
070:            }
071:
072:            /**
073:             * Set the value of ReportId
074:             *
075:             * @param v new value
076:             */
077:            public void setReportId(Integer v) {
078:
079:                if (!ObjectUtils.equals(this .reportId, v)) {
080:                    this .reportId = v;
081:                    setModified(true);
082:                }
083:
084:            }
085:
086:            /**
087:             * Get the UserId
088:             *
089:             * @return Integer
090:             */
091:            public Integer getUserId() {
092:                return userId;
093:            }
094:
095:            /**
096:             * Set the value of UserId
097:             *
098:             * @param v new value
099:             */
100:            public void setUserId(Integer v) throws TorqueException {
101:
102:                if (!ObjectUtils.equals(this .userId, v)) {
103:                    this .userId = v;
104:                    setModified(true);
105:                }
106:
107:                if (aScarabUser != null
108:                        && !ObjectUtils.equals(aScarabUser.getUserId(), v)) {
109:                    aScarabUser = null;
110:                }
111:
112:            }
113:
114:            /**
115:             * Get the ModuleId
116:             *
117:             * @return Integer
118:             */
119:            public Integer getModuleId() {
120:                return moduleId;
121:            }
122:
123:            /**
124:             * Set the value of ModuleId
125:             *
126:             * @param v new value
127:             */
128:            public void setModuleId(Integer v) throws TorqueException {
129:
130:                if (!ObjectUtils.equals(this .moduleId, v)) {
131:                    this .moduleId = v;
132:                    setModified(true);
133:                }
134:
135:                if (aModule != null
136:                        && !ObjectUtils.equals(aModule.getModuleId(), v)) {
137:                    aModule = null;
138:                }
139:
140:            }
141:
142:            /**
143:             * Get the IssueTypeId
144:             *
145:             * @return Integer
146:             */
147:            public Integer getIssueTypeId() {
148:                return issueTypeId;
149:            }
150:
151:            /**
152:             * Set the value of IssueTypeId
153:             *
154:             * @param v new value
155:             */
156:            public void setIssueTypeId(Integer v) throws TorqueException {
157:
158:                if (!ObjectUtils.equals(this .issueTypeId, v)) {
159:                    this .issueTypeId = v;
160:                    setModified(true);
161:                }
162:
163:                if (aIssueType != null
164:                        && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v)) {
165:                    aIssueType = null;
166:                }
167:
168:            }
169:
170:            /**
171:             * Get the Name
172:             *
173:             * @return String
174:             */
175:            public String getName() {
176:                return name;
177:            }
178:
179:            /**
180:             * Set the value of Name
181:             *
182:             * @param v new value
183:             */
184:            public void setName(String v) {
185:
186:                if (!ObjectUtils.equals(this .name, v)) {
187:                    this .name = v;
188:                    setModified(true);
189:                }
190:
191:            }
192:
193:            /**
194:             * Get the Description
195:             *
196:             * @return String
197:             */
198:            public String getDescription() {
199:                return description;
200:            }
201:
202:            /**
203:             * Set the value of Description
204:             *
205:             * @param v new value
206:             */
207:            public void setDescription(String v) {
208:
209:                if (!ObjectUtils.equals(this .description, v)) {
210:                    this .description = v;
211:                    setModified(true);
212:                }
213:
214:            }
215:
216:            /**
217:             * Get the QueryString
218:             *
219:             * @return String
220:             */
221:            public String getQueryString() {
222:                return queryString;
223:            }
224:
225:            /**
226:             * Set the value of QueryString
227:             *
228:             * @param v new value
229:             */
230:            public void setQueryString(String v) {
231:
232:                if (!ObjectUtils.equals(this .queryString, v)) {
233:                    this .queryString = v;
234:                    setModified(true);
235:                }
236:
237:            }
238:
239:            /**
240:             * Get the ScopeId
241:             *
242:             * @return Integer
243:             */
244:            public Integer getScopeId() {
245:                return scopeId;
246:            }
247:
248:            /**
249:             * Set the value of ScopeId
250:             *
251:             * @param v new value
252:             */
253:            public void setScopeId(Integer v) throws TorqueException {
254:
255:                if (!ObjectUtils.equals(this .scopeId, v)) {
256:                    this .scopeId = v;
257:                    setModified(true);
258:                }
259:
260:                if (aScope != null
261:                        && !ObjectUtils.equals(aScope.getScopeId(), v)) {
262:                    aScope = null;
263:                }
264:
265:            }
266:
267:            /**
268:             * Get the Deleted
269:             *
270:             * @return boolean
271:             */
272:            public boolean getDeleted() {
273:                return deleted;
274:            }
275:
276:            /**
277:             * Set the value of Deleted
278:             *
279:             * @param v new value
280:             */
281:            public void setDeleted(boolean v) {
282:
283:                if (this .deleted != v) {
284:                    this .deleted = v;
285:                    setModified(true);
286:                }
287:
288:            }
289:
290:            /**
291:             * Get the CreatedDate
292:             *
293:             * @return Date
294:             */
295:            public Date getCreatedDate() {
296:                return createdDate;
297:            }
298:
299:            /**
300:             * Set the value of CreatedDate
301:             *
302:             * @param v new value
303:             */
304:            public void setCreatedDate(Date v) {
305:
306:                if (!ObjectUtils.equals(this .createdDate, v)) {
307:                    this .createdDate = v;
308:                    setModified(true);
309:                }
310:
311:            }
312:
313:            private IssueType aIssueType;
314:
315:            /**
316:             * Declares an association between this object and a IssueType object
317:             *
318:             * @param v IssueType
319:             * @throws TorqueException
320:             */
321:            public void setIssueType(IssueType v) throws TorqueException {
322:                if (v == null) {
323:                    setIssueTypeId((Integer) null);
324:                } else {
325:                    setIssueTypeId(v.getIssueTypeId());
326:                }
327:                aIssueType = v;
328:            }
329:
330:            /**
331:             * Returns the associated IssueType object.
332:             * If it was not retrieved before, the object is retrieved from
333:             * the database
334:             *
335:             * @return the associated IssueType object
336:             * @throws TorqueException
337:             */
338:            public IssueType getIssueType() throws TorqueException {
339:                if (aIssueType == null
340:                        && (!ObjectUtils.equals(this .issueTypeId, null))) {
341:                    aIssueType = IssueTypeManager.getInstance(SimpleKey
342:                            .keyFor(this .issueTypeId));
343:                }
344:                return aIssueType;
345:            }
346:
347:            /**
348:             * Return the associated IssueType object
349:             * If it was not retrieved before, the object is retrieved from
350:             * the database using the passed connection
351:             *
352:             * @param connection the connection used to retrieve the associated object
353:             *        from the database, if it was not retrieved before
354:             * @return the associated IssueType object
355:             * @throws TorqueException
356:             */
357:            public IssueType getIssueType(Connection connection)
358:                    throws TorqueException {
359:                if (aIssueType == null
360:                        && (!ObjectUtils.equals(this .issueTypeId, null))) {
361:                    aIssueType = IssueTypeManager.getCachedInstance(SimpleKey
362:                            .keyFor(this .issueTypeId));
363:                    if (aIssueType == null) {
364:                        aIssueType = IssueTypePeer.retrieveByPK(SimpleKey
365:                                .keyFor(this .issueTypeId), connection);
366:                        IssueTypeManager.putInstance(aIssueType);
367:                    }
368:                }
369:                return aIssueType;
370:            }
371:
372:            /**
373:             * Provides convenient way to set a relationship based on a
374:             * ObjectKey, for example
375:             * <code>bar.setFooKey(foo.getPrimaryKey())</code>
376:             *
377:             */
378:            public void setIssueTypeKey(ObjectKey key) throws TorqueException {
379:
380:                setIssueTypeId(new Integer(((NumberKey) key).intValue()));
381:            }
382:
383:            private ScarabUser aScarabUser;
384:
385:            /**
386:             * Declares an association between this object and a ScarabUser object
387:             *
388:             * @param v ScarabUser
389:             * @throws TorqueException
390:             */
391:            public void setScarabUser(ScarabUser v) throws TorqueException {
392:                if (v == null) {
393:                    setUserId((Integer) null);
394:                } else {
395:                    setUserId(v.getUserId());
396:                }
397:                aScarabUser = v;
398:            }
399:
400:            /**
401:             * Returns the associated ScarabUser object.
402:             * If it was not retrieved before, the object is retrieved from
403:             * the database
404:             *
405:             * @return the associated ScarabUser object
406:             * @throws TorqueException
407:             */
408:            public ScarabUser getScarabUser() throws TorqueException {
409:                if (aScarabUser == null
410:                        && (!ObjectUtils.equals(this .userId, null))) {
411:                    aScarabUser = ScarabUserManager.getInstance(SimpleKey
412:                            .keyFor(this .userId));
413:                }
414:                return aScarabUser;
415:            }
416:
417:            /**
418:             * Return the associated ScarabUser object
419:             * If it was not retrieved before, the object is retrieved from
420:             * the database using the passed connection
421:             *
422:             * @param connection the connection used to retrieve the associated object
423:             *        from the database, if it was not retrieved before
424:             * @return the associated ScarabUser object
425:             * @throws TorqueException
426:             */
427:            public ScarabUser getScarabUser(Connection connection)
428:                    throws TorqueException {
429:                if (aScarabUser == null
430:                        && (!ObjectUtils.equals(this .userId, null))) {
431:                    aScarabUser = ScarabUserManager.getCachedInstance(SimpleKey
432:                            .keyFor(this .userId));
433:                    if (aScarabUser == null) {
434:                        aScarabUser = ScarabUserImplPeer
435:                                .retrieveScarabUserImplByPK(SimpleKey
436:                                        .keyFor(this .userId), connection);
437:                        ScarabUserManager.putInstance(aScarabUser);
438:                    }
439:                }
440:                return aScarabUser;
441:            }
442:
443:            /**
444:             * Provides convenient way to set a relationship based on a
445:             * ObjectKey, for example
446:             * <code>bar.setFooKey(foo.getPrimaryKey())</code>
447:             *
448:             */
449:            public void setScarabUserKey(ObjectKey key) throws TorqueException {
450:
451:                setUserId(new Integer(((NumberKey) key).intValue()));
452:            }
453:
454:            private Module aModule;
455:
456:            /**
457:             * Declares an association between this object and a Module object
458:             *
459:             * @param v Module
460:             * @throws TorqueException
461:             */
462:            public void setModule(Module v) throws TorqueException {
463:                if (v == null) {
464:                    setModuleId((Integer) null);
465:                } else {
466:                    setModuleId(v.getModuleId());
467:                }
468:                aModule = v;
469:            }
470:
471:            /**
472:             * Returns the associated Module object.
473:             * If it was not retrieved before, the object is retrieved from
474:             * the database
475:             *
476:             * @return the associated Module object
477:             * @throws TorqueException
478:             */
479:            public Module getModule() throws TorqueException {
480:                if (aModule == null
481:                        && (!ObjectUtils.equals(this .moduleId, null))) {
482:                    aModule = ModuleManager.getInstance(SimpleKey
483:                            .keyFor(this .moduleId));
484:                }
485:                return aModule;
486:            }
487:
488:            /**
489:             * Return the associated Module object
490:             * If it was not retrieved before, the object is retrieved from
491:             * the database using the passed connection
492:             *
493:             * @param connection the connection used to retrieve the associated object
494:             *        from the database, if it was not retrieved before
495:             * @return the associated Module object
496:             * @throws TorqueException
497:             */
498:            public Module getModule(Connection connection)
499:                    throws TorqueException {
500:                if (aModule == null
501:                        && (!ObjectUtils.equals(this .moduleId, null))) {
502:                    aModule = ModuleManager.getCachedInstance(SimpleKey
503:                            .keyFor(this .moduleId));
504:                    if (aModule == null) {
505:                        aModule = ScarabModulePeer.retrieveByPK(SimpleKey
506:                                .keyFor(this .moduleId), connection);
507:                        ModuleManager.putInstance(aModule);
508:                    }
509:                }
510:                return aModule;
511:            }
512:
513:            /**
514:             * Provides convenient way to set a relationship based on a
515:             * ObjectKey, for example
516:             * <code>bar.setFooKey(foo.getPrimaryKey())</code>
517:             *
518:             */
519:            public void setModuleKey(ObjectKey key) throws TorqueException {
520:
521:                setModuleId(new Integer(((NumberKey) key).intValue()));
522:            }
523:
524:            private Scope aScope;
525:
526:            /**
527:             * Declares an association between this object and a Scope object
528:             *
529:             * @param v Scope
530:             * @throws TorqueException
531:             */
532:            public void setScope(Scope v) throws TorqueException {
533:                if (v == null) {
534:                    setScopeId((Integer) null);
535:                } else {
536:                    setScopeId(v.getScopeId());
537:                }
538:                aScope = v;
539:            }
540:
541:            /**
542:             * Returns the associated Scope object.
543:             * If it was not retrieved before, the object is retrieved from
544:             * the database
545:             *
546:             * @return the associated Scope object
547:             * @throws TorqueException
548:             */
549:            public Scope getScope() throws TorqueException {
550:                if (aScope == null && (!ObjectUtils.equals(this .scopeId, null))) {
551:                    aScope = ScopeManager.getInstance(SimpleKey
552:                            .keyFor(this .scopeId));
553:                }
554:                return aScope;
555:            }
556:
557:            /**
558:             * Return the associated Scope object
559:             * If it was not retrieved before, the object is retrieved from
560:             * the database using the passed connection
561:             *
562:             * @param connection the connection used to retrieve the associated object
563:             *        from the database, if it was not retrieved before
564:             * @return the associated Scope object
565:             * @throws TorqueException
566:             */
567:            public Scope getScope(Connection connection) throws TorqueException {
568:                if (aScope == null && (!ObjectUtils.equals(this .scopeId, null))) {
569:                    aScope = ScopeManager.getCachedInstance(SimpleKey
570:                            .keyFor(this .scopeId));
571:                    if (aScope == null) {
572:                        aScope = ScopePeer.retrieveByPK(SimpleKey
573:                                .keyFor(this .scopeId), connection);
574:                        ScopeManager.putInstance(aScope);
575:                    }
576:                }
577:                return aScope;
578:            }
579:
580:            /**
581:             * Provides convenient way to set a relationship based on a
582:             * ObjectKey, for example
583:             * <code>bar.setFooKey(foo.getPrimaryKey())</code>
584:             *
585:             */
586:            public void setScopeKey(ObjectKey key) throws TorqueException {
587:
588:                setScopeId(new Integer(((NumberKey) key).intValue()));
589:            }
590:
591:            private static List fieldNames = null;
592:
593:            /**
594:             * Generate a list of field names.
595:             *
596:             * @return a list of field names
597:             */
598:            public static synchronized List getFieldNames() {
599:                if (fieldNames == null) {
600:                    fieldNames = new ArrayList();
601:                    fieldNames.add("ReportId");
602:                    fieldNames.add("UserId");
603:                    fieldNames.add("ModuleId");
604:                    fieldNames.add("IssueTypeId");
605:                    fieldNames.add("Name");
606:                    fieldNames.add("Description");
607:                    fieldNames.add("QueryString");
608:                    fieldNames.add("ScopeId");
609:                    fieldNames.add("Deleted");
610:                    fieldNames.add("CreatedDate");
611:                    fieldNames = Collections.unmodifiableList(fieldNames);
612:                }
613:                return fieldNames;
614:            }
615:
616:            /**
617:             * Retrieves a field from the object by name passed in as a String.
618:             *
619:             * @param name field name
620:             * @return value
621:             */
622:            public Object getByName(String name) {
623:                if (name.equals("ReportId")) {
624:                    return getReportId();
625:                }
626:                if (name.equals("UserId")) {
627:                    return getUserId();
628:                }
629:                if (name.equals("ModuleId")) {
630:                    return getModuleId();
631:                }
632:                if (name.equals("IssueTypeId")) {
633:                    return getIssueTypeId();
634:                }
635:                if (name.equals("Name")) {
636:                    return getName();
637:                }
638:                if (name.equals("Description")) {
639:                    return getDescription();
640:                }
641:                if (name.equals("QueryString")) {
642:                    return getQueryString();
643:                }
644:                if (name.equals("ScopeId")) {
645:                    return getScopeId();
646:                }
647:                if (name.equals("Deleted")) {
648:                    return Boolean.valueOf(getDeleted());
649:                }
650:                if (name.equals("CreatedDate")) {
651:                    return getCreatedDate();
652:                }
653:                return null;
654:            }
655:
656:            /**
657:             * Retrieves a field from the object by name passed in
658:             * as a String.  The String must be one of the static
659:             * Strings defined in this Class' Peer.
660:             *
661:             * @param name peer name
662:             * @return value
663:             */
664:            public Object getByPeerName(String name) {
665:                if (name.equals(ReportPeer.REPORT_ID)) {
666:                    return getReportId();
667:                }
668:                if (name.equals(ReportPeer.USER_ID)) {
669:                    return getUserId();
670:                }
671:                if (name.equals(ReportPeer.MODULE_ID)) {
672:                    return getModuleId();
673:                }
674:                if (name.equals(ReportPeer.ISSUE_TYPE_ID)) {
675:                    return getIssueTypeId();
676:                }
677:                if (name.equals(ReportPeer.NAME)) {
678:                    return getName();
679:                }
680:                if (name.equals(ReportPeer.DESCRIPTION)) {
681:                    return getDescription();
682:                }
683:                if (name.equals(ReportPeer.QUERY_STRING)) {
684:                    return getQueryString();
685:                }
686:                if (name.equals(ReportPeer.SCOPE_ID)) {
687:                    return getScopeId();
688:                }
689:                if (name.equals(ReportPeer.DELETED)) {
690:                    return Boolean.valueOf(getDeleted());
691:                }
692:                if (name.equals(ReportPeer.CREATED_DATE)) {
693:                    return getCreatedDate();
694:                }
695:                return null;
696:            }
697:
698:            /**
699:             * Retrieves a field from the object by Position as specified
700:             * in the xml schema.  Zero-based.
701:             *
702:             * @param pos position in xml schema
703:             * @return value
704:             */
705:            public Object getByPosition(int pos) {
706:                if (pos == 0) {
707:                    return getReportId();
708:                }
709:                if (pos == 1) {
710:                    return getUserId();
711:                }
712:                if (pos == 2) {
713:                    return getModuleId();
714:                }
715:                if (pos == 3) {
716:                    return getIssueTypeId();
717:                }
718:                if (pos == 4) {
719:                    return getName();
720:                }
721:                if (pos == 5) {
722:                    return getDescription();
723:                }
724:                if (pos == 6) {
725:                    return getQueryString();
726:                }
727:                if (pos == 7) {
728:                    return getScopeId();
729:                }
730:                if (pos == 8) {
731:                    return Boolean.valueOf(getDeleted());
732:                }
733:                if (pos == 9) {
734:                    return getCreatedDate();
735:                }
736:                return null;
737:            }
738:
739:            /**
740:             * Stores the object in the database.  If the object is new,
741:             * it inserts it; otherwise an update is performed.
742:             *
743:             * @throws TorqueException
744:             */
745:            public void save() throws TorqueException {
746:                save(ReportPeer.getMapBuilder().getDatabaseMap().getName());
747:            }
748:
749:            /**
750:             * Stores the object in the database.  If the object is new,
751:             * it inserts it; otherwise an update is performed.
752:             * Note: this code is here because the method body is
753:             * auto-generated conditionally and therefore needs to be
754:             * in this file instead of in the super class, BaseObject.
755:             *
756:             * @param dbName
757:             * @throws TorqueException
758:             */
759:            public void save(String dbName) throws TorqueException {
760:                Connection con = null;
761:                try {
762:                    con = Transaction.begin(dbName);
763:                    save(con);
764:                    Transaction.commit(con);
765:                } catch (TorqueException e) {
766:                    Transaction.safeRollback(con);
767:                    throw e;
768:                }
769:            }
770:
771:            /** flag to prevent endless save loop, if this object is referenced
772:              by another object which falls in this transaction. */
773:            private boolean alreadyInSave = false;
774:
775:            /**
776:             * Stores the object in the database.  If the object is new,
777:             * it inserts it; otherwise an update is performed.  This method
778:             * is meant to be used as part of a transaction, otherwise use
779:             * the save() method and the connection details will be handled
780:             * internally
781:             *
782:             * @param con
783:             * @throws TorqueException
784:             */
785:            public void save(Connection con) throws TorqueException {
786:                if (!alreadyInSave) {
787:                    alreadyInSave = true;
788:
789:                    // If this object has been modified, then save it to the database.
790:                    if (isModified()) {
791:                        if (isNew()) {
792:                            ReportPeer.doInsert((Report) this , con);
793:                            setNew(false);
794:                        } else {
795:                            ReportPeer.doUpdate((Report) this , con);
796:                        }
797:
798:                        if (isCacheOnSave()) {
799:                            ReportManager.putInstance(this );
800:                        }
801:                    }
802:
803:                    alreadyInSave = false;
804:                }
805:            }
806:
807:            /**
808:             * Specify whether to cache the object after saving to the db.
809:             * This method returns true
810:             */
811:            protected boolean isCacheOnSave() {
812:                return true;
813:            }
814:
815:            /**
816:             * Set the PrimaryKey using ObjectKey.
817:             *
818:             * @param key reportId ObjectKey
819:             */
820:            public void setPrimaryKey(ObjectKey key)
821:
822:            {
823:                setReportId(new Integer(((NumberKey) key).intValue()));
824:            }
825:
826:            /**
827:             * Set the PrimaryKey using a String.
828:             *
829:             * @param key
830:             */
831:            public void setPrimaryKey(String key) {
832:                setReportId(new Integer(key));
833:            }
834:
835:            /**
836:             * returns an id that differentiates this object from others
837:             * of its class.
838:             */
839:            public ObjectKey getPrimaryKey() {
840:                return SimpleKey.keyFor(getReportId());
841:            }
842:
843:            /**
844:             * get an id that differentiates this object from others
845:             * of its class.
846:             */
847:            public String getQueryKey() {
848:                if (getPrimaryKey() == null) {
849:                    return "";
850:                } else {
851:                    return getPrimaryKey().toString();
852:                }
853:            }
854:
855:            /**
856:             * set an id that differentiates this object from others
857:             * of its class.
858:             */
859:            public void setQueryKey(String key) throws TorqueException {
860:                setPrimaryKey(key);
861:            }
862:
863:            /**
864:             * Makes a copy of this object.
865:             * It creates a new object filling in the simple attributes.
866:             * It then fills all the association collections and sets the
867:             * related objects to isNew=true.
868:             */
869:            public Report copy() throws TorqueException {
870:                return copyInto(new Report());
871:            }
872:
873:            protected Report copyInto(Report copyObj) throws TorqueException {
874:                copyObj.setReportId(reportId);
875:                copyObj.setUserId(userId);
876:                copyObj.setModuleId(moduleId);
877:                copyObj.setIssueTypeId(issueTypeId);
878:                copyObj.setName(name);
879:                copyObj.setDescription(description);
880:                copyObj.setQueryString(queryString);
881:                copyObj.setScopeId(scopeId);
882:                copyObj.setDeleted(deleted);
883:                copyObj.setCreatedDate(createdDate);
884:
885:                copyObj.setReportId((Integer) null);
886:
887:                return copyObj;
888:            }
889:
890:            /**
891:             * returns a peer instance associated with this om.  Since Peer classes
892:             * are not to have any instance attributes, this method returns the
893:             * same instance for all member of this class. The method could therefore
894:             * be static, but this would prevent one from overriding the behavior.
895:             */
896:            public ReportPeer getPeer() {
897:                return peer;
898:            }
899:
900:            public String toString() {
901:                StringBuffer str = new StringBuffer();
902:                str.append("Report:\n");
903:                str.append("ReportId = ").append(getReportId()).append("\n");
904:                str.append("UserId = ").append(getUserId()).append("\n");
905:                str.append("ModuleId = ").append(getModuleId()).append("\n");
906:                str.append("IssueTypeId = ").append(getIssueTypeId()).append(
907:                        "\n");
908:                str.append("Name = ").append(getName()).append("\n");
909:                str.append("Description = ").append(getDescription()).append(
910:                        "\n");
911:                str.append("QueryString = ").append(getQueryString()).append(
912:                        "\n");
913:                str.append("ScopeId = ").append(getScopeId()).append("\n");
914:                str.append("Deleted = ").append(getDeleted()).append("\n");
915:                str.append("CreatedDate = ").append(getCreatedDate()).append(
916:                        "\n");
917:                return (str.toString());
918:            }
919:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.