0001: package org.tigris.scarab.om;
0002:
0003: import java.math.BigDecimal;
0004: import java.sql.Connection;
0005: import java.util.ArrayList;
0006: import java.util.Collections;
0007: import java.util.Date;
0008: import java.util.List;
0009:
0010: import org.apache.commons.lang.ObjectUtils;
0011: import org.apache.fulcrum.intake.Retrievable;
0012: import org.apache.torque.TorqueException;
0013: import org.apache.torque.om.BaseObject;
0014: import org.apache.torque.om.ComboKey;
0015: import org.apache.torque.om.DateKey;
0016: import org.apache.torque.om.NumberKey;
0017: import org.apache.torque.om.ObjectKey;
0018: import org.apache.torque.om.SimpleKey;
0019: import org.apache.torque.om.StringKey;
0020: import org.apache.torque.om.Persistent;
0021: import org.apache.torque.util.Criteria;
0022: import org.apache.torque.util.Transaction;
0023:
0024: /**
0025: * You should not use this class directly. It should not even be
0026: * extended all references should be to RModuleIssueType
0027: */
0028: public abstract class BaseRModuleIssueType extends BaseObject implements
0029: org.apache.fulcrum.intake.Retrievable {
0030: /** The Peer class */
0031: private static final RModuleIssueTypePeer peer = new RModuleIssueTypePeer();
0032:
0033: /** The value for the moduleId field */
0034: private Integer moduleId;
0035:
0036: /** The value for the issueTypeId field */
0037: private Integer issueTypeId;
0038:
0039: /** The value for the active field */
0040: private boolean active = true;
0041:
0042: /** The value for the display field */
0043: private boolean display = true;
0044:
0045: /** The value for the order field */
0046: private int order = 0;
0047:
0048: /** The value for the dedupe field */
0049: private boolean dedupe = true;
0050:
0051: /** The value for the history field */
0052: private int history = 5;
0053:
0054: /** The value for the comments field */
0055: private int comments = 5;
0056:
0057: /** The value for the displayName field */
0058: private String displayName;
0059:
0060: /** The value for the displayDescription field */
0061: private String displayDescription;
0062:
0063: /**
0064: * Get the ModuleId
0065: *
0066: * @return Integer
0067: */
0068: public Integer getModuleId() {
0069: return moduleId;
0070: }
0071:
0072: /**
0073: * Set the value of ModuleId
0074: *
0075: * @param v new value
0076: */
0077: public void setModuleId(Integer v) throws TorqueException {
0078:
0079: if (!ObjectUtils.equals(this .moduleId, v)) {
0080: this .moduleId = v;
0081: setModified(true);
0082: }
0083:
0084: if (aModule != null
0085: && !ObjectUtils.equals(aModule.getModuleId(), v)) {
0086: aModule = null;
0087: }
0088:
0089: // update associated Condition
0090: if (collConditions != null) {
0091: for (int i = 0; i < collConditions.size(); i++) {
0092: ((Condition) collConditions.get(i)).setModuleId(v);
0093: }
0094: }
0095: }
0096:
0097: /**
0098: * Get the IssueTypeId
0099: *
0100: * @return Integer
0101: */
0102: public Integer getIssueTypeId() {
0103: return issueTypeId;
0104: }
0105:
0106: /**
0107: * Set the value of IssueTypeId
0108: *
0109: * @param v new value
0110: */
0111: public void setIssueTypeId(Integer v) throws TorqueException {
0112:
0113: if (!ObjectUtils.equals(this .issueTypeId, v)) {
0114: this .issueTypeId = v;
0115: setModified(true);
0116: }
0117:
0118: if (aIssueType != null
0119: && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v)) {
0120: aIssueType = null;
0121: }
0122:
0123: // update associated Condition
0124: if (collConditions != null) {
0125: for (int i = 0; i < collConditions.size(); i++) {
0126: ((Condition) collConditions.get(i)).setIssueTypeId(v);
0127: }
0128: }
0129: }
0130:
0131: /**
0132: * Get the Active
0133: *
0134: * @return boolean
0135: */
0136: public boolean getActive() {
0137: return active;
0138: }
0139:
0140: /**
0141: * Set the value of Active
0142: *
0143: * @param v new value
0144: */
0145: public void setActive(boolean v) {
0146:
0147: if (this .active != v) {
0148: this .active = v;
0149: setModified(true);
0150: }
0151:
0152: }
0153:
0154: /**
0155: * Get the Display
0156: *
0157: * @return boolean
0158: */
0159: public boolean getDisplay() {
0160: return display;
0161: }
0162:
0163: /**
0164: * Set the value of Display
0165: *
0166: * @param v new value
0167: */
0168: public void setDisplay(boolean v) {
0169:
0170: if (this .display != v) {
0171: this .display = v;
0172: setModified(true);
0173: }
0174:
0175: }
0176:
0177: /**
0178: * Get the Order
0179: *
0180: * @return int
0181: */
0182: public int getOrder() {
0183: return order;
0184: }
0185:
0186: /**
0187: * Set the value of Order
0188: *
0189: * @param v new value
0190: */
0191: public void setOrder(int v) {
0192:
0193: if (this .order != v) {
0194: this .order = v;
0195: setModified(true);
0196: }
0197:
0198: }
0199:
0200: /**
0201: * Get the Dedupe
0202: *
0203: * @return boolean
0204: */
0205: public boolean getDedupe() {
0206: return dedupe;
0207: }
0208:
0209: /**
0210: * Set the value of Dedupe
0211: *
0212: * @param v new value
0213: */
0214: public void setDedupe(boolean v) {
0215:
0216: if (this .dedupe != v) {
0217: this .dedupe = v;
0218: setModified(true);
0219: }
0220:
0221: }
0222:
0223: /**
0224: * Get the History
0225: *
0226: * @return int
0227: */
0228: public int getHistory() {
0229: return history;
0230: }
0231:
0232: /**
0233: * Set the value of History
0234: *
0235: * @param v new value
0236: */
0237: public void setHistory(int v) {
0238:
0239: if (this .history != v) {
0240: this .history = v;
0241: setModified(true);
0242: }
0243:
0244: }
0245:
0246: /**
0247: * Get the Comments
0248: *
0249: * @return int
0250: */
0251: public int getComments() {
0252: return comments;
0253: }
0254:
0255: /**
0256: * Set the value of Comments
0257: *
0258: * @param v new value
0259: */
0260: public void setComments(int v) {
0261:
0262: if (this .comments != v) {
0263: this .comments = v;
0264: setModified(true);
0265: }
0266:
0267: }
0268:
0269: /**
0270: * Get the DisplayName
0271: *
0272: * @return String
0273: */
0274: public String getDisplayName() {
0275: return displayName;
0276: }
0277:
0278: /**
0279: * Set the value of DisplayName
0280: *
0281: * @param v new value
0282: */
0283: public void setDisplayName(String v) {
0284:
0285: if (!ObjectUtils.equals(this .displayName, v)) {
0286: this .displayName = v;
0287: setModified(true);
0288: }
0289:
0290: }
0291:
0292: /**
0293: * Get the DisplayDescription
0294: *
0295: * @return String
0296: */
0297: public String getDisplayDescription() {
0298: return displayDescription;
0299: }
0300:
0301: /**
0302: * Set the value of DisplayDescription
0303: *
0304: * @param v new value
0305: */
0306: public void setDisplayDescription(String v) {
0307:
0308: if (!ObjectUtils.equals(this .displayDescription, v)) {
0309: this .displayDescription = v;
0310: setModified(true);
0311: }
0312:
0313: }
0314:
0315: private Module aModule;
0316:
0317: /**
0318: * Declares an association between this object and a Module object
0319: *
0320: * @param v Module
0321: * @throws TorqueException
0322: */
0323: public void setModule(Module v) throws TorqueException {
0324: if (v == null) {
0325: setModuleId((Integer) null);
0326: } else {
0327: setModuleId(v.getModuleId());
0328: }
0329: aModule = v;
0330: }
0331:
0332: /**
0333: * Returns the associated Module object.
0334: * If it was not retrieved before, the object is retrieved from
0335: * the database
0336: *
0337: * @return the associated Module object
0338: * @throws TorqueException
0339: */
0340: public Module getModule() throws TorqueException {
0341: if (aModule == null
0342: && (!ObjectUtils.equals(this .moduleId, null))) {
0343: aModule = ModuleManager.getInstance(SimpleKey
0344: .keyFor(this .moduleId));
0345: }
0346: return aModule;
0347: }
0348:
0349: /**
0350: * Return the associated Module object
0351: * If it was not retrieved before, the object is retrieved from
0352: * the database using the passed connection
0353: *
0354: * @param connection the connection used to retrieve the associated object
0355: * from the database, if it was not retrieved before
0356: * @return the associated Module object
0357: * @throws TorqueException
0358: */
0359: public Module getModule(Connection connection)
0360: throws TorqueException {
0361: if (aModule == null
0362: && (!ObjectUtils.equals(this .moduleId, null))) {
0363: aModule = ModuleManager.getCachedInstance(SimpleKey
0364: .keyFor(this .moduleId));
0365: if (aModule == null) {
0366: aModule = ScarabModulePeer.retrieveByPK(SimpleKey
0367: .keyFor(this .moduleId), connection);
0368: ModuleManager.putInstance(aModule);
0369: }
0370: }
0371: return aModule;
0372: }
0373:
0374: /**
0375: * Provides convenient way to set a relationship based on a
0376: * ObjectKey, for example
0377: * <code>bar.setFooKey(foo.getPrimaryKey())</code>
0378: *
0379: */
0380: public void setModuleKey(ObjectKey key) throws TorqueException {
0381:
0382: setModuleId(new Integer(((NumberKey) key).intValue()));
0383: }
0384:
0385: private IssueType aIssueType;
0386:
0387: /**
0388: * Declares an association between this object and a IssueType object
0389: *
0390: * @param v IssueType
0391: * @throws TorqueException
0392: */
0393: public void setIssueType(IssueType v) throws TorqueException {
0394: if (v == null) {
0395: setIssueTypeId((Integer) null);
0396: } else {
0397: setIssueTypeId(v.getIssueTypeId());
0398: }
0399: aIssueType = v;
0400: }
0401:
0402: /**
0403: * Returns the associated IssueType object.
0404: * If it was not retrieved before, the object is retrieved from
0405: * the database
0406: *
0407: * @return the associated IssueType object
0408: * @throws TorqueException
0409: */
0410: public IssueType getIssueType() throws TorqueException {
0411: if (aIssueType == null
0412: && (!ObjectUtils.equals(this .issueTypeId, null))) {
0413: aIssueType = IssueTypeManager.getInstance(SimpleKey
0414: .keyFor(this .issueTypeId));
0415: }
0416: return aIssueType;
0417: }
0418:
0419: /**
0420: * Return the associated IssueType object
0421: * If it was not retrieved before, the object is retrieved from
0422: * the database using the passed connection
0423: *
0424: * @param connection the connection used to retrieve the associated object
0425: * from the database, if it was not retrieved before
0426: * @return the associated IssueType object
0427: * @throws TorqueException
0428: */
0429: public IssueType getIssueType(Connection connection)
0430: throws TorqueException {
0431: if (aIssueType == null
0432: && (!ObjectUtils.equals(this .issueTypeId, null))) {
0433: aIssueType = IssueTypeManager.getCachedInstance(SimpleKey
0434: .keyFor(this .issueTypeId));
0435: if (aIssueType == null) {
0436: aIssueType = IssueTypePeer.retrieveByPK(SimpleKey
0437: .keyFor(this .issueTypeId), connection);
0438: IssueTypeManager.putInstance(aIssueType);
0439: }
0440: }
0441: return aIssueType;
0442: }
0443:
0444: /**
0445: * Provides convenient way to set a relationship based on a
0446: * ObjectKey, for example
0447: * <code>bar.setFooKey(foo.getPrimaryKey())</code>
0448: *
0449: */
0450: public void setIssueTypeKey(ObjectKey key) throws TorqueException {
0451:
0452: setIssueTypeId(new Integer(((NumberKey) key).intValue()));
0453: }
0454:
0455: /**
0456: * Collection to store aggregation of collConditions
0457: */
0458: protected List collConditions;
0459:
0460: /**
0461: * Temporary storage of collConditions to save a possible db hit in
0462: * the event objects are add to the collection, but the
0463: * complete collection is never requested.
0464: */
0465: protected void initConditions() {
0466: if (collConditions == null) {
0467: collConditions = new ArrayList();
0468: }
0469: }
0470:
0471: /**
0472: * Method called to associate a Condition object to this object
0473: * through the Condition foreign key attribute
0474: *
0475: * @param l Condition
0476: * @throws TorqueException
0477: */
0478: public void addCondition(Condition l) throws TorqueException {
0479: getConditions().add(l);
0480: l.setRModuleIssueType((RModuleIssueType) this );
0481: }
0482:
0483: /**
0484: * The criteria used to select the current contents of collConditions
0485: */
0486: private Criteria lastConditionsCriteria = null;
0487:
0488: /**
0489: * If this collection has already been initialized, returns
0490: * the collection. Otherwise returns the results of
0491: * getConditions(new Criteria())
0492: *
0493: * @return the collection of associated objects
0494: * @throws TorqueException
0495: */
0496: public List getConditions() throws TorqueException {
0497: if (collConditions == null) {
0498: collConditions = getConditions(new Criteria(10));
0499: }
0500: return collConditions;
0501: }
0502:
0503: /**
0504: * If this collection has already been initialized with
0505: * an identical criteria, it returns the collection.
0506: * Otherwise if this RModuleIssueType has previously
0507: * been saved, it will retrieve related Conditions from storage.
0508: * If this RModuleIssueType is new, it will return
0509: * an empty collection or the current collection, the criteria
0510: * is ignored on a new object.
0511: *
0512: * @throws TorqueException
0513: */
0514: public List getConditions(Criteria criteria) throws TorqueException {
0515: if (collConditions == null) {
0516: if (isNew()) {
0517: collConditions = new ArrayList();
0518: } else {
0519: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0520: criteria.add(ConditionPeer.ISSUE_TYPE_ID,
0521: getIssueTypeId());
0522: collConditions = ConditionPeer.doSelect(criteria);
0523: }
0524: } else {
0525: // criteria has no effect for a new object
0526: if (!isNew()) {
0527: // the following code is to determine if a new query is
0528: // called for. If the criteria is the same as the last
0529: // one, just return the collection.
0530: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0531: criteria.add(ConditionPeer.ISSUE_TYPE_ID,
0532: getIssueTypeId());
0533: if (!lastConditionsCriteria.equals(criteria)) {
0534: collConditions = ConditionPeer.doSelect(criteria);
0535: }
0536: }
0537: }
0538: lastConditionsCriteria = criteria;
0539:
0540: return collConditions;
0541: }
0542:
0543: /**
0544: * If this collection has already been initialized, returns
0545: * the collection. Otherwise returns the results of
0546: * getConditions(new Criteria(),Connection)
0547: * This method takes in the Connection also as input so that
0548: * referenced objects can also be obtained using a Connection
0549: * that is taken as input
0550: */
0551: public List getConditions(Connection con) throws TorqueException {
0552: if (collConditions == null) {
0553: collConditions = getConditions(new Criteria(10), con);
0554: }
0555: return collConditions;
0556: }
0557:
0558: /**
0559: * If this collection has already been initialized with
0560: * an identical criteria, it returns the collection.
0561: * Otherwise if this RModuleIssueType has previously
0562: * been saved, it will retrieve related Conditions from storage.
0563: * If this RModuleIssueType is new, it will return
0564: * an empty collection or the current collection, the criteria
0565: * is ignored on a new object.
0566: * This method takes in the Connection also as input so that
0567: * referenced objects can also be obtained using a Connection
0568: * that is taken as input
0569: */
0570: public List getConditions(Criteria criteria, Connection con)
0571: throws TorqueException {
0572: if (collConditions == null) {
0573: if (isNew()) {
0574: collConditions = new ArrayList();
0575: } else {
0576: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0577: criteria.add(ConditionPeer.ISSUE_TYPE_ID,
0578: getIssueTypeId());
0579: collConditions = ConditionPeer.doSelect(criteria, con);
0580: }
0581: } else {
0582: // criteria has no effect for a new object
0583: if (!isNew()) {
0584: // the following code is to determine if a new query is
0585: // called for. If the criteria is the same as the last
0586: // one, just return the collection.
0587: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0588: criteria.add(ConditionPeer.ISSUE_TYPE_ID,
0589: getIssueTypeId());
0590: if (!lastConditionsCriteria.equals(criteria)) {
0591: collConditions = ConditionPeer.doSelect(criteria,
0592: con);
0593: }
0594: }
0595: }
0596: lastConditionsCriteria = criteria;
0597:
0598: return collConditions;
0599: }
0600:
0601: /**
0602: * If this collection has already been initialized with
0603: * an identical criteria, it returns the collection.
0604: * Otherwise if this RModuleIssueType is new, it will return
0605: * an empty collection; or if this RModuleIssueType has previously
0606: * been saved, it will retrieve related Conditions from storage.
0607: *
0608: * This method is protected by default in order to keep the public
0609: * api reasonable. You can provide public methods for those you
0610: * actually need in RModuleIssueType.
0611: */
0612: protected List getConditionsJoinRModuleAttribute(Criteria criteria)
0613: throws TorqueException {
0614: if (collConditions == null) {
0615: if (isNew()) {
0616: collConditions = new ArrayList();
0617: } else {
0618: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0619: criteria.add(ConditionPeer.ISSUE_TYPE_ID,
0620: getIssueTypeId());
0621: collConditions = ConditionPeer
0622: .doSelectJoinRModuleAttribute(criteria);
0623: }
0624: } else {
0625: // the following code is to determine if a new query is
0626: // called for. If the criteria is the same as the last
0627: // one, just return the collection.
0628: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0629: criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId());
0630: if (!lastConditionsCriteria.equals(criteria)) {
0631: collConditions = ConditionPeer
0632: .doSelectJoinRModuleAttribute(criteria);
0633: }
0634: }
0635: lastConditionsCriteria = criteria;
0636:
0637: return collConditions;
0638: }
0639:
0640: /**
0641: * If this collection has already been initialized with
0642: * an identical criteria, it returns the collection.
0643: * Otherwise if this RModuleIssueType is new, it will return
0644: * an empty collection; or if this RModuleIssueType has previously
0645: * been saved, it will retrieve related Conditions from storage.
0646: *
0647: * This method is protected by default in order to keep the public
0648: * api reasonable. You can provide public methods for those you
0649: * actually need in RModuleIssueType.
0650: */
0651: protected List getConditionsJoinTransition(Criteria criteria)
0652: throws TorqueException {
0653: if (collConditions == null) {
0654: if (isNew()) {
0655: collConditions = new ArrayList();
0656: } else {
0657: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0658: criteria.add(ConditionPeer.ISSUE_TYPE_ID,
0659: getIssueTypeId());
0660: collConditions = ConditionPeer
0661: .doSelectJoinTransition(criteria);
0662: }
0663: } else {
0664: // the following code is to determine if a new query is
0665: // called for. If the criteria is the same as the last
0666: // one, just return the collection.
0667: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0668: criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId());
0669: if (!lastConditionsCriteria.equals(criteria)) {
0670: collConditions = ConditionPeer
0671: .doSelectJoinTransition(criteria);
0672: }
0673: }
0674: lastConditionsCriteria = criteria;
0675:
0676: return collConditions;
0677: }
0678:
0679: /**
0680: * If this collection has already been initialized with
0681: * an identical criteria, it returns the collection.
0682: * Otherwise if this RModuleIssueType is new, it will return
0683: * an empty collection; or if this RModuleIssueType has previously
0684: * been saved, it will retrieve related Conditions from storage.
0685: *
0686: * This method is protected by default in order to keep the public
0687: * api reasonable. You can provide public methods for those you
0688: * actually need in RModuleIssueType.
0689: */
0690: protected List getConditionsJoinAttribute(Criteria criteria)
0691: throws TorqueException {
0692: if (collConditions == null) {
0693: if (isNew()) {
0694: collConditions = new ArrayList();
0695: } else {
0696: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0697: criteria.add(ConditionPeer.ISSUE_TYPE_ID,
0698: getIssueTypeId());
0699: collConditions = ConditionPeer
0700: .doSelectJoinAttribute(criteria);
0701: }
0702: } else {
0703: // the following code is to determine if a new query is
0704: // called for. If the criteria is the same as the last
0705: // one, just return the collection.
0706: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0707: criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId());
0708: if (!lastConditionsCriteria.equals(criteria)) {
0709: collConditions = ConditionPeer
0710: .doSelectJoinAttribute(criteria);
0711: }
0712: }
0713: lastConditionsCriteria = criteria;
0714:
0715: return collConditions;
0716: }
0717:
0718: /**
0719: * If this collection has already been initialized with
0720: * an identical criteria, it returns the collection.
0721: * Otherwise if this RModuleIssueType is new, it will return
0722: * an empty collection; or if this RModuleIssueType has previously
0723: * been saved, it will retrieve related Conditions from storage.
0724: *
0725: * This method is protected by default in order to keep the public
0726: * api reasonable. You can provide public methods for those you
0727: * actually need in RModuleIssueType.
0728: */
0729: protected List getConditionsJoinAttributeOption(Criteria criteria)
0730: throws TorqueException {
0731: if (collConditions == null) {
0732: if (isNew()) {
0733: collConditions = new ArrayList();
0734: } else {
0735: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0736: criteria.add(ConditionPeer.ISSUE_TYPE_ID,
0737: getIssueTypeId());
0738: collConditions = ConditionPeer
0739: .doSelectJoinAttributeOption(criteria);
0740: }
0741: } else {
0742: // the following code is to determine if a new query is
0743: // called for. If the criteria is the same as the last
0744: // one, just return the collection.
0745: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0746: criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId());
0747: if (!lastConditionsCriteria.equals(criteria)) {
0748: collConditions = ConditionPeer
0749: .doSelectJoinAttributeOption(criteria);
0750: }
0751: }
0752: lastConditionsCriteria = criteria;
0753:
0754: return collConditions;
0755: }
0756:
0757: /**
0758: * If this collection has already been initialized with
0759: * an identical criteria, it returns the collection.
0760: * Otherwise if this RModuleIssueType is new, it will return
0761: * an empty collection; or if this RModuleIssueType has previously
0762: * been saved, it will retrieve related Conditions from storage.
0763: *
0764: * This method is protected by default in order to keep the public
0765: * api reasonable. You can provide public methods for those you
0766: * actually need in RModuleIssueType.
0767: */
0768: protected List getConditionsJoinRModuleIssueType(Criteria criteria)
0769: throws TorqueException {
0770: if (collConditions == null) {
0771: if (isNew()) {
0772: collConditions = new ArrayList();
0773: } else {
0774: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0775: criteria.add(ConditionPeer.ISSUE_TYPE_ID,
0776: getIssueTypeId());
0777: collConditions = ConditionPeer
0778: .doSelectJoinRModuleIssueType(criteria);
0779: }
0780: } else {
0781: // the following code is to determine if a new query is
0782: // called for. If the criteria is the same as the last
0783: // one, just return the collection.
0784: criteria.add(ConditionPeer.MODULE_ID, getModuleId());
0785: criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId());
0786: if (!lastConditionsCriteria.equals(criteria)) {
0787: collConditions = ConditionPeer
0788: .doSelectJoinRModuleIssueType(criteria);
0789: }
0790: }
0791: lastConditionsCriteria = criteria;
0792:
0793: return collConditions;
0794: }
0795:
0796: private static List fieldNames = null;
0797:
0798: /**
0799: * Generate a list of field names.
0800: *
0801: * @return a list of field names
0802: */
0803: public static synchronized List getFieldNames() {
0804: if (fieldNames == null) {
0805: fieldNames = new ArrayList();
0806: fieldNames.add("ModuleId");
0807: fieldNames.add("IssueTypeId");
0808: fieldNames.add("Active");
0809: fieldNames.add("Display");
0810: fieldNames.add("Order");
0811: fieldNames.add("Dedupe");
0812: fieldNames.add("History");
0813: fieldNames.add("Comments");
0814: fieldNames.add("DisplayName");
0815: fieldNames.add("DisplayDescription");
0816: fieldNames = Collections.unmodifiableList(fieldNames);
0817: }
0818: return fieldNames;
0819: }
0820:
0821: /**
0822: * Retrieves a field from the object by name passed in as a String.
0823: *
0824: * @param name field name
0825: * @return value
0826: */
0827: public Object getByName(String name) {
0828: if (name.equals("ModuleId")) {
0829: return getModuleId();
0830: }
0831: if (name.equals("IssueTypeId")) {
0832: return getIssueTypeId();
0833: }
0834: if (name.equals("Active")) {
0835: return Boolean.valueOf(getActive());
0836: }
0837: if (name.equals("Display")) {
0838: return Boolean.valueOf(getDisplay());
0839: }
0840: if (name.equals("Order")) {
0841: return new Integer(getOrder());
0842: }
0843: if (name.equals("Dedupe")) {
0844: return Boolean.valueOf(getDedupe());
0845: }
0846: if (name.equals("History")) {
0847: return new Integer(getHistory());
0848: }
0849: if (name.equals("Comments")) {
0850: return new Integer(getComments());
0851: }
0852: if (name.equals("DisplayName")) {
0853: return getDisplayName();
0854: }
0855: if (name.equals("DisplayDescription")) {
0856: return getDisplayDescription();
0857: }
0858: return null;
0859: }
0860:
0861: /**
0862: * Retrieves a field from the object by name passed in
0863: * as a String. The String must be one of the static
0864: * Strings defined in this Class' Peer.
0865: *
0866: * @param name peer name
0867: * @return value
0868: */
0869: public Object getByPeerName(String name) {
0870: if (name.equals(RModuleIssueTypePeer.MODULE_ID)) {
0871: return getModuleId();
0872: }
0873: if (name.equals(RModuleIssueTypePeer.ISSUE_TYPE_ID)) {
0874: return getIssueTypeId();
0875: }
0876: if (name.equals(RModuleIssueTypePeer.ACTIVE)) {
0877: return Boolean.valueOf(getActive());
0878: }
0879: if (name.equals(RModuleIssueTypePeer.DISPLAY)) {
0880: return Boolean.valueOf(getDisplay());
0881: }
0882: if (name.equals(RModuleIssueTypePeer.PREFERRED_ORDER)) {
0883: return new Integer(getOrder());
0884: }
0885: if (name.equals(RModuleIssueTypePeer.DEDUPE)) {
0886: return Boolean.valueOf(getDedupe());
0887: }
0888: if (name.equals(RModuleIssueTypePeer.HISTORY)) {
0889: return new Integer(getHistory());
0890: }
0891: if (name.equals(RModuleIssueTypePeer.COMMENTS)) {
0892: return new Integer(getComments());
0893: }
0894: if (name.equals(RModuleIssueTypePeer.DISPLAY_NAME)) {
0895: return getDisplayName();
0896: }
0897: if (name.equals(RModuleIssueTypePeer.DISPLAY_DESCRIPTION)) {
0898: return getDisplayDescription();
0899: }
0900: return null;
0901: }
0902:
0903: /**
0904: * Retrieves a field from the object by Position as specified
0905: * in the xml schema. Zero-based.
0906: *
0907: * @param pos position in xml schema
0908: * @return value
0909: */
0910: public Object getByPosition(int pos) {
0911: if (pos == 0) {
0912: return getModuleId();
0913: }
0914: if (pos == 1) {
0915: return getIssueTypeId();
0916: }
0917: if (pos == 2) {
0918: return Boolean.valueOf(getActive());
0919: }
0920: if (pos == 3) {
0921: return Boolean.valueOf(getDisplay());
0922: }
0923: if (pos == 4) {
0924: return new Integer(getOrder());
0925: }
0926: if (pos == 5) {
0927: return Boolean.valueOf(getDedupe());
0928: }
0929: if (pos == 6) {
0930: return new Integer(getHistory());
0931: }
0932: if (pos == 7) {
0933: return new Integer(getComments());
0934: }
0935: if (pos == 8) {
0936: return getDisplayName();
0937: }
0938: if (pos == 9) {
0939: return getDisplayDescription();
0940: }
0941: return null;
0942: }
0943:
0944: /**
0945: * Stores the object in the database. If the object is new,
0946: * it inserts it; otherwise an update is performed.
0947: *
0948: * @throws TorqueException
0949: */
0950: public void save() throws TorqueException {
0951: save(RModuleIssueTypePeer.getMapBuilder().getDatabaseMap()
0952: .getName());
0953: }
0954:
0955: /**
0956: * Stores the object in the database. If the object is new,
0957: * it inserts it; otherwise an update is performed.
0958: * Note: this code is here because the method body is
0959: * auto-generated conditionally and therefore needs to be
0960: * in this file instead of in the super class, BaseObject.
0961: *
0962: * @param dbName
0963: * @throws TorqueException
0964: */
0965: public void save(String dbName) throws TorqueException {
0966: Connection con = null;
0967: try {
0968: con = Transaction.begin(dbName);
0969: save(con);
0970: Transaction.commit(con);
0971: } catch (TorqueException e) {
0972: Transaction.safeRollback(con);
0973: throw e;
0974: }
0975: }
0976:
0977: /** flag to prevent endless save loop, if this object is referenced
0978: by another object which falls in this transaction. */
0979: private boolean alreadyInSave = false;
0980:
0981: /**
0982: * Stores the object in the database. If the object is new,
0983: * it inserts it; otherwise an update is performed. This method
0984: * is meant to be used as part of a transaction, otherwise use
0985: * the save() method and the connection details will be handled
0986: * internally
0987: *
0988: * @param con
0989: * @throws TorqueException
0990: */
0991: public void save(Connection con) throws TorqueException {
0992: if (!alreadyInSave) {
0993: alreadyInSave = true;
0994:
0995: // If this object has been modified, then save it to the database.
0996: if (isModified()) {
0997: if (isNew()) {
0998: RModuleIssueTypePeer.doInsert(
0999: (RModuleIssueType) this , con);
1000: setNew(false);
1001: } else {
1002: RModuleIssueTypePeer.doUpdate(
1003: (RModuleIssueType) this , con);
1004: }
1005:
1006: if (isCacheOnSave()) {
1007: RModuleIssueTypeManager.putInstance(this );
1008: }
1009: }
1010:
1011: if (collConditions != null) {
1012: for (int i = 0; i < collConditions.size(); i++) {
1013: ((Condition) collConditions.get(i)).save(con);
1014: }
1015: }
1016: alreadyInSave = false;
1017: }
1018: }
1019:
1020: /**
1021: * Specify whether to cache the object after saving to the db.
1022: * This method returns true
1023: */
1024: protected boolean isCacheOnSave() {
1025: return true;
1026: }
1027:
1028: private final SimpleKey[] pks = new SimpleKey[2];
1029: private final ComboKey comboPK = new ComboKey(pks);
1030:
1031: /**
1032: * Set the PrimaryKey with an ObjectKey
1033: *
1034: * @param key
1035: */
1036: public void setPrimaryKey(ObjectKey key) throws TorqueException {
1037: SimpleKey[] keys = (SimpleKey[]) key.getValue();
1038: SimpleKey tmpKey = null;
1039: setModuleId(new Integer(((NumberKey) keys[0]).intValue()));
1040: setIssueTypeId(new Integer(((NumberKey) keys[1]).intValue()));
1041: }
1042:
1043: /**
1044: * Set the PrimaryKey using SimpleKeys.
1045: *
1046: * @param moduleId Integer
1047: * @param issueTypeId Integer
1048: */
1049: public void setPrimaryKey(Integer moduleId, Integer issueTypeId)
1050: throws TorqueException {
1051: setModuleId(moduleId);
1052: setIssueTypeId(issueTypeId);
1053: }
1054:
1055: /**
1056: * Set the PrimaryKey using a String.
1057: */
1058: public void setPrimaryKey(String key) throws TorqueException {
1059: setPrimaryKey(new ComboKey(key));
1060: }
1061:
1062: /**
1063: * returns an id that differentiates this object from others
1064: * of its class.
1065: */
1066: public ObjectKey getPrimaryKey() {
1067: pks[0] = SimpleKey.keyFor(getModuleId());
1068: pks[1] = SimpleKey.keyFor(getIssueTypeId());
1069: return comboPK;
1070: }
1071:
1072: /**
1073: * get an id that differentiates this object from others
1074: * of its class.
1075: */
1076: public String getQueryKey() {
1077: if (getPrimaryKey() == null) {
1078: return "";
1079: } else {
1080: return getPrimaryKey().toString();
1081: }
1082: }
1083:
1084: /**
1085: * set an id that differentiates this object from others
1086: * of its class.
1087: */
1088: public void setQueryKey(String key) throws TorqueException {
1089: setPrimaryKey(key);
1090: }
1091:
1092: /**
1093: * Makes a copy of this object.
1094: * It creates a new object filling in the simple attributes.
1095: * It then fills all the association collections and sets the
1096: * related objects to isNew=true.
1097: */
1098: public RModuleIssueType copy() throws TorqueException {
1099: return copyInto(new RModuleIssueType());
1100: }
1101:
1102: protected RModuleIssueType copyInto(RModuleIssueType copyObj)
1103: throws TorqueException {
1104: copyObj.setModuleId(moduleId);
1105: copyObj.setIssueTypeId(issueTypeId);
1106: copyObj.setActive(active);
1107: copyObj.setDisplay(display);
1108: copyObj.setOrder(order);
1109: copyObj.setDedupe(dedupe);
1110: copyObj.setHistory(history);
1111: copyObj.setComments(comments);
1112: copyObj.setDisplayName(displayName);
1113: copyObj.setDisplayDescription(displayDescription);
1114:
1115: copyObj.setModuleId((Integer) null);
1116: copyObj.setIssueTypeId((Integer) null);
1117:
1118: List v = getConditions();
1119: if (v != null) {
1120: for (int i = 0; i < v.size(); i++) {
1121: Condition obj = (Condition) v.get(i);
1122: copyObj.addCondition(obj.copy());
1123: }
1124: } else {
1125: copyObj.collConditions = null;
1126: }
1127: return copyObj;
1128: }
1129:
1130: /**
1131: * returns a peer instance associated with this om. Since Peer classes
1132: * are not to have any instance attributes, this method returns the
1133: * same instance for all member of this class. The method could therefore
1134: * be static, but this would prevent one from overriding the behavior.
1135: */
1136: public RModuleIssueTypePeer getPeer() {
1137: return peer;
1138: }
1139:
1140: public String toString() {
1141: StringBuffer str = new StringBuffer();
1142: str.append("RModuleIssueType:\n");
1143: str.append("ModuleId = ").append(getModuleId()).append("\n");
1144: str.append("IssueTypeId = ").append(getIssueTypeId()).append(
1145: "\n");
1146: str.append("Active = ").append(getActive()).append("\n");
1147: str.append("Display = ").append(getDisplay()).append("\n");
1148: str.append("Order = ").append(getOrder()).append("\n");
1149: str.append("Dedupe = ").append(getDedupe()).append("\n");
1150: str.append("History = ").append(getHistory()).append("\n");
1151: str.append("Comments = ").append(getComments()).append("\n");
1152: str.append("DisplayName = ").append(getDisplayName()).append(
1153: "\n");
1154: str.append("DisplayDescription = ").append(
1155: getDisplayDescription()).append("\n");
1156: return (str.toString());
1157: }
1158: }
|