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);
}
}
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);
}
}
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;
}
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());
}
}
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());
}
}
Aggregations