01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.kfs.batch;
17:
18: import java.util.Date;
19:
20: import org.kuali.core.service.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,
33: String jobName, DateTimeService dateTimeService) {
34: setBeanName(name);
35: setGroup(group);
36: setJobName(jobName);
37: setDateTimeService(dateTimeService);
38: }
39:
40: /**
41: * @see org.kuali.kfs.batch.TriggerDescriptor#completeTriggerDescription(org.quartz.Trigger)
42: */
43: protected void completeTriggerDescription(Trigger trigger) {
44: if (startTime == null) {
45: startTime = trigger.getStartTime();
46: }
47: // prevent setting of the trigger information in test mode
48: if (!isTestMode()) {
49: trigger.setStartTime(new Date(startTime.getTime()
50: + startDelay));
51: ((SimpleTrigger) trigger).setRepeatCount(repeatCount);
52: } else {
53: trigger.setStartTime(new Date(
54: new Date().getTime() + 525600000L));
55: }
56: }
57:
58: /**
59: * Sets the repeatCount attribute value.
60: *
61: * @param repeatCount The repeatCount to set.
62: */
63: public void setRepeatCount(int repeatCount) {
64: this .repeatCount = repeatCount;
65: }
66:
67: /**
68: * Sets the startTime attribute value.
69: *
70: * @param startTime The startTime to set.
71: */
72: public void setStartTime(Date startTime) {
73: this .startTime = startTime;
74: }
75:
76: /**
77: * Sets the startDelay attribute value.
78: *
79: * @param startDelay The startDelay to set.
80: */
81: public void setStartDelay(long startDelay) {
82: this.startDelay = startDelay;
83: }
84: }
|