Search in sources :

Example 1 with TimerDeclarationType

use of org.activiti.engine.impl.jobexecutor.TimerDeclarationType in project Activiti by Activiti.

the class TimerEventDefinitionParseHandler method createTimer.

protected TimerDeclarationImpl createTimer(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition, ScopeImpl timerActivity, String jobHandlerType) {
    TimerDeclarationType type = null;
    Expression expression = null;
    Expression endDate = null;
    Expression calendarName = null;
    ExpressionManager expressionManager = bpmnParse.getExpressionManager();
    if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDate())) {
        // TimeDate
        type = TimerDeclarationType.DATE;
        expression = expressionManager.createExpression(timerEventDefinition.getTimeDate());
    } else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeCycle())) {
        // TimeCycle
        type = TimerDeclarationType.CYCLE;
        expression = expressionManager.createExpression(timerEventDefinition.getTimeCycle());
        //support for endDate
        if (StringUtils.isNotEmpty(timerEventDefinition.getEndDate())) {
            endDate = expressionManager.createExpression(timerEventDefinition.getEndDate());
        }
    } else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDuration())) {
        // TimeDuration
        type = TimerDeclarationType.DURATION;
        expression = expressionManager.createExpression(timerEventDefinition.getTimeDuration());
    }
    if (StringUtils.isNotEmpty(timerEventDefinition.getCalendarName())) {
        calendarName = expressionManager.createExpression(timerEventDefinition.getCalendarName());
    }
    // neither date, cycle or duration configured!
    if (expression == null) {
        logger.warn("Timer needs configuration (either timeDate, timeCycle or timeDuration is needed) (" + timerActivity.getId() + ")");
    }
    String jobHandlerConfiguration = timerActivity.getId();
    if (jobHandlerType.equalsIgnoreCase(TimerExecuteNestedActivityJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerCatchIntermediateEventJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerStartEventJobHandler.TYPE)) {
        jobHandlerConfiguration = TimerStartEventJobHandler.createConfiguration(timerActivity.getId(), endDate, calendarName);
    }
    // Parse the timer declaration
    // TODO move the timer declaration into the bpmn activity or next to the
    // TimerSession
    TimerDeclarationImpl timerDeclaration = new TimerDeclarationImpl(expression, type, jobHandlerType, endDate, calendarName);
    timerDeclaration.setJobHandlerConfiguration(jobHandlerConfiguration);
    timerDeclaration.setExclusive(true);
    return timerDeclaration;
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) TimerDeclarationImpl(org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl) Expression(org.activiti.engine.delegate.Expression) TimerDeclarationType(org.activiti.engine.impl.jobexecutor.TimerDeclarationType)

Aggregations

Expression (org.activiti.engine.delegate.Expression)1 ExpressionManager (org.activiti.engine.impl.el.ExpressionManager)1 TimerDeclarationImpl (org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl)1 TimerDeclarationType (org.activiti.engine.impl.jobexecutor.TimerDeclarationType)1