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;
232425/***26 * This class was autogenerated by Torque on:27 *28 * [Thu Apr 22 23:12:36 EDT 2004]29 *30 * You should not use this class directly. It should not even be31 * extended all references should be to Mediatype32 */33publicabstractclassBaseMediatypeextends BaseObject
34 {
35/*** The Peer class */36privatestaticfinalMediatypePeer peer =
37newMediatypePeer();
383940/*** The value for the id field */41privatelong id;
4243/*** The value for the name field */44private String name;
4546/*** The value for the hidden field */47privateboolean hidden=false;
4849/*** The value for the mimetype field */50private String mimetype;
5152/*** The value for the role field */53private String role;
5455/*** The value for the title field */56private String title;
5758/*** The value for the description field */59private String description;
6061/*** The value for the image field */62private String image;
636465/***66 * Get the Id67 * @return long68 */69publiclong getId()
70 {
71return id;
72 }
737475/***76 * Set the value of Id77 */78publicvoid setId(long v ) throws TorqueException
79 {
8081if (this.id != v)
82 {
83this.id = v;
84 setModified(true);
85 }
86878889// update associated PortletMediatype90if (collPortletMediatypes != null )
91 {
92for (int i = 0; i < collPortletMediatypes.size(); i++)
93 {
94 ((PortletMediatype)collPortletMediatypes.get(i))
95 .setMediaId(v);
96 }
97 }
98 }
99100101/***102 * Get the Name103 * @return String104 */105public String getName()
106 {
107return name;
108 }
109110111/***112 * Set the value of Name113 */114publicvoid setName(String v )
115 {
116117if (!ObjectUtils.equals(this.name, v))
118 {
119this.name = v;
120 setModified(true);
121 }
122123124 }
125126127/***128 * Get the Hidden129 * @return boolean130 */131publicboolean getHidden()
132 {
133return hidden;
134 }
135136137/***138 * Set the value of Hidden139 */140publicvoid setHidden(boolean v )
141 {
142143if (this.hidden != v)
144 {
145this.hidden = v;
146 setModified(true);
147 }
148149150 }
151152153/***154 * Get the Mimetype155 * @return String156 */157public String getMimetype()
158 {
159return mimetype;
160 }
161162163/***164 * Set the value of Mimetype165 */166publicvoid setMimetype(String v )
167 {
168169if (!ObjectUtils.equals(this.mimetype, v))
170 {
171this.mimetype = v;
172 setModified(true);
173 }
174175176 }
177178179/***180 * Get the Role181 * @return String182 */183public String getRole()
184 {
185return role;
186 }
187188189/***190 * Set the value of Role191 */192publicvoid setRole(String v )
193 {
194195if (!ObjectUtils.equals(this.role, v))
196 {
197this.role = v;
198 setModified(true);
199 }
200201202 }
203204205/***206 * Get the Title207 * @return String208 */209public String getTitle()
210 {
211return title;
212 }
213214215/***216 * Set the value of Title217 */218publicvoid setTitle(String v )
219 {
220221if (!ObjectUtils.equals(this.title, v))
222 {
223this.title = v;
224 setModified(true);
225 }
226227228 }
229230231/***232 * Get the Description233 * @return String234 */235public String getDescription()
236 {
237return description;
238 }
239240241/***242 * Set the value of Description243 */244publicvoid setDescription(String v )
245 {
246247if (!ObjectUtils.equals(this.description, v))
248 {
249this.description = v;
250 setModified(true);
251 }
252253254 }
255256257/***258 * Get the Image259 * @return String260 */261public String getImage()
262 {
263return image;
264 }
265266267/***268 * Set the value of Image269 */270publicvoid setImage(String v )
271 {
272273if (!ObjectUtils.equals(this.image, v))
274 {
275this.image = v;
276 setModified(true);
277 }
278279280 }
281282283284285286/***287 * Collection to store aggregation of collPortletMediatypes288 */289protected List collPortletMediatypes;
290291/***292 * Temporary storage of collPortletMediatypes to save a possible db hit in293 * the event objects are add to the collection, but the294 * complete collection is never requested.295 */296protectedvoid initPortletMediatypes()
297 {
298if (collPortletMediatypes == null)
299 {
300 collPortletMediatypes = new ArrayList();
301 }
302 }
303304305/***306 * Method called to associate a PortletMediatype object to this object307 * through the PortletMediatype foreign key attribute308 *309 * @param PortletMediatype l310 */311publicvoid addPortletMediatype(PortletMediatype l) throws TorqueException
312 {
313 getPortletMediatypes().add(l);
314 l.setMediatype((Mediatype)this);
315 }
316317/***318 * The criteria used to select the current contents of collPortletMediatypes319 */320private Criteria lastPortletMediatypesCriteria = null;
321322/***323 * If this collection has already been initialized, returns324 * the collection. Otherwise returns the results of325 * getPortletMediatypes(new Criteria())326 */327public List getPortletMediatypes() throws TorqueException
328 {
329if (collPortletMediatypes == null)
330 {
331 collPortletMediatypes = getPortletMediatypes(new Criteria(10));
332 }
333return collPortletMediatypes;
334 }
335336/***337 * If this collection has already been initialized with338 * an identical criteria, it returns the collection.339 * Otherwise if this Mediatype has previously340 * been saved, it will retrieve related PortletMediatypes from storage.341 * If this Mediatype is new, it will return342 * an empty collection or the current collection, the criteria343 * is ignored on a new object.344 */345public List getPortletMediatypes(Criteria criteria) throws TorqueException
346 {
347if (collPortletMediatypes == null)
348 {
349if (isNew())
350 {
351 collPortletMediatypes = new ArrayList();
352 }
353else354 {
355 criteria.add(PortletMediatypePeer.MEDIA_ID, getId() );
356 collPortletMediatypes = PortletMediatypePeer.doSelect(criteria);
357 }
358 }
359else360 {
361// criteria has no effect for a new object362if (!isNew())
363 {
364// the following code is to determine if a new query is365// called for. If the criteria is the same as the last366// one, just return the collection.367 criteria.add(PortletMediatypePeer.MEDIA_ID, getId() );
368if (!lastPortletMediatypesCriteria.equals(criteria))
369 {
370 collPortletMediatypes = PortletMediatypePeer.doSelect(criteria);
371 }
372 }
373 }
374 lastPortletMediatypesCriteria = criteria;
375376return collPortletMediatypes;
377 }
378379/***380 * If this collection has already been initialized, returns381 * the collection. Otherwise returns the results of382 * getPortletMediatypes(new Criteria(),Connection)383 * This method takes in the Connection also as input so that384 * referenced objects can also be obtained using a Connection385 * that is taken as input386 */387public List getPortletMediatypes(Connection con) throws TorqueException
388 {
389if (collPortletMediatypes == null)
390 {
391 collPortletMediatypes = getPortletMediatypes(new Criteria(10),con);
392 }
393return collPortletMediatypes;
394 }
395396/***397 * If this collection has already been initialized with398 * an identical criteria, it returns the collection.399 * Otherwise if this Mediatype has previously400 * been saved, it will retrieve related PortletMediatypes from storage.401 * If this Mediatype is new, it will return402 * an empty collection or the current collection, the criteria403 * is ignored on a new object.404 * This method takes in the Connection also as input so that405 * referenced objects can also be obtained using a Connection406 * that is taken as input407 */408public List getPortletMediatypes(Criteria criteria,Connection con) throws TorqueException
409 {
410if (collPortletMediatypes == null)
411 {
412if (isNew())
413 {
414 collPortletMediatypes = new ArrayList();
415 }
416else417 {
418 criteria.add(PortletMediatypePeer.MEDIA_ID, getId() );
419 collPortletMediatypes = PortletMediatypePeer.doSelect(criteria,con);
420 }
421 }
422else423 {
424// criteria has no effect for a new object425if (!isNew())
426 {
427// the following code is to determine if a new query is428// called for. If the criteria is the same as the last429// one, just return the collection.430 criteria.add(PortletMediatypePeer.MEDIA_ID, getId() );
431if (!lastPortletMediatypesCriteria.equals(criteria))
432 {
433 collPortletMediatypes = PortletMediatypePeer.doSelect(criteria,con);
434 }
435 }
436 }
437 lastPortletMediatypesCriteria = criteria;
438439return collPortletMediatypes;
440 }
441442443444445446447448449450451452453/***454 * If this collection has already been initialized with455 * an identical criteria, it returns the collection.456 * Otherwise if this Mediatype is new, it will return457 * an empty collection; or if this Mediatype has previously458 * been saved, it will retrieve related PortletMediatypes from storage.459 *460 * This method is protected by default in order to keep the public461 * api reasonable. You can provide public methods for those you462 * actually need in Mediatype.463 */464protected List getPortletMediatypesJoinPortletDbEntry(Criteria criteria)
465 throws TorqueException
466 {
467if (collPortletMediatypes == null)
468 {
469if (isNew())
470 {
471 collPortletMediatypes = new ArrayList();
472 }
473else474 {
475 criteria.add(PortletMediatypePeer.MEDIA_ID, getId() );
476 collPortletMediatypes = PortletMediatypePeer.doSelectJoinPortletDbEntry(criteria);
477 }
478 }
479else480 {
481// the following code is to determine if a new query is482// called for. If the criteria is the same as the last483// one, just return the collection.484boolean newCriteria = true;
485 criteria.add(PortletMediatypePeer.MEDIA_ID, getId() );
486if (!lastPortletMediatypesCriteria.equals(criteria))
487 {
488 collPortletMediatypes = PortletMediatypePeer.doSelectJoinPortletDbEntry(criteria);
489 }
490 }
491 lastPortletMediatypesCriteria = criteria;
492493return collPortletMediatypes;
494 }
495496497498499500501502503504/***505 * If this collection has already been initialized with506 * an identical criteria, it returns the collection.507 * Otherwise if this Mediatype is new, it will return508 * an empty collection; or if this Mediatype has previously509 * been saved, it will retrieve related PortletMediatypes from storage.510 *511 * This method is protected by default in order to keep the public512 * api reasonable. You can provide public methods for those you513 * actually need in Mediatype.514 */515protected List getPortletMediatypesJoinMediatype(Criteria criteria)
516 throws TorqueException
517 {
518if (collPortletMediatypes == null)
519 {
520if (isNew())
521 {
522 collPortletMediatypes = new ArrayList();
523 }
524else525 {
526 criteria.add(PortletMediatypePeer.MEDIA_ID, getId() );
527 collPortletMediatypes = PortletMediatypePeer.doSelectJoinMediatype(criteria);
528 }
529 }
530else531 {
532// the following code is to determine if a new query is533// called for. If the criteria is the same as the last534// one, just return the collection.535boolean newCriteria = true;
536 criteria.add(PortletMediatypePeer.MEDIA_ID, getId() );
537if (!lastPortletMediatypesCriteria.equals(criteria))
538 {
539 collPortletMediatypes = PortletMediatypePeer.doSelectJoinMediatype(criteria);
540 }
541 }
542 lastPortletMediatypesCriteria = criteria;
543544return collPortletMediatypes;
545 }
546547548549550privatestatic List fieldNames = null;
551552/***553 * Generate a list of field names.554 */555publicstaticsynchronized List getFieldNames()
556 {
557if (fieldNames == null)
558 {
559 fieldNames = new ArrayList();
560 fieldNames.add("Id");
561 fieldNames.add("Name");
562 fieldNames.add("Hidden");
563 fieldNames.add("Mimetype");
564 fieldNames.add("Role");
565 fieldNames.add("Title");
566 fieldNames.add("Description");
567 fieldNames.add("Image");
568 fieldNames = Collections.unmodifiableList(fieldNames);
569 }
570return fieldNames;
571 }
572573/***574 * Retrieves a field from the object by name passed in575 * as a String.576 */577public Object getByName(String name)
578 {
579if (name.equals("Id"))
580 {
581returnnew Long(getId());
582 }
583if (name.equals("Name"))
584 {
585return getName();
586 }
587if (name.equals("Hidden"))
588 {
589returnnew Boolean(getHidden());
590 }
591if (name.equals("Mimetype"))
592 {
593return getMimetype();
594 }
595if (name.equals("Role"))
596 {
597return getRole();
598 }
599if (name.equals("Title"))
600 {
601return getTitle();
602 }
603if (name.equals("Description"))
604 {
605return getDescription();
606 }
607if (name.equals("Image"))
608 {
609return getImage();
610 }
611returnnull;
612 }
613614/***615 * Retrieves a field from the object by name passed in616 * as a String. The String must be one of the static617 * Strings defined in this Class' Peer.618 */619public Object getByPeerName(String name)
620 {
621if (name.equals(MediatypePeer.ID ))
622 {
623returnnew Long(getId());
624 }
625if (name.equals(MediatypePeer.NAME ))
626 {
627return getName();
628 }
629if (name.equals(MediatypePeer.HIDDEN ))
630 {
631returnnew Boolean(getHidden());
632 }
633if (name.equals(MediatypePeer.MIMETYPE ))
634 {
635return getMimetype();
636 }
637if (name.equals(MediatypePeer.ROLE ))
638 {
639return getRole();
640 }
641if (name.equals(MediatypePeer.TITLE ))
642 {
643return getTitle();
644 }
645if (name.equals(MediatypePeer.DESCRIPTION ))
646 {
647return getDescription();
648 }
649if (name.equals(MediatypePeer.IMAGE ))
650 {
651return getImage();
652 }
653returnnull;
654 }
655656/***657 * Retrieves a field from the object by Position as specified658 * in the xml schema. Zero-based.659 */660public Object getByPosition(int pos)
661 {
662if ( pos == 0 )
663 {
664returnnew Long(getId());
665 }
666if ( pos == 1 )
667 {
668return getName();
669 }
670if ( pos == 2 )
671 {
672returnnew Boolean(getHidden());
673 }
674if ( pos == 3 )
675 {
676return getMimetype();
677 }
678if ( pos == 4 )
679 {
680return getRole();
681 }
682if ( pos == 5 )
683 {
684return getTitle();
685 }
686if ( pos == 6 )
687 {
688return getDescription();
689 }
690if ( pos == 7 )
691 {
692return getImage();
693 }
694returnnull;
695 }
696697/***698 * Stores the object in the database. If the object is new,699 * it inserts it; otherwise an update is performed.700 */701publicvoid save() throws Exception
702 {
703 save(MediatypePeer.getMapBuilder()
704 .getDatabaseMap().getName());
705 }
706707/***708 * Stores the object in the database. If the object is new,709 * it inserts it; otherwise an update is performed.710 * Note: this code is here because the method body is711 * auto-generated conditionally and therefore needs to be712 * in this file instead of in the super class, BaseObject.713 */714publicvoid save(String dbName) throws TorqueException
715 {
716 Connection con = null;
717try718 {
719 con = Transaction.begin(dbName);
720 save(con);
721 Transaction.commit(con);
722 }
723catch(TorqueException e)
724 {
725 Transaction.safeRollback(con);
726throw e;
727 }
728 }
729730/*** flag to prevent endless save loop, if this object is referenced731 by another object which falls in this transaction. */732privateboolean alreadyInSave = false;
733/***734 * Stores the object in the database. If the object is new,735 * it inserts it; otherwise an update is performed. This method736 * is meant to be used as part of a transaction, otherwise use737 * the save() method and the connection details will be handled738 * internally739 */740publicvoid save(Connection con) throws TorqueException
741 {
742if (!alreadyInSave)
743 {
744 alreadyInSave = true;
745746747748// If this object has been modified, then save it to the database.749if (isModified())
750 {
751if (isNew())
752 {
753 MediatypePeer.doInsert((Mediatype)this, con);
754 setNew(false);
755 }
756else757 {
758 MediatypePeer.doUpdate((Mediatype)this, con);
759 }
760761if (isCacheOnSave())
762 {
763 MediatypeManager.putInstance(this);
764 }
765 }
766767768if (collPortletMediatypes != null )
769 {
770for (int i = 0; i < collPortletMediatypes.size(); i++)
771 {
772 ((PortletMediatype)collPortletMediatypes.get(i)).save(con);
773 }
774 }
775 alreadyInSave = false;
776 }
777 }
778779/***780 * Specify whether to cache the object after saving to the db.781 * This method returns false782 */783protectedboolean isCacheOnSave()
784 {
785returntrue;
786 }
787788789/***790 * Set the PrimaryKey using ObjectKey.791 *792 * @param ObjectKey id793 */794publicvoid setPrimaryKey(ObjectKey id)
795 throws TorqueException {
796 setId(((NumberKey)id).longValue());
797 }
798799/***800 * Set the PrimaryKey using a String.801 */802publicvoid setPrimaryKey(String key) throws TorqueException
803 {
804 setId(Long.parseLong(key));
805 }
806807808/***809 * returns an id that differentiates this object from others810 * of its class.811 */812public ObjectKey getPrimaryKey()
813 {
814return SimpleKey.keyFor(getId());
815 }
816817818/***819 * Makes a copy of this object.820 * It creates a new object filling in the simple attributes.821 * It then fills all the association collections.822 */823publicMediatype copy() throws TorqueException
824 {
825Mediatype copyObj = newMediatype();
826 copyObj.setId(id);
827 copyObj.setName(name);
828 copyObj.setHidden(hidden);
829 copyObj.setMimetype(mimetype);
830 copyObj.setRole(role);
831 copyObj.setTitle(title);
832 copyObj.setDescription(description);
833 copyObj.setImage(image);
834835 copyObj.setId(0);
836837838839 List v = getPortletMediatypes();
840for (int i = 0; i < v.size(); i++)
841 {
842PortletMediatype obj = (PortletMediatype) v.get(i);
843 copyObj.addPortletMediatype(obj.copy());
844 }
845return copyObj;
846 }
847848/***849 * returns a peer instance associated with this om. Since Peer classes850 * are not to have any instance attributes, this method returns the851 * same instance for all member of this class. The method could therefore852 * be static, but this would prevent one from overriding the behavior.853 */854publicMediatypePeer getPeer()
855 {
856return peer;
857 }
858 }