Search in sources :

Example 26 with ActivityImpl

use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.

the class TimerCatchIntermediateEventJobHandler method execute.

public void execute(TimerJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) {
    String activityId = configuration.getTimerElementKey();
    ActivityImpl intermediateEventActivity = execution.getProcessDefinition().findActivity(activityId);
    ensureNotNull("Error while firing timer: intermediate event activity " + configuration + " not found", "intermediateEventActivity", intermediateEventActivity);
    try {
        if (activityId.equals(execution.getActivityId())) {
            // Regular Intermediate timer catch
            execution.signal("signal", null);
        } else {
            // Event based gateway
            execution.executeEventHandlerActivity(intermediateEventActivity);
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new ProcessEngineException("exception during timer execution: " + e.getMessage(), e);
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 27 with ActivityImpl

use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.

the class TimerExecuteNestedActivityJobHandler method execute.

public void execute(TimerJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) {
    String activityId = configuration.getTimerElementKey();
    ActivityImpl activity = execution.getProcessDefinition().findActivity(activityId);
    ensureNotNull("Error while firing timer: boundary event activity " + configuration + " not found", "boundary event activity", activity);
    try {
        execution.executeEventHandlerActivity(activity);
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new ProcessEngineException("exception during timer execution: " + e.getMessage(), e);
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 28 with ActivityImpl

use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.

the class CompensationInstanceHandler method createMigratingEventScopeInstance.

protected MigratingProcessElementInstance createMigratingEventScopeInstance(MigratingInstanceParseContext parseContext, EventSubscriptionEntity element) {
    ActivityImpl compensatingActivity = parseContext.getSourceProcessDefinition().findActivity(element.getActivityId());
    MigrationInstruction migrationInstruction = getMigrationInstruction(parseContext, compensatingActivity);
    ActivityImpl eventSubscriptionTargetScope = null;
    if (migrationInstruction != null) {
        if (compensatingActivity.isCompensationHandler()) {
            ActivityImpl targetEventScope = (ActivityImpl) parseContext.getTargetActivity(migrationInstruction).getEventScope();
            eventSubscriptionTargetScope = targetEventScope.findCompensationHandler();
        } else {
            eventSubscriptionTargetScope = parseContext.getTargetActivity(migrationInstruction);
        }
    }
    ExecutionEntity eventScopeExecution = CompensationUtil.getCompensatingExecution(element);
    MigrationInstruction eventScopeInstruction = parseContext.findSingleMigrationInstruction(eventScopeExecution.getActivityId());
    ActivityImpl targetScope = parseContext.getTargetActivity(eventScopeInstruction);
    MigratingEventScopeInstance migratingCompensationInstance = parseContext.getMigratingProcessInstance().addEventScopeInstance(eventScopeInstruction, eventScopeExecution, eventScopeExecution.getActivity(), targetScope, migrationInstruction, element, compensatingActivity, eventSubscriptionTargetScope);
    parseContext.consume(element);
    parseContext.submit(migratingCompensationInstance);
    parseDependentEntities(parseContext, migratingCompensationInstance);
    return migratingCompensationInstance;
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) MigratingEventScopeInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingEventScopeInstance)

Example 29 with ActivityImpl

use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.

the class CompensationInstanceHandler method getMigrationInstruction.

protected MigrationInstruction getMigrationInstruction(MigratingInstanceParseContext parseContext, ActivityImpl activity) {
    if (activity.isCompensationHandler()) {
        Properties compensationHandlerProperties = activity.getProperties();
        ActivityImpl eventTrigger = compensationHandlerProperties.get(BpmnProperties.COMPENSATION_BOUNDARY_EVENT);
        if (eventTrigger == null) {
            eventTrigger = compensationHandlerProperties.get(BpmnProperties.INITIAL_ACTIVITY);
        }
        return parseContext.findSingleMigrationInstruction(eventTrigger.getActivityId());
    } else {
        return parseContext.findSingleMigrationInstruction(activity.getActivityId());
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) BpmnProperties(org.camunda.bpm.engine.impl.bpmn.helper.BpmnProperties) Properties(org.camunda.bpm.engine.impl.core.model.Properties)

Example 30 with ActivityImpl

use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.

the class ActivityInstanceJobHandler method handle.

@Override
public void handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance activityInstance, List<JobEntity> elements) {
    Map<String, TimerDeclarationImpl> timerDeclarationsInEventScope = getTimerDeclarationsByTriggeringActivity(activityInstance.getTargetScope());
    for (JobEntity job : elements) {
        if (!isTimerJob(job)) {
            // skip non timer jobs
            continue;
        }
        MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(job.getActivityId());
        ActivityImpl targetActivity = parseContext.getTargetActivity(migrationInstruction);
        if (targetActivity != null && activityInstance.migratesTo(targetActivity.getEventScope())) {
            // the timer job is migrated
            JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(targetActivity.getActivityId(), job.getJobHandlerType());
            TimerDeclarationImpl targetTimerDeclaration = timerDeclarationsInEventScope.remove(targetActivity.getId());
            MigratingJobInstance migratingTimerJobInstance = new MigratingTimerJobInstance(job, targetJobDefinitionEntity, targetActivity, migrationInstruction.isUpdateEventTrigger(), targetTimerDeclaration);
            activityInstance.addMigratingDependentInstance(migratingTimerJobInstance);
            parseContext.submit(migratingTimerJobInstance);
        } else {
            // the timer job is removed
            MigratingJobInstance removingJobInstance = new MigratingTimerJobInstance(job);
            activityInstance.addRemovingDependentInstance(removingJobInstance);
            parseContext.submit(removingJobInstance);
        }
        parseContext.consume(job);
    }
    if (activityInstance.migrates()) {
        addEmergingTimerJobs(activityInstance, timerDeclarationsInEventScope.values());
    }
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) TimerDeclarationImpl(org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl) JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) MigratingJobInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance) MigratingTimerJobInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingTimerJobInstance)

Aggregations

ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)94 Deployment (org.camunda.bpm.engine.test.Deployment)29 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)12 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)12 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)10 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)10 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)8 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)8 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)7 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)7 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)5 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)4 ArrayList (java.util.ArrayList)3 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)3 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)3 ConditionalEventBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior)2 MultiInstanceActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior)2 SequentialMultiInstanceActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.SequentialMultiInstanceActivityBehavior)2 CoreModelElement (org.camunda.bpm.engine.impl.core.model.CoreModelElement)2 AsyncContinuationConfiguration (org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)2