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