Exemplo n.º 1
0
  public void upgradeToCurrentVersion() {
    if (isInitialImport()) {
      initialImports.forEach(InitialImport::performInitialImport);
      versionProvider.writeLastVersion(getCurrentVersion());
    } else if (getLastVersion().get() < getCurrentVersion()) {
      List<VersionUpgrade> upgraders = new ArrayList<>(upgrades);
      Collections.sort(upgraders);

      upgraders
          .stream()
          .filter(upgrader -> upgrader.getVersion() > getLastVersion().get())
          .forEach(
              upgrader -> {
                log.info(
                    "Performing upgrade from version {} to {} using {}",
                    getLastVersion(),
                    upgrader.getVersion(),
                    upgrader.getClass().getSimpleName());
                upgrader.performUpgrade();
              });
      versionProvider.writeLastVersion(getCurrentVersion());
    } else {
      log.debug("no upgrade nessessary");
    }
  }
Exemplo n.º 2
0
 public Optional<Integer> getLastVersion() {
   return versionProvider.getLastVersion();
 }
Exemplo n.º 3
0
 public int getCurrentVersion() {
   return versionProvider.getCurrentVersion();
 }