@Test public void shouldUpdatePersistentClasses() { task.run(); assertEquals(2, repository.list(PersistentPreparation.class).count()); List<PersistentPreparation> persistentPreparationList = repository .list(PersistentPreparation.class) .sorted(Comparator.comparingInt(p1 -> p1.getSteps().size())) .collect(Collectors.toList()); persistentPreparationList.forEach(p -> { assertNotNull(p.getSteps()); assertNotNull(p.getRowMetadata()); assertFalse(p.getSteps().isEmpty()); assertEquals(Type.INTEGER.getName(), p.getRowMetadata().getColumns().get(0).getType()); }); assertEquals(6, persistentPreparationList.get(0).getRowMetadata().getColumns().size()); assertEquals(5, persistentPreparationList.get(1).getRowMetadata().getColumns().size()); repository.list(Preparation.class).forEach(p -> { assertNotNull(p.getSteps()); assertFalse(p.getSteps().isEmpty()); }); assertEquals(10, repository.list(PersistentStep.class).filter(s -> s.getParentId() != null).count()); repository.list(Step.class).forEach(s -> assertNotNull(s.getId())); }
@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."); }
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."); } }
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."); }  }
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."); }  @Override void run(); @Override int getOrder(); @Override target getTarget(); }
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."); }  @Override void run(); @Override int getOrder(); @Override target getTarget();  }