Source Code Cross Referenced for BaseAttributeType.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 AttributeType
027:         */
028:        public abstract class BaseAttributeType extends BaseObject implements 
029:                org.apache.fulcrum.intake.Retrievable {
030:            /** The Peer class */
031:            private static final AttributeTypePeer peer = new AttributeTypePeer();
032:
033:            /** The value for the attributeTypeId field */
034:            private Integer attributeTypeId;
035:
036:            /** The value for the classId field */
037:            private Integer classId;
038:
039:            /** The value for the name field */
040:            private String name;
041:
042:            /** The value for the javaClassName field */
043:            private String javaClassName;
044:
045:            /** The value for the validationKey field */
046:            private String validationKey;
047:
048:            /**
049:             * Get the AttributeTypeId
050:             *
051:             * @return Integer
052:             */
053:            public Integer getAttributeTypeId() {
054:                return attributeTypeId;
055:            }
056:
057:            /**
058:             * Set the value of AttributeTypeId
059:             *
060:             * @param v new value
061:             */
062:            public void setAttributeTypeId(Integer v) throws TorqueException {
063:
064:                if (!ObjectUtils.equals(this .attributeTypeId, v)) {
065:                    this .attributeTypeId = v;
066:                    setModified(true);
067:                }
068:
069:                // update associated Attribute
070:                if (collAttributes != null) {
071:                    for (int i = 0; i < collAttributes.size(); i++) {
072:                        ((Attribute) collAttributes.get(i)).setTypeId(v);
073:                    }
074:                }
075:            }
076:
077:            /**
078:             * Get the ClassId
079:             *
080:             * @return Integer
081:             */
082:            public Integer getClassId() {
083:                return classId;
084:            }
085:
086:            /**
087:             * Set the value of ClassId
088:             *
089:             * @param v new value
090:             */
091:            public void setClassId(Integer v) throws TorqueException {
092:
093:                if (!ObjectUtils.equals(this .classId, v)) {
094:                    this .classId = v;
095:                    setModified(true);
096:                }
097:
098:                if (aAttributeClass != null
099:                        && !ObjectUtils.equals(aAttributeClass
100:                                .getAttributeClassId(), v)) {
101:                    aAttributeClass = null;
102:                }
103:
104:            }
105:
106:            /**
107:             * Get the Name
108:             *
109:             * @return String
110:             */
111:            public String getName() {
112:                return name;
113:            }
114:
115:            /**
116:             * Set the value of Name
117:             *
118:             * @param v new value
119:             */
120:            public void setName(String v) {
121:
122:                if (!ObjectUtils.equals(this .name, v)) {
123:                    this .name = v;
124:                    setModified(true);
125:                }
126:
127:            }
128:
129:            /**
130:             * Get the JavaClassName
131:             *
132:             * @return String
133:             */
134:            public String getJavaClassName() {
135:                return javaClassName;
136:            }
137:
138:            /**
139:             * Set the value of JavaClassName
140:             *
141:             * @param v new value
142:             */
143:            public void setJavaClassName(String v) {
144:
145:                if (!ObjectUtils.equals(this .javaClassName, v)) {
146:                    this .javaClassName = v;
147:                    setModified(true);
148:                }
149:
150:            }
151:
152:            /**
153:             * Get the ValidationKey
154:             *
155:             * @return String
156:             */
157:            public String getValidationKey() {
158:                return validationKey;
159:            }
160:
161:            /**
162:             * Set the value of ValidationKey
163:             *
164:             * @param v new value
165:             */
166:            public void setValidationKey(String v) {
167:
168:                if (!ObjectUtils.equals(this .validationKey, v)) {
169:                    this .validationKey = v;
170:                    setModified(true);
171:                }
172:
173:            }
174:
175:            private AttributeClass aAttributeClass;
176:
177:            /**
178:             * Declares an association between this object and a AttributeClass object
179:             *
180:             * @param v AttributeClass
181:             * @throws TorqueException
182:             */
183:            public void setAttributeClass(AttributeClass v)
184:                    throws TorqueException {
185:                if (v == null) {
186:                    setClassId((Integer) null);
187:                } else {
188:                    setClassId(v.getAttributeClassId());
189:                }
190:                aAttributeClass = v;
191:            }
192:
193:            /**
194:             * Returns the associated AttributeClass object.
195:             * If it was not retrieved before, the object is retrieved from
196:             * the database
197:             *
198:             * @return the associated AttributeClass object
199:             * @throws TorqueException
200:             */
201:            public AttributeClass getAttributeClass() throws TorqueException {
202:                if (aAttributeClass == null
203:                        && (!ObjectUtils.equals(this .classId, null))) {
204:                    aAttributeClass = AttributeClassManager
205:                            .getInstance(SimpleKey.keyFor(this .classId));
206:                }
207:                return aAttributeClass;
208:            }
209:
210:            /**
211:             * Return the associated AttributeClass object
212:             * If it was not retrieved before, the object is retrieved from
213:             * the database using the passed connection
214:             *
215:             * @param connection the connection used to retrieve the associated object
216:             *        from the database, if it was not retrieved before
217:             * @return the associated AttributeClass object
218:             * @throws TorqueException
219:             */
220:            public AttributeClass getAttributeClass(Connection connection)
221:                    throws TorqueException {
222:                if (aAttributeClass == null
223:                        && (!ObjectUtils.equals(this .classId, null))) {
224:                    aAttributeClass = AttributeClassManager
225:                            .getCachedInstance(SimpleKey.keyFor(this .classId));
226:                    if (aAttributeClass == null) {
227:                        aAttributeClass = AttributeClassPeer.retrieveByPK(
228:                                SimpleKey.keyFor(this .classId), connection);
229:                        AttributeClassManager.putInstance(aAttributeClass);
230:                    }
231:                }
232:                return aAttributeClass;
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 setAttributeClassKey(ObjectKey key)
242:                    throws TorqueException {
243:
244:                setClassId(new Integer(((NumberKey) key).intValue()));
245:            }
246:
247:            /**
248:             * Collection to store aggregation of collAttributes
249:             */
250:            protected List collAttributes;
251:
252:            /**
253:             * Temporary storage of collAttributes to save a possible db hit in
254:             * the event objects are add to the collection, but the
255:             * complete collection is never requested.
256:             */
257:            protected void initAttributes() {
258:                if (collAttributes == null) {
259:                    collAttributes = new ArrayList();
260:                }
261:            }
262:
263:            /**
264:             * Method called to associate a Attribute object to this object
265:             * through the Attribute foreign key attribute
266:             *
267:             * @param l Attribute
268:             * @throws TorqueException
269:             */
270:            public void addAttribute(Attribute l) throws TorqueException {
271:                getAttributes().add(l);
272:                l.setAttributeType((AttributeType) this );
273:            }
274:
275:            /**
276:             * The criteria used to select the current contents of collAttributes
277:             */
278:            private Criteria lastAttributesCriteria = null;
279:
280:            /**
281:             * If this collection has already been initialized, returns
282:             * the collection. Otherwise returns the results of
283:             * getAttributes(new Criteria())
284:             *
285:             * @return the collection of associated objects
286:             * @throws TorqueException
287:             */
288:            public List getAttributes() throws TorqueException {
289:                if (collAttributes == null) {
290:                    collAttributes = getAttributes(new Criteria(10));
291:                }
292:                return collAttributes;
293:            }
294:
295:            /**
296:             * If this collection has already been initialized with
297:             * an identical criteria, it returns the collection.
298:             * Otherwise if this AttributeType has previously
299:             * been saved, it will retrieve related Attributes from storage.
300:             * If this AttributeType is new, it will return
301:             * an empty collection or the current collection, the criteria
302:             * is ignored on a new object.
303:             *
304:             * @throws TorqueException
305:             */
306:            public List getAttributes(Criteria criteria) throws TorqueException {
307:                if (collAttributes == null) {
308:                    if (isNew()) {
309:                        collAttributes = new ArrayList();
310:                    } else {
311:                        criteria.add(AttributePeer.ATTRIBUTE_TYPE_ID,
312:                                getAttributeTypeId());
313:                        collAttributes = AttributePeer.doSelect(criteria);
314:                    }
315:                } else {
316:                    // criteria has no effect for a new object
317:                    if (!isNew()) {
318:                        // the following code is to determine if a new query is
319:                        // called for.  If the criteria is the same as the last
320:                        // one, just return the collection.
321:                        criteria.add(AttributePeer.ATTRIBUTE_TYPE_ID,
322:                                getAttributeTypeId());
323:                        if (!lastAttributesCriteria.equals(criteria)) {
324:                            collAttributes = AttributePeer.doSelect(criteria);
325:                        }
326:                    }
327:                }
328:                lastAttributesCriteria = criteria;
329:
330:                return collAttributes;
331:            }
332:
333:            /**
334:             * If this collection has already been initialized, returns
335:             * the collection. Otherwise returns the results of
336:             * getAttributes(new Criteria(),Connection)
337:             * This method takes in the Connection also as input so that
338:             * referenced objects can also be obtained using a Connection
339:             * that is taken as input
340:             */
341:            public List getAttributes(Connection con) throws TorqueException {
342:                if (collAttributes == null) {
343:                    collAttributes = getAttributes(new Criteria(10), con);
344:                }
345:                return collAttributes;
346:            }
347:
348:            /**
349:             * If this collection has already been initialized with
350:             * an identical criteria, it returns the collection.
351:             * Otherwise if this AttributeType has previously
352:             * been saved, it will retrieve related Attributes from storage.
353:             * If this AttributeType is new, it will return
354:             * an empty collection or the current collection, the criteria
355:             * is ignored on a new object.
356:             * This method takes in the Connection also as input so that
357:             * referenced objects can also be obtained using a Connection
358:             * that is taken as input
359:             */
360:            public List getAttributes(Criteria criteria, Connection con)
361:                    throws TorqueException {
362:                if (collAttributes == null) {
363:                    if (isNew()) {
364:                        collAttributes = new ArrayList();
365:                    } else {
366:                        criteria.add(AttributePeer.ATTRIBUTE_TYPE_ID,
367:                                getAttributeTypeId());
368:                        collAttributes = AttributePeer.doSelect(criteria, con);
369:                    }
370:                } else {
371:                    // criteria has no effect for a new object
372:                    if (!isNew()) {
373:                        // the following code is to determine if a new query is
374:                        // called for.  If the criteria is the same as the last
375:                        // one, just return the collection.
376:                        criteria.add(AttributePeer.ATTRIBUTE_TYPE_ID,
377:                                getAttributeTypeId());
378:                        if (!lastAttributesCriteria.equals(criteria)) {
379:                            collAttributes = AttributePeer.doSelect(criteria,
380:                                    con);
381:                        }
382:                    }
383:                }
384:                lastAttributesCriteria = criteria;
385:
386:                return collAttributes;
387:            }
388:
389:            /**
390:             * If this collection has already been initialized with
391:             * an identical criteria, it returns the collection.
392:             * Otherwise if this AttributeType is new, it will return
393:             * an empty collection; or if this AttributeType has previously
394:             * been saved, it will retrieve related Attributes from storage.
395:             *
396:             * This method is protected by default in order to keep the public
397:             * api reasonable.  You can provide public methods for those you
398:             * actually need in AttributeType.
399:             */
400:            protected List getAttributesJoinAttributeType(Criteria criteria)
401:                    throws TorqueException {
402:                if (collAttributes == null) {
403:                    if (isNew()) {
404:                        collAttributes = new ArrayList();
405:                    } else {
406:                        criteria.add(AttributePeer.ATTRIBUTE_TYPE_ID,
407:                                getAttributeTypeId());
408:                        collAttributes = AttributePeer
409:                                .doSelectJoinAttributeType(criteria);
410:                    }
411:                } else {
412:                    // the following code is to determine if a new query is
413:                    // called for.  If the criteria is the same as the last
414:                    // one, just return the collection.
415:                    criteria.add(AttributePeer.ATTRIBUTE_TYPE_ID,
416:                            getAttributeTypeId());
417:                    if (!lastAttributesCriteria.equals(criteria)) {
418:                        collAttributes = AttributePeer
419:                                .doSelectJoinAttributeType(criteria);
420:                    }
421:                }
422:                lastAttributesCriteria = criteria;
423:
424:                return collAttributes;
425:            }
426:
427:            /**
428:             * If this collection has already been initialized with
429:             * an identical criteria, it returns the collection.
430:             * Otherwise if this AttributeType is new, it will return
431:             * an empty collection; or if this AttributeType has previously
432:             * been saved, it will retrieve related Attributes from storage.
433:             *
434:             * This method is protected by default in order to keep the public
435:             * api reasonable.  You can provide public methods for those you
436:             * actually need in AttributeType.
437:             */
438:            protected List getAttributesJoinAttributeOption(Criteria criteria)
439:                    throws TorqueException {
440:                if (collAttributes == null) {
441:                    if (isNew()) {
442:                        collAttributes = new ArrayList();
443:                    } else {
444:                        criteria.add(AttributePeer.ATTRIBUTE_TYPE_ID,
445:                                getAttributeTypeId());
446:                        collAttributes = AttributePeer
447:                                .doSelectJoinAttributeOption(criteria);
448:                    }
449:                } else {
450:                    // the following code is to determine if a new query is
451:                    // called for.  If the criteria is the same as the last
452:                    // one, just return the collection.
453:                    criteria.add(AttributePeer.ATTRIBUTE_TYPE_ID,
454:                            getAttributeTypeId());
455:                    if (!lastAttributesCriteria.equals(criteria)) {
456:                        collAttributes = AttributePeer
457:                                .doSelectJoinAttributeOption(criteria);
458:                    }
459:                }
460:                lastAttributesCriteria = criteria;
461:
462:                return collAttributes;
463:            }
464:
465:            /**
466:             * If this collection has already been initialized with
467:             * an identical criteria, it returns the collection.
468:             * Otherwise if this AttributeType is new, it will return
469:             * an empty collection; or if this AttributeType has previously
470:             * been saved, it will retrieve related Attributes from storage.
471:             *
472:             * This method is protected by default in order to keep the public
473:             * api reasonable.  You can provide public methods for those you
474:             * actually need in AttributeType.
475:             */
476:            protected List getAttributesJoinScarabUserImpl(Criteria criteria)
477:                    throws TorqueException {
478:                if (collAttributes == null) {
479:                    if (isNew()) {
480:                        collAttributes = new ArrayList();
481:                    } else {
482:                        criteria.add(AttributePeer.ATTRIBUTE_TYPE_ID,
483:                                getAttributeTypeId());
484:                        collAttributes = AttributePeer
485:                                .doSelectJoinScarabUserImpl(criteria);
486:                    }
487:                } else {
488:                    // the following code is to determine if a new query is
489:                    // called for.  If the criteria is the same as the last
490:                    // one, just return the collection.
491:                    criteria.add(AttributePeer.ATTRIBUTE_TYPE_ID,
492:                            getAttributeTypeId());
493:                    if (!lastAttributesCriteria.equals(criteria)) {
494:                        collAttributes = AttributePeer
495:                                .doSelectJoinScarabUserImpl(criteria);
496:                    }
497:                }
498:                lastAttributesCriteria = criteria;
499:
500:                return collAttributes;
501:            }
502:
503:            private static List fieldNames = null;
504:
505:            /**
506:             * Generate a list of field names.
507:             *
508:             * @return a list of field names
509:             */
510:            public static synchronized List getFieldNames() {
511:                if (fieldNames == null) {
512:                    fieldNames = new ArrayList();
513:                    fieldNames.add("AttributeTypeId");
514:                    fieldNames.add("ClassId");
515:                    fieldNames.add("Name");
516:                    fieldNames.add("JavaClassName");
517:                    fieldNames.add("ValidationKey");
518:                    fieldNames = Collections.unmodifiableList(fieldNames);
519:                }
520:                return fieldNames;
521:            }
522:
523:            /**
524:             * Retrieves a field from the object by name passed in as a String.
525:             *
526:             * @param name field name
527:             * @return value
528:             */
529:            public Object getByName(String name) {
530:                if (name.equals("AttributeTypeId")) {
531:                    return getAttributeTypeId();
532:                }
533:                if (name.equals("ClassId")) {
534:                    return getClassId();
535:                }
536:                if (name.equals("Name")) {
537:                    return getName();
538:                }
539:                if (name.equals("JavaClassName")) {
540:                    return getJavaClassName();
541:                }
542:                if (name.equals("ValidationKey")) {
543:                    return getValidationKey();
544:                }
545:                return null;
546:            }
547:
548:            /**
549:             * Retrieves a field from the object by name passed in
550:             * as a String.  The String must be one of the static
551:             * Strings defined in this Class' Peer.
552:             *
553:             * @param name peer name
554:             * @return value
555:             */
556:            public Object getByPeerName(String name) {
557:                if (name.equals(AttributeTypePeer.ATTRIBUTE_TYPE_ID)) {
558:                    return getAttributeTypeId();
559:                }
560:                if (name.equals(AttributeTypePeer.ATTRIBUTE_CLASS_ID)) {
561:                    return getClassId();
562:                }
563:                if (name.equals(AttributeTypePeer.ATTRIBUTE_TYPE_NAME)) {
564:                    return getName();
565:                }
566:                if (name.equals(AttributeTypePeer.JAVA_CLASS_NAME)) {
567:                    return getJavaClassName();
568:                }
569:                if (name.equals(AttributeTypePeer.VALIDATION_KEY)) {
570:                    return getValidationKey();
571:                }
572:                return null;
573:            }
574:
575:            /**
576:             * Retrieves a field from the object by Position as specified
577:             * in the xml schema.  Zero-based.
578:             *
579:             * @param pos position in xml schema
580:             * @return value
581:             */
582:            public Object getByPosition(int pos) {
583:                if (pos == 0) {
584:                    return getAttributeTypeId();
585:                }
586:                if (pos == 1) {
587:                    return getClassId();
588:                }
589:                if (pos == 2) {
590:                    return getName();
591:                }
592:                if (pos == 3) {
593:                    return getJavaClassName();
594:                }
595:                if (pos == 4) {
596:                    return getValidationKey();
597:                }
598:                return null;
599:            }
600:
601:            /**
602:             * Stores the object in the database.  If the object is new,
603:             * it inserts it; otherwise an update is performed.
604:             *
605:             * @throws TorqueException
606:             */
607:            public void save() throws TorqueException {
608:                save(AttributeTypePeer.getMapBuilder().getDatabaseMap()
609:                        .getName());
610:            }
611:
612:            /**
613:             * Stores the object in the database.  If the object is new,
614:             * it inserts it; otherwise an update is performed.
615:             * Note: this code is here because the method body is
616:             * auto-generated conditionally and therefore needs to be
617:             * in this file instead of in the super class, BaseObject.
618:             *
619:             * @param dbName
620:             * @throws TorqueException
621:             */
622:            public void save(String dbName) throws TorqueException {
623:                Connection con = null;
624:                try {
625:                    con = Transaction.begin(dbName);
626:                    save(con);
627:                    Transaction.commit(con);
628:                } catch (TorqueException e) {
629:                    Transaction.safeRollback(con);
630:                    throw e;
631:                }
632:            }
633:
634:            /** flag to prevent endless save loop, if this object is referenced
635:              by another object which falls in this transaction. */
636:            private boolean alreadyInSave = false;
637:
638:            /**
639:             * Stores the object in the database.  If the object is new,
640:             * it inserts it; otherwise an update is performed.  This method
641:             * is meant to be used as part of a transaction, otherwise use
642:             * the save() method and the connection details will be handled
643:             * internally
644:             *
645:             * @param con
646:             * @throws TorqueException
647:             */
648:            public void save(Connection con) throws TorqueException {
649:                if (!alreadyInSave) {
650:                    alreadyInSave = true;
651:
652:                    // If this object has been modified, then save it to the database.
653:                    if (isModified()) {
654:                        if (isNew()) {
655:                            AttributeTypePeer.doInsert((AttributeType) this ,
656:                                    con);
657:                            setNew(false);
658:                        } else {
659:                            AttributeTypePeer.doUpdate((AttributeType) this ,
660:                                    con);
661:                        }
662:
663:                        if (isCacheOnSave()) {
664:                            AttributeTypeManager.putInstance(this );
665:                        }
666:                    }
667:
668:                    if (collAttributes != null) {
669:                        for (int i = 0; i < collAttributes.size(); i++) {
670:                            ((Attribute) collAttributes.get(i)).save(con);
671:                        }
672:                    }
673:                    alreadyInSave = false;
674:                }
675:            }
676:
677:            /**
678:             * Specify whether to cache the object after saving to the db.
679:             * This method returns true
680:             */
681:            protected boolean isCacheOnSave() {
682:                return true;
683:            }
684:
685:            /**
686:             * Set the PrimaryKey using ObjectKey.
687:             *
688:             * @param key attributeTypeId ObjectKey
689:             */
690:            public void setPrimaryKey(ObjectKey key) throws TorqueException {
691:                setAttributeTypeId(new Integer(((NumberKey) key).intValue()));
692:            }
693:
694:            /**
695:             * Set the PrimaryKey using a String.
696:             *
697:             * @param key
698:             */
699:            public void setPrimaryKey(String key) throws TorqueException {
700:                setAttributeTypeId(new Integer(key));
701:            }
702:
703:            /**
704:             * returns an id that differentiates this object from others
705:             * of its class.
706:             */
707:            public ObjectKey getPrimaryKey() {
708:                return SimpleKey.keyFor(getAttributeTypeId());
709:            }
710:
711:            /**
712:             * get an id that differentiates this object from others
713:             * of its class.
714:             */
715:            public String getQueryKey() {
716:                if (getPrimaryKey() == null) {
717:                    return "";
718:                } else {
719:                    return getPrimaryKey().toString();
720:                }
721:            }
722:
723:            /**
724:             * set an id that differentiates this object from others
725:             * of its class.
726:             */
727:            public void setQueryKey(String key) throws TorqueException {
728:                setPrimaryKey(key);
729:            }
730:
731:            /**
732:             * Makes a copy of this object.
733:             * It creates a new object filling in the simple attributes.
734:             * It then fills all the association collections and sets the
735:             * related objects to isNew=true.
736:             */
737:            public AttributeType copy() throws TorqueException {
738:                return copyInto(new AttributeType());
739:            }
740:
741:            protected AttributeType copyInto(AttributeType copyObj)
742:                    throws TorqueException {
743:                copyObj.setAttributeTypeId(attributeTypeId);
744:                copyObj.setClassId(classId);
745:                copyObj.setName(name);
746:                copyObj.setJavaClassName(javaClassName);
747:                copyObj.setValidationKey(validationKey);
748:
749:                copyObj.setAttributeTypeId((Integer) null);
750:
751:                List v = getAttributes();
752:                if (v != null) {
753:                    for (int i = 0; i < v.size(); i++) {
754:                        Attribute obj = (Attribute) v.get(i);
755:                        copyObj.addAttribute(obj.copy());
756:                    }
757:                } else {
758:                    copyObj.collAttributes = null;
759:                }
760:                return copyObj;
761:            }
762:
763:            /**
764:             * returns a peer instance associated with this om.  Since Peer classes
765:             * are not to have any instance attributes, this method returns the
766:             * same instance for all member of this class. The method could therefore
767:             * be static, but this would prevent one from overriding the behavior.
768:             */
769:            public AttributeTypePeer getPeer() {
770:                return peer;
771:            }
772:
773:            public String toString() {
774:                StringBuffer str = new StringBuffer();
775:                str.append("AttributeType:\n");
776:                str.append("AttributeTypeId = ").append(getAttributeTypeId())
777:                        .append("\n");
778:                str.append("ClassId = ").append(getClassId()).append("\n");
779:                str.append("Name = ").append(getName()).append("\n");
780:                str.append("JavaClassName = ").append(getJavaClassName())
781:                        .append("\n");
782:                str.append("ValidationKey = ").append(getValidationKey())
783:                        .append("\n");
784:                return (str.toString());
785:            }
786:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.