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