Search in sources :

Example 1 with VariableInstanceEntity

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

the class ParallelMultiInstanceActivityBehavior method onParseMigratingInstance.

@Override
public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) {
    ExecutionEntity scopeExecution = migratingInstance.resolveRepresentativeExecution();
    List<ActivityExecution> concurrentInActiveExecutions = scopeExecution.findInactiveChildExecutions(getInnerActivity((ActivityImpl) migratingInstance.getSourceScope()));
    // them from the parse context here to avoid a validation exception
    for (ActivityExecution execution : concurrentInActiveExecutions) {
        for (VariableInstanceEntity variable : ((ExecutionEntity) execution).getVariablesInternal()) {
            parseContext.consume(variable);
        }
    }
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ActivityExecution(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution) VariableInstanceEntity(org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)

Example 2 with VariableInstanceEntity

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

the class VariableInstanceQueryImpl method executeList.

@Override
public List<VariableInstance> executeList(CommandContext commandContext, Page page) {
    checkQueryOk();
    ensureVariablesInitialized();
    List<VariableInstance> result = commandContext.getVariableInstanceManager().findVariableInstanceByQueryCriteria(this, page);
    if (result == null) {
        return result;
    }
    // iterate over the result array to initialize the value and serialized value of the variable
    for (VariableInstance variableInstance : result) {
        VariableInstanceEntity variableInstanceEntity = (VariableInstanceEntity) variableInstance;
        if (shouldFetchValue(variableInstanceEntity)) {
            try {
                variableInstanceEntity.getTypedValue(isCustomObjectDeserializationEnabled);
            } catch (Exception t) {
                // do not fail if one of the variables fails to load
                LOG.exceptionWhileGettingValueForVariable(t);
            }
        }
    }
    return result;
}
Also used : VariableInstanceEntity(org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance)

Example 3 with VariableInstanceEntity

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

the class CaseExecutionEntity method remove.

// delete/remove ///////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
public void remove() {
    super.remove();
    for (VariableInstanceEntity variableInstance : variableStore.getVariables()) {
        invokeVariableLifecycleListenersDelete(variableInstance, this, Arrays.<VariableInstanceLifecycleListener<CoreVariableInstance>>asList((VariableInstanceLifecycleListener) VariableInstanceEntityPersistenceListener.INSTANCE));
        variableStore.removeVariable(variableInstance.getName());
    }
    CommandContext commandContext = Context.getCommandContext();
    for (CaseSentryPartEntity sentryPart : getCaseSentryParts()) {
        commandContext.getCaseSentryPartManager().deleteSentryPart(sentryPart);
    }
    // finally delete this execution
    commandContext.getCaseExecutionManager().deleteCaseExecution(this);
}
Also used : CoreVariableInstance(org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) VariableInstanceEntity(org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity) VariableInstanceLifecycleListener(org.camunda.bpm.engine.impl.core.variable.scope.VariableInstanceLifecycleListener)

Example 4 with VariableInstanceEntity

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

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

VariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)13 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)9 ArrayList (java.util.ArrayList)3 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)3 CoreVariableInstance (org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance)2 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)2 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)2 VariableInstanceLifecycleListener (org.camunda.bpm.engine.impl.core.variable.scope.VariableInstanceLifecycleListener)1 DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)1 MigratingActivityInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)1 MigratingUserTaskInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingUserTaskInstance)1 MigratingVariableInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingVariableInstance)1 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)1 ExternalTaskEntity (org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity)1 IncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity)1 JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)1 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)1 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)1 ActivityExecution (org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)1 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)1