use of org.camunda.bpm.engine.delegate.VariableScope in project camunda-bpm-platform by camunda.
the class EventSubscriptionDeclaration method createSubscriptionForStartEvent.
public EventSubscriptionEntity createSubscriptionForStartEvent(ProcessDefinitionEntity processDefinition) {
EventSubscriptionEntity eventSubscriptionEntity = new EventSubscriptionEntity(eventType);
VariableScope scopeForExpression = StartProcessVariableScope.getSharedInstance();
String eventName = resolveExpressionOfEventName(scopeForExpression);
eventSubscriptionEntity.setEventName(eventName);
eventSubscriptionEntity.setActivityId(activityId);
eventSubscriptionEntity.setConfiguration(processDefinition.getId());
eventSubscriptionEntity.setTenantId(processDefinition.getTenantId());
return eventSubscriptionEntity;
}
use of org.camunda.bpm.engine.delegate.VariableScope in project camunda-bpm-platform by camunda.
the class DelegateExpressionTaskListener method notify.
public void notify(DelegateTask delegateTask) {
// Note: we can't cache the result of the expression, because the
// execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
VariableScope variableScope = delegateTask.getExecution();
if (variableScope == null) {
variableScope = delegateTask.getCaseExecution();
}
Object delegate = expression.getValue(variableScope);
applyFieldDeclaration(fieldDeclarations, delegate);
if (delegate instanceof TaskListener) {
try {
Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new TaskListenerInvocation((TaskListener) delegate, delegateTask));
} catch (Exception e) {
throw new ProcessEngineException("Exception while invoking TaskListener: " + e.getMessage(), e);
}
} else {
throw new ProcessEngineException("Delegate expression " + expression + " did not resolve to an implementation of " + TaskListener.class);
}
}
use of org.camunda.bpm.engine.delegate.VariableScope in project camunda-bpm-platform by camunda.
the class FormFieldHandler method createFormField.
public FormField createFormField(ExecutionEntity executionEntity) {
FormFieldImpl formField = new FormFieldImpl();
// set id
formField.setId(id);
// set label (evaluate expression)
VariableScope variableScope = executionEntity != null ? executionEntity : StartProcessVariableScope.getSharedInstance();
if (label != null) {
Object labelValueObject = label.getValue(variableScope);
if (labelValueObject != null) {
formField.setLabel(labelValueObject.toString());
}
}
formField.setBusinessKey(businessKey);
// set type
formField.setType(type);
// set default value (evaluate expression)
Object defaultValue = null;
if (defaultValueExpression != null) {
defaultValue = defaultValueExpression.getValue(variableScope);
if (defaultValue != null) {
formField.setDefaultValue(type.convertFormValueToModelValue(defaultValue));
} else {
formField.setDefaultValue(null);
}
}
// value
TypedValue value = variableScope.getVariableTyped(id);
if (value != null) {
formField.setValue(type.convertToFormValue(value));
} else {
// first, need to convert to model value since the default value may be a String Constant specified in the model xml.
TypedValue typedDefaultValue = type.convertToModelValue(Variables.untypedValue(defaultValue));
// now convert to form value
formField.setValue(type.convertToFormValue(typedDefaultValue));
}
// properties
formField.setProperties(properties);
// validation
List<FormFieldValidationConstraint> validationConstraints = formField.getValidationConstraints();
for (FormFieldValidationConstraintHandler validationHandler : validationHandlers) {
// do not add custom validators
if (!"validator".equals(validationHandler.name)) {
validationConstraints.add(validationHandler.createValidationConstraint(executionEntity));
}
}
return formField;
}
use of org.camunda.bpm.engine.delegate.VariableScope 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);
}
}
}
use of org.camunda.bpm.engine.delegate.VariableScope in project camunda-bpm-platform by camunda.
the class VariableScopeElResolver method setValue.
public void setValue(ELContext context, Object base, Object property, Object value) {
if (base == null) {
String variable = (String) property;
Object object = context.getContext(VariableScope.class);
if (object != null) {
VariableScope variableScope = (VariableScope) object;
if (variableScope.hasVariable(variable)) {
variableScope.setVariable(variable, value);
}
}
}
}
Aggregations