View Javadoc

1   package org.apache.turbine.services.schedule;
2   
3   
4   import java.math.BigDecimal;
5   import java.sql.Connection;
6   import java.util.ArrayList;
7   import java.util.Collections;
8   import java.util.Date;
9   import java.util.List;
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   * This class was autogenerated by Torque on:
27   *
28   * [Mon Oct 03 14:24:57 CEST 2005]
29   *
30   * You should not use this class directly.  It should not even be
31   * extended all references should be to JobEntry
32   */
33  public abstract class BaseJobEntry extends BaseObject
34  {
35      /*** The Peer class */
36      private static final JobEntryPeer peer =
37          new JobEntryPeer();
38  
39          
40      /*** The value for the jobId field */
41      private int jobId;
42                                            
43      /*** The value for the second field */
44      private int second = -1;
45                                            
46      /*** The value for the minute field */
47      private int minute = -1;
48                                            
49      /*** The value for the hour field */
50      private int hour = -1;
51                                            
52      /*** The value for the weekDay field */
53      private int weekDay = -1;
54                                            
55      /*** The value for the dayOfMonth field */
56      private int dayOfMonth = -1;
57        
58      /*** The value for the task field */
59      private String task;
60        
61      /*** The value for the email field */
62      private String email;
63        
64      /*** The value for the property field */
65      private byte[] property;
66    
67      
68      /***
69       * Get the JobId
70       *
71       * @return int
72       */
73      public int getJobId()
74      {
75          return jobId;
76      }
77  
78                          
79      /***
80       * Set the value of JobId
81       *
82       * @param v new value
83       */
84      public void setJobId(int v) 
85      {
86      
87                    if (this.jobId != v)
88                {
89              this.jobId = v;
90              setModified(true);
91          }
92      
93            
94                }
95    
96      /***
97       * Get the Second
98       *
99       * @return int
100      */
101     public int getSecond()
102     {
103         return second;
104     }
105 
106                         
107     /***
108      * Set the value of Second
109      *
110      * @param v new value
111      */
112     public void setSecond(int v) 
113     {
114     
115                   if (this.second != v)
116               {
117             this.second = v;
118             setModified(true);
119         }
120     
121           
122               }
123   
124     /***
125      * Get the Minute
126      *
127      * @return int
128      */
129     public int getMinute()
130     {
131         return minute;
132     }
133 
134                         
135     /***
136      * Set the value of Minute
137      *
138      * @param v new value
139      */
140     public void setMinute(int v) 
141     {
142     
143                   if (this.minute != v)
144               {
145             this.minute = v;
146             setModified(true);
147         }
148     
149           
150               }
151   
152     /***
153      * Get the Hour
154      *
155      * @return int
156      */
157     public int getHour()
158     {
159         return hour;
160     }
161 
162                         
163     /***
164      * Set the value of Hour
165      *
166      * @param v new value
167      */
168     public void setHour(int v) 
169     {
170     
171                   if (this.hour != v)
172               {
173             this.hour = v;
174             setModified(true);
175         }
176     
177           
178               }
179   
180     /***
181      * Get the WeekDay
182      *
183      * @return int
184      */
185     public int getWeekDay()
186     {
187         return weekDay;
188     }
189 
190                         
191     /***
192      * Set the value of WeekDay
193      *
194      * @param v new value
195      */
196     public void setWeekDay(int v) 
197     {
198     
199                   if (this.weekDay != v)
200               {
201             this.weekDay = v;
202             setModified(true);
203         }
204     
205           
206               }
207   
208     /***
209      * Get the DayOfMonth
210      *
211      * @return int
212      */
213     public int getDayOfMonth()
214     {
215         return dayOfMonth;
216     }
217 
218                         
219     /***
220      * Set the value of DayOfMonth
221      *
222      * @param v new value
223      */
224     public void setDayOfMonth(int v) 
225     {
226     
227                   if (this.dayOfMonth != v)
228               {
229             this.dayOfMonth = v;
230             setModified(true);
231         }
232     
233           
234               }
235   
236     /***
237      * Get the Task
238      *
239      * @return String
240      */
241     public String getTask()
242     {
243         return task;
244     }
245 
246                         
247     /***
248      * Set the value of Task
249      *
250      * @param v new value
251      */
252     public void setTask(String v) 
253     {
254     
255                   if (!ObjectUtils.equals(this.task, v))
256               {
257             this.task = v;
258             setModified(true);
259         }
260     
261           
262               }
263   
264     /***
265      * Get the Email
266      *
267      * @return String
268      */
269     public String getEmail()
270     {
271         return email;
272     }
273 
274                         
275     /***
276      * Set the value of Email
277      *
278      * @param v new value
279      */
280     public void setEmail(String v) 
281     {
282     
283                   if (!ObjectUtils.equals(this.email, v))
284               {
285             this.email = v;
286             setModified(true);
287         }
288     
289           
290               }
291   
292     /***
293      * Get the Property
294      *
295      * @return byte[]
296      */
297     public byte[] getProperty()
298     {
299         return property;
300     }
301 
302                         
303     /***
304      * Set the value of Property
305      *
306      * @param v new value
307      */
308     public void setProperty(byte[] v) 
309     {
310     
311                   if (!ObjectUtils.equals(this.property, v))
312               {
313             this.property = v;
314             setModified(true);
315         }
316     
317           
318               }
319   
320          
321                 
322     private static List fieldNames = null;
323 
324     /***
325      * Generate a list of field names.
326      *
327      * @return a list of field names
328      */
329     public static synchronized List getFieldNames()
330     {
331         if (fieldNames == null)
332         {
333             fieldNames = new ArrayList();
334               fieldNames.add("JobId");
335               fieldNames.add("Second");
336               fieldNames.add("Minute");
337               fieldNames.add("Hour");
338               fieldNames.add("WeekDay");
339               fieldNames.add("DayOfMonth");
340               fieldNames.add("Task");
341               fieldNames.add("Email");
342               fieldNames.add("Property");
343               fieldNames = Collections.unmodifiableList(fieldNames);
344         }
345         return fieldNames;
346     }
347 
348     /***
349      * Retrieves a field from the object by name passed in as a String.
350      *
351      * @param name field name
352      * @return value
353      */
354     public Object getByName(String name)
355     {
356           if (name.equals("JobId"))
357         {
358                 return new Integer(getJobId());
359             }
360           if (name.equals("Second"))
361         {
362                 return new Integer(getSecond());
363             }
364           if (name.equals("Minute"))
365         {
366                 return new Integer(getMinute());
367             }
368           if (name.equals("Hour"))
369         {
370                 return new Integer(getHour());
371             }
372           if (name.equals("WeekDay"))
373         {
374                 return new Integer(getWeekDay());
375             }
376           if (name.equals("DayOfMonth"))
377         {
378                 return new Integer(getDayOfMonth());
379             }
380           if (name.equals("Task"))
381         {
382                 return getTask();
383             }
384           if (name.equals("Email"))
385         {
386                 return getEmail();
387             }
388           if (name.equals("Property"))
389         {
390                 return getProperty();
391             }
392           return null;
393     }
394     
395     /***
396      * Retrieves a field from the object by name passed in
397      * as a String.  The String must be one of the static
398      * Strings defined in this Class' Peer.
399      *
400      * @param name peer name
401      * @return value
402      */
403     public Object getByPeerName(String name)
404     {
405           if (name.equals(JobEntryPeer.JOB_ID))
406         {
407                 return new Integer(getJobId());
408             }
409           if (name.equals(JobEntryPeer.SECOND))
410         {
411                 return new Integer(getSecond());
412             }
413           if (name.equals(JobEntryPeer.MINUTE))
414         {
415                 return new Integer(getMinute());
416             }
417           if (name.equals(JobEntryPeer.HOUR))
418         {
419                 return new Integer(getHour());
420             }
421           if (name.equals(JobEntryPeer.WEEK_DAY))
422         {
423                 return new Integer(getWeekDay());
424             }
425           if (name.equals(JobEntryPeer.DAY_OF_MONTH))
426         {
427                 return new Integer(getDayOfMonth());
428             }
429           if (name.equals(JobEntryPeer.TASK))
430         {
431                 return getTask();
432             }
433           if (name.equals(JobEntryPeer.EMAIL))
434         {
435                 return getEmail();
436             }
437           if (name.equals(JobEntryPeer.PROPERTY))
438         {
439                 return getProperty();
440             }
441           return null;
442     }
443 
444     /***
445      * Retrieves a field from the object by Position as specified
446      * in the xml schema.  Zero-based.
447      *
448      * @param pos position in xml schema
449      * @return value
450      */
451     public Object getByPosition(int pos)
452     {
453             if (pos == 0)
454         {
455                 return new Integer(getJobId());
456             }
457               if (pos == 1)
458         {
459                 return new Integer(getSecond());
460             }
461               if (pos == 2)
462         {
463                 return new Integer(getMinute());
464             }
465               if (pos == 3)
466         {
467                 return new Integer(getHour());
468             }
469               if (pos == 4)
470         {
471                 return new Integer(getWeekDay());
472             }
473               if (pos == 5)
474         {
475                 return new Integer(getDayOfMonth());
476             }
477               if (pos == 6)
478         {
479                 return getTask();
480             }
481               if (pos == 7)
482         {
483                 return getEmail();
484             }
485               if (pos == 8)
486         {
487                 return getProperty();
488             }
489               return null;
490     }
491      
492     /***
493      * Stores the object in the database.  If the object is new,
494      * it inserts it; otherwise an update is performed.
495      *
496      * @throws Exception
497      */
498     public void save() throws Exception
499     {
500           save(JobEntryPeer.getMapBuilder()
501                 .getDatabaseMap().getName());
502       }
503 
504     /***
505      * Stores the object in the database.  If the object is new,
506      * it inserts it; otherwise an update is performed.
507        * Note: this code is here because the method body is
508      * auto-generated conditionally and therefore needs to be
509      * in this file instead of in the super class, BaseObject.
510        *
511      * @param dbName
512      * @throws TorqueException
513      */
514     public void save(String dbName) throws TorqueException
515     {
516         Connection con = null;
517           try
518         {
519             con = Transaction.begin(dbName);
520             save(con);
521             Transaction.commit(con);
522         }
523         catch(TorqueException e)
524         {
525             Transaction.safeRollback(con);
526             throw e;
527         }
528       }
529 
530       /*** flag to prevent endless save loop, if this object is referenced
531         by another object which falls in this transaction. */
532     private boolean alreadyInSave = false;
533       /***
534      * Stores the object in the database.  If the object is new,
535      * it inserts it; otherwise an update is performed.  This method
536      * is meant to be used as part of a transaction, otherwise use
537      * the save() method and the connection details will be handled
538      * internally
539      *
540      * @param con
541      * @throws TorqueException
542      */
543     public void save(Connection con) throws TorqueException
544     {
545           if (!alreadyInSave)
546         {
547             alreadyInSave = true;
548 
549 
550   
551             // If this object has been modified, then save it to the database.
552             if (isModified())
553             {
554                 if (isNew())
555                 {
556                     JobEntryPeer.doInsert((JobEntry) this, con);
557                     setNew(false);
558                 }
559                 else
560                 {
561                     JobEntryPeer.doUpdate((JobEntry) this, con);
562                 }
563             }
564 
565                       alreadyInSave = false;
566         }
567       }
568 
569                   
570       /***
571      * Set the PrimaryKey using ObjectKey.
572      *
573      * @param key jobId ObjectKey
574      */
575     public void setPrimaryKey(ObjectKey key)
576         
577     {
578             setJobId(((NumberKey) key).intValue());
579         }
580 
581     /***
582      * Set the PrimaryKey using a String.
583      *
584      * @param key
585      */
586     public void setPrimaryKey(String key) 
587     {
588             setJobId(Integer.parseInt(key));
589         }
590 
591   
592     /***
593      * returns an id that differentiates this object from others
594      * of its class.
595      */
596     public ObjectKey getPrimaryKey()
597     {
598           return SimpleKey.keyFor(getJobId());
599       }
600  
601 
602     /***
603      * Makes a copy of this object.
604      * It creates a new object filling in the simple attributes.
605        * It then fills all the association collections and sets the
606      * related objects to isNew=true.
607        */
608       public JobEntry copy() throws TorqueException
609     {
610         return copyInto(new JobEntry());
611     }
612   
613     protected JobEntry copyInto(JobEntry copyObj) throws TorqueException
614     {
615           copyObj.setJobId(jobId);
616           copyObj.setSecond(second);
617           copyObj.setMinute(minute);
618           copyObj.setHour(hour);
619           copyObj.setWeekDay(weekDay);
620           copyObj.setDayOfMonth(dayOfMonth);
621           copyObj.setTask(task);
622           copyObj.setEmail(email);
623           copyObj.setProperty(property);
624   
625                             copyObj.setJobId( 0);
626                                                             
627                 return copyObj;
628     }
629 
630     /***
631      * returns a peer instance associated with this om.  Since Peer classes
632      * are not to have any instance attributes, this method returns the
633      * same instance for all member of this class. The method could therefore
634      * be static, but this would prevent one from overriding the behavior.
635      */
636     public JobEntryPeer getPeer()
637     {
638         return peer;
639     }
640 
641     public String toString()
642     {
643         StringBuffer str = new StringBuffer();
644         str.append("JobEntry:\n");
645         str.append("JobId = ")
646                .append(getJobId())
647              .append("\n");
648         str.append("Second = ")
649                .append(getSecond())
650              .append("\n");
651         str.append("Minute = ")
652                .append(getMinute())
653              .append("\n");
654         str.append("Hour = ")
655                .append(getHour())
656              .append("\n");
657         str.append("WeekDay = ")
658                .append(getWeekDay())
659              .append("\n");
660         str.append("DayOfMonth = ")
661                .append(getDayOfMonth())
662              .append("\n");
663         str.append("Task = ")
664                .append(getTask())
665              .append("\n");
666         str.append("Email = ")
667                .append(getEmail())
668              .append("\n");
669         str.append("Property = ")
670                .append("<binary>")
671              .append("\n");
672         return(str.toString());
673     }
674 }