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 java.util.Date;
19  
20  import org.kuali.rice.core.api.datetime.DateTimeService;
21  import org.quartz.SimpleTrigger;
22  import org.quartz.Trigger;
23  
24  public class SimpleTriggerDescriptor extends TriggerDescriptor {
25      private Date startTime;
26      private long startDelay;
27      private int repeatCount;
28  
29      public SimpleTriggerDescriptor() {
30      }
31  
32      public SimpleTriggerDescriptor(String name, String group, String jobName, DateTimeService dateTimeService) {
33          setBeanName(name);
34          setGroup(group);
35          setJobName(jobName);
36          setDateTimeService(dateTimeService);
37      }
38  
39      /**
40       * @see org.kuali.ole.sys.batch.TriggerDescriptor#completeTriggerDescription(org.quartz.Trigger)
41       */
42      protected void completeTriggerDescription(Trigger trigger) {
43          if (startTime == null) {
44              startTime = trigger.getStartTime();
45          }
46          // prevent setting of the trigger information in test mode
47          if (!isTestMode()) {
48              trigger.setStartTime(new Date(startTime.getTime() + startDelay));
49              ((SimpleTrigger) trigger).setRepeatCount(repeatCount);
50          }
51          else {
52              trigger.setStartTime(new Date(new Date().getTime() + 525600000L));
53          }
54      }
55  
56      /**
57       * Sets the repeatCount attribute value.
58       * 
59       * @param repeatCount The repeatCount to set.
60       */
61      public void setRepeatCount(int repeatCount) {
62          this.repeatCount = repeatCount;
63      }
64  
65      /**
66       * Sets the startTime attribute value.
67       * 
68       * @param startTime The startTime to set.
69       */
70      public void setStartTime(Date startTime) {
71          this.startTime = startTime;
72      }
73  
74      /**
75       * Sets the startDelay attribute value.
76       * 
77       * @param startDelay The startDelay to set.
78       */
79      public void setStartDelay(long startDelay) {
80          this.startDelay = startDelay;
81      }
82  }