use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class SignalEventReceivedCmd method startProcessInstances.
private void startProcessInstances(List<EventSubscriptionEntity> startSignalEventSubscriptions, Map<String, ProcessDefinitionEntity> processDefinitions) {
for (EventSubscriptionEntity signalStartEventSubscription : startSignalEventSubscriptions) {
ProcessDefinitionEntity processDefinition = processDefinitions.get(signalStartEventSubscription.getId());
if (processDefinition != null) {
ActivityImpl signalStartEvent = processDefinition.findActivity(signalStartEventSubscription.getActivityId());
PvmProcessInstance processInstance = processDefinition.createProcessInstanceForInitial(signalStartEvent);
processInstance.start(builder.getVariables());
}
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class SignalEventReceivedCmd method sendSignalToExecution.
protected void sendSignalToExecution(CommandContext commandContext, String signalName, String executionId) {
ExecutionManager executionManager = commandContext.getExecutionManager();
ExecutionEntity execution = executionManager.findExecutionById(executionId);
ensureNotNull("Cannot find execution with id '" + executionId + "'", "execution", execution);
EventSubscriptionManager eventSubscriptionManager = commandContext.getEventSubscriptionManager();
List<EventSubscriptionEntity> signalEvents = eventSubscriptionManager.findSignalEventSubscriptionsByNameAndExecution(signalName, executionId);
ensureNotEmpty("Execution '" + executionId + "' has not subscribed to a signal event with name '" + signalName + "'.", signalEvents);
checkAuthorizationOfCatchSignals(commandContext, signalEvents);
notifyExecutions(signalEvents);
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class CompensationEventHandler method handleEvent.
@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, String businessKey, CommandContext commandContext) {
eventSubscription.delete();
String configuration = eventSubscription.getConfiguration();
ensureNotNull("Compensating execution not set for compensate event subscription with id " + eventSubscription.getId(), "configuration", configuration);
ExecutionEntity compensatingExecution = commandContext.getExecutionManager().findExecutionById(configuration);
ActivityImpl compensationHandler = eventSubscription.getActivity();
// activate execution
compensatingExecution.setActive(true);
if (compensatingExecution.getActivity().getActivityBehavior() instanceof CompositeActivityBehavior) {
compensatingExecution.getParent().setActivityInstanceId(compensatingExecution.getActivityInstanceId());
}
if (compensationHandler.isScope() && !compensationHandler.isCompensationHandler()) {
// descend into scope:
List<EventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions();
CompensationUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);
} else {
try {
if (compensationHandler.isSubProcessScope() && compensationHandler.isTriggeredByEvent()) {
compensatingExecution.executeActivity(compensationHandler);
} else {
// since we already have a scope execution, we don't need to create another one
// for a simple scoped compensation handler
compensatingExecution.setActivity(compensationHandler);
compensatingExecution.performOperation(PvmAtomicOperation.ACTIVITY_START);
}
} catch (Exception e) {
throw new ProcessEngineException("Error while handling compensation event " + eventSubscription, e);
}
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class LegacyBehavior method removeLegacySubscriptionOnParent.
/**
* <p>Required for migrating active sequential MI receive tasks. These activities were formerly not scope,
* but are now. This has the following implications:
*
* <p>Before migration:
* <ul><li> the event subscription is attached to the miBody scope execution</ul>
*
* <p>After migration:
* <ul><li> a new subscription is created for every instance
* <li> the new subscription is attached to a dedicated scope execution as a child of the miBody scope
* execution</ul>
*
* <p>Thus, this method removes the subscription on the miBody scope
*/
public static void removeLegacySubscriptionOnParent(ExecutionEntity execution, EventSubscriptionEntity eventSubscription) {
ActivityImpl activity = execution.getActivity();
if (activity == null) {
return;
}
ActivityBehavior behavior = activity.getActivityBehavior();
ActivityBehavior parentBehavior = (ActivityBehavior) (activity.getFlowScope() != null ? activity.getFlowScope().getActivityBehavior() : null);
if (behavior instanceof ReceiveTaskActivityBehavior && parentBehavior instanceof MultiInstanceActivityBehavior) {
List<EventSubscriptionEntity> parentSubscriptions = execution.getParent().getEventSubscriptions();
for (EventSubscriptionEntity subscription : parentSubscriptions) {
// distinguish a boundary event on the mi body with the same message name from the receive task subscription
if (areEqualEventSubscriptions(subscription, eventSubscription)) {
subscription.delete();
}
}
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class DefaultConditionHandler method evaluateConditionStartByEventSubscription.
protected List<ConditionHandlerResult> evaluateConditionStartByEventSubscription(CommandContext commandContext, ConditionSet conditionSet) {
List<EventSubscriptionEntity> subscriptions = findConditionalStartEventSubscriptions(commandContext, conditionSet);
if (subscriptions.isEmpty()) {
throw LOG.exceptionWhenEvaluatingConditionalStartEvent();
}
List<ConditionHandlerResult> results = new ArrayList<ConditionHandlerResult>();
for (EventSubscriptionEntity subscription : subscriptions) {
ProcessDefinitionEntity processDefinition = subscription.getProcessDefinition();
if (!processDefinition.isSuspended()) {
ActivityImpl activity = subscription.getActivity();
if (evaluateCondition(conditionSet, activity)) {
results.add(new ConditionHandlerResult(processDefinition, activity));
}
}
}
return results;
}
Aggregations