Search in sources :

Example 51 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity 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 52 with ExecutionEntity

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

the class MigratingEventScopeInstance method attachState.

@Override
public void attachState(MigratingScopeInstance targetActivityInstance) {
    setParent(targetActivityInstance);
    migratingEventSubscription.attachState(targetActivityInstance);
    ExecutionEntity representativeExecution = targetActivityInstance.resolveRepresentativeExecution();
    eventScopeExecution.setParent(representativeExecution);
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)

Example 53 with ExecutionEntity

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

the class MigratingExternalTaskInstance method attachState.

@Override
public void attachState(MigratingScopeInstance owningInstance) {
    ExecutionEntity representativeExecution = owningInstance.resolveRepresentativeExecution();
    representativeExecution.addExternalTask(externalTask);
    externalTask.setExecution(representativeExecution);
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)

Example 54 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity 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 55 with ExecutionEntity

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

the class TransitionInstanceHandler method collectTransitionInstanceVariables.

protected List<VariableInstanceEntity> collectTransitionInstanceVariables(MigratingTransitionInstance instance) {
    List<VariableInstanceEntity> variables = new ArrayList<VariableInstanceEntity>();
    ExecutionEntity representativeExecution = instance.resolveRepresentativeExecution();
    if (representativeExecution.isConcurrent()) {
        variables.addAll(representativeExecution.getVariablesInternal());
    } else {
        variables.addAll(ActivityInstanceHandler.getConcurrentLocalVariables(representativeExecution));
    }
    return variables;
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ArrayList(java.util.ArrayList) VariableInstanceEntity(org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)

Aggregations

ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)170 Deployment (org.camunda.bpm.engine.test.Deployment)42 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)18 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)17 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)16 Execution (org.camunda.bpm.engine.runtime.Execution)14 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)13 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)12 Task (org.camunda.bpm.engine.task.Task)12 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)10 ArrayList (java.util.ArrayList)9 VariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)9 Test (org.junit.Test)9 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)7 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)7 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)7 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)6 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)5