use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.
the class CompensationUtil method collectCompensateEventSubscriptionsForScope.
/**
* Collect all compensate event subscriptions for scope of given execution.
*/
public static List<EventSubscriptionEntity> collectCompensateEventSubscriptionsForScope(ActivityExecution execution) {
final Map<ScopeImpl, PvmExecutionImpl> scopeExecutionMapping = execution.createActivityExecutionMapping();
ScopeImpl activity = (ScopeImpl) execution.getActivity();
// <LEGACY>: different flow scopes may have the same scope execution =>
// collect subscriptions in a set
final Set<EventSubscriptionEntity> subscriptions = new HashSet<EventSubscriptionEntity>();
TreeVisitor<ScopeImpl> eventSubscriptionCollector = new TreeVisitor<ScopeImpl>() {
@Override
public void visit(ScopeImpl obj) {
PvmExecutionImpl execution = scopeExecutionMapping.get(obj);
subscriptions.addAll(((ExecutionEntity) execution).getCompensateEventSubscriptions());
}
};
new FlowScopeWalker(activity).addPostVisitor(eventSubscriptionCollector).walkUntil(new ReferenceWalker.WalkCondition<ScopeImpl>() {
@Override
public boolean isFulfilled(ScopeImpl element) {
Boolean consumesCompensationProperty = (Boolean) element.getProperty(BpmnParse.PROPERTYNAME_CONSUMES_COMPENSATION);
return consumesCompensationProperty == null || consumesCompensationProperty == Boolean.TRUE;
}
});
return new ArrayList<EventSubscriptionEntity>(subscriptions);
}
use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.
the class MigratingVariableInstance method attachState.
@Override
public void attachState(MigratingScopeInstance owningActivityInstance) {
ExecutionEntity representativeExecution = owningActivityInstance.resolveRepresentativeExecution();
ScopeImpl currentScope = owningActivityInstance.getCurrentScope();
ExecutionEntity newOwningExecution = representativeExecution;
if (currentScope.isScope() && isConcurrentLocalInParentScope) {
newOwningExecution = representativeExecution.getParent();
}
newOwningExecution.addVariableInternal(variable);
}
use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.
the class TransitionInstanceJobHandler method handle.
@Override
public void handle(MigratingInstanceParseContext parseContext, MigratingTransitionInstance transitionInstance, List<JobEntity> elements) {
for (JobEntity job : elements) {
if (!isAsyncContinuation(job)) {
continue;
}
ScopeImpl targetScope = transitionInstance.getTargetScope();
if (targetScope != null) {
JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(transitionInstance.getTargetScope().getId(), job.getJobHandlerType());
MigratingAsyncJobInstance migratingJobInstance = new MigratingAsyncJobInstance(job, targetJobDefinitionEntity, transitionInstance.getTargetScope());
transitionInstance.setDependentJobInstance(migratingJobInstance);
parseContext.submit(migratingJobInstance);
}
parseContext.consume(job);
}
}
use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.
the class TransitionInstanceHandler method handle.
@Override
public void handle(MigratingInstanceParseContext parseContext, TransitionInstance transitionInstance) {
if (!isAsyncTransitionInstance(transitionInstance)) {
return;
}
MigrationInstruction applyingInstruction = parseContext.getInstructionFor(transitionInstance.getActivityId());
ScopeImpl sourceScope = parseContext.getSourceProcessDefinition().findActivity(transitionInstance.getActivityId());
ScopeImpl targetScope = null;
if (applyingInstruction != null) {
String activityId = applyingInstruction.getTargetActivityId();
targetScope = parseContext.getTargetProcessDefinition().findActivity(activityId);
}
ExecutionEntity asyncExecution = Context.getCommandContext().getExecutionManager().findExecutionById(transitionInstance.getExecutionId());
MigratingTransitionInstance migratingTransitionInstance = parseContext.getMigratingProcessInstance().addTransitionInstance(applyingInstruction, transitionInstance, sourceScope, targetScope, asyncExecution);
MigratingActivityInstance parentInstance = parseContext.getMigratingActivityInstanceById(transitionInstance.getParentActivityInstanceId());
migratingTransitionInstance.setParent(parentInstance);
List<JobEntity> jobs = asyncExecution.getJobs();
parseContext.handleDependentTransitionInstanceJobs(migratingTransitionInstance, jobs);
parseContext.handleDependentVariables(migratingTransitionInstance, collectTransitionInstanceVariables(migratingTransitionInstance));
}
use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.
the class VariableConflictActivityInstanceValidator method validate.
@Override
public void validate(MigratingActivityInstance migratingInstance, MigratingProcessInstance migratingProcessInstance, MigratingActivityInstanceValidationReportImpl instanceReport) {
ScopeImpl sourceScope = migratingInstance.getSourceScope();
ScopeImpl targetScope = migratingInstance.getTargetScope();
if (migratingInstance.migrates()) {
boolean becomesNonScope = sourceScope.isScope() && !targetScope.isScope();
if (becomesNonScope) {
Map<String, List<MigratingVariableInstance>> dependentVariablesByName = getMigratingVariableInstancesByName(migratingInstance);
for (String variableName : dependentVariablesByName.keySet()) {
if (dependentVariablesByName.get(variableName).size() > 1) {
instanceReport.addFailure("The variable '" + variableName + "' exists in both, this scope and " + "concurrent local in the parent scope. " + "Migrating to a non-scope activity would overwrite one of them.");
}
}
}
}
}
Aggregations