use of org.activiti.engine.delegate.VariableScope in project Activiti by Activiti.
the class TimerEntity method restoreExtraData.
protected void restoreExtraData(CommandContext commandContext, String jobHandlerConfiguration) {
String embededActivityId = jobHandlerConfiguration;
if (jobHandlerType.equalsIgnoreCase(TimerExecuteNestedActivityJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerCatchIntermediateEventJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerStartEventJobHandler.TYPE)) {
embededActivityId = TimerEventHandler.getActivityIdFromConfiguration(jobHandlerConfiguration);
String endDateExpressionString = TimerEventHandler.getEndDateFromConfiguration(jobHandlerConfiguration);
if (endDateExpressionString != null) {
Expression endDateExpression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(endDateExpressionString);
String endDateString = null;
BusinessCalendar businessCalendar = Context.getProcessEngineConfiguration().getBusinessCalendarManager().getBusinessCalendar(getBusinessCalendarName(TimerEventHandler.geCalendarNameFromConfiguration(jobHandlerConfiguration)));
VariableScope executionEntity = null;
if (executionId != null) {
executionEntity = commandContext.getExecutionEntityManager().findExecutionById(executionId);
}
if (executionEntity == null) {
executionEntity = NoExecutionVariableScope.getSharedInstance();
}
if (endDateExpression != null) {
Object endDateValue = endDateExpression.getValue(executionEntity);
if (endDateValue instanceof String) {
endDateString = (String) endDateValue;
} else if (endDateValue instanceof Date) {
endDate = (Date) endDateValue;
} else {
throw new ActivitiException("Timer '" + ((ExecutionEntity) executionEntity).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 (endDate == null) {
endDate = businessCalendar.resolveEndDate(endDateString);
}
}
}
}
if (processDefinitionId != null) {
ProcessDefinition definition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
maxIterations = checkStartEventDefinitions(definition, embededActivityId);
if (maxIterations <= 1) {
maxIterations = checkBoundaryEventsDefinitions(definition, embededActivityId);
}
} else {
maxIterations = 1;
}
}
use of org.activiti.engine.delegate.VariableScope in project Activiti by Activiti.
the class TimerEntity method getBusinessCalendarName.
protected String getBusinessCalendarName(String calendarName) {
String businessCalendarName = CycleBusinessCalendar.NAME;
if (StringUtils.isNotEmpty(calendarName)) {
VariableScope execution = NoExecutionVariableScope.getSharedInstance();
if (StringUtils.isNotEmpty(this.executionId)) {
execution = Context.getCommandContext().getExecutionEntityManager().findExecutionById(this.executionId);
}
businessCalendarName = (String) Context.getProcessEngineConfiguration().getExpressionManager().createExpression(calendarName).getValue(execution);
}
return businessCalendarName;
}
use of org.activiti.engine.delegate.VariableScope in project Activiti by Activiti.
the class ScriptEventHandler method handle.
@Override
public void handle(SimulationEvent event) {
ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();
VariableScope execution = SimulationRunContext.getExecution();
try {
scriptingEngines.evaluate((String) event.getProperty(this.scriptPropertyName), language, execution, false);
} catch (ActivitiException e) {
log.warn("Exception while executing simulation event " + event + " scriptPropertyName :" + this.scriptPropertyName + "\n script: " + event.getProperty(this.scriptPropertyName) + "\n exception is:" + e.getMessage());
throw e;
}
}
use of org.activiti.engine.delegate.VariableScope in project Activiti by Activiti.
the class Assignment method evaluate.
public void evaluate(ActivityExecution execution) {
VariableScope variableScope = (VariableScope) execution;
Object value = this.fromExpression.getValue(variableScope);
this.toExpression.setValue(value, variableScope);
}
use of org.activiti.engine.delegate.VariableScope in project CzechIdMng by bcvsolutions.
the class AbstractApprovableEventProcessor method process.
@Override
public EventResult<DTO> process(EntityEvent<DTO> event) {
Map<String, Object> variables = new HashMap<>();
variables.put(EntityEvent.EVENT_PROPERTY, event);
//
ProcessInstance processInstance = processInstance(variables);
//
boolean suspend = true;
if (processInstance.isEnded()) {
suspend = false;
} else if (processInstance instanceof VariableScope) {
Object skipApproving = ((VariableScope) processInstance).getVariable(WF_VARIABLE_SKIP_APPROVING);
if (skipApproving instanceof Boolean && Boolean.TRUE.equals(skipApproving)) {
suspend = false;
}
}
//
return new DefaultEventResult.Builder<>(event, this).setSuspended(suspend).setResult(getResult(processInstance)).build();
}
Aggregations