Source Code Cross Referenced for BaseRModuleOptionPeer.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) 


0001:        package org.tigris.scarab.om;
0002:
0003:        import java.math.BigDecimal;
0004:        import java.sql.Connection;
0005:        import java.sql.SQLException;
0006:        import java.util.ArrayList;
0007:        import java.util.Date;
0008:        import java.util.Iterator;
0009:        import java.util.LinkedList;
0010:        import java.util.List;
0011:
0012:        import org.apache.torque.NoRowsException;
0013:        import org.apache.torque.TooManyRowsException;
0014:        import org.apache.torque.Torque;
0015:        import org.apache.torque.TorqueException;
0016:        import org.apache.torque.map.MapBuilder;
0017:        import org.apache.torque.map.TableMap;
0018:        import org.apache.torque.om.DateKey;
0019:        import org.apache.torque.om.NumberKey;
0020:        import org.apache.torque.om.StringKey;
0021:        import org.apache.torque.om.ObjectKey;
0022:        import org.apache.torque.om.SimpleKey;
0023:        import org.apache.torque.util.BasePeer;
0024:        import org.apache.torque.util.Criteria;
0025:
0026:        import com.workingdogs.village.DataSetException;
0027:        import com.workingdogs.village.QueryDataSet;
0028:        import com.workingdogs.village.Record;
0029:
0030:        // Local classes
0031:        import org.tigris.scarab.om.map.*;
0032:
0033:        /**
0034:         */
0035:        public abstract class BaseRModuleOptionPeer extends BasePeer {
0036:
0037:            /** the default database name for this class */
0038:            public static final String DATABASE_NAME = "scarab";
0039:
0040:            /** the table name for this class */
0041:            public static final String TABLE_NAME = "SCARAB_R_MODULE_OPTION";
0042:
0043:            /**
0044:             * @return the map builder for this peer
0045:             * @throws TorqueException Any exceptions caught during processing will be
0046:             *         rethrown wrapped into a TorqueException.
0047:             */
0048:            public static MapBuilder getMapBuilder() throws TorqueException {
0049:                return getMapBuilder(RModuleOptionMapBuilder.CLASS_NAME);
0050:            }
0051:
0052:            /** the column name for the MODULE_ID field */
0053:            public static final String MODULE_ID;
0054:            /** the column name for the ISSUE_TYPE_ID field */
0055:            public static final String ISSUE_TYPE_ID;
0056:            /** the column name for the OPTION_ID field */
0057:            public static final String OPTION_ID;
0058:            /** the column name for the DISPLAY_VALUE field */
0059:            public static final String DISPLAY_VALUE;
0060:            /** the column name for the ACTIVE field */
0061:            public static final String ACTIVE;
0062:            /** the column name for the PREFERRED_ORDER field */
0063:            public static final String PREFERRED_ORDER;
0064:            /** the column name for the WEIGHT field */
0065:            public static final String WEIGHT;
0066:
0067:            static {
0068:                MODULE_ID = "SCARAB_R_MODULE_OPTION.MODULE_ID";
0069:                ISSUE_TYPE_ID = "SCARAB_R_MODULE_OPTION.ISSUE_TYPE_ID";
0070:                OPTION_ID = "SCARAB_R_MODULE_OPTION.OPTION_ID";
0071:                DISPLAY_VALUE = "SCARAB_R_MODULE_OPTION.DISPLAY_VALUE";
0072:                ACTIVE = "SCARAB_R_MODULE_OPTION.ACTIVE";
0073:                PREFERRED_ORDER = "SCARAB_R_MODULE_OPTION.PREFERRED_ORDER";
0074:                WEIGHT = "SCARAB_R_MODULE_OPTION.WEIGHT";
0075:                if (Torque.isInit()) {
0076:                    try {
0077:                        getMapBuilder(RModuleOptionMapBuilder.CLASS_NAME);
0078:                    } catch (Exception e) {
0079:                        log.error("Could not initialize Peer", e);
0080:                        throw new RuntimeException(e);
0081:                    }
0082:                } else {
0083:                    Torque
0084:                            .registerMapBuilder(RModuleOptionMapBuilder.CLASS_NAME);
0085:                }
0086:            }
0087:
0088:            /** number of columns for this peer */
0089:            public static final int numColumns = 7;
0090:
0091:            /** A class that can be returned by this peer. */
0092:            protected static final String CLASSNAME_DEFAULT = "org.tigris.scarab.om.RModuleOption";
0093:
0094:            /** A class that can be returned by this peer. */
0095:            protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
0096:
0097:            /**
0098:             * Class object initialization method.
0099:             *
0100:             * @param className name of the class to initialize
0101:             * @return the initialized class
0102:             */
0103:            private static Class initClass(String className) {
0104:                Class c = null;
0105:                try {
0106:                    c = Class.forName(className);
0107:                } catch (Throwable t) {
0108:                    log
0109:                            .error(
0110:                                    "A FATAL ERROR has occurred which should not "
0111:                                            + "have happened under any circumstance.  Please notify "
0112:                                            + "the Torque developers <torque-dev@db.apache.org> "
0113:                                            + "and give as many details as possible (including the error "
0114:                                            + "stack trace).", t);
0115:
0116:                    // Error objects should always be propogated.
0117:                    if (t instanceof  Error) {
0118:                        throw (Error) t.fillInStackTrace();
0119:                    }
0120:                }
0121:                return c;
0122:            }
0123:
0124:            /**
0125:             * Get the list of objects for a ResultSet.  Please not that your
0126:             * resultset MUST return columns in the right order.  You can use
0127:             * getFieldNames() in BaseObject to get the correct sequence.
0128:             *
0129:             * @param results the ResultSet
0130:             * @return the list of objects
0131:             * @throws TorqueException Any exceptions caught during processing will be
0132:             *         rethrown wrapped into a TorqueException.
0133:             */
0134:            public static List resultSet2Objects(java.sql.ResultSet results)
0135:                    throws TorqueException {
0136:                try {
0137:                    QueryDataSet qds = null;
0138:                    List rows = null;
0139:                    try {
0140:                        qds = new QueryDataSet(results);
0141:                        rows = getSelectResults(qds);
0142:                    } finally {
0143:                        if (qds != null) {
0144:                            qds.close();
0145:                        }
0146:                    }
0147:
0148:                    return populateObjects(rows);
0149:                } catch (SQLException e) {
0150:                    throw new TorqueException(e);
0151:                } catch (DataSetException e) {
0152:                    throw new TorqueException(e);
0153:                }
0154:            }
0155:
0156:            /**
0157:             * Method to do inserts.
0158:             *
0159:             * @param criteria object used to create the INSERT statement.
0160:             * @throws TorqueException Any exceptions caught during processing will be
0161:             *         rethrown wrapped into a TorqueException.
0162:             */
0163:            public static ObjectKey doInsert(Criteria criteria)
0164:                    throws TorqueException {
0165:                return BaseRModuleOptionPeer.doInsert(criteria,
0166:                        (Connection) null);
0167:            }
0168:
0169:            /**
0170:             * Method to do inserts.  This method is to be used during a transaction,
0171:             * otherwise use the doInsert(Criteria) method.  It will take care of
0172:             * the connection details internally.
0173:             *
0174:             * @param criteria object used to create the INSERT statement.
0175:             * @param con the connection to use
0176:             * @throws TorqueException Any exceptions caught during processing will be
0177:             *         rethrown wrapped into a TorqueException.
0178:             */
0179:            public static ObjectKey doInsert(Criteria criteria, Connection con)
0180:                    throws TorqueException {
0181:                correctBooleans(criteria);
0182:
0183:                setDbName(criteria);
0184:
0185:                if (con == null) {
0186:                    return BasePeer.doInsert(criteria);
0187:                } else {
0188:                    return BasePeer.doInsert(criteria, con);
0189:                }
0190:            }
0191:
0192:            /**
0193:             * Add all the columns needed to create a new object.
0194:             *
0195:             * @param criteria object containing the columns to add.
0196:             * @throws TorqueException Any exceptions caught during processing will be
0197:             *         rethrown wrapped into a TorqueException.
0198:             */
0199:            public static void addSelectColumns(Criteria criteria)
0200:                    throws TorqueException {
0201:                criteria.addSelectColumn(MODULE_ID);
0202:                criteria.addSelectColumn(ISSUE_TYPE_ID);
0203:                criteria.addSelectColumn(OPTION_ID);
0204:                criteria.addSelectColumn(DISPLAY_VALUE);
0205:                criteria.addSelectColumn(ACTIVE);
0206:                criteria.addSelectColumn(PREFERRED_ORDER);
0207:                criteria.addSelectColumn(WEIGHT);
0208:            }
0209:
0210:            /**
0211:             * changes the boolean values in the criteria to the appropriate type,
0212:             * whenever a booleanchar or booleanint column is involved.
0213:             * This enables the user to create criteria using Boolean values
0214:             * for booleanchar or booleanint columns
0215:             * @param criteria the criteria in which the boolean values should be corrected
0216:             */
0217:            public static void correctBooleans(Criteria criteria) {
0218:                // check for conversion from boolean to int
0219:                if (criteria.containsKey(ACTIVE)) {
0220:                    Object possibleBoolean = criteria.get(ACTIVE);
0221:                    if (possibleBoolean instanceof  Boolean) {
0222:                        criteria.add(ACTIVE, ((Boolean) possibleBoolean)
0223:                                .booleanValue() ? 1 : 0);
0224:                    }
0225:                }
0226:            }
0227:
0228:            /**
0229:             * Create a new object of type cls from a resultset row starting
0230:             * from a specified offset.  This is done so that you can select
0231:             * other rows than just those needed for this object.  You may
0232:             * for example want to create two objects from the same row.
0233:             *
0234:             * @throws TorqueException Any exceptions caught during processing will be
0235:             *         rethrown wrapped into a TorqueException.
0236:             */
0237:            public static RModuleOption row2Object(Record row, int offset,
0238:                    Class cls) throws TorqueException {
0239:                try {
0240:                    RModuleOption obj = (RModuleOption) cls.newInstance();
0241:                    RModuleOptionPeer.populateObject(row, offset, obj);
0242:                    obj.setModified(false);
0243:                    obj.setNew(false);
0244:
0245:                    return obj;
0246:                } catch (InstantiationException e) {
0247:                    throw new TorqueException(e);
0248:                } catch (IllegalAccessException e) {
0249:                    throw new TorqueException(e);
0250:                }
0251:            }
0252:
0253:            /**
0254:             * Populates an object from a resultset row starting
0255:             * from a specified offset.  This is done so that you can select
0256:             * other rows than just those needed for this object.  You may
0257:             * for example want to create two objects from the same row.
0258:             *
0259:             * @throws TorqueException Any exceptions caught during processing will be
0260:             *         rethrown wrapped into a TorqueException.
0261:             */
0262:            public static void populateObject(Record row, int offset,
0263:                    RModuleOption obj) throws TorqueException {
0264:                try {
0265:                    obj.setModuleId(row.getValue(offset + 0).asIntegerObj());
0266:                    obj.setIssueTypeId(row.getValue(offset + 1).asIntegerObj());
0267:                    obj.setOptionId(row.getValue(offset + 2).asIntegerObj());
0268:                    obj.setDisplayValue(row.getValue(offset + 3).asString());
0269:                    obj.setActive(row.getValue(offset + 4).asBoolean());
0270:                    obj.setOrder(row.getValue(offset + 5).asInt());
0271:                    obj.setWeight(row.getValue(offset + 6).asInt());
0272:                } catch (DataSetException e) {
0273:                    throw new TorqueException(e);
0274:                }
0275:            }
0276:
0277:            /**
0278:             * Method to do selects.
0279:             *
0280:             * @param criteria object used to create the SELECT statement.
0281:             * @return List of selected Objects
0282:             * @throws TorqueException Any exceptions caught during processing will be
0283:             *         rethrown wrapped into a TorqueException.
0284:             */
0285:            public static List doSelect(Criteria criteria)
0286:                    throws TorqueException {
0287:                return populateObjects(doSelectVillageRecords(criteria));
0288:            }
0289:
0290:            /**
0291:             * Method to do selects within a transaction.
0292:             *
0293:             * @param criteria object used to create the SELECT statement.
0294:             * @param con the connection to use
0295:             * @return List of selected Objects
0296:             * @throws TorqueException Any exceptions caught during processing will be
0297:             *         rethrown wrapped into a TorqueException.
0298:             */
0299:            public static List doSelect(Criteria criteria, Connection con)
0300:                    throws TorqueException {
0301:                return populateObjects(doSelectVillageRecords(criteria, con));
0302:            }
0303:
0304:            /**
0305:             * Grabs the raw Village records to be formed into objects.
0306:             * This method handles connections internally.  The Record objects
0307:             * returned by this method should be considered readonly.  Do not
0308:             * alter the data and call save(), your results may vary, but are
0309:             * certainly likely to result in hard to track MT bugs.
0310:             *
0311:             * @throws TorqueException Any exceptions caught during processing will be
0312:             *         rethrown wrapped into a TorqueException.
0313:             */
0314:            public static List doSelectVillageRecords(Criteria criteria)
0315:                    throws TorqueException {
0316:                return BaseRModuleOptionPeer.doSelectVillageRecords(criteria,
0317:                        (Connection) null);
0318:            }
0319:
0320:            /**
0321:             * Grabs the raw Village records to be formed into objects.
0322:             * This method should be used for transactions
0323:             *
0324:             * @param criteria object used to create the SELECT statement.
0325:             * @param con the connection to use
0326:             * @throws TorqueException Any exceptions caught during processing will be
0327:             *         rethrown wrapped into a TorqueException.
0328:             */
0329:            public static List doSelectVillageRecords(Criteria criteria,
0330:                    Connection con) throws TorqueException {
0331:                if (criteria.getSelectColumns().size() == 0) {
0332:                    addSelectColumns(criteria);
0333:                }
0334:                correctBooleans(criteria);
0335:
0336:                setDbName(criteria);
0337:
0338:                // BasePeer returns a List of Value (Village) arrays.  The array
0339:                // order follows the order columns were placed in the Select clause.
0340:                if (con == null) {
0341:                    return BasePeer.doSelect(criteria);
0342:                } else {
0343:                    return BasePeer.doSelect(criteria, con);
0344:                }
0345:            }
0346:
0347:            /**
0348:             * The returned List will contain objects of the default type or
0349:             * objects that inherit from the default.
0350:             *
0351:             * @throws TorqueException Any exceptions caught during processing will be
0352:             *         rethrown wrapped into a TorqueException.
0353:             */
0354:            public static List populateObjects(List records)
0355:                    throws TorqueException {
0356:                List results = new ArrayList(records.size());
0357:
0358:                // populate the object(s)
0359:                for (int i = 0; i < records.size(); i++) {
0360:                    Record row = (Record) records.get(i);
0361:                    results.add(RModuleOptionPeer.row2Object(row, 1,
0362:                            RModuleOptionPeer.getOMClass()));
0363:                }
0364:                return results;
0365:            }
0366:
0367:            /**
0368:             * The class that the Peer will make instances of.
0369:             * If the BO is abstract then you must implement this method
0370:             * in the BO.
0371:             *
0372:             * @throws TorqueException Any exceptions caught during processing will be
0373:             *         rethrown wrapped into a TorqueException.
0374:             */
0375:            public static Class getOMClass() throws TorqueException {
0376:                return CLASS_DEFAULT;
0377:            }
0378:
0379:            /**
0380:             * Method to do updates.
0381:             *
0382:             * @param criteria object containing data that is used to create the UPDATE
0383:             *        statement.
0384:             * @throws TorqueException Any exceptions caught during processing will be
0385:             *         rethrown wrapped into a TorqueException.
0386:             */
0387:            public static void doUpdate(Criteria criteria)
0388:                    throws TorqueException {
0389:                BaseRModuleOptionPeer.doUpdate(criteria, (Connection) null);
0390:            }
0391:
0392:            /**
0393:             * Method to do updates.  This method is to be used during a transaction,
0394:             * otherwise use the doUpdate(Criteria) method.  It will take care of
0395:             * the connection details internally.
0396:             *
0397:             * @param criteria object containing data that is used to create the UPDATE
0398:             *        statement.
0399:             * @param con the connection to use
0400:             * @throws TorqueException Any exceptions caught during processing will be
0401:             *         rethrown wrapped into a TorqueException.
0402:             */
0403:            public static void doUpdate(Criteria criteria, Connection con)
0404:                    throws TorqueException {
0405:                Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
0406:                correctBooleans(criteria);
0407:
0408:                selectCriteria.put(MODULE_ID, criteria.remove(MODULE_ID));
0409:
0410:                selectCriteria.put(ISSUE_TYPE_ID, criteria
0411:                        .remove(ISSUE_TYPE_ID));
0412:
0413:                selectCriteria.put(OPTION_ID, criteria.remove(OPTION_ID));
0414:
0415:                setDbName(criteria);
0416:
0417:                if (con == null) {
0418:                    BasePeer.doUpdate(selectCriteria, criteria);
0419:                } else {
0420:                    BasePeer.doUpdate(selectCriteria, criteria, con);
0421:                }
0422:            }
0423:
0424:            /**
0425:             * Method to do deletes.
0426:             *
0427:             * @param criteria object containing data that is used DELETE from database.
0428:             * @throws TorqueException Any exceptions caught during processing will be
0429:             *         rethrown wrapped into a TorqueException.
0430:             */
0431:            public static void doDelete(Criteria criteria)
0432:                    throws TorqueException {
0433:                RModuleOptionPeer.doDelete(criteria, (Connection) null);
0434:            }
0435:
0436:            /**
0437:             * Method to do deletes.  This method is to be used during a transaction,
0438:             * otherwise use the doDelete(Criteria) method.  It will take care of
0439:             * the connection details internally.
0440:             *
0441:             * @param criteria object containing data that is used DELETE from database.
0442:             * @param con the connection to use
0443:             * @throws TorqueException Any exceptions caught during processing will be
0444:             *         rethrown wrapped into a TorqueException.
0445:             */
0446:            public static void doDelete(Criteria criteria, Connection con)
0447:                    throws TorqueException {
0448:                correctBooleans(criteria);
0449:
0450:                setDbName(criteria);
0451:
0452:                if (con == null) {
0453:                    BasePeer.doDelete(criteria);
0454:                } else {
0455:                    BasePeer.doDelete(criteria, con);
0456:                }
0457:            }
0458:
0459:            /**
0460:             * Method to do selects
0461:             *
0462:             * @throws TorqueException Any exceptions caught during processing will be
0463:             *         rethrown wrapped into a TorqueException.
0464:             */
0465:            public static List doSelect(RModuleOption obj)
0466:                    throws TorqueException {
0467:                return doSelect(buildSelectCriteria(obj));
0468:            }
0469:
0470:            /**
0471:             * Method to do inserts
0472:             *
0473:             * @throws TorqueException Any exceptions caught during processing will be
0474:             *         rethrown wrapped into a TorqueException.
0475:             */
0476:            public static void doInsert(RModuleOption obj)
0477:                    throws TorqueException {
0478:                doInsert(buildCriteria(obj));
0479:                obj.setNew(false);
0480:                obj.setModified(false);
0481:            }
0482:
0483:            /**
0484:             * @param obj the data object to update in the database.
0485:             * @throws TorqueException Any exceptions caught during processing will be
0486:             *         rethrown wrapped into a TorqueException.
0487:             */
0488:            public static void doUpdate(RModuleOption obj)
0489:                    throws TorqueException {
0490:                doUpdate(buildCriteria(obj));
0491:                obj.setModified(false);
0492:            }
0493:
0494:            /**
0495:             * @param obj the data object to delete in the database.
0496:             * @throws TorqueException Any exceptions caught during processing will be
0497:             *         rethrown wrapped into a TorqueException.
0498:             */
0499:            public static void doDelete(RModuleOption obj)
0500:                    throws TorqueException {
0501:                doDelete(buildSelectCriteria(obj));
0502:            }
0503:
0504:            /**
0505:             * Method to do inserts.  This method is to be used during a transaction,
0506:             * otherwise use the doInsert(RModuleOption) method.  It will take
0507:             * care of the connection details internally.
0508:             *
0509:             * @param obj the data object to insert into the database.
0510:             * @param con the connection to use
0511:             * @throws TorqueException Any exceptions caught during processing will be
0512:             *         rethrown wrapped into a TorqueException.
0513:             */
0514:            public static void doInsert(RModuleOption obj, Connection con)
0515:                    throws TorqueException {
0516:                doInsert(buildCriteria(obj), con);
0517:                obj.setNew(false);
0518:                obj.setModified(false);
0519:            }
0520:
0521:            /**
0522:             * Method to do update.  This method is to be used during a transaction,
0523:             * otherwise use the doUpdate(RModuleOption) method.  It will take
0524:             * care of the connection details internally.
0525:             *
0526:             * @param obj the data object to update in the database.
0527:             * @param con the connection to use
0528:             * @throws TorqueException Any exceptions caught during processing will be
0529:             *         rethrown wrapped into a TorqueException.
0530:             */
0531:            public static void doUpdate(RModuleOption obj, Connection con)
0532:                    throws TorqueException {
0533:                doUpdate(buildCriteria(obj), con);
0534:                obj.setModified(false);
0535:            }
0536:
0537:            /**
0538:             * Method to delete.  This method is to be used during a transaction,
0539:             * otherwise use the doDelete(RModuleOption) method.  It will take
0540:             * care of the connection details internally.
0541:             *
0542:             * @param obj the data object to delete in the database.
0543:             * @param con the connection to use
0544:             * @throws TorqueException Any exceptions caught during processing will be
0545:             *         rethrown wrapped into a TorqueException.
0546:             */
0547:            public static void doDelete(RModuleOption obj, Connection con)
0548:                    throws TorqueException {
0549:                doDelete(buildSelectCriteria(obj), con);
0550:            }
0551:
0552:            /**
0553:             * Method to do deletes.
0554:             *
0555:             * @param pk ObjectKey that is used DELETE from database.
0556:             * @throws TorqueException Any exceptions caught during processing will be
0557:             *         rethrown wrapped into a TorqueException.
0558:             */
0559:            public static void doDelete(ObjectKey pk) throws TorqueException {
0560:                BaseRModuleOptionPeer.doDelete(pk, (Connection) null);
0561:            }
0562:
0563:            /**
0564:             * Method to delete.  This method is to be used during a transaction,
0565:             * otherwise use the doDelete(ObjectKey) method.  It will take
0566:             * care of the connection details internally.
0567:             *
0568:             * @param pk the primary key for the object to delete in the database.
0569:             * @param con the connection to use
0570:             * @throws TorqueException Any exceptions caught during processing will be
0571:             *         rethrown wrapped into a TorqueException.
0572:             */
0573:            public static void doDelete(ObjectKey pk, Connection con)
0574:                    throws TorqueException {
0575:                doDelete(buildCriteria(pk), con);
0576:            }
0577:
0578:            /** Build a Criteria object from an ObjectKey */
0579:            public static Criteria buildCriteria(ObjectKey pk) {
0580:                Criteria criteria = new Criteria();
0581:                SimpleKey[] keys = (SimpleKey[]) pk.getValue();
0582:                criteria.add(MODULE_ID, keys[0]);
0583:                criteria.add(ISSUE_TYPE_ID, keys[1]);
0584:                criteria.add(OPTION_ID, keys[2]);
0585:                return criteria;
0586:            }
0587:
0588:            /** Build a Criteria object from the data object for this peer */
0589:            public static Criteria buildCriteria(RModuleOption obj) {
0590:                Criteria criteria = new Criteria(DATABASE_NAME);
0591:                criteria.add(MODULE_ID, obj.getModuleId());
0592:                criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
0593:                criteria.add(OPTION_ID, obj.getOptionId());
0594:                criteria.add(DISPLAY_VALUE, obj.getDisplayValue());
0595:                criteria.add(ACTIVE, obj.getActive());
0596:                criteria.add(PREFERRED_ORDER, obj.getOrder());
0597:                criteria.add(WEIGHT, obj.getWeight());
0598:                return criteria;
0599:            }
0600:
0601:            /** Build a Criteria object from the data object for this peer, skipping all binary columns */
0602:            public static Criteria buildSelectCriteria(RModuleOption obj) {
0603:                Criteria criteria = new Criteria(DATABASE_NAME);
0604:                criteria.add(MODULE_ID, obj.getModuleId());
0605:                criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
0606:                criteria.add(OPTION_ID, obj.getOptionId());
0607:                criteria.add(DISPLAY_VALUE, obj.getDisplayValue());
0608:                criteria.add(ACTIVE, obj.getActive());
0609:                criteria.add(PREFERRED_ORDER, obj.getOrder());
0610:                criteria.add(WEIGHT, obj.getWeight());
0611:                return criteria;
0612:            }
0613:
0614:            /**
0615:             * Retrieve a single object by pk
0616:             *
0617:             * @param pk the primary key
0618:             * @throws TorqueException Any exceptions caught during processing will be
0619:             *         rethrown wrapped into a TorqueException.
0620:             * @throws NoRowsException Primary key was not found in database.
0621:             * @throws TooManyRowsException Primary key was not found in database.
0622:             */
0623:            public static RModuleOption retrieveByPK(ObjectKey pk)
0624:                    throws TorqueException, NoRowsException,
0625:                    TooManyRowsException {
0626:                Connection db = null;
0627:                RModuleOption retVal = null;
0628:                try {
0629:                    db = Torque.getConnection(DATABASE_NAME);
0630:                    retVal = retrieveByPK(pk, db);
0631:                } finally {
0632:                    Torque.closeConnection(db);
0633:                }
0634:                return retVal;
0635:            }
0636:
0637:            /**
0638:             * Retrieve a single object by pk
0639:             *
0640:             * @param pk the primary key
0641:             * @param con the connection to use
0642:             * @throws TorqueException Any exceptions caught during processing will be
0643:             *         rethrown wrapped into a TorqueException.
0644:             * @throws NoRowsException Primary key was not found in database.
0645:             * @throws TooManyRowsException Primary key was not found in database.
0646:             */
0647:            public static RModuleOption retrieveByPK(ObjectKey pk,
0648:                    Connection con) throws TorqueException, NoRowsException,
0649:                    TooManyRowsException {
0650:                Criteria criteria = buildCriteria(pk);
0651:                List v = doSelect(criteria, con);
0652:                if (v.size() == 0) {
0653:                    throw new NoRowsException("Failed to select a row.");
0654:                } else if (v.size() > 1) {
0655:                    throw new TooManyRowsException(
0656:                            "Failed to select only one row.");
0657:                } else {
0658:                    return (RModuleOption) v.get(0);
0659:                }
0660:            }
0661:
0662:            /**
0663:             * Retrieve a multiple objects by pk
0664:             *
0665:             * @param pks List of primary keys
0666:             * @throws TorqueException Any exceptions caught during processing will be
0667:             *         rethrown wrapped into a TorqueException.
0668:             */
0669:            public static List retrieveByPKs(List pks) throws TorqueException {
0670:                Connection db = null;
0671:                List retVal = null;
0672:                try {
0673:                    db = Torque.getConnection(DATABASE_NAME);
0674:                    retVal = retrieveByPKs(pks, db);
0675:                } finally {
0676:                    Torque.closeConnection(db);
0677:                }
0678:                return retVal;
0679:            }
0680:
0681:            /**
0682:             * Retrieve a multiple objects by pk
0683:             *
0684:             * @param pks List of primary keys
0685:             * @param dbcon the connection to use
0686:             * @throws TorqueException Any exceptions caught during processing will be
0687:             *         rethrown wrapped into a TorqueException.
0688:             */
0689:            public static List retrieveByPKs(List pks, Connection dbcon)
0690:                    throws TorqueException {
0691:                List objs = null;
0692:                if (pks == null || pks.size() == 0) {
0693:                    objs = new LinkedList();
0694:                } else {
0695:                    Criteria criteria = new Criteria();
0696:                    Iterator iter = pks.iterator();
0697:                    while (iter.hasNext()) {
0698:                        ObjectKey pk = (ObjectKey) iter.next();
0699:                        SimpleKey[] keys = (SimpleKey[]) pk.getValue();
0700:                        Criteria.Criterion c0 = criteria.getNewCriterion(
0701:                                MODULE_ID, keys[0], Criteria.EQUAL);
0702:                        Criteria.Criterion c1 = criteria.getNewCriterion(
0703:                                ISSUE_TYPE_ID, keys[1], Criteria.EQUAL);
0704:                        c0.and(c1);
0705:                        Criteria.Criterion c2 = criteria.getNewCriterion(
0706:                                OPTION_ID, keys[2], Criteria.EQUAL);
0707:                        c1.and(c2);
0708:                        criteria.or(c0);
0709:                    }
0710:                    objs = doSelect(criteria, dbcon);
0711:                }
0712:                return objs;
0713:            }
0714:
0715:            /**
0716:             * retrieve object using using pk values.
0717:             *
0718:             * @param module_id Integer
0719:             * @param issue_type_id Integer
0720:             * @param option_id Integer
0721:             */
0722:            public static RModuleOption retrieveByPK(Integer module_id,
0723:                    Integer issue_type_id, Integer option_id)
0724:                    throws TorqueException {
0725:                Connection db = null;
0726:                RModuleOption retVal = null;
0727:                try {
0728:                    db = Torque.getConnection(DATABASE_NAME);
0729:                    retVal = retrieveByPK(module_id, issue_type_id, option_id,
0730:                            db);
0731:                } finally {
0732:                    Torque.closeConnection(db);
0733:                }
0734:                return retVal;
0735:            }
0736:
0737:            /**
0738:             * retrieve object using using pk values.
0739:             *
0740:             * @param module_id Integer
0741:             * @param issue_type_id Integer
0742:             * @param option_id Integer
0743:             * @param con Connection
0744:             */
0745:            public static RModuleOption retrieveByPK(Integer module_id,
0746:                    Integer issue_type_id, Integer option_id, Connection con)
0747:                    throws TorqueException {
0748:
0749:                Criteria criteria = new Criteria(5);
0750:                criteria.add(MODULE_ID, module_id);
0751:                criteria.add(ISSUE_TYPE_ID, issue_type_id);
0752:                criteria.add(OPTION_ID, option_id);
0753:                List v = doSelect(criteria, con);
0754:                if (v.size() == 1) {
0755:                    return (RModuleOption) v.get(0);
0756:                } else {
0757:                    throw new TorqueException(
0758:                            "Failed to select one and only one row.");
0759:                }
0760:            }
0761:
0762:            /**
0763:             * selects a collection of RModuleOption objects pre-filled with their
0764:             * AttributeOption objects.
0765:             *
0766:             * This method is protected by default in order to keep the public
0767:             * api reasonable.  You can provide public methods for those you
0768:             * actually need in RModuleOptionPeer.
0769:             *
0770:             * @throws TorqueException Any exceptions caught during processing will be
0771:             *         rethrown wrapped into a TorqueException.
0772:             */
0773:            protected static List doSelectJoinAttributeOption(Criteria criteria)
0774:                    throws TorqueException {
0775:                return doSelectJoinAttributeOption(criteria, null);
0776:            }
0777:
0778:            /**
0779:             * selects a collection of RModuleOption objects pre-filled with their
0780:             * AttributeOption objects.
0781:             *
0782:             * This method is protected by default in order to keep the public
0783:             * api reasonable.  You can provide public methods for those you
0784:             * actually need in RModuleOptionPeer.
0785:             *
0786:             * @throws TorqueException Any exceptions caught during processing will be
0787:             *         rethrown wrapped into a TorqueException.
0788:             */
0789:            protected static List doSelectJoinAttributeOption(
0790:                    Criteria criteria, Connection conn) throws TorqueException {
0791:                setDbName(criteria);
0792:
0793:                RModuleOptionPeer.addSelectColumns(criteria);
0794:                int offset = numColumns + 1;
0795:                AttributeOptionPeer.addSelectColumns(criteria);
0796:
0797:                criteria.addJoin(RModuleOptionPeer.OPTION_ID,
0798:                        AttributeOptionPeer.OPTION_ID);
0799:
0800:                correctBooleans(criteria);
0801:
0802:                List rows;
0803:                if (conn == null) {
0804:                    rows = BasePeer.doSelect(criteria);
0805:                } else {
0806:                    rows = BasePeer.doSelect(criteria, conn);
0807:                }
0808:
0809:                List results = new ArrayList();
0810:
0811:                for (int i = 0; i < rows.size(); i++) {
0812:                    Record row = (Record) rows.get(i);
0813:
0814:                    Class omClass = RModuleOptionPeer.getOMClass();
0815:                    RModuleOption obj1 = (RModuleOption) RModuleOptionPeer
0816:                            .row2Object(row, 1, omClass);
0817:                    omClass = AttributeOptionPeer.getOMClass();
0818:                    AttributeOption obj2 = (AttributeOption) AttributeOptionPeer
0819:                            .row2Object(row, offset, omClass);
0820:
0821:                    boolean newObject = true;
0822:                    for (int j = 0; j < results.size(); j++) {
0823:                        RModuleOption temp_obj1 = (RModuleOption) results
0824:                                .get(j);
0825:                        AttributeOption temp_obj2 = (AttributeOption) temp_obj1
0826:                                .getAttributeOption();
0827:                        if (temp_obj2.getPrimaryKey().equals(
0828:                                obj2.getPrimaryKey())) {
0829:                            newObject = false;
0830:                            temp_obj2.addRModuleOption(obj1);
0831:                            break;
0832:                        }
0833:                    }
0834:                    if (newObject) {
0835:                        obj2.initRModuleOptions();
0836:                        obj2.addRModuleOption(obj1);
0837:                    }
0838:                    results.add(obj1);
0839:                }
0840:                return results;
0841:            }
0842:
0843:            /**
0844:             * selects a collection of RModuleOption objects pre-filled with their
0845:             * ScarabModule objects.
0846:             *
0847:             * This method is protected by default in order to keep the public
0848:             * api reasonable.  You can provide public methods for those you
0849:             * actually need in RModuleOptionPeer.
0850:             *
0851:             * @throws TorqueException Any exceptions caught during processing will be
0852:             *         rethrown wrapped into a TorqueException.
0853:             */
0854:            protected static List doSelectJoinScarabModule(Criteria criteria)
0855:                    throws TorqueException {
0856:                return doSelectJoinScarabModule(criteria, null);
0857:            }
0858:
0859:            /**
0860:             * selects a collection of RModuleOption objects pre-filled with their
0861:             * ScarabModule objects.
0862:             *
0863:             * This method is protected by default in order to keep the public
0864:             * api reasonable.  You can provide public methods for those you
0865:             * actually need in RModuleOptionPeer.
0866:             *
0867:             * @throws TorqueException Any exceptions caught during processing will be
0868:             *         rethrown wrapped into a TorqueException.
0869:             */
0870:            protected static List doSelectJoinScarabModule(Criteria criteria,
0871:                    Connection conn) throws TorqueException {
0872:                setDbName(criteria);
0873:
0874:                RModuleOptionPeer.addSelectColumns(criteria);
0875:                int offset = numColumns + 1;
0876:                ScarabModulePeer.addSelectColumns(criteria);
0877:
0878:                criteria.addJoin(RModuleOptionPeer.MODULE_ID,
0879:                        ScarabModulePeer.MODULE_ID);
0880:
0881:                correctBooleans(criteria);
0882:
0883:                List rows;
0884:                if (conn == null) {
0885:                    rows = BasePeer.doSelect(criteria);
0886:                } else {
0887:                    rows = BasePeer.doSelect(criteria, conn);
0888:                }
0889:
0890:                List results = new ArrayList();
0891:
0892:                for (int i = 0; i < rows.size(); i++) {
0893:                    Record row = (Record) rows.get(i);
0894:
0895:                    Class omClass = RModuleOptionPeer.getOMClass();
0896:                    RModuleOption obj1 = (RModuleOption) RModuleOptionPeer
0897:                            .row2Object(row, 1, omClass);
0898:                    omClass = ScarabModulePeer.getOMClass(row, offset);
0899:                    ScarabModule obj2 = (ScarabModule) ScarabModulePeer
0900:                            .row2Object(row, offset, omClass);
0901:
0902:                    boolean newObject = true;
0903:                    for (int j = 0; j < results.size(); j++) {
0904:                        RModuleOption temp_obj1 = (RModuleOption) results
0905:                                .get(j);
0906:                        ScarabModule temp_obj2 = (ScarabModule) temp_obj1
0907:                                .getModule();
0908:                        if (temp_obj2.getPrimaryKey().equals(
0909:                                obj2.getPrimaryKey())) {
0910:                            newObject = false;
0911:                            temp_obj2.addRModuleOption(obj1);
0912:                            break;
0913:                        }
0914:                    }
0915:                    if (newObject) {
0916:                        obj2.initRModuleOptions();
0917:                        obj2.addRModuleOption(obj1);
0918:                    }
0919:                    results.add(obj1);
0920:                }
0921:                return results;
0922:            }
0923:
0924:            /**
0925:             * selects a collection of RModuleOption objects pre-filled with their
0926:             * IssueType objects.
0927:             *
0928:             * This method is protected by default in order to keep the public
0929:             * api reasonable.  You can provide public methods for those you
0930:             * actually need in RModuleOptionPeer.
0931:             *
0932:             * @throws TorqueException Any exceptions caught during processing will be
0933:             *         rethrown wrapped into a TorqueException.
0934:             */
0935:            protected static List doSelectJoinIssueType(Criteria criteria)
0936:                    throws TorqueException {
0937:                return doSelectJoinIssueType(criteria, null);
0938:            }
0939:
0940:            /**
0941:             * selects a collection of RModuleOption objects pre-filled with their
0942:             * IssueType objects.
0943:             *
0944:             * This method is protected by default in order to keep the public
0945:             * api reasonable.  You can provide public methods for those you
0946:             * actually need in RModuleOptionPeer.
0947:             *
0948:             * @throws TorqueException Any exceptions caught during processing will be
0949:             *         rethrown wrapped into a TorqueException.
0950:             */
0951:            protected static List doSelectJoinIssueType(Criteria criteria,
0952:                    Connection conn) throws TorqueException {
0953:                setDbName(criteria);
0954:
0955:                RModuleOptionPeer.addSelectColumns(criteria);
0956:                int offset = numColumns + 1;
0957:                IssueTypePeer.addSelectColumns(criteria);
0958:
0959:                criteria.addJoin(RModuleOptionPeer.ISSUE_TYPE_ID,
0960:                        IssueTypePeer.ISSUE_TYPE_ID);
0961:
0962:                correctBooleans(criteria);
0963:
0964:                List rows;
0965:                if (conn == null) {
0966:                    rows = BasePeer.doSelect(criteria);
0967:                } else {
0968:                    rows = BasePeer.doSelect(criteria, conn);
0969:                }
0970:
0971:                List results = new ArrayList();
0972:
0973:                for (int i = 0; i < rows.size(); i++) {
0974:                    Record row = (Record) rows.get(i);
0975:
0976:                    Class omClass = RModuleOptionPeer.getOMClass();
0977:                    RModuleOption obj1 = (RModuleOption) RModuleOptionPeer
0978:                            .row2Object(row, 1, omClass);
0979:                    omClass = IssueTypePeer.getOMClass();
0980:                    IssueType obj2 = (IssueType) IssueTypePeer.row2Object(row,
0981:                            offset, omClass);
0982:
0983:                    boolean newObject = true;
0984:                    for (int j = 0; j < results.size(); j++) {
0985:                        RModuleOption temp_obj1 = (RModuleOption) results
0986:                                .get(j);
0987:                        IssueType temp_obj2 = (IssueType) temp_obj1
0988:                                .getIssueType();
0989:                        if (temp_obj2.getPrimaryKey().equals(
0990:                                obj2.getPrimaryKey())) {
0991:                            newObject = false;
0992:                            temp_obj2.addRModuleOption(obj1);
0993:                            break;
0994:                        }
0995:                    }
0996:                    if (newObject) {
0997:                        obj2.initRModuleOptions();
0998:                        obj2.addRModuleOption(obj1);
0999:                    }
1000:                    results.add(obj1);
1001:                }
1002:                return results;
1003:            }
1004:
1005:            /**
1006:             * selects a collection of RModuleOption objects pre-filled with
1007:             * all related objects.
1008:             *
1009:             * This method is protected by default in order to keep the public
1010:             * api reasonable.  You can provide public methods for those you
1011:             * actually need in RModuleOptionPeer.
1012:             *
1013:             * @throws TorqueException Any exceptions caught during processing will be
1014:             *         rethrown wrapped into a TorqueException.
1015:             */
1016:            protected static List doSelectJoinAllExceptAttributeOption(
1017:                    Criteria criteria) throws TorqueException {
1018:                return doSelectJoinAllExceptAttributeOption(criteria, null);
1019:            }
1020:
1021:            /**
1022:             * selects a collection of RModuleOption objects pre-filled with
1023:             * all related objects.
1024:             *
1025:             * This method is protected by default in order to keep the public
1026:             * api reasonable.  You can provide public methods for those you
1027:             * actually need in RModuleOptionPeer.
1028:             *
1029:             * @throws TorqueException Any exceptions caught during processing will be
1030:             *         rethrown wrapped into a TorqueException.
1031:             */
1032:            protected static List doSelectJoinAllExceptAttributeOption(
1033:                    Criteria criteria, Connection conn) throws TorqueException {
1034:                setDbName(criteria);
1035:
1036:                addSelectColumns(criteria);
1037:                int offset2 = numColumns + 1;
1038:
1039:                ScarabModulePeer.addSelectColumns(criteria);
1040:                criteria.addJoin(RModuleOptionPeer.MODULE_ID,
1041:                        ScarabModulePeer.MODULE_ID);
1042:                int offset3 = offset2 + ScarabModulePeer.numColumns;
1043:
1044:                IssueTypePeer.addSelectColumns(criteria);
1045:                criteria.addJoin(RModuleOptionPeer.ISSUE_TYPE_ID,
1046:                        IssueTypePeer.ISSUE_TYPE_ID);
1047:
1048:                correctBooleans(criteria);
1049:
1050:                List rows;
1051:                if (conn == null) {
1052:                    rows = BasePeer.doSelect(criteria);
1053:                } else {
1054:                    rows = BasePeer.doSelect(criteria, conn);
1055:                }
1056:
1057:                List results = new ArrayList();
1058:
1059:                for (int i = 0; i < rows.size(); i++) {
1060:                    Record row = (Record) rows.get(i);
1061:
1062:                    Class omClass = RModuleOptionPeer.getOMClass();
1063:                    RModuleOption obj1 = (RModuleOption) RModuleOptionPeer
1064:                            .row2Object(row, 1, omClass);
1065:
1066:                    omClass = ScarabModulePeer.getOMClass(row, offset2);
1067:                    ScarabModule obj2 = (ScarabModule) ScarabModulePeer
1068:                            .row2Object(row, offset2, omClass);
1069:
1070:                    boolean newObject = true;
1071:                    for (int j = 0; j < results.size(); j++) {
1072:                        RModuleOption temp_obj1 = (RModuleOption) results
1073:                                .get(j);
1074:                        ScarabModule temp_obj2 = (ScarabModule) temp_obj1
1075:                                .getModule();
1076:                        if (temp_obj2.getPrimaryKey().equals(
1077:                                obj2.getPrimaryKey())) {
1078:                            newObject = false;
1079:                            temp_obj2.addRModuleOption(obj1);
1080:                            break;
1081:                        }
1082:                    }
1083:                    if (newObject) {
1084:                        obj2.initRModuleOptions();
1085:                        obj2.addRModuleOption(obj1);
1086:                    }
1087:
1088:                    omClass = IssueTypePeer.getOMClass();
1089:                    IssueType obj3 = (IssueType) IssueTypePeer.row2Object(row,
1090:                            offset3, omClass);
1091:
1092:                    newObject = true;
1093:                    for (int j = 0; j < results.size(); j++) {
1094:                        RModuleOption temp_obj1 = (RModuleOption) results
1095:                                .get(j);
1096:                        IssueType temp_obj3 = (IssueType) temp_obj1
1097:                                .getIssueType();
1098:                        if (temp_obj3.getPrimaryKey().equals(
1099:                                obj3.getPrimaryKey())) {
1100:                            newObject = false;
1101:                            temp_obj3.addRModuleOption(obj1);
1102:                            break;
1103:                        }
1104:                    }
1105:                    if (newObject) {
1106:                        obj3.initRModuleOptions();
1107:                        obj3.addRModuleOption(obj1);
1108:                    }
1109:                    results.add(obj1);
1110:                }
1111:                return results;
1112:            }
1113:
1114:            /**
1115:             * selects a collection of RModuleOption objects pre-filled with
1116:             * all related objects.
1117:             *
1118:             * This method is protected by default in order to keep the public
1119:             * api reasonable.  You can provide public methods for those you
1120:             * actually need in RModuleOptionPeer.
1121:             *
1122:             * @throws TorqueException Any exceptions caught during processing will be
1123:             *         rethrown wrapped into a TorqueException.
1124:             */
1125:            protected static List doSelectJoinAllExceptScarabModule(
1126:                    Criteria criteria) throws TorqueException {
1127:                return doSelectJoinAllExceptScarabModule(criteria, null);
1128:            }
1129:
1130:            /**
1131:             * selects a collection of RModuleOption objects pre-filled with
1132:             * all related objects.
1133:             *
1134:             * This method is protected by default in order to keep the public
1135:             * api reasonable.  You can provide public methods for those you
1136:             * actually need in RModuleOptionPeer.
1137:             *
1138:             * @throws TorqueException Any exceptions caught during processing will be
1139:             *         rethrown wrapped into a TorqueException.
1140:             */
1141:            protected static List doSelectJoinAllExceptScarabModule(
1142:                    Criteria criteria, Connection conn) throws TorqueException {
1143:                setDbName(criteria);
1144:
1145:                addSelectColumns(criteria);
1146:                int offset2 = numColumns + 1;
1147:
1148:                AttributeOptionPeer.addSelectColumns(criteria);
1149:                criteria.addJoin(RModuleOptionPeer.OPTION_ID,
1150:                        AttributeOptionPeer.OPTION_ID);
1151:                int offset3 = offset2 + AttributeOptionPeer.numColumns;
1152:
1153:                IssueTypePeer.addSelectColumns(criteria);
1154:                criteria.addJoin(RModuleOptionPeer.ISSUE_TYPE_ID,
1155:                        IssueTypePeer.ISSUE_TYPE_ID);
1156:
1157:                correctBooleans(criteria);
1158:
1159:                List rows;
1160:                if (conn == null) {
1161:                    rows = BasePeer.doSelect(criteria);
1162:                } else {
1163:                    rows = BasePeer.doSelect(criteria, conn);
1164:                }
1165:
1166:                List results = new ArrayList();
1167:
1168:                for (int i = 0; i < rows.size(); i++) {
1169:                    Record row = (Record) rows.get(i);
1170:
1171:                    Class omClass = RModuleOptionPeer.getOMClass();
1172:                    RModuleOption obj1 = (RModuleOption) RModuleOptionPeer
1173:                            .row2Object(row, 1, omClass);
1174:
1175:                    omClass = AttributeOptionPeer.getOMClass();
1176:                    AttributeOption obj2 = (AttributeOption) AttributeOptionPeer
1177:                            .row2Object(row, offset2, omClass);
1178:
1179:                    boolean newObject = true;
1180:                    for (int j = 0; j < results.size(); j++) {
1181:                        RModuleOption temp_obj1 = (RModuleOption) results
1182:                                .get(j);
1183:                        AttributeOption temp_obj2 = (AttributeOption) temp_obj1
1184:                                .getAttributeOption();
1185:                        if (temp_obj2.getPrimaryKey().equals(
1186:                                obj2.getPrimaryKey())) {
1187:                            newObject = false;
1188:                            temp_obj2.addRModuleOption(obj1);
1189:                            break;
1190:                        }
1191:                    }
1192:                    if (newObject) {
1193:                        obj2.initRModuleOptions();
1194:                        obj2.addRModuleOption(obj1);
1195:                    }
1196:
1197:                    omClass = IssueTypePeer.getOMClass();
1198:                    IssueType obj3 = (IssueType) IssueTypePeer.row2Object(row,
1199:                            offset3, omClass);
1200:
1201:                    newObject = true;
1202:                    for (int j = 0; j < results.size(); j++) {
1203:                        RModuleOption temp_obj1 = (RModuleOption) results
1204:                                .get(j);
1205:                        IssueType temp_obj3 = (IssueType) temp_obj1
1206:                                .getIssueType();
1207:                        if (temp_obj3.getPrimaryKey().equals(
1208:                                obj3.getPrimaryKey())) {
1209:                            newObject = false;
1210:                            temp_obj3.addRModuleOption(obj1);
1211:                            break;
1212:                        }
1213:                    }
1214:                    if (newObject) {
1215:                        obj3.initRModuleOptions();
1216:                        obj3.addRModuleOption(obj1);
1217:                    }
1218:                    results.add(obj1);
1219:                }
1220:                return results;
1221:            }
1222:
1223:            /**
1224:             * selects a collection of RModuleOption objects pre-filled with
1225:             * all related objects.
1226:             *
1227:             * This method is protected by default in order to keep the public
1228:             * api reasonable.  You can provide public methods for those you
1229:             * actually need in RModuleOptionPeer.
1230:             *
1231:             * @throws TorqueException Any exceptions caught during processing will be
1232:             *         rethrown wrapped into a TorqueException.
1233:             */
1234:            protected static List doSelectJoinAllExceptIssueType(
1235:                    Criteria criteria) throws TorqueException {
1236:                return doSelectJoinAllExceptIssueType(criteria, null);
1237:            }
1238:
1239:            /**
1240:             * selects a collection of RModuleOption objects pre-filled with
1241:             * all related objects.
1242:             *
1243:             * This method is protected by default in order to keep the public
1244:             * api reasonable.  You can provide public methods for those you
1245:             * actually need in RModuleOptionPeer.
1246:             *
1247:             * @throws TorqueException Any exceptions caught during processing will be
1248:             *         rethrown wrapped into a TorqueException.
1249:             */
1250:            protected static List doSelectJoinAllExceptIssueType(
1251:                    Criteria criteria, Connection conn) throws TorqueException {
1252:                setDbName(criteria);
1253:
1254:                addSelectColumns(criteria);
1255:                int offset2 = numColumns + 1;
1256:
1257:                AttributeOptionPeer.addSelectColumns(criteria);
1258:                criteria.addJoin(RModuleOptionPeer.OPTION_ID,
1259:                        AttributeOptionPeer.OPTION_ID);
1260:                int offset3 = offset2 + AttributeOptionPeer.numColumns;
1261:
1262:                ScarabModulePeer.addSelectColumns(criteria);
1263:                criteria.addJoin(RModuleOptionPeer.MODULE_ID,
1264:                        ScarabModulePeer.MODULE_ID);
1265:
1266:                correctBooleans(criteria);
1267:
1268:                List rows;
1269:                if (conn == null) {
1270:                    rows = BasePeer.doSelect(criteria);
1271:                } else {
1272:                    rows = BasePeer.doSelect(criteria, conn);
1273:                }
1274:
1275:                List results = new ArrayList();
1276:
1277:                for (int i = 0; i < rows.size(); i++) {
1278:                    Record row = (Record) rows.get(i);
1279:
1280:                    Class omClass = RModuleOptionPeer.getOMClass();
1281:                    RModuleOption obj1 = (RModuleOption) RModuleOptionPeer
1282:                            .row2Object(row, 1, omClass);
1283:
1284:                    omClass = AttributeOptionPeer.getOMClass();
1285:                    AttributeOption obj2 = (AttributeOption) AttributeOptionPeer
1286:                            .row2Object(row, offset2, omClass);
1287:
1288:                    boolean newObject = true;
1289:                    for (int j = 0; j < results.size(); j++) {
1290:                        RModuleOption temp_obj1 = (RModuleOption) results
1291:                                .get(j);
1292:                        AttributeOption temp_obj2 = (AttributeOption) temp_obj1
1293:                                .getAttributeOption();
1294:                        if (temp_obj2.getPrimaryKey().equals(
1295:                                obj2.getPrimaryKey())) {
1296:                            newObject = false;
1297:                            temp_obj2.addRModuleOption(obj1);
1298:                            break;
1299:                        }
1300:                    }
1301:                    if (newObject) {
1302:                        obj2.initRModuleOptions();
1303:                        obj2.addRModuleOption(obj1);
1304:                    }
1305:
1306:                    omClass = ScarabModulePeer.getOMClass(row, offset3);
1307:                    ScarabModule obj3 = (ScarabModule) ScarabModulePeer
1308:                            .row2Object(row, offset3, omClass);
1309:
1310:                    newObject = true;
1311:                    for (int j = 0; j < results.size(); j++) {
1312:                        RModuleOption temp_obj1 = (RModuleOption) results
1313:                                .get(j);
1314:                        ScarabModule temp_obj3 = (ScarabModule) temp_obj1
1315:                                .getModule();
1316:                        if (temp_obj3.getPrimaryKey().equals(
1317:                                obj3.getPrimaryKey())) {
1318:                            newObject = false;
1319:                            temp_obj3.addRModuleOption(obj1);
1320:                            break;
1321:                        }
1322:                    }
1323:                    if (newObject) {
1324:                        obj3.initRModuleOptions();
1325:                        obj3.addRModuleOption(obj1);
1326:                    }
1327:
1328:                    results.add(obj1);
1329:                }
1330:                return results;
1331:            }
1332:
1333:            /**
1334:             * Returns the TableMap related to this peer.  This method is not
1335:             * needed for general use but a specific application could have a need.
1336:             *
1337:             * @throws TorqueException Any exceptions caught during processing will be
1338:             *         rethrown wrapped into a TorqueException.
1339:             */
1340:            protected static TableMap getTableMap() throws TorqueException {
1341:                return Torque.getDatabaseMap(DATABASE_NAME)
1342:                        .getTable(TABLE_NAME);
1343:            }
1344:
1345:            private static void setDbName(Criteria crit) {
1346:                // Set the correct dbName if it has not been overridden
1347:                // crit.getDbName will return the same object if not set to
1348:                // another value so == check is okay and faster
1349:                if (crit.getDbName() == Torque.getDefaultDB()) {
1350:                    crit.setDbName(DATABASE_NAME);
1351:                }
1352:            }
1353:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.