Search in sources :

Example 1 with BusinessCalendar

use of org.camunda.bpm.engine.impl.calendar.BusinessCalendar in project camunda-bpm-platform by camunda.

the class TimerDeclarationImpl method initializeConfiguration.

protected void initializeConfiguration(ExecutionEntity context, TimerEntity job) {
    BusinessCalendar businessCalendar = Context.getProcessEngineConfiguration().getBusinessCalendarManager().getBusinessCalendar(type.calendarName);
    if (description == null) {
        throw new ProcessEngineException("Timer '" + context.getActivityId() + "' was not configured with a valid duration/time");
    }
    String dueDateString = null;
    Date duedate = null;
    // ACT-1415: timer-declaration on start-event may contain expressions NOT
    // evaluating variables but other context, evaluating should happen nevertheless
    VariableScope scopeForExpression = context;
    if (scopeForExpression == null) {
        scopeForExpression = StartProcessVariableScope.getSharedInstance();
    }
    Object dueDateValue = description.getValue(scopeForExpression);
    if (dueDateValue instanceof String) {
        dueDateString = (String) dueDateValue;
    } else if (dueDateValue instanceof Date) {
        duedate = (Date) dueDateValue;
    } else {
        throw new ProcessEngineException("Timer '" + context.getActivityId() + "' was not configured with a valid duration/time, either hand in a java.util.Date or a String in format 'yyyy-MM-dd'T'hh:mm:ss'");
    }
    if (duedate == null) {
        duedate = businessCalendar.resolveDuedate(dueDateString);
    }
    job.setDuedate(duedate);
    if (type == TimerDeclarationType.CYCLE && jobHandlerType != TimerCatchIntermediateEventJobHandler.TYPE) {
        // See ACT-1427: A boundary timer with a cancelActivity='true', doesn't need to repeat itself
        if (!isInterruptingTimer) {
            String prepared = prepareRepeat(dueDateString);
            job.setRepeat(prepared);
        }
    }
}
Also used : BusinessCalendar(org.camunda.bpm.engine.impl.calendar.BusinessCalendar) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Date(java.util.Date) VariableScope(org.camunda.bpm.engine.delegate.VariableScope) StartProcessVariableScope(org.camunda.bpm.engine.impl.el.StartProcessVariableScope)

Aggregations

Date (java.util.Date)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 VariableScope (org.camunda.bpm.engine.delegate.VariableScope)1 BusinessCalendar (org.camunda.bpm.engine.impl.calendar.BusinessCalendar)1 StartProcessVariableScope (org.camunda.bpm.engine.impl.el.StartProcessVariableScope)1