1packageorg.apache.jetspeed.om.dbregistry;
234import java.math.BigDecimal;
5import java.sql.Connection;
6import java.util.ArrayList;
7import java.util.Collections;
8import java.util.Date;
9import java.util.List;
1011import org.apache.commons.lang.ObjectUtils;
12import org.apache.torque.TorqueException;
13import org.apache.torque.om.BaseObject;
14import org.apache.torque.om.ComboKey;
15import org.apache.torque.om.DateKey;
16import org.apache.torque.om.NumberKey;
17import org.apache.torque.om.ObjectKey;
18import org.apache.torque.om.SimpleKey;
19import org.apache.torque.om.StringKey;
20import org.apache.torque.om.Persistent;
21import org.apache.torque.util.Criteria;
22import org.apache.torque.util.Transaction;
23242526/***27 * This class was autogenerated by Torque on:28 *29 * [Thu Apr 22 23:12:36 EDT 2004]30 *31 * You should not use this class directly. It should not even be32 * extended all references should be to PortletCategory33 */34publicabstractclassBasePortletCategoryextends BaseObject
35 {
36/*** The Peer class */37privatestaticfinalPortletCategoryPeer peer =
38newPortletCategoryPeer();
394041/*** The value for the id field */42privatelong id;
4344/*** The value for the name field */45private String name;
4647/*** The value for the group field */48private String group;
4950/*** The value for the owner field */51privatelong owner;
525354/***55 * Get the Id56 * @return long57 */58publiclong getId()
59 {
60return id;
61 }
626364/***65 * Set the value of Id66 */67publicvoid setId(long v )
68 {
6970if (this.id != v)
71 {
72this.id = v;
73 setModified(true);
74 }
757677 }
787980/***81 * Get the Name82 * @return String83 */84public String getName()
85 {
86return name;
87 }
888990/***91 * Set the value of Name92 */93publicvoid setName(String v )
94 {
9596if (!ObjectUtils.equals(this.name, v))
97 {
98this.name = v;
99 setModified(true);
100 }
101102103 }
104105106/***107 * Get the Group108 * @return String109 */110public String getGroup()
111 {
112return group;
113 }
114115116/***117 * Set the value of Group118 */119publicvoid setGroup(String v )
120 {
121122if (!ObjectUtils.equals(this.group, v))
123 {
124this.group = v;
125 setModified(true);
126 }
127128129 }
130131132/***133 * Get the Owner134 * @return long135 */136publiclong getOwner()
137 {
138return owner;
139 }
140141142/***143 * Set the value of Owner144 */145publicvoid setOwner(long v ) throws TorqueException
146 {
147148if (this.owner != v)
149 {
150this.owner = v;
151 setModified(true);
152 }
153154155if (aPortletDbEntry != null && !(aPortletDbEntry.getId() == v))
156 {
157 aPortletDbEntry = null;
158 }
159160 }
161162163164165166privatePortletDbEntry aPortletDbEntry;
167168/***169 * Declares an association between this object and a PortletDbEntry object170 *171 * @param PortletDbEntry v172 */173publicvoid setPortletDbEntry(PortletDbEntry v) throws TorqueException
174 {
175if (v == null)
176 {
177 setOwner(0);
178 }
179else180 {
181 setOwner(v.getId());
182 }
183 aPortletDbEntry = v;
184 }
185186187publicPortletDbEntry getPortletDbEntry() throws TorqueException
188 {
189if ( getOwner()>0 )
190 {
191return PortletDbEntryManager.getInstance(SimpleKey.keyFor(getOwner()));
192 }
193return aPortletDbEntry;
194 }
195196/***197 * Provides convenient way to set a relationship based on a198 * ObjectKey. e.g.199 * <code>bar.setFooKey(foo.getPrimaryKey())</code>200 *201 */202publicvoid setPortletDbEntryKey(ObjectKey key) throws TorqueException
203 {
204205 setOwner(((NumberKey) key).longValue());
206 }
207208209210privatestatic List fieldNames = null;
211212/***213 * Generate a list of field names.214 */215publicstaticsynchronized List getFieldNames()
216 {
217if (fieldNames == null)
218 {
219 fieldNames = new ArrayList();
220 fieldNames.add("Id");
221 fieldNames.add("Name");
222 fieldNames.add("Group");
223 fieldNames.add("Owner");
224 fieldNames = Collections.unmodifiableList(fieldNames);
225 }
226return fieldNames;
227 }
228229/***230 * Retrieves a field from the object by name passed in231 * as a String.232 */233public Object getByName(String name)
234 {
235if (name.equals("Id"))
236 {
237returnnew Long(getId());
238 }
239if (name.equals("Name"))
240 {
241return getName();
242 }
243if (name.equals("Group"))
244 {
245return getGroup();
246 }
247if (name.equals("Owner"))
248 {
249returnnew Long(getOwner());
250 }
251returnnull;
252 }
253254/***255 * Retrieves a field from the object by name passed in256 * as a String. The String must be one of the static257 * Strings defined in this Class' Peer.258 */259public Object getByPeerName(String name)
260 {
261if (name.equals(PortletCategoryPeer.ID ))
262 {
263returnnew Long(getId());
264 }
265if (name.equals(PortletCategoryPeer.NAME ))
266 {
267return getName();
268 }
269if (name.equals(PortletCategoryPeer.GROUPE ))
270 {
271return getGroup();
272 }
273if (name.equals(PortletCategoryPeer.OWNER ))
274 {
275returnnew Long(getOwner());
276 }
277returnnull;
278 }
279280/***281 * Retrieves a field from the object by Position as specified282 * in the xml schema. Zero-based.283 */284public Object getByPosition(int pos)
285 {
286if ( pos == 0 )
287 {
288returnnew Long(getId());
289 }
290if ( pos == 1 )
291 {
292return getName();
293 }
294if ( pos == 2 )
295 {
296return getGroup();
297 }
298if ( pos == 3 )
299 {
300returnnew Long(getOwner());
301 }
302returnnull;
303 }
304305/***306 * Stores the object in the database. If the object is new,307 * it inserts it; otherwise an update is performed.308 */309publicvoid save() throws Exception
310 {
311 save(PortletCategoryPeer.getMapBuilder()
312 .getDatabaseMap().getName());
313 }
314315/***316 * Stores the object in the database. If the object is new,317 * it inserts it; otherwise an update is performed.318 * Note: this code is here because the method body is319 * auto-generated conditionally and therefore needs to be320 * in this file instead of in the super class, BaseObject.321 */322publicvoid save(String dbName) throws TorqueException
323 {
324 Connection con = null;
325try326 {
327 con = Transaction.begin(dbName);
328 save(con);
329 Transaction.commit(con);
330 }
331catch(TorqueException e)
332 {
333 Transaction.safeRollback(con);
334throw e;
335 }
336 }
337338/*** flag to prevent endless save loop, if this object is referenced339 by another object which falls in this transaction. */340privateboolean alreadyInSave = false;
341/***342 * Stores the object in the database. If the object is new,343 * it inserts it; otherwise an update is performed. This method344 * is meant to be used as part of a transaction, otherwise use345 * the save() method and the connection details will be handled346 * internally347 */348publicvoid save(Connection con) throws TorqueException
349 {
350if (!alreadyInSave)
351 {
352 alreadyInSave = true;
353354355356// If this object has been modified, then save it to the database.357if (isModified())
358 {
359if (isNew())
360 {
361 PortletCategoryPeer.doInsert((PortletCategory)this, con);
362 setNew(false);
363 }
364else365 {
366 PortletCategoryPeer.doUpdate((PortletCategory)this, con);
367 }
368369if (isCacheOnSave())
370 {
371 PortletCategoryManager.putInstance(this);
372 }
373 }
374375 alreadyInSave = false;
376 }
377 }
378379/***380 * Specify whether to cache the object after saving to the db.381 * This method returns false382 */383protectedboolean isCacheOnSave()
384 {
385returntrue;
386 }
387388389/***390 * Set the PrimaryKey using ObjectKey.391 *392 * @param ObjectKey id393 */394publicvoid setPrimaryKey(ObjectKey id)
395 {
396 setId(((NumberKey)id).longValue());
397 }
398399/***400 * Set the PrimaryKey using a String.401 */402publicvoid setPrimaryKey(String key)
403 {
404 setId(Long.parseLong(key));
405 }
406407408/***409 * returns an id that differentiates this object from others410 * of its class.411 */412public ObjectKey getPrimaryKey()
413 {
414return SimpleKey.keyFor(getId());
415 }
416417418/***419 * Makes a copy of this object.420 * It creates a new object filling in the simple attributes.421 * It then fills all the association collections.422 */423publicPortletCategory copy() throws TorqueException
424 {
425PortletCategory copyObj = newPortletCategory();
426 copyObj.setId(id);
427 copyObj.setName(name);
428 copyObj.setGroup(group);
429 copyObj.setOwner(owner);
430431 copyObj.setId(0);
432433return copyObj;
434 }
435436/***437 * returns a peer instance associated with this om. Since Peer classes438 * are not to have any instance attributes, this method returns the439 * same instance for all member of this class. The method could therefore440 * be static, but this would prevent one from overriding the behavior.441 */442publicPortletCategoryPeer getPeer()
443 {
444return peer;
445 }
446 }