use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class SignalEventReceivedCmd method getProcessDefinitionsOfSubscriptions.
protected Map<String, ProcessDefinitionEntity> getProcessDefinitionsOfSubscriptions(List<EventSubscriptionEntity> startSignalEventSubscriptions) {
DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache();
Map<String, ProcessDefinitionEntity> processDefinitions = new HashMap<String, ProcessDefinitionEntity>();
for (EventSubscriptionEntity eventSubscription : startSignalEventSubscriptions) {
String processDefinitionId = eventSubscription.getConfiguration();
ensureNotNull("Configuration of signal start event subscription '" + eventSubscription.getId() + "' contains no process definition id.", processDefinitionId);
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition != null && !processDefinition.isSuspended()) {
processDefinitions.put(eventSubscription.getId(), processDefinition);
}
}
return processDefinitions;
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class CompensationEventSubscriptionWalker method collectCompensationEventSubscriptions.
protected static List<EventSubscriptionEntity> collectCompensationEventSubscriptions(Collection<MigratingActivityInstance> activityInstances) {
List<EventSubscriptionEntity> eventSubscriptions = new ArrayList<EventSubscriptionEntity>();
for (MigratingActivityInstance activityInstance : activityInstances) {
if (activityInstance.getSourceScope().isScope()) {
ExecutionEntity scopeExecution = activityInstance.resolveRepresentativeExecution();
eventSubscriptions.addAll(scopeExecution.getCompensateEventSubscriptions());
}
}
return eventSubscriptions;
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class EventSubscriptionInstanceHandler method handle.
@Override
public void handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance owningInstance, List<EventSubscriptionEntity> elements) {
Map<String, EventSubscriptionDeclaration> targetDeclarations = getDeclarationsByTriggeringActivity(owningInstance.getTargetScope());
for (EventSubscriptionEntity eventSubscription : elements) {
if (!getSupportedEventTypes().contains(eventSubscription.getEventType())) {
// ignore unsupported event subscriptions
continue;
}
MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(eventSubscription.getActivityId());
ActivityImpl targetActivity = parseContext.getTargetActivity(migrationInstruction);
if (targetActivity != null && owningInstance.migratesTo(targetActivity.getEventScope())) {
// the event subscription is migrated
EventSubscriptionDeclaration targetDeclaration = targetDeclarations.remove(targetActivity.getId());
owningInstance.addMigratingDependentInstance(new MigratingEventSubscriptionInstance(eventSubscription, targetActivity, migrationInstruction.isUpdateEventTrigger(), targetDeclaration));
} else {
// the event subscription will be removed
owningInstance.addRemovingDependentInstance(new MigratingEventSubscriptionInstance(eventSubscription));
}
parseContext.consume(eventSubscription);
}
if (owningInstance.migrates()) {
addEmergingEventSubscriptions(owningInstance, targetDeclarations);
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class ProcessEventJobHandler method execute.
public void execute(EventSubscriptionJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) {
// lookup subscription:
String eventSubscriptionId = configuration.getEventSubscriptionId();
EventSubscriptionEntity eventSubscription = commandContext.getEventSubscriptionManager().findEventSubscriptionById(eventSubscriptionId);
// if event subscription is null, ignore
if (eventSubscription != null) {
eventSubscription.eventReceived(null, false);
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class ConditionalStartEventTest method testUpdateProcessVersionCancelsSubscriptions.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/conditional/ConditionalStartEventTest.testSingleConditionalStartEvent.bpmn20.xml")
public void testUpdateProcessVersionCancelsSubscriptions() {
// given a deployed process
List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list();
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list();
assertEquals(1, eventSubscriptions.size());
assertEquals(1, processDefinitions.size());
// when
testRule.deploy("org/camunda/bpm/engine/test/bpmn/event/conditional/ConditionalStartEventTest.testSingleConditionalStartEvent.bpmn20.xml");
// then
List<EventSubscription> newEventSubscriptions = runtimeService.createEventSubscriptionQuery().list();
List<ProcessDefinition> newProcessDefinitions = repositoryService.createProcessDefinitionQuery().list();
assertEquals(1, newEventSubscriptions.size());
assertEquals(2, newProcessDefinitions.size());
for (ProcessDefinition processDefinition : newProcessDefinitions) {
if (processDefinition.getVersion() == 1) {
for (EventSubscription subscription : newEventSubscriptions) {
EventSubscriptionEntity subscriptionEntity = (EventSubscriptionEntity) subscription;
assertFalse(subscriptionEntity.getConfiguration().equals(processDefinition.getId()));
}
} else {
for (EventSubscription subscription : newEventSubscriptions) {
EventSubscriptionEntity subscriptionEntity = (EventSubscriptionEntity) subscription;
assertTrue(subscriptionEntity.getConfiguration().equals(processDefinition.getId()));
}
}
}
assertFalse(eventSubscriptions.equals(newEventSubscriptions));
}
Aggregations