View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.batch;
17  
18  import org.kuali.rice.core.api.datetime.DateTimeService;
19  import org.quartz.CronTrigger;
20  import org.quartz.SimpleTrigger;
21  import org.quartz.Trigger;
22  import org.springframework.beans.factory.BeanNameAware;
23  
24  public abstract class TriggerDescriptor implements BeanNameAware {
25      private String name;
26      private String group;
27      private String jobName;
28      private DateTimeService dateTimeService;
29      private boolean testMode = false;
30  
31      protected abstract void completeTriggerDescription(Trigger trigger);
32  
33      public Trigger getTrigger() {
34          Trigger trigger = null;
35          if (getClass().equals(SimpleTriggerDescriptor.class)) {
36              trigger = new SimpleTrigger(name, group);
37          }
38          else {
39              trigger = new CronTrigger(name, group);
40          }
41          trigger.setJobName(jobName);
42          trigger.setJobGroup(group);
43          trigger.setStartTime(dateTimeService.getCurrentDate());
44          completeTriggerDescription(trigger);
45          return trigger;
46      }
47  
48      /**
49       * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
50       */
51      public void setBeanName(String name) {
52          this.name = name;
53      }
54  
55      /**
56       * Sets the group attribute value.
57       * 
58       * @param group The group to set.
59       */
60      public void setGroup(String group) {
61          this.group = group;
62      }
63  
64      /**
65       * Sets the jobName attribute value.
66       * 
67       * @param jobName The jobName to set.
68       */
69      public void setJobName(String jobName) {
70          this.jobName = jobName;
71      }
72  
73      protected String getJobName() {
74          return jobName;
75      }
76  
77      /**
78       * Sets the dateTimeService attribute value.
79       * 
80       * @param dateTimeService The dateTimeService to set.
81       */
82      public void setDateTimeService(DateTimeService dateTimeService) {
83          this.dateTimeService = dateTimeService;
84      }
85  
86      protected DateTimeService getDateTimeService() {
87          return dateTimeService;
88      }
89  
90      public boolean isTestMode() {
91          return testMode;
92      }
93  
94      public void setTestMode(boolean testMode) {
95          this.testMode = testMode;
96      }
97  }