class ToPEPersistentIdentifiable implements BaseUpgradeTaskTo_2_1_0_PE {

    @Override
    public void run() {
        LOGGER.debug("starting upgrade from {} to {}.", Step.class, PersistentStep.class);
        final AtomicLong counter = new AtomicLong(0L);
        fileSystemPreparationRepository.list(Step.class).forEach(s -> {
            fileSystemPreparationRepository.remove(s);
            PersistentStep persistentStep = turnToPersistentStep(s);
            preparationRepository.add(persistentStep);
            LOGGER.debug("step {} updated to {}", s, persistentStep);
            counter.incrementAndGet();
        });
        LOGGER.info("Upgrade from {} to {} done, {} steps processed.", Step.class, PersistentStep.class, counter.get());

        LOGGER.debug("starting upgrade from {} to {}.", Preparation.class, PersistentPreparation.class);
        final Stream<Preparation> preparations = fileSystemPreparationRepository.list(Preparation.class);
        preparations.forEach(p -> {
            fileSystemPreparationRepository.remove(p);
            PersistentPreparation persistentPreparation = turnToPersistentPreparation(p);
            preparationRepository.add(persistentPreparation);
        });
        LOGGER.info("Upgrade from {} to {} done.", Preparation.class, PersistentPreparation.class);

        LOGGER.info("Migration of step ids in preparation...");
        final Stream<PersistentPreparation> persistentPreparations =
                preparationRepository.list(PersistentPreparation.class);
        persistentPreparations.forEach(p -> {
            LOGGER.info("Migration of preparation #{}", p.getId());
            final List<String> stepsIds = preparationUtils.listStepsIds(p.getHeadId(), preparationRepository);
            p.setSteps(stepsIds);

            final DataSetMetadata metadata = dataSetMetadataRepository.get(p.getDataSetId());
            if (metadata != null) {
                LOGGER.info("Set metadata {} in preparation {}.", p.getDataSetId(), p.getId());
                p.setRowMetadata(metadata.getRowMetadata());
            } else {
                LOGGER.info("Metadata {} not found for preparation {}.", p.getDataSetId(), p.getId());
                p.setRowMetadata(new RowMetadata());
            }

            preparationRepository.add(p);
            LOGGER.info("Migration of preparation #{} done ({} steps)", p.getId(), stepsIds.size());
        });
        LOGGER.info("Migration of step ids in preparation done.");
    }

}