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