Package org.rssowl.core.internal.persist.service

Examples of org.rssowl.core.internal.persist.service.Migration


   * @param destinationFormat The desired format of the database.
   * @return a Migration or {@code} null.
   */
  public final Migration getMigration(int originFormat, int destinationFormat) {
    Assert.isLegal(originFormat < destinationFormat, "Only forward migrations supported currently, originFormat: " + originFormat + ", destinationFormat: " + destinationFormat); //$NON-NLS-1$ //$NON-NLS-2$
    Migration migration = doGetMigration(originFormat, destinationFormat);
    if (migration != null)
      return migration;

    List<Migration> chainedMigrations = findChainedMigrations(originFormat, destinationFormat);
    if (chainedMigrations.isEmpty())
View Full Code Here


  private LinkedList<LinkedList<Migration>> findMigrationQueues(LinkedList<LinkedList<Migration>> migrationQueues, int destinationFormat) {
    boolean changed = false;
    LinkedList<LinkedList<Migration>> migrationQueuesCopy = new LinkedList<LinkedList<Migration>>(migrationQueues);
    for (ListIterator<LinkedList<Migration>> it = migrationQueuesCopy.listIterator(); it.hasNext(); ) {
      LinkedList<Migration> migrationQueue = it.next();
      Migration migration = migrationQueue.getLast();
      if (migration.getDestinationFormat() == destinationFormat)
        continue;

      it.remove();

      for (Migration innerMigration : fMigrations) {
        if (migration.equals(innerMigration))
          continue;

        if (migration.getDestinationFormat() == innerMigration.getOriginFormat()) {
          changed = true;
          LinkedList<Migration> newMigrationQueue = new LinkedList<Migration>(migrationQueue);
          newMigrationQueue.add(innerMigration);
          it.add(newMigrationQueue);
        }
View Full Code Here

   * @param destinationFormat The desired format of the database.
   * @return a Migration or {@code} null.
   */
  public final Migration getMigration(int originFormat, int destinationFormat) {
    Assert.isLegal(originFormat < destinationFormat, "Only forward migrations supported currently, originFormat: " + originFormat + ", destinationFormat: " + destinationFormat); //$NON-NLS-1$ //$NON-NLS-2$
    Migration migration = doGetMigration(originFormat, destinationFormat);
    if (migration != null)
      return migration;

    List<Migration> chainedMigrations = findChainedMigrations(originFormat, destinationFormat);
    if (chainedMigrations.isEmpty())
View Full Code Here

  private LinkedList<LinkedList<Migration>> findMigrationQueues(LinkedList<LinkedList<Migration>> migrationQueues, int destinationFormat) {
    boolean changed = false;
    LinkedList<LinkedList<Migration>> migrationQueuesCopy = new LinkedList<LinkedList<Migration>>(migrationQueues);
    for (ListIterator<LinkedList<Migration>> it = migrationQueuesCopy.listIterator(); it.hasNext();) {
      LinkedList<Migration> migrationQueue = it.next();
      Migration migration = migrationQueue.getLast();
      if (migration.getDestinationFormat() == destinationFormat)
        continue;

      it.remove();

      for (Migration innerMigration : fMigrations) {
        if (migration.equals(innerMigration))
          continue;

        if (migration.getDestinationFormat() == innerMigration.getOriginFormat()) {
          changed = true;
          LinkedList<Migration> newMigrationQueue = new LinkedList<Migration>(migrationQueue);
          newMigrationQueue.add(innerMigration);
          it.add(newMigrationQueue);
        }
View Full Code Here

   * Test if no migration is possible
   */
  @Test
  public void testNoMigrationPossible() {
    Migrations migrations = new Migrations(new MigrationImpl(2, 3), new MigrationImpl(3, 4));
    Migration migration = migrations.getMigration(1, 4);
    assertNull(migration);
  }
View Full Code Here

   * Tests simple migration scenarios.
   */
  @Test
  public void testGetMigration() {
    Migrations migrations = new Migrations(new MigrationImpl(1, 2), new MigrationImpl(2, 3), new MigrationImpl(3, 4));
    Migration migration = migrations.getMigration(2, 4);
    assertEquals(ChainedMigration.class, migration.getClass());
    ChainedMigration chainedMigration = (ChainedMigration) migration;

    assertEquals(2, chainedMigration.getMigrations().size());
    assertEquals(migrations.getMigrations().get(1), chainedMigration.getMigrations().get(0));

View Full Code Here

    Migrations migrations = new Migrations(new MigrationImpl(1, 2), new MigrationImpl(2, 3),
        new MigrationImpl(3, 4), new MigrationImpl(4, 6), new MigrationImpl(3, 5),
        new MigrationImpl(2, 4), new MigrationImpl(5, 6), new MigrationImpl(7, 9),
        new MigrationImpl(7, 8), new MigrationImpl(8, 9), new MigrationImpl(6, 8));

    Migration migration = migrations.getMigration(2, 8);

    assertEquals(ChainedMigration.class, migration.getClass());
    ChainedMigration chainedMigration = (ChainedMigration) migration;
    assertEquals(3, chainedMigration.getMigrations().size());
    assertEquals(migrations.getMigrations().get(5), chainedMigration.getMigrations().get(0));
    assertEquals(migrations.getMigrations().get(3), chainedMigration.getMigrations().get(1));
    assertEquals(migrations.getMigrations().get(10), chainedMigration.getMigrations().get(2));
View Full Code Here

TOP

Related Classes of org.rssowl.core.internal.persist.service.Migration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.