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;
2324252627/***28 * This class was autogenerated by Torque on:29 *30 * [Thu Apr 22 23:12:36 EDT 2004]31 *32 * You should not use this class directly. It should not even be33 * extended all references should be to PortletMediatype34 */35publicabstractclassBasePortletMediatypeextends BaseObject
36 {
37/*** The Peer class */38privatestaticfinalPortletMediatypePeer peer =
39newPortletMediatypePeer();
404142/*** The value for the id field */43privatelong id;
4445/*** The value for the mediaId field */46privatelong mediaId;
474849/***50 * Get the Id51 * @return long52 */53publiclong getId()
54 {
55return id;
56 }
575859/***60 * Set the value of Id61 */62publicvoid setId(long v ) throws TorqueException
63 {
6465if (this.id != v)
66 {
67this.id = v;
68 setModified(true);
69 }
707172if (aPortletDbEntry != null && !(aPortletDbEntry.getId() == v))
73 {
74 aPortletDbEntry = null;
75 }
7677 }
787980/***81 * Get the MediaId82 * @return long83 */84publiclong getMediaId()
85 {
86return mediaId;
87 }
888990/***91 * Set the value of MediaId92 */93publicvoid setMediaId(long v ) throws TorqueException
94 {
9596if (this.mediaId != v)
97 {
98this.mediaId = v;
99 setModified(true);
100 }
101102103if (aMediatype != null && !(aMediatype.getId() == v))
104 {
105 aMediatype = null;
106 }
107108 }
109110111112113114privatePortletDbEntry aPortletDbEntry;
115116/***117 * Declares an association between this object and a PortletDbEntry object118 *119 * @param PortletDbEntry v120 */121publicvoid setPortletDbEntry(PortletDbEntry v) throws TorqueException
122 {
123if (v == null)
124 {
125 setId(0);
126 }
127else128 {
129 setId(v.getId());
130 }
131 aPortletDbEntry = v;
132 }
133134135publicPortletDbEntry getPortletDbEntry() throws TorqueException
136 {
137if ( getId()>0 )
138 {
139return PortletDbEntryManager.getInstance(SimpleKey.keyFor(getId()));
140 }
141return aPortletDbEntry;
142 }
143144/***145 * Provides convenient way to set a relationship based on a146 * ObjectKey. e.g.147 * <code>bar.setFooKey(foo.getPrimaryKey())</code>148 *149 */150publicvoid setPortletDbEntryKey(ObjectKey key) throws TorqueException
151 {
152153 setId(((NumberKey) key).longValue());
154 }
155156157158159privateMediatype aMediatype;
160161/***162 * Declares an association between this object and a Mediatype object163 *164 * @param Mediatype v165 */166publicvoid setMediatype(Mediatype v) throws TorqueException
167 {
168if (v == null)
169 {
170 setMediaId(0);
171 }
172else173 {
174 setMediaId(v.getId());
175 }
176 aMediatype = v;
177 }
178179180publicMediatype getMediatype() throws TorqueException
181 {
182if ( getMediaId()>0 )
183 {
184return MediatypeManager.getInstance(SimpleKey.keyFor(getMediaId()));
185 }
186return aMediatype;
187 }
188189/***190 * Provides convenient way to set a relationship based on a191 * ObjectKey. e.g.192 * <code>bar.setFooKey(foo.getPrimaryKey())</code>193 *194 */195publicvoid setMediatypeKey(ObjectKey key) throws TorqueException
196 {
197198 setMediaId(((NumberKey) key).longValue());
199 }
200201202203privatestatic List fieldNames = null;
204205/***206 * Generate a list of field names.207 */208publicstaticsynchronized List getFieldNames()
209 {
210if (fieldNames == null)
211 {
212 fieldNames = new ArrayList();
213 fieldNames.add("Id");
214 fieldNames.add("MediaId");
215 fieldNames = Collections.unmodifiableList(fieldNames);
216 }
217return fieldNames;
218 }
219220/***221 * Retrieves a field from the object by name passed in222 * as a String.223 */224public Object getByName(String name)
225 {
226if (name.equals("Id"))
227 {
228returnnew Long(getId());
229 }
230if (name.equals("MediaId"))
231 {
232returnnew Long(getMediaId());
233 }
234returnnull;
235 }
236237/***238 * Retrieves a field from the object by name passed in239 * as a String. The String must be one of the static240 * Strings defined in this Class' Peer.241 */242public Object getByPeerName(String name)
243 {
244if (name.equals(PortletMediatypePeer.ID ))
245 {
246returnnew Long(getId());
247 }
248if (name.equals(PortletMediatypePeer.MEDIA_ID ))
249 {
250returnnew Long(getMediaId());
251 }
252returnnull;
253 }
254255/***256 * Retrieves a field from the object by Position as specified257 * in the xml schema. Zero-based.258 */259public Object getByPosition(int pos)
260 {
261if ( pos == 0 )
262 {
263returnnew Long(getId());
264 }
265if ( pos == 1 )
266 {
267returnnew Long(getMediaId());
268 }
269returnnull;
270 }
271272/***273 * Stores the object in the database. If the object is new,274 * it inserts it; otherwise an update is performed.275 */276publicvoid save() throws Exception
277 {
278 save(PortletMediatypePeer.getMapBuilder()
279 .getDatabaseMap().getName());
280 }
281282/***283 * Stores the object in the database. If the object is new,284 * it inserts it; otherwise an update is performed.285 * Note: this code is here because the method body is286 * auto-generated conditionally and therefore needs to be287 * in this file instead of in the super class, BaseObject.288 */289publicvoid save(String dbName) throws TorqueException
290 {
291 Connection con = null;
292try293 {
294 con = Transaction.begin(dbName);
295 save(con);
296 Transaction.commit(con);
297 }
298catch(TorqueException e)
299 {
300 Transaction.safeRollback(con);
301throw e;
302 }
303 }
304305/*** flag to prevent endless save loop, if this object is referenced306 by another object which falls in this transaction. */307privateboolean alreadyInSave = false;
308/***309 * Stores the object in the database. If the object is new,310 * it inserts it; otherwise an update is performed. This method311 * is meant to be used as part of a transaction, otherwise use312 * the save() method and the connection details will be handled313 * internally314 */315publicvoid save(Connection con) throws TorqueException
316 {
317if (!alreadyInSave)
318 {
319 alreadyInSave = true;
320321322323// If this object has been modified, then save it to the database.324if (isModified())
325 {
326if (isNew())
327 {
328 PortletMediatypePeer.doInsert((PortletMediatype)this, con);
329 setNew(false);
330 }
331else332 {
333 PortletMediatypePeer.doUpdate((PortletMediatype)this, con);
334 }
335336 }
337338 alreadyInSave = false;
339 }
340 }
341342343344345/***346 * returns an id that differentiates this object from others347 * of its class.348 */349public ObjectKey getPrimaryKey()
350 {
351returnnull;
352 }
353354355/***356 * Makes a copy of this object.357 * It creates a new object filling in the simple attributes.358 * It then fills all the association collections.359 */360publicPortletMediatype copy() throws TorqueException
361 {
362PortletMediatype copyObj = newPortletMediatype();
363 copyObj.setId(id);
364 copyObj.setMediaId(mediaId);
365366367return copyObj;
368 }
369370/***371 * returns a peer instance associated with this om. Since Peer classes372 * are not to have any instance attributes, this method returns the373 * same instance for all member of this class. The method could therefore374 * be static, but this would prevent one from overriding the behavior.375 */376publicPortletMediatypePeer getPeer()
377 {
378return peer;
379 }
380 }