use of com.serotonin.m2m2.db.dao.migration.MigrationProgressDao.MigrationProgress in project ma-core-public by MangoAutomation.
the class MigrationPointValueDao method postConstruct.
@PostConstruct
private void postConstruct() {
if (env.getProperty("db.migration.startNewMigration", boolean.class, false)) {
migrationProgressDao.deleteAll();
}
if (migrationProgressDao.count() > 0) {
// migration in progress, restore from DB
try (var stream = migrationProgressDao.stream()) {
stream.map(progress -> new MigrationSeries(progress.getSeriesId(), progress.getStatus(), progress.getTimestamp())).forEach(this::addMigration);
}
} else {
// start a new migration, get all points and insert progress items for them
try (var stream = dataPointDao.streamSeriesIds()) {
Stream<MigrationProgress> progressStream = stream.mapToObj(MigrationSeries::new).peek(this::addMigration).map(migration -> new MigrationProgress(migration.seriesId, migration.status, migration.timestamp));
migrationProgressDao.bulkInsert(progressStream);
}
}
context.addApplicationListener((ApplicationListener<MangoConfigurationReloadedEvent>) e -> loadProperties());
loadProperties();
}
use of com.serotonin.m2m2.db.dao.migration.MigrationProgressDao.MigrationProgress in project ma-core-public by infiniteautomation.
the class MigrationPointValueDao method postConstruct.
@PostConstruct
private void postConstruct() {
if (env.getProperty("db.migration.startNewMigration", boolean.class, false)) {
migrationProgressDao.deleteAll();
}
if (migrationProgressDao.count() > 0) {
// migration in progress, restore from DB
try (var stream = migrationProgressDao.stream()) {
stream.map(progress -> new MigrationSeries(progress.getSeriesId(), progress.getStatus(), progress.getTimestamp())).forEach(this::addMigration);
}
} else {
// start a new migration, get all points and insert progress items for them
try (var stream = dataPointDao.streamSeriesIds()) {
Stream<MigrationProgress> progressStream = stream.mapToObj(MigrationSeries::new).peek(this::addMigration).map(migration -> new MigrationProgress(migration.seriesId, migration.status, migration.timestamp));
migrationProgressDao.bulkInsert(progressStream);
}
}
context.addApplicationListener((ApplicationListener<MangoConfigurationReloadedEvent>) e -> loadProperties());
loadProperties();
}
Aggregations