List of usage examples for org.joda.time Interval Interval
public Interval(Object interval, Chronology chronology)
From source file:com.sos.jobnet.creator.JobNetPlanCreator.java
License:Apache License
public JobNetPlanCreator(JobNetCreatorOptions options) { super(options); DateTime from = new DateTime(); DateTime to = new DateTime(options.TimeHorizon.getEndFromNow()); this.interval4StartTimes = new Interval(from, to); this.startOrder = options.StartOrder.value(); this.jobChain = options.JobChainName.Value(); this.checkFrequency = options.CheckFrequency.value(); this.executor = new JobNetPlanExecutor(options); executor.registerOrderStarter(this); this.jobnetId = options.JobNetId.Value(); this.jobnetParameterName = options.JobNetIdParameterName.Value(); this.checker = new FrequencyChecker(options); this.schedulerId = getOptions().SCHEDULER_ID.Value(); // this.externalUUID = (jobnetId.isEmpty()) ? "" : jobChain + JobNetConstants.JOBNET_ID_DELIMITER + jobnetId; this.createGraph = options.CreateGraph.value(); this.restart = options.StartOption; this.configFile = new File(getOptions().hibernate_connection_config_file.Value()); this.planDbLayer = new JobNetPlanDBLayer(configFile, schedulerId); this.historyDbLayer = new JobNetHistoryDBLayer(configFile, schedulerId); this.nodeDbLayer = new JobNetNodeDBLayer(configFile); this.eventsDbLayer = new EventsDBLayer(configFile); this.liveObjectFactory = options.getLiveConnector().getFactory(); logger.info("Timeinterval to search for start times: " + fmtDateTime.print(from) + " to " + fmtDateTime.print(to));/*from w w w. j a v a 2s . c o m*/ }
From source file:com.sos.jobnet.db.JobNetHistoryDBLayer.java
License:Apache License
public Interval getRunTime(JobNetHistoryDBItem historyRecord) { DateTime fromDate = new DateTime(historyRecord.getStartTime()); DateTime toDate = new DateTime(historyRecord.getRunTime()); return new Interval(fromDate, toDate); }
From source file:com.sos.scheduler.model.objects.IntervalConstants.java
License:Apache License
public Interval getInterval() { DateTime from = new DateTime(); DateTime to = null;//from w w w. ja v a 2s. c o m switch (this) { case CURRENT_DAY: from = from.minusMillis(from.getMillisOfDay()); to = from.plusDays(1); break; case CURRENT_WEEK: from = from.minusMillis(from.getMillisOfDay()).minusDays(from.getDayOfWeek()); to = from.plusWeeks(1); break; case REST_OF_DAY: to = from.minusMillis(from.getMillisOfDay()).plusDays(1); break; case NEXT_24H: to = from.plusDays(1); break; case NEXT_WEEK: to = from.plusWeeks(1); break; } return new Interval(from, to); }
From source file:com.sos.scheduler.model.objects.JSObjHolidays.java
License:Apache License
public boolean isHoliday(DateTime date) { DateTime from = JodaTools.getStartOfDay(date); List<DateTime> result = getHolidays(new Interval(from, from.plusDays(1))); return (result.size() == 0) ? false : true; }
From source file:com.sos.scheduler.model.objects.JSObjMonthdaysDay.java
License:Apache License
@Override public RunTimeElements getRunTimeElements(Interval timeRange) { RunTimeElements result = new RunTimeElements(timeRange); Iterator<Integer> it = getDay().iterator(); while (it.hasNext()) { int day = it.next(); DateTime date = JodaTools.getDayInIntervalOrNull(timeRange, day); while (date != null) { Iterator<Period> itP = getPeriod().iterator(); while (itP.hasNext()) { Period p = itP.next(); JSObjPeriod period = new JSObjPeriod(objFactory); period.setObjectFieldsFrom(p); DateTime start = period.getDtSingleStartOrNull(date); if (start != null && timeRange.contains(start)) result.add(new RunTimeElement(start, period.getWhenHoliday())); }// w w w . ja v a 2 s.c o m DateTime start = JodaTools.getStartOfMonth(date.plusMonths(1)); if (!timeRange.contains(start)) break; Interval i = new Interval(start, timeRange.getEnd()); date = JodaTools.getDayInIntervalOrNull(i, day); } } // Collections.sort(result, DateTimeComparator.getInstance()); return result; }
From source file:com.sos.scheduler.model.objects.JSObjPeriod.java
License:Apache License
public Interval getPeriodOrNull(DateTime date) { Interval result = null;/*from w ww .j a v a 2s. c o m*/ if (getBegin() != null && getEnd() != null) { DateTime begin = getDate(date, getBegin()); DateTime end = getDate(date, getEnd()); result = new Interval(begin, end); } return result; }
From source file:com.sos.scheduler.model.objects.JSObjRunTime.java
License:Apache License
public List<DateTime> getDtSingleStarts(final Interval timeRange) { // get all runtimes one including one day before and one day after the given time range also // because some holiday defintion could move the calculated dates into the original timeRange given // in the parameter (see getStartDatesAwareHolidays) Interval extendedTimeRange = new Interval(timeRange.getStart().minusDays(1), timeRange.getEnd().plusDays(1)); RunTimeElements runTimes = new RunTimeElements(timeRange); runTimes.putAll(getDtWeekdays(extendedTimeRange)); runTimes.putAll(getDtPeriod(extendedTimeRange)); runTimes.putAll(getDtAt(extendedTimeRange)); runTimes.putAll(getDtDate(extendedTimeRange)); runTimes.putAll(getDtMonthdays(extendedTimeRange)); runTimes.putAll(getDtUltimos(extendedTimeRange)); // the single start given in the run_time element is only relevant if no subsequent // period element is given. if (runTimes.size() == 0) { RunTimeElements periodStartTimes = period.getRunTimeElements(extendedTimeRange); runTimes.putAll(periodStartTimes); }//from ww w . j a va 2 s . com List<DateTime> result = new ArrayList<DateTime>(); for (DateTime d : getJsObjHolidays().getStartDatesAwareHolidays(runTimes)) { if (timeRange.contains(d)) // only dates inside the given time range should be in the result set result.add(d); } return result; }
From source file:com.sos.scheduler.model.objects.JSObjUltimosDay.java
License:Apache License
@Override public RunTimeElements getRunTimeElements(Interval timeRange) { RunTimeElements result = new RunTimeElements(timeRange); Iterator<Integer> it = getDay().iterator(); while (it.hasNext()) { int day = it.next(); DateTime date = JodaTools.getDayInIntervalOrNull(timeRange, (day * -1)); while (date != null) { Iterator<Period> itP = getPeriod().iterator(); while (itP.hasNext()) { Period p = itP.next(); JSObjPeriod period = new JSObjPeriod(objFactory); period.setObjectFieldsFrom(p); DateTime start = period.getDtSingleStartOrNull(date); if (start != null && timeRange.contains(start)) result.add(new RunTimeElement(start, period.getWhenHoliday())); }/*from w ww . j a v a 2 s.c o m*/ DateTime start = JodaTools.getStartOfMonth(date.plusMonths(1)); if (!timeRange.contains(start)) break; Interval i = new Interval(start, timeRange.getEnd()); date = JodaTools.getDayInIntervalOrNull(i, day); } } // Collections.sort(result, DateTimeComparator.getInstance()); return result; }
From source file:com.sos.scheduler.model.objects.JSObjWeekday.java
License:Apache License
@Override public RunTimeElements getRunTimeElements(Interval timeRange) { RunTimeElements result = new RunTimeElements(timeRange); int which = Integer.valueOf(getWhich()); Iterator<String> it = getDay().iterator(); while (it.hasNext()) { String dayList = it.next(); List<Integer> weekdays = JodaTools.getJodaWeekdays(dayList); for (int weekday : weekdays) { DateTime d = JodaTools.getWeekdayInIntervalOrNull(timeRange, weekday, which); while (d != null) { Iterator<Period> itP = getPeriod().iterator(); while (itP.hasNext()) { Period p = itP.next(); JSObjPeriod period = new JSObjPeriod(objFactory); period.setObjectFieldsFrom(p); DateTime start = period.getDtSingleStartOrNull(d); if (start != null && timeRange.contains(start)) result.add(new RunTimeElement(start, period.getWhenHoliday())); }//w w w .jav a 2s . co m DateTime start = JodaTools.getStartOfMonth(d.plusMonths(1)); if (!timeRange.contains(start)) break; Interval i = new Interval(start, timeRange.getEnd()); d = JodaTools.getWeekdayInIntervalOrNull(i, weekday, which); } } } // Collections.sort(result, DateTimeComparator.getInstance()); return result; }
From source file:com.sos.scheduler.model.tools.RunTimeElements.java
License:Apache License
public RunTimeElements(DateTime baseDate) { super(DateTimeComparator.getInstance()); DateTime from = JodaTools.getStartOfDay(baseDate); this.timeRange = new Interval(from, from.plusDays(1)); }