use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class UelExpressionCondition method evaluate.
public boolean evaluate(String sequenceFlowId, DelegateExecution execution) {
String conditionExpression = null;
if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) {
ObjectNode elementProperties = Context.getBpmnOverrideElementProperties(sequenceFlowId, execution.getProcessDefinitionId());
conditionExpression = getActiveValue(initialConditionExpression, DynamicBpmnConstants.SEQUENCE_FLOW_CONDITION, elementProperties);
} else {
conditionExpression = initialConditionExpression;
}
Expression expression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(conditionExpression);
Object result = expression.getValue(execution);
if (result == null) {
throw new ActivitiException("condition expression returns null");
}
if (!(result instanceof Boolean)) {
throw new ActivitiException("condition expression returns non-Boolean: " + result + " (" + result.getClass().getName() + ")");
}
return (Boolean) result;
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class AbstractEventHandler method handleEvent.
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {
ExecutionEntity execution = eventSubscription.getExecution();
ActivityImpl activity = eventSubscription.getActivity();
if (activity == null) {
throw new ActivitiException("Error while sending signal for event subscription '" + eventSubscription.getId() + "': " + "no activity associated with event subscription");
}
if (payload instanceof Map) {
@SuppressWarnings("unchecked") Map<String, Object> processVariables = (Map<String, Object>) payload;
execution.setVariables(processVariables);
}
ActivityBehavior activityBehavior = activity.getActivityBehavior();
if (activityBehavior instanceof BoundaryEventActivityBehavior || activityBehavior instanceof EventSubProcessStartEventActivityBehavior) {
try {
dispatchActivitiesCanceledIfNeeded(eventSubscription, execution, activity, commandContext);
activityBehavior.execute(execution);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new ActivitiException("exception while sending signal for event subscription '" + eventSubscription + "':" + e.getMessage(), e);
}
} else {
// not boundary
if (!activity.equals(execution.getActivity())) {
execution.setActivity(activity);
}
execution.signal(eventSubscription.getEventName(), payload);
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class CompensationEventHandler method handleEvent.
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {
String configuration = eventSubscription.getConfiguration();
if (configuration == null) {
throw new ActivitiException("Compensating execution not set for compensate event subscription with id " + eventSubscription.getId());
}
ExecutionEntity compensatingExecution = commandContext.getExecutionEntityManager().findExecutionById(configuration);
ActivityImpl compensationHandler = eventSubscription.getActivity();
if ((compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION) == null || !(Boolean) compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION)) && compensationHandler.isScope()) {
// descend into scope:
List<CompensateEventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions();
ScopeUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);
} else {
try {
if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createActivityEvent(ActivitiEventType.ACTIVITY_COMPENSATE, compensationHandler.getId(), (String) compensationHandler.getProperty("name"), compensatingExecution.getId(), compensatingExecution.getProcessInstanceId(), compensatingExecution.getProcessDefinitionId(), (String) compensatingExecution.getActivity().getProperties().get("type"), compensatingExecution.getActivity().getActivityBehavior().getClass().getCanonicalName()));
}
compensatingExecution.setActivity(compensationHandler);
// executing the atomic operation makes sure activity start events are fired
compensatingExecution.performOperation(AtomicOperation.ACTIVITY_START);
} catch (Exception e) {
throw new ActivitiException("Error while handling compensation event " + eventSubscription, e);
}
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class GetRenderedStartFormCmd method execute.
public Object execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("Process Definition '" + processDefinitionId + "' not found", ProcessDefinition.class);
}
StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
if (startFormHandler == null) {
return null;
}
FormEngine formEngine = commandContext.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
if (formEngine == null) {
throw new ActivitiException("No formEngine '" + formEngineName + "' defined process engine configuration");
}
StartFormData startForm = startFormHandler.createStartFormData(processDefinition);
return formEngine.renderStartForm(startForm);
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class DeleteHistoricProcessInstanceCmd method execute.
public Object execute(CommandContext commandContext) {
if (processInstanceId == null) {
throw new ActivitiIllegalArgumentException("processInstanceId is null");
}
// Check if process instance is still running
HistoricProcessInstance instance = commandContext.getHistoricProcessInstanceEntityManager().findHistoricProcessInstance(processInstanceId);
if (instance == null) {
throw new ActivitiObjectNotFoundException("No historic process instance found with id: " + processInstanceId, HistoricProcessInstance.class);
}
if (instance.getEndTime() == null) {
throw new ActivitiException("Process instance is still running, cannot delete historic process instance: " + processInstanceId);
}
commandContext.getHistoricProcessInstanceEntityManager().deleteHistoricProcessInstanceById(processInstanceId);
return null;
}
Aggregations