2 * ============LICENSE_START========================================================================
\r
3 * ONAP : tr-069-adapter
\r
4 * =================================================================================================
\r
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
\r
6 * =================================================================================================
\r
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
\r
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
\r
9 * may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
\r
14 * either express or implied. See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
16 * ===============LICENSE_END=======================================================================
\r
19 package org.commscope.tr069adapter.common.scheduler;
\r
21 import java.io.Serializable;
\r
22 import java.util.Date;
\r
24 import org.apache.logging.log4j.core.util.CronExpression;
\r
26 public class TriggerInfo implements Serializable {
\r
31 private static final long serialVersionUID = 6020368636888997385L;
\r
34 * Date representing the start of the job that is to be scheduled. If not provided it assumes the
\r
35 * current time as the start time.
\r
37 private Date startDate = null;
\r
40 * Object which represent the time unit in which the interval to be calculated for periodic jobs.
\r
43 private TimeUnit timeUnit = TimeUnit.DAYS;
\r
46 * long represents the interval.Which scheduling the jobs this property along with timeUnit is
\r
47 * used to calculate the interval in between job executions for periodic jobs.
\r
49 private long interval = -1;
\r
52 * Date representing the end date of the scheduled periodic jobs. If there is not end date is
\r
53 * provided then scheduling will be executed forever for every periodic interval.Periodic interval
\r
54 * is calculated using interval and Timeunit properties of this object.
\r
56 private Date endDate = null;
\r
59 * This string representing valid cron expression to run Cron Triggger type of jobs. If the string
\r
60 * which is set is not a valid cron expression it will throw an scheduler exception indicating
\r
61 * invalid cron expression..
\r
63 private String cronExpr = null;
\r
65 private Date nextFireTime = null;
\r
67 public Date getNextFireTime() {
\r
68 return nextFireTime;
\r
71 public void setNextFireTime(Date nextFireTime) {
\r
72 this.nextFireTime = nextFireTime;
\r
75 public Date getEndDate() {
\r
79 public void setEndDate(Date endDate) {
\r
80 this.endDate = endDate;
\r
83 public String getCronExpr() {
\r
87 public void setCronExpr(String cronExpr) throws SchedulerException {
\r
89 new CronExpression(cronExpr);
\r
90 } catch (Exception excep) {
\r
91 throw new SchedulerException(SchedulerError.INVALID_CRON_EXPRESSION);
\r
93 this.cronExpr = cronExpr;
\r
96 public Date getStartDate() {
\r
101 public void setStartDate(Date startDate) {
\r
102 this.startDate = startDate;
\r
105 public TimeUnit getTimeUnit() {
\r
109 public void setTimeUnit(TimeUnit timeUnit) {
\r
110 this.timeUnit = timeUnit;
\r
113 public long getInterval() {
\r
117 public void setInterval(long interval) throws SchedulerException {
\r
119 throw new SchedulerException(SchedulerError.INVALID_TIME_INTERVAL);
\r
120 this.interval = interval;
\r
123 public TriggerInfo() {}
\r
125 public TriggerInfo(Date startDate) {
\r
126 this.startDate = startDate;
\r
129 public TriggerInfo(Date startDate, long interval) throws SchedulerException {
\r
132 throw new SchedulerException(SchedulerError.INVALID_TIME_INTERVAL);
\r
133 this.interval = interval;
\r
136 public TriggerInfo(Date startDate, Date endDate, long interval) throws SchedulerException {
\r
137 this(startDate, interval);
\r
139 if (endDate.getTime() < startDate.getTime())
\r
140 throw new SchedulerException(SchedulerError.INVALID_ENDDATE);
\r
141 this.endDate = endDate;
\r
145 public TriggerInfo(String cronExpression) throws SchedulerException {
\r
147 new CronExpression(cronExpression);
\r
148 } catch (Exception excep) {
\r
149 throw new SchedulerException(SchedulerError.INVALID_CRON_EXPRESSION);
\r
151 this.cronExpr = cronExpression;
\r