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;
}
Aggregations