Source Code Cross Referenced for BaseRQueryUser.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 RQueryUser
027:         */
028:        public abstract class BaseRQueryUser extends BaseObject implements 
029:                org.apache.fulcrum.intake.Retrievable {
030:            /** The Peer class */
031:            private static final RQueryUserPeer peer = new RQueryUserPeer();
032:
033:            /** The value for the queryId field */
034:            private Long queryId;
035:
036:            /** The value for the userId field */
037:            private Integer userId;
038:
039:            /** The value for the isSubscribed field */
040:            private boolean isSubscribed = false;
041:
042:            /** The value for the subscriptionFrequency field */
043:            private Integer subscriptionFrequency;
044:
045:            /** The value for the isdefault field */
046:            private boolean isdefault = false;
047:
048:            /**
049:             * Get the QueryId
050:             *
051:             * @return Long
052:             */
053:            public Long getQueryId() {
054:                return queryId;
055:            }
056:
057:            /**
058:             * Set the value of QueryId
059:             *
060:             * @param v new value
061:             */
062:            public void setQueryId(Long v) throws TorqueException {
063:
064:                if (!ObjectUtils.equals(this .queryId, v)) {
065:                    this .queryId = v;
066:                    setModified(true);
067:                }
068:
069:                if (aQuery != null
070:                        && !ObjectUtils.equals(aQuery.getQueryId(), v)) {
071:                    aQuery = null;
072:                }
073:
074:            }
075:
076:            /**
077:             * Get the UserId
078:             *
079:             * @return Integer
080:             */
081:            public Integer getUserId() {
082:                return userId;
083:            }
084:
085:            /**
086:             * Set the value of UserId
087:             *
088:             * @param v new value
089:             */
090:            public void setUserId(Integer v) throws TorqueException {
091:
092:                if (!ObjectUtils.equals(this .userId, v)) {
093:                    this .userId = v;
094:                    setModified(true);
095:                }
096:
097:                if (aScarabUser != null
098:                        && !ObjectUtils.equals(aScarabUser.getUserId(), v)) {
099:                    aScarabUser = null;
100:                }
101:
102:            }
103:
104:            /**
105:             * Get the IsSubscribed
106:             *
107:             * @return boolean
108:             */
109:            public boolean getIsSubscribed() {
110:                return isSubscribed;
111:            }
112:
113:            /**
114:             * Set the value of IsSubscribed
115:             *
116:             * @param v new value
117:             */
118:            public void setIsSubscribed(boolean v) {
119:
120:                if (this .isSubscribed != v) {
121:                    this .isSubscribed = v;
122:                    setModified(true);
123:                }
124:
125:            }
126:
127:            /**
128:             * Get the SubscriptionFrequency
129:             *
130:             * @return Integer
131:             */
132:            public Integer getSubscriptionFrequency() {
133:                return subscriptionFrequency;
134:            }
135:
136:            /**
137:             * Set the value of SubscriptionFrequency
138:             *
139:             * @param v new value
140:             */
141:            public void setSubscriptionFrequency(Integer v)
142:                    throws TorqueException {
143:
144:                if (!ObjectUtils.equals(this .subscriptionFrequency, v)) {
145:                    this .subscriptionFrequency = v;
146:                    setModified(true);
147:                }
148:
149:                if (aFrequency != null
150:                        && !ObjectUtils.equals(aFrequency.getFrequencyId(), v)) {
151:                    aFrequency = null;
152:                }
153:
154:            }
155:
156:            /**
157:             * Get the Isdefault
158:             *
159:             * @return boolean
160:             */
161:            public boolean getIsdefault() {
162:                return isdefault;
163:            }
164:
165:            /**
166:             * Set the value of Isdefault
167:             *
168:             * @param v new value
169:             */
170:            public void setIsdefault(boolean v) {
171:
172:                if (this .isdefault != v) {
173:                    this .isdefault = v;
174:                    setModified(true);
175:                }
176:
177:            }
178:
179:            private Query aQuery;
180:
181:            /**
182:             * Declares an association between this object and a Query object
183:             *
184:             * @param v Query
185:             * @throws TorqueException
186:             */
187:            public void setQuery(Query v) throws TorqueException {
188:                if (v == null) {
189:                    setQueryId((Long) null);
190:                } else {
191:                    setQueryId(v.getQueryId());
192:                }
193:                aQuery = v;
194:            }
195:
196:            /**
197:             * Returns the associated Query object.
198:             * If it was not retrieved before, the object is retrieved from
199:             * the database
200:             *
201:             * @return the associated Query object
202:             * @throws TorqueException
203:             */
204:            public Query getQuery() throws TorqueException {
205:                if (aQuery == null && (!ObjectUtils.equals(this .queryId, null))) {
206:                    aQuery = QueryManager.getInstance(SimpleKey
207:                            .keyFor(this .queryId));
208:                }
209:                return aQuery;
210:            }
211:
212:            /**
213:             * Return the associated Query object
214:             * If it was not retrieved before, the object is retrieved from
215:             * the database using the passed connection
216:             *
217:             * @param connection the connection used to retrieve the associated object
218:             *        from the database, if it was not retrieved before
219:             * @return the associated Query object
220:             * @throws TorqueException
221:             */
222:            public Query getQuery(Connection connection) throws TorqueException {
223:                if (aQuery == null && (!ObjectUtils.equals(this .queryId, null))) {
224:                    aQuery = QueryManager.getCachedInstance(SimpleKey
225:                            .keyFor(this .queryId));
226:                    if (aQuery == null) {
227:                        aQuery = QueryPeer.retrieveByPK(SimpleKey
228:                                .keyFor(this .queryId), connection);
229:                        QueryManager.putInstance(aQuery);
230:                    }
231:                }
232:                return aQuery;
233:            }
234:
235:            /**
236:             * Provides convenient way to set a relationship based on a
237:             * ObjectKey, for example
238:             * <code>bar.setFooKey(foo.getPrimaryKey())</code>
239:             *
240:             */
241:            public void setQueryKey(ObjectKey key) throws TorqueException {
242:
243:                setQueryId(new Long(((NumberKey) key).longValue()));
244:            }
245:
246:            private ScarabUser aScarabUser;
247:
248:            /**
249:             * Declares an association between this object and a ScarabUser object
250:             *
251:             * @param v ScarabUser
252:             * @throws TorqueException
253:             */
254:            public void setScarabUser(ScarabUser v) throws TorqueException {
255:                if (v == null) {
256:                    setUserId((Integer) null);
257:                } else {
258:                    setUserId(v.getUserId());
259:                }
260:                aScarabUser = v;
261:            }
262:
263:            /**
264:             * Returns the associated ScarabUser object.
265:             * If it was not retrieved before, the object is retrieved from
266:             * the database
267:             *
268:             * @return the associated ScarabUser object
269:             * @throws TorqueException
270:             */
271:            public ScarabUser getScarabUser() throws TorqueException {
272:                if (aScarabUser == null
273:                        && (!ObjectUtils.equals(this .userId, null))) {
274:                    aScarabUser = ScarabUserManager.getInstance(SimpleKey
275:                            .keyFor(this .userId));
276:                }
277:                return aScarabUser;
278:            }
279:
280:            /**
281:             * Return the associated ScarabUser object
282:             * If it was not retrieved before, the object is retrieved from
283:             * the database using the passed connection
284:             *
285:             * @param connection the connection used to retrieve the associated object
286:             *        from the database, if it was not retrieved before
287:             * @return the associated ScarabUser object
288:             * @throws TorqueException
289:             */
290:            public ScarabUser getScarabUser(Connection connection)
291:                    throws TorqueException {
292:                if (aScarabUser == null
293:                        && (!ObjectUtils.equals(this .userId, null))) {
294:                    aScarabUser = ScarabUserManager.getCachedInstance(SimpleKey
295:                            .keyFor(this .userId));
296:                    if (aScarabUser == null) {
297:                        aScarabUser = ScarabUserImplPeer
298:                                .retrieveScarabUserImplByPK(SimpleKey
299:                                        .keyFor(this .userId), connection);
300:                        ScarabUserManager.putInstance(aScarabUser);
301:                    }
302:                }
303:                return aScarabUser;
304:            }
305:
306:            /**
307:             * Provides convenient way to set a relationship based on a
308:             * ObjectKey, for example
309:             * <code>bar.setFooKey(foo.getPrimaryKey())</code>
310:             *
311:             */
312:            public void setScarabUserKey(ObjectKey key) throws TorqueException {
313:
314:                setUserId(new Integer(((NumberKey) key).intValue()));
315:            }
316:
317:            private Frequency aFrequency;
318:
319:            /**
320:             * Declares an association between this object and a Frequency object
321:             *
322:             * @param v Frequency
323:             * @throws TorqueException
324:             */
325:            public void setFrequency(Frequency v) throws TorqueException {
326:                if (v == null) {
327:                    setSubscriptionFrequency((Integer) null);
328:                } else {
329:                    setSubscriptionFrequency(v.getFrequencyId());
330:                }
331:                aFrequency = v;
332:            }
333:
334:            /**
335:             * Returns the associated Frequency object.
336:             * If it was not retrieved before, the object is retrieved from
337:             * the database
338:             *
339:             * @return the associated Frequency object
340:             * @throws TorqueException
341:             */
342:            public Frequency getFrequency() throws TorqueException {
343:                if (aFrequency == null
344:                        && (!ObjectUtils.equals(this .subscriptionFrequency,
345:                                null))) {
346:                    aFrequency = FrequencyManager.getInstance(SimpleKey
347:                            .keyFor(this .subscriptionFrequency));
348:                }
349:                return aFrequency;
350:            }
351:
352:            /**
353:             * Return the associated Frequency object
354:             * If it was not retrieved before, the object is retrieved from
355:             * the database using the passed connection
356:             *
357:             * @param connection the connection used to retrieve the associated object
358:             *        from the database, if it was not retrieved before
359:             * @return the associated Frequency object
360:             * @throws TorqueException
361:             */
362:            public Frequency getFrequency(Connection connection)
363:                    throws TorqueException {
364:                if (aFrequency == null
365:                        && (!ObjectUtils.equals(this .subscriptionFrequency,
366:                                null))) {
367:                    aFrequency = FrequencyManager.getCachedInstance(SimpleKey
368:                            .keyFor(this .subscriptionFrequency));
369:                    if (aFrequency == null) {
370:                        aFrequency = FrequencyPeer
371:                                .retrieveByPK(SimpleKey
372:                                        .keyFor(this .subscriptionFrequency),
373:                                        connection);
374:                        FrequencyManager.putInstance(aFrequency);
375:                    }
376:                }
377:                return aFrequency;
378:            }
379:
380:            /**
381:             * Provides convenient way to set a relationship based on a
382:             * ObjectKey, for example
383:             * <code>bar.setFooKey(foo.getPrimaryKey())</code>
384:             *
385:             */
386:            public void setFrequencyKey(ObjectKey key) throws TorqueException {
387:
388:                setSubscriptionFrequency(new Integer(((NumberKey) key)
389:                        .intValue()));
390:            }
391:
392:            private static List fieldNames = null;
393:
394:            /**
395:             * Generate a list of field names.
396:             *
397:             * @return a list of field names
398:             */
399:            public static synchronized List getFieldNames() {
400:                if (fieldNames == null) {
401:                    fieldNames = new ArrayList();
402:                    fieldNames.add("QueryId");
403:                    fieldNames.add("UserId");
404:                    fieldNames.add("IsSubscribed");
405:                    fieldNames.add("SubscriptionFrequency");
406:                    fieldNames.add("Isdefault");
407:                    fieldNames = Collections.unmodifiableList(fieldNames);
408:                }
409:                return fieldNames;
410:            }
411:
412:            /**
413:             * Retrieves a field from the object by name passed in as a String.
414:             *
415:             * @param name field name
416:             * @return value
417:             */
418:            public Object getByName(String name) {
419:                if (name.equals("QueryId")) {
420:                    return getQueryId();
421:                }
422:                if (name.equals("UserId")) {
423:                    return getUserId();
424:                }
425:                if (name.equals("IsSubscribed")) {
426:                    return Boolean.valueOf(getIsSubscribed());
427:                }
428:                if (name.equals("SubscriptionFrequency")) {
429:                    return getSubscriptionFrequency();
430:                }
431:                if (name.equals("Isdefault")) {
432:                    return Boolean.valueOf(getIsdefault());
433:                }
434:                return null;
435:            }
436:
437:            /**
438:             * Retrieves a field from the object by name passed in
439:             * as a String.  The String must be one of the static
440:             * Strings defined in this Class' Peer.
441:             *
442:             * @param name peer name
443:             * @return value
444:             */
445:            public Object getByPeerName(String name) {
446:                if (name.equals(RQueryUserPeer.QUERY_ID)) {
447:                    return getQueryId();
448:                }
449:                if (name.equals(RQueryUserPeer.USER_ID)) {
450:                    return getUserId();
451:                }
452:                if (name.equals(RQueryUserPeer.IS_SUBSCRIBED)) {
453:                    return Boolean.valueOf(getIsSubscribed());
454:                }
455:                if (name.equals(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID)) {
456:                    return getSubscriptionFrequency();
457:                }
458:                if (name.equals(RQueryUserPeer.ISDEFAULT)) {
459:                    return Boolean.valueOf(getIsdefault());
460:                }
461:                return null;
462:            }
463:
464:            /**
465:             * Retrieves a field from the object by Position as specified
466:             * in the xml schema.  Zero-based.
467:             *
468:             * @param pos position in xml schema
469:             * @return value
470:             */
471:            public Object getByPosition(int pos) {
472:                if (pos == 0) {
473:                    return getQueryId();
474:                }
475:                if (pos == 1) {
476:                    return getUserId();
477:                }
478:                if (pos == 2) {
479:                    return Boolean.valueOf(getIsSubscribed());
480:                }
481:                if (pos == 3) {
482:                    return getSubscriptionFrequency();
483:                }
484:                if (pos == 4) {
485:                    return Boolean.valueOf(getIsdefault());
486:                }
487:                return null;
488:            }
489:
490:            /**
491:             * Stores the object in the database.  If the object is new,
492:             * it inserts it; otherwise an update is performed.
493:             *
494:             * @throws TorqueException
495:             */
496:            public void save() throws TorqueException {
497:                save(RQueryUserPeer.getMapBuilder().getDatabaseMap().getName());
498:            }
499:
500:            /**
501:             * Stores the object in the database.  If the object is new,
502:             * it inserts it; otherwise an update is performed.
503:             * Note: this code is here because the method body is
504:             * auto-generated conditionally and therefore needs to be
505:             * in this file instead of in the super class, BaseObject.
506:             *
507:             * @param dbName
508:             * @throws TorqueException
509:             */
510:            public void save(String dbName) throws TorqueException {
511:                Connection con = null;
512:                try {
513:                    con = Transaction.begin(dbName);
514:                    save(con);
515:                    Transaction.commit(con);
516:                } catch (TorqueException e) {
517:                    Transaction.safeRollback(con);
518:                    throw e;
519:                }
520:            }
521:
522:            /** flag to prevent endless save loop, if this object is referenced
523:              by another object which falls in this transaction. */
524:            private boolean alreadyInSave = false;
525:
526:            /**
527:             * Stores the object in the database.  If the object is new,
528:             * it inserts it; otherwise an update is performed.  This method
529:             * is meant to be used as part of a transaction, otherwise use
530:             * the save() method and the connection details will be handled
531:             * internally
532:             *
533:             * @param con
534:             * @throws TorqueException
535:             */
536:            public void save(Connection con) throws TorqueException {
537:                if (!alreadyInSave) {
538:                    alreadyInSave = true;
539:
540:                    // If this object has been modified, then save it to the database.
541:                    if (isModified()) {
542:                        if (isNew()) {
543:                            RQueryUserPeer.doInsert((RQueryUser) this , con);
544:                            setNew(false);
545:                        } else {
546:                            RQueryUserPeer.doUpdate((RQueryUser) this , con);
547:                        }
548:
549:                        if (isCacheOnSave()) {
550:                            RQueryUserManager.putInstance(this );
551:                        }
552:                    }
553:
554:                    alreadyInSave = false;
555:                }
556:            }
557:
558:            /**
559:             * Specify whether to cache the object after saving to the db.
560:             * This method returns true
561:             */
562:            protected boolean isCacheOnSave() {
563:                return true;
564:            }
565:
566:            private final SimpleKey[] pks = new SimpleKey[2];
567:            private final ComboKey comboPK = new ComboKey(pks);
568:
569:            /**
570:             * Set the PrimaryKey with an ObjectKey
571:             *
572:             * @param key
573:             */
574:            public void setPrimaryKey(ObjectKey key) throws TorqueException {
575:                SimpleKey[] keys = (SimpleKey[]) key.getValue();
576:                SimpleKey tmpKey = null;
577:                setQueryId(new Long(((NumberKey) keys[0]).longValue()));
578:                setUserId(new Integer(((NumberKey) keys[1]).intValue()));
579:            }
580:
581:            /**
582:             * Set the PrimaryKey using SimpleKeys.
583:             *
584:             * @param queryId Long
585:             * @param userId Integer
586:             */
587:            public void setPrimaryKey(Long queryId, Integer userId)
588:                    throws TorqueException {
589:                setQueryId(queryId);
590:                setUserId(userId);
591:            }
592:
593:            /**
594:             * Set the PrimaryKey using a String.
595:             */
596:            public void setPrimaryKey(String key) throws TorqueException {
597:                setPrimaryKey(new ComboKey(key));
598:            }
599:
600:            /**
601:             * returns an id that differentiates this object from others
602:             * of its class.
603:             */
604:            public ObjectKey getPrimaryKey() {
605:                pks[0] = SimpleKey.keyFor(getQueryId());
606:                pks[1] = SimpleKey.keyFor(getUserId());
607:                return comboPK;
608:            }
609:
610:            /**
611:             * get an id that differentiates this object from others
612:             * of its class.
613:             */
614:            public String getQueryKey() {
615:                if (getPrimaryKey() == null) {
616:                    return "";
617:                } else {
618:                    return getPrimaryKey().toString();
619:                }
620:            }
621:
622:            /**
623:             * set an id that differentiates this object from others
624:             * of its class.
625:             */
626:            public void setQueryKey(String key) throws TorqueException {
627:                setPrimaryKey(key);
628:            }
629:
630:            /**
631:             * Makes a copy of this object.
632:             * It creates a new object filling in the simple attributes.
633:             * It then fills all the association collections and sets the
634:             * related objects to isNew=true.
635:             */
636:            public RQueryUser copy() throws TorqueException {
637:                return copyInto(new RQueryUser());
638:            }
639:
640:            protected RQueryUser copyInto(RQueryUser copyObj)
641:                    throws TorqueException {
642:                copyObj.setQueryId(queryId);
643:                copyObj.setUserId(userId);
644:                copyObj.setIsSubscribed(isSubscribed);
645:                copyObj.setSubscriptionFrequency(subscriptionFrequency);
646:                copyObj.setIsdefault(isdefault);
647:
648:                copyObj.setQueryId((Long) null);
649:                copyObj.setUserId((Integer) null);
650:
651:                return copyObj;
652:            }
653:
654:            /**
655:             * returns a peer instance associated with this om.  Since Peer classes
656:             * are not to have any instance attributes, this method returns the
657:             * same instance for all member of this class. The method could therefore
658:             * be static, but this would prevent one from overriding the behavior.
659:             */
660:            public RQueryUserPeer getPeer() {
661:                return peer;
662:            }
663:
664:            public String toString() {
665:                StringBuffer str = new StringBuffer();
666:                str.append("RQueryUser:\n");
667:                str.append("QueryId = ").append(getQueryId()).append("\n");
668:                str.append("UserId = ").append(getUserId()).append("\n");
669:                str.append("IsSubscribed = ").append(getIsSubscribed()).append(
670:                        "\n");
671:                str.append("SubscriptionFrequency = ").append(
672:                        getSubscriptionFrequency()).append("\n");
673:                str.append("Isdefault = ").append(getIsdefault()).append("\n");
674:                return (str.toString());
675:            }
676:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.