Source Code Cross Referenced for BaseOptionRelationship.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 OptionRelationship
027:         */
028:        public abstract class BaseOptionRelationship extends BaseObject
029:                implements  org.apache.fulcrum.intake.Retrievable {
030:            /** The Peer class */
031:            private static final OptionRelationshipPeer peer = new OptionRelationshipPeer();
032:
033:            /** The value for the relationshipId field */
034:            private Integer relationshipId;
035:
036:            /** The value for the name field */
037:            private String name;
038:
039:            /**
040:             * Get the RelationshipId
041:             *
042:             * @return Integer
043:             */
044:            public Integer getRelationshipId() {
045:                return relationshipId;
046:            }
047:
048:            /**
049:             * Set the value of RelationshipId
050:             *
051:             * @param v new value
052:             */
053:            public void setRelationshipId(Integer v) throws TorqueException {
054:
055:                if (!ObjectUtils.equals(this .relationshipId, v)) {
056:                    this .relationshipId = v;
057:                    setModified(true);
058:                }
059:
060:                // update associated ROptionOption
061:                if (collROptionOptions != null) {
062:                    for (int i = 0; i < collROptionOptions.size(); i++) {
063:                        ((ROptionOption) collROptionOptions.get(i))
064:                                .setRelationshipId(v);
065:                    }
066:                }
067:            }
068:
069:            /**
070:             * Get the Name
071:             *
072:             * @return String
073:             */
074:            public String getName() {
075:                return name;
076:            }
077:
078:            /**
079:             * Set the value of Name
080:             *
081:             * @param v new value
082:             */
083:            public void setName(String v) {
084:
085:                if (!ObjectUtils.equals(this .name, v)) {
086:                    this .name = v;
087:                    setModified(true);
088:                }
089:
090:            }
091:
092:            /**
093:             * Collection to store aggregation of collROptionOptions
094:             */
095:            protected List collROptionOptions;
096:
097:            /**
098:             * Temporary storage of collROptionOptions to save a possible db hit in
099:             * the event objects are add to the collection, but the
100:             * complete collection is never requested.
101:             */
102:            protected void initROptionOptions() {
103:                if (collROptionOptions == null) {
104:                    collROptionOptions = new ArrayList();
105:                }
106:            }
107:
108:            /**
109:             * Method called to associate a ROptionOption object to this object
110:             * through the ROptionOption foreign key attribute
111:             *
112:             * @param l ROptionOption
113:             * @throws TorqueException
114:             */
115:            public void addROptionOption(ROptionOption l)
116:                    throws TorqueException {
117:                getROptionOptions().add(l);
118:                l.setOptionRelationship((OptionRelationship) this );
119:            }
120:
121:            /**
122:             * The criteria used to select the current contents of collROptionOptions
123:             */
124:            private Criteria lastROptionOptionsCriteria = null;
125:
126:            /**
127:             * If this collection has already been initialized, returns
128:             * the collection. Otherwise returns the results of
129:             * getROptionOptions(new Criteria())
130:             *
131:             * @return the collection of associated objects
132:             * @throws TorqueException
133:             */
134:            public List getROptionOptions() throws TorqueException {
135:                if (collROptionOptions == null) {
136:                    collROptionOptions = getROptionOptions(new Criteria(10));
137:                }
138:                return collROptionOptions;
139:            }
140:
141:            /**
142:             * If this collection has already been initialized with
143:             * an identical criteria, it returns the collection.
144:             * Otherwise if this OptionRelationship has previously
145:             * been saved, it will retrieve related ROptionOptions from storage.
146:             * If this OptionRelationship is new, it will return
147:             * an empty collection or the current collection, the criteria
148:             * is ignored on a new object.
149:             *
150:             * @throws TorqueException
151:             */
152:            public List getROptionOptions(Criteria criteria)
153:                    throws TorqueException {
154:                if (collROptionOptions == null) {
155:                    if (isNew()) {
156:                        collROptionOptions = new ArrayList();
157:                    } else {
158:                        criteria.add(ROptionOptionPeer.RELATIONSHIP_ID,
159:                                getRelationshipId());
160:                        collROptionOptions = ROptionOptionPeer
161:                                .doSelect(criteria);
162:                    }
163:                } else {
164:                    // criteria has no effect for a new object
165:                    if (!isNew()) {
166:                        // the following code is to determine if a new query is
167:                        // called for.  If the criteria is the same as the last
168:                        // one, just return the collection.
169:                        criteria.add(ROptionOptionPeer.RELATIONSHIP_ID,
170:                                getRelationshipId());
171:                        if (!lastROptionOptionsCriteria.equals(criteria)) {
172:                            collROptionOptions = ROptionOptionPeer
173:                                    .doSelect(criteria);
174:                        }
175:                    }
176:                }
177:                lastROptionOptionsCriteria = criteria;
178:
179:                return collROptionOptions;
180:            }
181:
182:            /**
183:             * If this collection has already been initialized, returns
184:             * the collection. Otherwise returns the results of
185:             * getROptionOptions(new Criteria(),Connection)
186:             * This method takes in the Connection also as input so that
187:             * referenced objects can also be obtained using a Connection
188:             * that is taken as input
189:             */
190:            public List getROptionOptions(Connection con)
191:                    throws TorqueException {
192:                if (collROptionOptions == null) {
193:                    collROptionOptions = getROptionOptions(new Criteria(10),
194:                            con);
195:                }
196:                return collROptionOptions;
197:            }
198:
199:            /**
200:             * If this collection has already been initialized with
201:             * an identical criteria, it returns the collection.
202:             * Otherwise if this OptionRelationship has previously
203:             * been saved, it will retrieve related ROptionOptions from storage.
204:             * If this OptionRelationship is new, it will return
205:             * an empty collection or the current collection, the criteria
206:             * is ignored on a new object.
207:             * This method takes in the Connection also as input so that
208:             * referenced objects can also be obtained using a Connection
209:             * that is taken as input
210:             */
211:            public List getROptionOptions(Criteria criteria, Connection con)
212:                    throws TorqueException {
213:                if (collROptionOptions == null) {
214:                    if (isNew()) {
215:                        collROptionOptions = new ArrayList();
216:                    } else {
217:                        criteria.add(ROptionOptionPeer.RELATIONSHIP_ID,
218:                                getRelationshipId());
219:                        collROptionOptions = ROptionOptionPeer.doSelect(
220:                                criteria, con);
221:                    }
222:                } else {
223:                    // criteria has no effect for a new object
224:                    if (!isNew()) {
225:                        // the following code is to determine if a new query is
226:                        // called for.  If the criteria is the same as the last
227:                        // one, just return the collection.
228:                        criteria.add(ROptionOptionPeer.RELATIONSHIP_ID,
229:                                getRelationshipId());
230:                        if (!lastROptionOptionsCriteria.equals(criteria)) {
231:                            collROptionOptions = ROptionOptionPeer.doSelect(
232:                                    criteria, con);
233:                        }
234:                    }
235:                }
236:                lastROptionOptionsCriteria = criteria;
237:
238:                return collROptionOptions;
239:            }
240:
241:            /**
242:             * If this collection has already been initialized with
243:             * an identical criteria, it returns the collection.
244:             * Otherwise if this OptionRelationship is new, it will return
245:             * an empty collection; or if this OptionRelationship has previously
246:             * been saved, it will retrieve related ROptionOptions from storage.
247:             *
248:             * This method is protected by default in order to keep the public
249:             * api reasonable.  You can provide public methods for those you
250:             * actually need in OptionRelationship.
251:             */
252:            protected List getROptionOptionsJoinAttributeOptionRelatedByOption1Id(
253:                    Criteria criteria) throws TorqueException {
254:                if (collROptionOptions == null) {
255:                    if (isNew()) {
256:                        collROptionOptions = new ArrayList();
257:                    } else {
258:                        criteria.add(ROptionOptionPeer.RELATIONSHIP_ID,
259:                                getRelationshipId());
260:                        collROptionOptions = ROptionOptionPeer
261:                                .doSelectJoinAttributeOptionRelatedByOption1Id(criteria);
262:                    }
263:                } else {
264:                    // the following code is to determine if a new query is
265:                    // called for.  If the criteria is the same as the last
266:                    // one, just return the collection.
267:                    criteria.add(ROptionOptionPeer.RELATIONSHIP_ID,
268:                            getRelationshipId());
269:                    if (!lastROptionOptionsCriteria.equals(criteria)) {
270:                        collROptionOptions = ROptionOptionPeer
271:                                .doSelectJoinAttributeOptionRelatedByOption1Id(criteria);
272:                    }
273:                }
274:                lastROptionOptionsCriteria = criteria;
275:
276:                return collROptionOptions;
277:            }
278:
279:            /**
280:             * If this collection has already been initialized with
281:             * an identical criteria, it returns the collection.
282:             * Otherwise if this OptionRelationship is new, it will return
283:             * an empty collection; or if this OptionRelationship has previously
284:             * been saved, it will retrieve related ROptionOptions from storage.
285:             *
286:             * This method is protected by default in order to keep the public
287:             * api reasonable.  You can provide public methods for those you
288:             * actually need in OptionRelationship.
289:             */
290:            protected List getROptionOptionsJoinAttributeOptionRelatedByOption2Id(
291:                    Criteria criteria) throws TorqueException {
292:                if (collROptionOptions == null) {
293:                    if (isNew()) {
294:                        collROptionOptions = new ArrayList();
295:                    } else {
296:                        criteria.add(ROptionOptionPeer.RELATIONSHIP_ID,
297:                                getRelationshipId());
298:                        collROptionOptions = ROptionOptionPeer
299:                                .doSelectJoinAttributeOptionRelatedByOption2Id(criteria);
300:                    }
301:                } else {
302:                    // the following code is to determine if a new query is
303:                    // called for.  If the criteria is the same as the last
304:                    // one, just return the collection.
305:                    criteria.add(ROptionOptionPeer.RELATIONSHIP_ID,
306:                            getRelationshipId());
307:                    if (!lastROptionOptionsCriteria.equals(criteria)) {
308:                        collROptionOptions = ROptionOptionPeer
309:                                .doSelectJoinAttributeOptionRelatedByOption2Id(criteria);
310:                    }
311:                }
312:                lastROptionOptionsCriteria = criteria;
313:
314:                return collROptionOptions;
315:            }
316:
317:            /**
318:             * If this collection has already been initialized with
319:             * an identical criteria, it returns the collection.
320:             * Otherwise if this OptionRelationship is new, it will return
321:             * an empty collection; or if this OptionRelationship has previously
322:             * been saved, it will retrieve related ROptionOptions from storage.
323:             *
324:             * This method is protected by default in order to keep the public
325:             * api reasonable.  You can provide public methods for those you
326:             * actually need in OptionRelationship.
327:             */
328:            protected List getROptionOptionsJoinOptionRelationship(
329:                    Criteria criteria) throws TorqueException {
330:                if (collROptionOptions == null) {
331:                    if (isNew()) {
332:                        collROptionOptions = new ArrayList();
333:                    } else {
334:                        criteria.add(ROptionOptionPeer.RELATIONSHIP_ID,
335:                                getRelationshipId());
336:                        collROptionOptions = ROptionOptionPeer
337:                                .doSelectJoinOptionRelationship(criteria);
338:                    }
339:                } else {
340:                    // the following code is to determine if a new query is
341:                    // called for.  If the criteria is the same as the last
342:                    // one, just return the collection.
343:                    criteria.add(ROptionOptionPeer.RELATIONSHIP_ID,
344:                            getRelationshipId());
345:                    if (!lastROptionOptionsCriteria.equals(criteria)) {
346:                        collROptionOptions = ROptionOptionPeer
347:                                .doSelectJoinOptionRelationship(criteria);
348:                    }
349:                }
350:                lastROptionOptionsCriteria = criteria;
351:
352:                return collROptionOptions;
353:            }
354:
355:            private static List fieldNames = null;
356:
357:            /**
358:             * Generate a list of field names.
359:             *
360:             * @return a list of field names
361:             */
362:            public static synchronized List getFieldNames() {
363:                if (fieldNames == null) {
364:                    fieldNames = new ArrayList();
365:                    fieldNames.add("RelationshipId");
366:                    fieldNames.add("Name");
367:                    fieldNames = Collections.unmodifiableList(fieldNames);
368:                }
369:                return fieldNames;
370:            }
371:
372:            /**
373:             * Retrieves a field from the object by name passed in as a String.
374:             *
375:             * @param name field name
376:             * @return value
377:             */
378:            public Object getByName(String name) {
379:                if (name.equals("RelationshipId")) {
380:                    return getRelationshipId();
381:                }
382:                if (name.equals("Name")) {
383:                    return getName();
384:                }
385:                return null;
386:            }
387:
388:            /**
389:             * Retrieves a field from the object by name passed in
390:             * as a String.  The String must be one of the static
391:             * Strings defined in this Class' Peer.
392:             *
393:             * @param name peer name
394:             * @return value
395:             */
396:            public Object getByPeerName(String name) {
397:                if (name.equals(OptionRelationshipPeer.RELATIONSHIP_ID)) {
398:                    return getRelationshipId();
399:                }
400:                if (name.equals(OptionRelationshipPeer.RELATIONSHIP_NAME)) {
401:                    return getName();
402:                }
403:                return null;
404:            }
405:
406:            /**
407:             * Retrieves a field from the object by Position as specified
408:             * in the xml schema.  Zero-based.
409:             *
410:             * @param pos position in xml schema
411:             * @return value
412:             */
413:            public Object getByPosition(int pos) {
414:                if (pos == 0) {
415:                    return getRelationshipId();
416:                }
417:                if (pos == 1) {
418:                    return getName();
419:                }
420:                return null;
421:            }
422:
423:            /**
424:             * Stores the object in the database.  If the object is new,
425:             * it inserts it; otherwise an update is performed.
426:             *
427:             * @throws TorqueException
428:             */
429:            public void save() throws TorqueException {
430:                save(OptionRelationshipPeer.getMapBuilder().getDatabaseMap()
431:                        .getName());
432:            }
433:
434:            /**
435:             * Stores the object in the database.  If the object is new,
436:             * it inserts it; otherwise an update is performed.
437:             * Note: this code is here because the method body is
438:             * auto-generated conditionally and therefore needs to be
439:             * in this file instead of in the super class, BaseObject.
440:             *
441:             * @param dbName
442:             * @throws TorqueException
443:             */
444:            public void save(String dbName) throws TorqueException {
445:                Connection con = null;
446:                try {
447:                    con = Transaction.begin(dbName);
448:                    save(con);
449:                    Transaction.commit(con);
450:                } catch (TorqueException e) {
451:                    Transaction.safeRollback(con);
452:                    throw e;
453:                }
454:            }
455:
456:            /** flag to prevent endless save loop, if this object is referenced
457:              by another object which falls in this transaction. */
458:            private boolean alreadyInSave = false;
459:
460:            /**
461:             * Stores the object in the database.  If the object is new,
462:             * it inserts it; otherwise an update is performed.  This method
463:             * is meant to be used as part of a transaction, otherwise use
464:             * the save() method and the connection details will be handled
465:             * internally
466:             *
467:             * @param con
468:             * @throws TorqueException
469:             */
470:            public void save(Connection con) throws TorqueException {
471:                if (!alreadyInSave) {
472:                    alreadyInSave = true;
473:
474:                    // If this object has been modified, then save it to the database.
475:                    if (isModified()) {
476:                        if (isNew()) {
477:                            OptionRelationshipPeer.doInsert(
478:                                    (OptionRelationship) this , con);
479:                            setNew(false);
480:                        } else {
481:                            OptionRelationshipPeer.doUpdate(
482:                                    (OptionRelationship) this , con);
483:                        }
484:
485:                        if (isCacheOnSave()) {
486:                            OptionRelationshipManager.putInstance(this );
487:                        }
488:                    }
489:
490:                    if (collROptionOptions != null) {
491:                        for (int i = 0; i < collROptionOptions.size(); i++) {
492:                            ((ROptionOption) collROptionOptions.get(i))
493:                                    .save(con);
494:                        }
495:                    }
496:                    alreadyInSave = false;
497:                }
498:            }
499:
500:            /**
501:             * Specify whether to cache the object after saving to the db.
502:             * This method returns true
503:             */
504:            protected boolean isCacheOnSave() {
505:                return true;
506:            }
507:
508:            /**
509:             * Set the PrimaryKey using ObjectKey.
510:             *
511:             * @param key relationshipId ObjectKey
512:             */
513:            public void setPrimaryKey(ObjectKey key) throws TorqueException {
514:                setRelationshipId(new Integer(((NumberKey) key).intValue()));
515:            }
516:
517:            /**
518:             * Set the PrimaryKey using a String.
519:             *
520:             * @param key
521:             */
522:            public void setPrimaryKey(String key) throws TorqueException {
523:                setRelationshipId(new Integer(key));
524:            }
525:
526:            /**
527:             * returns an id that differentiates this object from others
528:             * of its class.
529:             */
530:            public ObjectKey getPrimaryKey() {
531:                return SimpleKey.keyFor(getRelationshipId());
532:            }
533:
534:            /**
535:             * get an id that differentiates this object from others
536:             * of its class.
537:             */
538:            public String getQueryKey() {
539:                if (getPrimaryKey() == null) {
540:                    return "";
541:                } else {
542:                    return getPrimaryKey().toString();
543:                }
544:            }
545:
546:            /**
547:             * set an id that differentiates this object from others
548:             * of its class.
549:             */
550:            public void setQueryKey(String key) throws TorqueException {
551:                setPrimaryKey(key);
552:            }
553:
554:            /**
555:             * Makes a copy of this object.
556:             * It creates a new object filling in the simple attributes.
557:             * It then fills all the association collections and sets the
558:             * related objects to isNew=true.
559:             */
560:            public OptionRelationship copy() throws TorqueException {
561:                return copyInto(new OptionRelationship());
562:            }
563:
564:            protected OptionRelationship copyInto(OptionRelationship copyObj)
565:                    throws TorqueException {
566:                copyObj.setRelationshipId(relationshipId);
567:                copyObj.setName(name);
568:
569:                copyObj.setRelationshipId((Integer) null);
570:
571:                List v = getROptionOptions();
572:                if (v != null) {
573:                    for (int i = 0; i < v.size(); i++) {
574:                        ROptionOption obj = (ROptionOption) v.get(i);
575:                        copyObj.addROptionOption(obj.copy());
576:                    }
577:                } else {
578:                    copyObj.collROptionOptions = null;
579:                }
580:                return copyObj;
581:            }
582:
583:            /**
584:             * returns a peer instance associated with this om.  Since Peer classes
585:             * are not to have any instance attributes, this method returns the
586:             * same instance for all member of this class. The method could therefore
587:             * be static, but this would prevent one from overriding the behavior.
588:             */
589:            public OptionRelationshipPeer getPeer() {
590:                return peer;
591:            }
592:
593:            public String toString() {
594:                StringBuffer str = new StringBuffer();
595:                str.append("OptionRelationship:\n");
596:                str.append("RelationshipId = ").append(getRelationshipId())
597:                        .append("\n");
598:                str.append("Name = ").append(getName()).append("\n");
599:                return (str.toString());
600:            }
601:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.