Search in sources :

Example 26 with EventSubscriptionEntity

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;
}
Also used : HashMap(java.util.HashMap) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 27 with EventSubscriptionEntity

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;
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ArrayList(java.util.ArrayList) MigratingActivityInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 28 with EventSubscriptionEntity

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);
    }
}
Also used : MigratingEventSubscriptionInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingEventSubscriptionInstance) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) EventSubscriptionDeclaration(org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 29 with EventSubscriptionEntity

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);
    }
}
Also used : EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 30 with EventSubscriptionEntity

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));
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)33 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)8 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)7 ArrayList (java.util.ArrayList)6 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)5 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 EventSubscription (org.camunda.bpm.engine.runtime.EventSubscription)4 Deployment (org.camunda.bpm.engine.test.Deployment)4 EventSubscriptionManager (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager)3 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)2 MigratingActivityInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)2 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)2 CompositeActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior)2 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)2 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 VariableScope (org.camunda.bpm.engine.delegate.VariableScope)1