001: package org.tigris.scarab.om;
002:
003: import java.math.BigDecimal;
004: import java.sql.Connection;
005: import java.util.ArrayList;
006: import java.util.Collections;
007: import java.util.Date;
008: import java.util.List;
009:
010: import org.apache.commons.lang.ObjectUtils;
011: import org.apache.fulcrum.intake.Retrievable;
012: import org.apache.torque.TorqueException;
013: import org.apache.torque.om.BaseObject;
014: import org.apache.torque.om.ComboKey;
015: import org.apache.torque.om.DateKey;
016: import org.apache.torque.om.NumberKey;
017: import org.apache.torque.om.ObjectKey;
018: import org.apache.torque.om.SimpleKey;
019: import org.apache.torque.om.StringKey;
020: import org.apache.torque.om.Persistent;
021: import org.apache.torque.util.Criteria;
022: import org.apache.torque.util.Transaction;
023:
024: /**
025: * You should not use this class directly. It should not even be
026: * extended all references should be to ScarabRoleImpl
027: */
028: public abstract class BaseScarabRoleImpl extends
029: org.apache.fulcrum.security.impl.db.entity.TurbineRole
030: implements org.apache.fulcrum.intake.Retrievable {
031: /** The Peer class */
032: private static final ScarabRoleImplPeer peer = new ScarabRoleImplPeer();
033:
034: /**
035: * Collection to store aggregation of collNotificationDefaultFilters
036: */
037: protected List collNotificationDefaultFilters;
038:
039: /**
040: * Temporary storage of collNotificationDefaultFilters to save a possible db hit in
041: * the event objects are add to the collection, but the
042: * complete collection is never requested.
043: */
044: protected void initNotificationDefaultFilters() {
045: if (collNotificationDefaultFilters == null) {
046: collNotificationDefaultFilters = new ArrayList();
047: }
048: }
049:
050: /**
051: * Method called to associate a NotificationDefaultFilter object to this object
052: * through the NotificationDefaultFilter foreign key attribute
053: *
054: * @param l NotificationDefaultFilter
055: * @throws TorqueException
056: */
057: public void addNotificationDefaultFilter(NotificationDefaultFilter l)
058: throws TorqueException {
059: getNotificationDefaultFilters().add(l);
060: l.setScarabRoleImpl((ScarabRoleImpl) this );
061: }
062:
063: /**
064: * The criteria used to select the current contents of collNotificationDefaultFilters
065: */
066: private Criteria lastNotificationDefaultFiltersCriteria = null;
067:
068: /**
069: * If this collection has already been initialized, returns
070: * the collection. Otherwise returns the results of
071: * getNotificationDefaultFilters(new Criteria())
072: *
073: * @return the collection of associated objects
074: * @throws TorqueException
075: */
076: public List getNotificationDefaultFilters() throws TorqueException {
077: if (collNotificationDefaultFilters == null) {
078: collNotificationDefaultFilters = getNotificationDefaultFilters(new Criteria(
079: 10));
080: }
081: return collNotificationDefaultFilters;
082: }
083:
084: /**
085: * If this collection has already been initialized with
086: * an identical criteria, it returns the collection.
087: * Otherwise if this ScarabRoleImpl has previously
088: * been saved, it will retrieve related NotificationDefaultFilters from storage.
089: * If this ScarabRoleImpl is new, it will return
090: * an empty collection or the current collection, the criteria
091: * is ignored on a new object.
092: *
093: * @throws TorqueException
094: */
095: public List getNotificationDefaultFilters(Criteria criteria)
096: throws TorqueException {
097: if (collNotificationDefaultFilters == null) {
098: if (isNew()) {
099: collNotificationDefaultFilters = new ArrayList();
100: } else {
101: criteria.add(NotificationDefaultFilterPeer.ROLE_ID,
102: getRoleId());
103: collNotificationDefaultFilters = NotificationDefaultFilterPeer
104: .doSelect(criteria);
105: }
106: } else {
107: // criteria has no effect for a new object
108: if (!isNew()) {
109: // the following code is to determine if a new query is
110: // called for. If the criteria is the same as the last
111: // one, just return the collection.
112: criteria.add(NotificationDefaultFilterPeer.ROLE_ID,
113: getRoleId());
114: if (!lastNotificationDefaultFiltersCriteria
115: .equals(criteria)) {
116: collNotificationDefaultFilters = NotificationDefaultFilterPeer
117: .doSelect(criteria);
118: }
119: }
120: }
121: lastNotificationDefaultFiltersCriteria = criteria;
122:
123: return collNotificationDefaultFilters;
124: }
125:
126: /**
127: * If this collection has already been initialized, returns
128: * the collection. Otherwise returns the results of
129: * getNotificationDefaultFilters(new Criteria(),Connection)
130: * This method takes in the Connection also as input so that
131: * referenced objects can also be obtained using a Connection
132: * that is taken as input
133: */
134: public List getNotificationDefaultFilters(Connection con)
135: throws TorqueException {
136: if (collNotificationDefaultFilters == null) {
137: collNotificationDefaultFilters = getNotificationDefaultFilters(
138: new Criteria(10), con);
139: }
140: return collNotificationDefaultFilters;
141: }
142:
143: /**
144: * If this collection has already been initialized with
145: * an identical criteria, it returns the collection.
146: * Otherwise if this ScarabRoleImpl has previously
147: * been saved, it will retrieve related NotificationDefaultFilters from storage.
148: * If this ScarabRoleImpl is new, it will return
149: * an empty collection or the current collection, the criteria
150: * is ignored on a new object.
151: * This method takes in the Connection also as input so that
152: * referenced objects can also be obtained using a Connection
153: * that is taken as input
154: */
155: public List getNotificationDefaultFilters(Criteria criteria,
156: Connection con) throws TorqueException {
157: if (collNotificationDefaultFilters == null) {
158: if (isNew()) {
159: collNotificationDefaultFilters = new ArrayList();
160: } else {
161: criteria.add(NotificationDefaultFilterPeer.ROLE_ID,
162: getRoleId());
163: collNotificationDefaultFilters = NotificationDefaultFilterPeer
164: .doSelect(criteria, con);
165: }
166: } else {
167: // criteria has no effect for a new object
168: if (!isNew()) {
169: // the following code is to determine if a new query is
170: // called for. If the criteria is the same as the last
171: // one, just return the collection.
172: criteria.add(NotificationDefaultFilterPeer.ROLE_ID,
173: getRoleId());
174: if (!lastNotificationDefaultFiltersCriteria
175: .equals(criteria)) {
176: collNotificationDefaultFilters = NotificationDefaultFilterPeer
177: .doSelect(criteria, con);
178: }
179: }
180: }
181: lastNotificationDefaultFiltersCriteria = criteria;
182:
183: return collNotificationDefaultFilters;
184: }
185:
186: /**
187: * If this collection has already been initialized with
188: * an identical criteria, it returns the collection.
189: * Otherwise if this ScarabRoleImpl is new, it will return
190: * an empty collection; or if this ScarabRoleImpl has previously
191: * been saved, it will retrieve related NotificationDefaultFilters from storage.
192: *
193: * This method is protected by default in order to keep the public
194: * api reasonable. You can provide public methods for those you
195: * actually need in ScarabRoleImpl.
196: */
197: protected List getNotificationDefaultFiltersJoinScarabRoleImpl(
198: Criteria criteria) throws TorqueException {
199: if (collNotificationDefaultFilters == null) {
200: if (isNew()) {
201: collNotificationDefaultFilters = new ArrayList();
202: } else {
203: criteria.add(NotificationDefaultFilterPeer.ROLE_ID,
204: getRoleId());
205: collNotificationDefaultFilters = NotificationDefaultFilterPeer
206: .doSelectJoinScarabRoleImpl(criteria);
207: }
208: } else {
209: // the following code is to determine if a new query is
210: // called for. If the criteria is the same as the last
211: // one, just return the collection.
212: criteria.add(NotificationDefaultFilterPeer.ROLE_ID,
213: getRoleId());
214: if (!lastNotificationDefaultFiltersCriteria
215: .equals(criteria)) {
216: collNotificationDefaultFilters = NotificationDefaultFilterPeer
217: .doSelectJoinScarabRoleImpl(criteria);
218: }
219: }
220: lastNotificationDefaultFiltersCriteria = criteria;
221:
222: return collNotificationDefaultFilters;
223: }
224:
225: /**
226: * If this collection has already been initialized with
227: * an identical criteria, it returns the collection.
228: * Otherwise if this ScarabRoleImpl is new, it will return
229: * an empty collection; or if this ScarabRoleImpl has previously
230: * been saved, it will retrieve related NotificationDefaultFilters from storage.
231: *
232: * This method is protected by default in order to keep the public
233: * api reasonable. You can provide public methods for those you
234: * actually need in ScarabRoleImpl.
235: */
236: protected List getNotificationDefaultFiltersJoinScarabModule(
237: Criteria criteria) throws TorqueException {
238: if (collNotificationDefaultFilters == null) {
239: if (isNew()) {
240: collNotificationDefaultFilters = new ArrayList();
241: } else {
242: criteria.add(NotificationDefaultFilterPeer.ROLE_ID,
243: getRoleId());
244: collNotificationDefaultFilters = NotificationDefaultFilterPeer
245: .doSelectJoinScarabModule(criteria);
246: }
247: } else {
248: // the following code is to determine if a new query is
249: // called for. If the criteria is the same as the last
250: // one, just return the collection.
251: criteria.add(NotificationDefaultFilterPeer.ROLE_ID,
252: getRoleId());
253: if (!lastNotificationDefaultFiltersCriteria
254: .equals(criteria)) {
255: collNotificationDefaultFilters = NotificationDefaultFilterPeer
256: .doSelectJoinScarabModule(criteria);
257: }
258: }
259: lastNotificationDefaultFiltersCriteria = criteria;
260:
261: return collNotificationDefaultFilters;
262: }
263:
264: /**
265: * get an id that differentiates this object from others
266: * of its class.
267: */
268: public String getQueryKey() {
269: if (getPrimaryKey() == null) {
270: return "";
271: } else {
272: return getPrimaryKey().toString();
273: }
274: }
275:
276: /**
277: * set an id that differentiates this object from others
278: * of its class.
279: */
280: public void setQueryKey(String key) throws TorqueException {
281: try {
282: setPrimaryKey(key);
283: } catch (Exception e) {
284: throw new TorqueException("Unable to set query key", e);
285: }
286: }
287:
288: public String toString() {
289: StringBuffer str = new StringBuffer();
290: str.append("ScarabRoleImpl:\n");
291: str.append("RoleId = ").append(getRoleId()).append("\n");
292: return (str.toString());
293: }
294: }
|