use of org.camunda.bpm.engine.impl.migration.instance.MigratingTimerJobInstance 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