KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > om > dbregistry > BasePortletParameter


1 package org.apache.jetspeed.om.dbregistry;
2
3
4 import java.math.BigDecimal JavaDoc;
5 import java.sql.Connection JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Collections JavaDoc;
8 import java.util.Date JavaDoc;
9 import java.util.List JavaDoc;
10
11 import org.apache.commons.lang.ObjectUtils;
12 import org.apache.torque.TorqueException;
13 import org.apache.torque.om.BaseObject;
14 import org.apache.torque.om.ComboKey;
15 import org.apache.torque.om.DateKey;
16 import org.apache.torque.om.NumberKey;
17 import org.apache.torque.om.ObjectKey;
18 import org.apache.torque.om.SimpleKey;
19 import org.apache.torque.om.StringKey;
20 import org.apache.torque.om.Persistent;
21 import org.apache.torque.util.Criteria;
22 import org.apache.torque.util.Transaction;
23
24   
25   
26 /**
27  * This class was autogenerated by Torque on:
28  *
29  * [Thu Apr 22 15:30:48 PDT 2004]
30  *
31  * You should not use this class directly. It should not even be
32  * extended all references should be to PortletParameter
33  */

34 public abstract class BasePortletParameter extends BaseObject
35 {
36     /** The Peer class */
37     private static final PortletParameterPeer peer =
38         new PortletParameterPeer();
39
40       
41     /** The value for the id field */
42     private long id;
43       
44     /** The value for the name field */
45     private String JavaDoc name;
46                                                 
47     /** The value for the value field */
48     private String JavaDoc value="0";
49       
50     /** The value for the type field */
51     private String JavaDoc type;
52                                                                 
53     /** The value for the hidden field */
54     private boolean hidden=false;
55       
56     /** The value for the role field */
57     private String JavaDoc role;
58                                                                 
59     /** The value for the cachedonvalue field */
60     private boolean cachedonvalue=true;
61                                                                 
62     /** The value for the cachedonname field */
63     private boolean cachedonname=true;
64       
65     /** The value for the title field */
66     private String JavaDoc title;
67       
68     /** The value for the description field */
69     private String JavaDoc description;
70       
71     /** The value for the image field */
72     private String JavaDoc image;
73       
74     /** The value for the portletId field */
75     private long portletId;
76       
77     /** The value for the securityRef field */
78     private String JavaDoc securityRef;
79   
80   
81     /**
82      * Get the Id
83      * @return long
84      */

85     public long getId()
86     {
87         return id;
88     }
89
90                         
91     /**
92      * Set the value of Id
93      */

94     public void setId(long v )
95     {
96     
97                   if (this.id != v)
98               {
99             this.id = v;
100             setModified(true);
101         }
102     
103           
104               }
105
106   
107     /**
108      * Get the Name
109      * @return String
110      */

111     public String JavaDoc getName()
112     {
113         return name;
114     }
115
116                         
117     /**
118      * Set the value of Name
119      */

120     public void setName(String JavaDoc v )
121     {
122     
123                   if (!ObjectUtils.equals(this.name, v))
124               {
125             this.name = v;
126             setModified(true);
127         }
128     
129           
130               }
131
132   
133     /**
134      * Get the Value
135      * @return String
136      */

137     public String JavaDoc getValue()
138     {
139         return value;
140     }
141
142                         
143     /**
144      * Set the value of Value
145      */

146     public void setValue(String JavaDoc v )
147     {
148     
149                   if (!ObjectUtils.equals(this.value, v))
150               {
151             this.value = v;
152             setModified(true);
153         }
154     
155           
156               }
157
158   
159     /**
160      * Get the Type
161      * @return String
162      */

163     public String JavaDoc getType()
164     {
165         return type;
166     }
167
168                         
169     /**
170      * Set the value of Type
171      */

172     public void setType(String JavaDoc v )
173     {
174     
175                   if (!ObjectUtils.equals(this.type, v))
176               {
177             this.type = v;
178             setModified(true);
179         }
180     
181           
182               }
183
184   
185     /**
186      * Get the Hidden
187      * @return boolean
188      */

189     public boolean getHidden()
190     {
191         return hidden;
192     }
193
194                         
195     /**
196      * Set the value of Hidden
197      */

198     public void setHidden(boolean v )
199     {
200     
201                   if (this.hidden != v)
202               {
203             this.hidden = v;
204             setModified(true);
205         }
206     
207           
208               }
209
210   
211     /**
212      * Get the Role
213      * @return String
214      */

215     public String JavaDoc getRole()
216     {
217         return role;
218     }
219
220                         
221     /**
222      * Set the value of Role
223      */

224     public void setRole(String JavaDoc v )
225     {
226     
227                   if (!ObjectUtils.equals(this.role, v))
228               {
229             this.role = v;
230             setModified(true);
231         }
232     
233           
234               }
235
236   
237     /**
238      * Get the Cachedonvalue
239      * @return boolean
240      */

241     public boolean getCachedonvalue()
242     {
243         return cachedonvalue;
244     }
245
246                         
247     /**
248      * Set the value of Cachedonvalue
249      */

250     public void setCachedonvalue(boolean v )
251     {
252     
253                   if (this.cachedonvalue != v)
254               {
255             this.cachedonvalue = v;
256             setModified(true);
257         }
258     
259           
260               }
261
262   
263     /**
264      * Get the Cachedonname
265      * @return boolean
266      */

267     public boolean getCachedonname()
268     {
269         return cachedonname;
270     }
271
272                         
273     /**
274      * Set the value of Cachedonname
275      */

276     public void setCachedonname(boolean v )
277     {
278     
279                   if (this.cachedonname != v)
280               {
281             this.cachedonname = v;
282             setModified(true);
283         }
284     
285           
286               }
287
288   
289     /**
290      * Get the Title
291      * @return String
292      */

293     public String JavaDoc getTitle()
294     {
295         return title;
296     }
297
298                         
299     /**
300      * Set the value of Title
301      */

302     public void setTitle(String JavaDoc v )
303     {
304     
305                   if (!ObjectUtils.equals(this.title, v))
306               {
307             this.title = v;
308             setModified(true);
309         }
310     
311           
312               }
313
314   
315     /**
316      * Get the Description
317      * @return String
318      */

319     public String JavaDoc getDescription()
320     {
321         return description;
322     }
323
324                         
325     /**
326      * Set the value of Description
327      */

328     public void setDescription(String JavaDoc v )
329     {
330     
331                   if (!ObjectUtils.equals(this.description, v))
332               {
333             this.description = v;
334             setModified(true);
335         }
336     
337           
338               }
339
340   
341     /**
342      * Get the Image
343      * @return String
344      */

345     public String JavaDoc getImage()
346     {
347         return image;
348     }
349
350                         
351     /**
352      * Set the value of Image
353      */

354     public void setImage(String JavaDoc v )
355     {
356     
357                   if (!ObjectUtils.equals(this.image, v))
358               {
359             this.image = v;
360             setModified(true);
361         }
362     
363           
364               }
365
366   
367     /**
368      * Get the PortletId
369      * @return long
370      */

371     public long getPortletId()
372     {
373         return portletId;
374     }
375
376                               
377     /**
378      * Set the value of PortletId
379      */

380     public void setPortletId(long v ) throws TorqueException
381     {
382     
383                   if (this.portletId != v)
384               {
385             this.portletId = v;
386             setModified(true);
387         }
388     
389                                   
390                 if (aPortletDbEntry != null && !(aPortletDbEntry.getId() == v))
391                 {
392             aPortletDbEntry = null;
393         }
394       
395               }
396
397   
398     /**
399      * Get the SecurityRef
400      * @return String
401      */

402     public String JavaDoc getSecurityRef()
403     {
404         return securityRef;
405     }
406
407                         
408     /**
409      * Set the value of SecurityRef
410      */

411     public void setSecurityRef(String JavaDoc v )
412     {
413     
414                   if (!ObjectUtils.equals(this.securityRef, v))
415               {
416             this.securityRef = v;
417             setModified(true);
418         }
419     
420           
421               }
422
423   
424       
425         
426                   
427         private PortletDbEntry aPortletDbEntry;
428
429     /**
430      * Declares an association between this object and a PortletDbEntry object
431      *
432      * @param PortletDbEntry v
433      */

434     public void setPortletDbEntry(PortletDbEntry v) throws TorqueException
435     {
436             if (v == null)
437         {
438                   setPortletId(0);
439               }
440         else
441         {
442             setPortletId(v.getId());
443         }
444             aPortletDbEntry = v;
445     }
446
447                         
448     public PortletDbEntry getPortletDbEntry() throws TorqueException
449     {
450         if ( getPortletId()>0 )
451         {
452                 return PortletDbEntryManager.getInstance(SimpleKey.keyFor(getPortletId()));
453             }
454         return aPortletDbEntry;
455     }
456
457     /**
458      * Provides convenient way to set a relationship based on a
459      * ObjectKey. e.g.
460      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
461      *
462          */

463     public void setPortletDbEntryKey(ObjectKey key) throws TorqueException
464     {
465     
466                     setPortletId(((NumberKey) key).longValue());
467               }
468
469      
470                 
471     private static List JavaDoc fieldNames = null;
472
473     /**
474      * Generate a list of field names.
475      */

476     public static synchronized List JavaDoc getFieldNames()
477     {
478         if (fieldNames == null)
479         {
480             fieldNames = new ArrayList JavaDoc();
481               fieldNames.add("Id");
482               fieldNames.add("Name");
483               fieldNames.add("Value");
484               fieldNames.add("Type");
485               fieldNames.add("Hidden");
486               fieldNames.add("Role");
487               fieldNames.add("Cachedonvalue");
488               fieldNames.add("Cachedonname");
489               fieldNames.add("Title");
490               fieldNames.add("Description");
491               fieldNames.add("Image");
492               fieldNames.add("PortletId");
493               fieldNames.add("SecurityRef");
494               fieldNames = Collections.unmodifiableList(fieldNames);
495         }
496         return fieldNames;
497     }
498
499     /**
500      * Retrieves a field from the object by name passed in
501      * as a String.
502      */

503     public Object JavaDoc getByName(String JavaDoc name)
504     {
505           if (name.equals("Id"))
506         {
507                 return new Long JavaDoc(getId());
508             }
509           if (name.equals("Name"))
510         {
511                 return getName();
512             }
513           if (name.equals("Value"))
514         {
515                 return getValue();
516             }
517           if (name.equals("Type"))
518         {
519                 return getType();
520             }
521           if (name.equals("Hidden"))
522         {
523                 return new Boolean JavaDoc(getHidden());
524             }
525           if (name.equals("Role"))
526         {
527                 return getRole();
528             }
529           if (name.equals("Cachedonvalue"))
530         {
531                 return new Boolean JavaDoc(getCachedonvalue());
532             }
533           if (name.equals("Cachedonname"))
534         {
535                 return new Boolean JavaDoc(getCachedonname());
536             }
537           if (name.equals("Title"))
538         {
539                 return getTitle();
540             }
541           if (name.equals("Description"))
542         {
543                 return getDescription();
544             }
545           if (name.equals("Image"))
546         {
547                 return getImage();
548             }
549           if (name.equals("PortletId"))
550         {
551                 return new Long JavaDoc(getPortletId());
552             }
553           if (name.equals("SecurityRef"))
554         {
555                 return getSecurityRef();
556             }
557           return null;
558     }
559     
560     /**
561      * Retrieves a field from the object by name passed in
562      * as a String. The String must be one of the static
563      * Strings defined in this Class' Peer.
564      */

565     public Object JavaDoc getByPeerName(String JavaDoc name)
566     {
567           if (name.equals(PortletParameterPeer.ID ))
568         {
569                 return new Long JavaDoc(getId());
570             }
571           if (name.equals(PortletParameterPeer.NAME ))
572         {
573                 return getName();
574             }
575           if (name.equals(PortletParameterPeer.VALUE ))
576         {
577                 return getValue();
578             }
579           if (name.equals(PortletParameterPeer.TYPE ))
580         {
581                 return getType();
582             }
583           if (name.equals(PortletParameterPeer.HIDDEN ))
584         {
585                 return new Boolean JavaDoc(getHidden());
586             }
587           if (name.equals(PortletParameterPeer.ROLE ))
588         {
589                 return getRole();
590             }
591           if (name.equals(PortletParameterPeer.CACHEDONVALUE ))
592         {
593                 return new Boolean JavaDoc(getCachedonvalue());
594             }
595           if (name.equals(PortletParameterPeer.CACHEDONNAME ))
596         {
597                 return new Boolean JavaDoc(getCachedonname());
598             }
599           if (name.equals(PortletParameterPeer.TITLE ))
600         {
601                 return getTitle();
602             }
603           if (name.equals(PortletParameterPeer.DESCRIPTION ))
604         {
605                 return getDescription();
606             }
607           if (name.equals(PortletParameterPeer.IMAGE ))
608         {
609                 return getImage();
610             }
611           if (name.equals(PortletParameterPeer.PORTLET_ID ))
612         {
613                 return new Long JavaDoc(getPortletId());
614             }
615           if (name.equals(PortletParameterPeer.SECURITY ))
616         {
617                 return getSecurityRef();
618             }
619           return null;
620     }
621
622     /**
623      * Retrieves a field from the object by Position as specified
624      * in the xml schema. Zero-based.
625      */

626     public Object JavaDoc getByPosition(int pos)
627     {
628             if ( pos == 0 )
629         {
630                 return new Long JavaDoc(getId());
631             }
632               if ( pos == 1 )
633         {
634                 return getName();
635             }
636               if ( pos == 2 )
637         {
638                 return getValue();
639             }
640               if ( pos == 3 )
641         {
642                 return getType();
643             }
644               if ( pos == 4 )
645         {
646                 return new Boolean JavaDoc(getHidden());
647             }
648               if ( pos == 5 )
649         {
650                 return getRole();
651             }
652               if ( pos == 6 )
653         {
654                 return new Boolean JavaDoc(getCachedonvalue());
655             }
656               if ( pos == 7 )
657         {
658                 return new Boolean JavaDoc(getCachedonname());
659             }
660               if ( pos == 8 )
661         {
662                 return getTitle();
663             }
664               if ( pos == 9 )
665         {
666                 return getDescription();
667             }
668               if ( pos == 10 )
669         {
670                 return getImage();
671             }
672               if ( pos == 11 )
673         {
674                 return new Long JavaDoc(getPortletId());
675             }
676               if ( pos == 12 )
677         {
678                 return getSecurityRef();
679             }
680               return null;
681     }
682      
683     /**
684      * Stores the object in the database. If the object is new,
685      * it inserts it; otherwise an update is performed.
686      */

687     public void save() throws Exception JavaDoc
688     {
689           save(PortletParameterPeer.getMapBuilder()
690                 .getDatabaseMap().getName());
691       }
692
693     /**
694      * Stores the object in the database. If the object is new,
695      * it inserts it; otherwise an update is performed.
696        * Note: this code is here because the method body is
697      * auto-generated conditionally and therefore needs to be
698      * in this file instead of in the super class, BaseObject.
699        */

700     public void save(String JavaDoc dbName) throws TorqueException
701     {
702         Connection JavaDoc con = null;
703           try
704         {
705             con = Transaction.begin(dbName);
706             save(con);
707             Transaction.commit(con);
708         }
709         catch(TorqueException e)
710         {
711             Transaction.safeRollback(con);
712             throw e;
713         }
714       }
715
716       /** flag to prevent endless save loop, if this object is referenced
717         by another object which falls in this transaction. */

718     private boolean alreadyInSave = false;
719       /**
720      * Stores the object in the database. If the object is new,
721      * it inserts it; otherwise an update is performed. This method
722      * is meant to be used as part of a transaction, otherwise use
723      * the save() method and the connection details will be handled
724      * internally
725      */

726     public void save(Connection JavaDoc con) throws TorqueException
727     {
728           if (!alreadyInSave)
729         {
730             alreadyInSave = true;
731
732
733   
734             // If this object has been modified, then save it to the database.
735
if (isModified())
736             {
737                 if (isNew())
738                 {
739                     PortletParameterPeer.doInsert((PortletParameter)this, con);
740                     setNew(false);
741                 }
742                 else
743                 {
744                     PortletParameterPeer.doUpdate((PortletParameter)this, con);
745                 }
746
747                       if (isCacheOnSave())
748                 {
749                     PortletParameterManager.putInstance(this);
750                 }
751               }
752
753                       alreadyInSave = false;
754         }
755       }
756
757     /**
758      * Specify whether to cache the object after saving to the db.
759      * This method returns false
760      */

761     protected boolean isCacheOnSave()
762     {
763         return true;
764     }
765
766                   
767       /**
768      * Set the PrimaryKey using ObjectKey.
769      *
770      * @param ObjectKey id
771      */

772     public void setPrimaryKey(ObjectKey id)
773          {
774             setId(((NumberKey)id).longValue());
775         }
776
777     /**
778      * Set the PrimaryKey using a String.
779      */

780     public void setPrimaryKey(String JavaDoc key)
781     {
782             setId(Long.parseLong(key));
783         }
784
785   
786     /**
787      * returns an id that differentiates this object from others
788      * of its class.
789      */

790     public ObjectKey getPrimaryKey()
791     {
792           return SimpleKey.keyFor(getId());
793       }
794  
795
796     /**
797      * Makes a copy of this object.
798      * It creates a new object filling in the simple attributes.
799        * It then fills all the association collections.
800        */

801       public PortletParameter copy() throws TorqueException
802     {
803         PortletParameter copyObj = new PortletParameter();
804             copyObj.setId(id);
805           copyObj.setName(name);
806           copyObj.setValue(value);
807           copyObj.setType(type);
808           copyObj.setHidden(hidden);
809           copyObj.setRole(role);
810           copyObj.setCachedonvalue(cachedonvalue);
811           copyObj.setCachedonname(cachedonname);
812           copyObj.setTitle(title);
813           copyObj.setDescription(description);
814           copyObj.setImage(image);
815           copyObj.setPortletId(portletId);
816           copyObj.setSecurityRef(securityRef);
817   
818                       copyObj.setId(0);
819                                                                                     
820                 return copyObj;
821     }
822
823     /**
824      * returns a peer instance associated with this om. Since Peer classes
825      * are not to have any instance attributes, this method returns the
826      * same instance for all member of this class. The method could therefore
827      * be static, but this would prevent one from overriding the behavior.
828      */

829     public PortletParameterPeer getPeer()
830     {
831         return peer;
832     }
833 }
834
Popular Tags