001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.sys.batch; 017 018 import java.util.Date; 019 020 import org.kuali.rice.kns.service.DateTimeService; 021 import org.quartz.SimpleTrigger; 022 import org.quartz.Trigger; 023 024 public class SimpleTriggerDescriptor extends TriggerDescriptor { 025 private Date startTime; 026 private long startDelay; 027 private int repeatCount; 028 029 public SimpleTriggerDescriptor() { 030 } 031 032 public SimpleTriggerDescriptor(String name, String group, String jobName, DateTimeService dateTimeService) { 033 setBeanName(name); 034 setGroup(group); 035 setJobName(jobName); 036 setDateTimeService(dateTimeService); 037 } 038 039 /** 040 * @see org.kuali.kfs.sys.batch.TriggerDescriptor#completeTriggerDescription(org.quartz.Trigger) 041 */ 042 protected void completeTriggerDescription(Trigger trigger) { 043 if (startTime == null) { 044 startTime = trigger.getStartTime(); 045 } 046 // prevent setting of the trigger information in test mode 047 if (!isTestMode()) { 048 trigger.setStartTime(new Date(startTime.getTime() + startDelay)); 049 ((SimpleTrigger) trigger).setRepeatCount(repeatCount); 050 } 051 else { 052 trigger.setStartTime(new Date(new Date().getTime() + 525600000L)); 053 } 054 } 055 056 /** 057 * Sets the repeatCount attribute value. 058 * 059 * @param repeatCount The repeatCount to set. 060 */ 061 public void setRepeatCount(int repeatCount) { 062 this.repeatCount = repeatCount; 063 } 064 065 /** 066 * Sets the startTime attribute value. 067 * 068 * @param startTime The startTime to set. 069 */ 070 public void setStartTime(Date startTime) { 071 this.startTime = startTime; 072 } 073 074 /** 075 * Sets the startDelay attribute value. 076 * 077 * @param startDelay The startDelay to set. 078 */ 079 public void setStartDelay(long startDelay) { 080 this.startDelay = startDelay; 081 } 082 }