@Override public Date resolveDuedate(String duedate, int maxIterations) { try { DurationHelper dh = new DurationHelper(duedate, clockReader); return dh.getDateAfter(); } catch (Exception e) { throw new FlowableException("couldn't resolve duedate: " + e.getMessage(), e); } }
public Calendar getCalendarAfter(Calendar time) { if (isRepeat) { return getDateAfterRepeat(time); } // TODO: is this correct? if (end != null) { return end; } return add(start, period); }
public Date getDateAfter() { Calendar date = getCalendarAfter(); return date == null ? null : date.getTime(); }
@Override public Boolean validateDuedate(String duedateDescription, int maxIterations, Date endDate, Date newTimer) { if (endDate != null) { return super.validateDuedate(duedateDescription, maxIterations, endDate, newTimer); } // end date could be part of the cron expression try { if (duedateDescription != null && duedateDescription.startsWith("R")) { return new DurationHelper(duedateDescription, maxIterations, clockReader).isValidDate(newTimer); } else { return true; } } catch (Exception e) { throw new FlowableException("Failed to parse cron expression: " + duedateDescription, e); } }
DurationHelper durationHelper = new DurationHelper(failedJobRetryTimeCycleValue, processEngineConfig.getClock()); int jobRetries = job.getRetries(); if (job.getExceptionMessage() == null) { jobRetries = durationHelper.getTimes(); newJobEntity.setDuedate(durationHelper.getDateAfter()); LOGGER.debug("Applying JobRetryStrategy '{}' the first time for job {} with {} retries", failedJobRetryTimeCycleValue, job.getId(), durationHelper.getTimes());
@Override public Date resolve(String duedateDescription, ClockReader clockReader, TimeZone timeZone) { Calendar nextRun = null; try { if (duedateDescription.startsWith("R")) { nextRun = new DurationHelper(duedateDescription, clockReader).getCalendarAfter(clockReader.getCurrentCalendar(timeZone)); } else { CronExpression cronExpression = new CronExpression(duedateDescription, clockReader); cronExpression.setTimeZone(timeZone); Date nextRunDate = cronExpression.getTimeAfter(clockReader.getCurrentCalendar(timeZone).getTime()); nextRun = new GregorianCalendar(); nextRun.setTime(nextRunDate); } } catch (Exception e) { throw new FlowableException("Failed to parse scheduler expression: " + duedateDescription, e); } return nextRun == null ? null : nextRun.getTime(); }
if (isDuration(expression.get(0))) { period = parsePeriod(expression.get(0)); end = expression.size() == 1 ? null : parseDate(expression.get(1)); } else { start = parseDate(expression.get(0)); if (isDuration(expression.get(1))) { period = parsePeriod(expression.get(1)); } else { end = parseDate(expression.get(1)); period = datatypeFactory.newDuration(end.getTimeInMillis() - start.getTimeInMillis());
private Calendar getDateAfterRepeat(Calendar date) { Calendar current = TimeZoneUtil.convertToTimeZone(start, date.getTimeZone()); if (repeatWithNoBounds) { while (current.before(date) || current.equals(date)) { // As long as current date is not past the engine date, we keep looping Calendar newTime = add(current, period); if (newTime.equals(current) || newTime.before(current)) { break; } current = newTime; } } else { int maxLoops = times; if (maxIterations > 0) { maxLoops = maxIterations - times; } for (int i = 0; i < maxLoops + 1 && !current.after(date); i++) { current = add(current, period); } } return current.before(date) ? date : TimeZoneUtil.convertToTimeZone(current, clockReader.getCurrentTimeZone()); }
String failedJobRetryTimeCycle = activity.getFailedJobRetryTimeCycleValue(); try { DurationHelper durationHelper = new DurationHelper(failedJobRetryTimeCycle, processEngineConfig.getClock()); int jobRetries = job.getRetries(); if (job.getExceptionMessage() == null) { jobRetries = durationHelper.getTimes(); newJobEntity.setDuedate(durationHelper.getDateAfter()); LOGGER.debug("Applying JobRetryStrategy '{}' the first time for job {} with {} retries", failedJobRetryTimeCycle, job.getId(), durationHelper.getTimes());
@Override public Date resolveDuedate(String duedateDescription, int maxIterations) { try { if (duedateDescription != null && duedateDescription.startsWith("R")) { return new DurationHelper(duedateDescription, maxIterations, clockReader).getDateAfter(); } else { CronExpression ce = new CronExpression(duedateDescription, clockReader); return ce.getTimeAfter(clockReader.getCurrentTime()); } } catch (Exception e) { throw new FlowableException("Failed to parse cron expression: " + duedateDescription, e); } }
public Calendar getCalendarAfter() { return getCalendarAfter(clockReader.getCurrentCalendar()); }