Search in sources :

Example 16 with EventSubscriptionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.

the class ConditionalStartEventTest method testEventSubscriptionAfterDeleteLatestProcessVersion.

@Test
@Ignore("CAM-8666")
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/conditional/ConditionalStartEventTest.testSingleConditionalStartEvent.bpmn20.xml")
public void testEventSubscriptionAfterDeleteLatestProcessVersion() {
    // given a deployed process
    ProcessDefinition processDefinitionV1 = repositoryService.createProcessDefinitionQuery().singleResult();
    assertNotNull(processDefinitionV1);
    // deploy second version of the process
    String deploymentId = testRule.deploy(SINGLE_CONDITIONAL_XML).getId();
    // when
    repositoryService.deleteDeployment(deploymentId, true);
    // then
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(CONDITIONAL_EVENT_PROCESS).singleResult();
    assertEquals(processDefinitionV1.getId(), processDefinition.getId());
    EventSubscriptionEntity eventSubscription = (EventSubscriptionEntity) runtimeService.createEventSubscriptionQuery().singleResult();
    assertNotNull(eventSubscription);
    assertEquals(processDefinitionV1.getId(), eventSubscription.getConfiguration());
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity) Ignore(org.junit.Ignore) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 17 with EventSubscriptionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.

the class CompensationEventSubscriptionWalker method nextElements.

@Override
protected Collection<EventSubscriptionEntity> nextElements() {
    EventSubscriptionEntity eventSubscriptionEntity = getCurrentElement();
    ExecutionEntity compensatingExecution = CompensationUtil.getCompensatingExecution(eventSubscriptionEntity);
    if (compensatingExecution != null) {
        return compensatingExecution.getCompensateEventSubscriptions();
    } else {
        return Collections.emptyList();
    }
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 18 with EventSubscriptionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.

the class MigratingInstanceParser method parse.

public MigratingProcessInstance parse(String processInstanceId, MigrationPlan migrationPlan, MigratingProcessInstanceValidationReportImpl processInstanceReport) {
    CommandContext commandContext = Context.getCommandContext();
    List<EventSubscriptionEntity> eventSubscriptions = fetchEventSubscriptions(commandContext, processInstanceId);
    List<ExecutionEntity> executions = fetchExecutions(commandContext, processInstanceId);
    List<ExternalTaskEntity> externalTasks = fetchExternalTasks(commandContext, processInstanceId);
    List<IncidentEntity> incidents = fetchIncidents(commandContext, processInstanceId);
    List<JobEntity> jobs = fetchJobs(commandContext, processInstanceId);
    List<TaskEntity> tasks = fetchTasks(commandContext, processInstanceId);
    List<VariableInstanceEntity> variables = fetchVariables(commandContext, processInstanceId);
    ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId);
    processInstance.restoreProcessInstance(executions, eventSubscriptions, variables, tasks, jobs, incidents, externalTasks);
    ProcessDefinitionEntity targetProcessDefinition = Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedProcessDefinitionById(migrationPlan.getTargetProcessDefinitionId());
    List<JobDefinitionEntity> targetJobDefinitions = fetchJobDefinitions(commandContext, targetProcessDefinition.getId());
    final MigratingInstanceParseContext parseContext = new MigratingInstanceParseContext(this, migrationPlan, processInstance, targetProcessDefinition).eventSubscriptions(eventSubscriptions).externalTasks(externalTasks).incidents(incidents).jobs(jobs).tasks(tasks).targetJobDefinitions(targetJobDefinitions).variables(variables);
    ActivityInstance activityInstance = engine.getRuntimeService().getActivityInstance(processInstanceId);
    ActivityInstanceWalker activityInstanceWalker = new ActivityInstanceWalker(activityInstance);
    activityInstanceWalker.addPreVisitor(new TreeVisitor<ActivityInstance>() {

        @Override
        public void visit(ActivityInstance obj) {
            activityInstanceHandler.handle(parseContext, obj);
        }
    });
    activityInstanceWalker.walkWhile();
    CompensationEventSubscriptionWalker compensateSubscriptionsWalker = new CompensationEventSubscriptionWalker(parseContext.getMigratingActivityInstances());
    compensateSubscriptionsWalker.addPreVisitor(new TreeVisitor<EventSubscriptionEntity>() {

        @Override
        public void visit(EventSubscriptionEntity obj) {
            compensationInstanceHandler.handle(parseContext, obj);
        }
    });
    compensateSubscriptionsWalker.walkWhile();
    for (IncidentEntity incidentEntity : incidents) {
        incidentHandler.handle(parseContext, incidentEntity);
    }
    parseContext.validateNoEntitiesLeft(processInstanceReport);
    return parseContext.getMigratingProcessInstance();
}
Also used : ExternalTaskEntity(org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) MigratingActivityInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) VariableInstanceEntity(org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity) JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity) IncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity) ExternalTaskEntity(org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity) JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 19 with EventSubscriptionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.

the class MigrationCompensationInstanceVisitor method instantiateScopes.

@Override
protected void instantiateScopes(MigratingScopeInstance ancestorScopeInstance, MigratingScopeInstanceBranch executionBranch, List<ScopeImpl> scopesToInstantiate) {
    if (scopesToInstantiate.isEmpty()) {
        return;
    }
    ExecutionEntity ancestorScopeExecution = ancestorScopeInstance.resolveRepresentativeExecution();
    ExecutionEntity parentExecution = ancestorScopeExecution;
    for (ScopeImpl scope : scopesToInstantiate) {
        ExecutionEntity compensationScopeExecution = parentExecution.createExecution();
        compensationScopeExecution.setScope(true);
        compensationScopeExecution.setEventScope(true);
        compensationScopeExecution.setActivity((PvmActivity) scope);
        compensationScopeExecution.setActive(false);
        compensationScopeExecution.activityInstanceStarting();
        compensationScopeExecution.enterActivityInstance();
        EventSubscriptionEntity eventSubscription = EventSubscriptionEntity.createAndInsert(parentExecution, EventType.COMPENSATE, (ActivityImpl) scope);
        eventSubscription.setConfiguration(compensationScopeExecution.getId());
        executionBranch.visited(new MigratingEventScopeInstance(eventSubscription, compensationScopeExecution, scope));
        parentExecution = compensationScopeExecution;
    }
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 20 with EventSubscriptionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.

the class DefaultCorrelationHandler method correlateStartMessageByEventSubscription.

protected List<CorrelationHandlerResult> correlateStartMessageByEventSubscription(CommandContext commandContext, String messageName, CorrelationSet correlationSet) {
    List<CorrelationHandlerResult> results = new ArrayList<CorrelationHandlerResult>();
    DeploymentCache deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentCache();
    List<EventSubscriptionEntity> messageEventSubscriptions = findMessageStartEventSubscriptions(commandContext, messageName, correlationSet);
    for (EventSubscriptionEntity messageEventSubscription : messageEventSubscriptions) {
        if (messageEventSubscription.getConfiguration() != null) {
            String processDefinitionId = messageEventSubscription.getConfiguration();
            ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
            // only an active process definition will be returned
            if (processDefinition != null && !processDefinition.isSuspended()) {
                CorrelationHandlerResult result = CorrelationHandlerResult.matchedProcessDefinition(processDefinition, messageEventSubscription.getActivityId());
                results.add(result);
            } else {
                LOG.couldNotFindProcessDefinitionForEventSubscription(messageEventSubscription, processDefinitionId);
            }
        }
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) 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)

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