Search in sources :

Example 1 with EventSubscriptionDeclaration

use of org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration in project camunda-bpm-platform by camunda.

the class ExecutionEntity method initialize.

// scopes ///////////////////////////////////////////////////////////////////
@Override
@SuppressWarnings("unchecked")
public void initialize() {
    LOG.initializeExecution(this);
    ScopeImpl scope = getScopeActivity();
    ensureParentInitialized();
    List<VariableDeclaration> variableDeclarations = (List<VariableDeclaration>) scope.getProperty(BpmnParse.PROPERTYNAME_VARIABLE_DECLARATIONS);
    if (variableDeclarations != null) {
        for (VariableDeclaration variableDeclaration : variableDeclarations) {
            variableDeclaration.initialize(this, parent);
        }
    }
    if (isProcessInstanceExecution()) {
        String initiatorVariableName = (String) processDefinition.getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME);
        if (initiatorVariableName != null) {
            String authenticatedUserId = Context.getCommandContext().getAuthenticatedUserId();
            setVariable(initiatorVariableName, authenticatedUserId);
        }
    }
    // create event subscriptions for the current scope
    for (EventSubscriptionDeclaration declaration : EventSubscriptionDeclaration.getDeclarationsForScope(scope).values()) {
        if (!declaration.isStartEvent()) {
            declaration.createSubscriptionForExecution(this);
        }
    }
}
Also used : VariableDeclaration(org.camunda.bpm.engine.impl.variable.VariableDeclaration) List(java.util.List) ArrayList(java.util.ArrayList) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) EventSubscriptionDeclaration(org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration)

Example 2 with EventSubscriptionDeclaration

use of org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration 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)

Aggregations

EventSubscriptionDeclaration (org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 MigratingEventSubscriptionInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingEventSubscriptionInstance)1 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)1 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)1 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)1 VariableDeclaration (org.camunda.bpm.engine.impl.variable.VariableDeclaration)1 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)1