net.sourceforge.floggy.persistence.migration
Class MigrationManager

java.lang.Object
  extended by net.sourceforge.floggy.persistence.migration.MigrationManager

public abstract class MigrationManager
extends Object

A class that helps the developer migrate from a previous version of its application to a new version.
The general use of it follows:

MigrationManager manager = MigrationManager.getInstance();
* String[] notMigratedClasses = manager.getNotMigratedClasses();
*
* for (int i = 0; i < notMigratedClasses.length; i++) {
*
*  if (notMigratedClasses[i].equals("net.sourceforge.floggy.Person")) {
*   //does a quickMigration because the classes didn't changed between versions
*   manager.quickMigration(Class.forName(notMigratedClasses[i]));
*  }
*
*  if (notMigratedClasses[i].equals("net.sourceforge.floggy.Phone")) {
*   Enumeration enumeration = manager.start(Class.forName(notMigratedClasses[i]), null);
*   while (enumeration.hasMoreElements()) {
*    Hashtable fields = enumeration.nextElement();
*    Integer countryCode = fields.get("countryCode");
*    if (countryCode == null) {
*     enumeration.delete();
*    } else {
*     Phone phone = new Phone();
*     phone.setNumber(fields.get("number"));
*     phone.setType(Phone.GENERAL);
*     enumeration.update(phone);
*    }
*   }
*  }
* }

Since:
1.3.0
Author:
Thiago Moreira

Field Summary
static String ITERATION_MODE
          It enables the developer to iterate over all registers without update or delete it.
static String LAZY_LOAD
          It drives the migration avoiding or not the loading of Persistable fields
static String MIGRATE_FROM_PREVIOUS_1_3_0_VERSION
          It enables the developer to migrate from a version earlier than 1.3.0
 
Constructor Summary
MigrationManager()
           
 
Method Summary
abstract  void finish(Class persistableClass)
          Finish the whole migration process.
static MigrationManager getInstance()
          Returns the current instance of PersistableManager.
abstract  String[] getNotMigratedClasses()
          Retrieves a list with all classes that needs to be migrated.
abstract  void quickMigration(Class persistableClass)
          Execute a quick migration in classes that didn't changed between versions.
abstract  Enumeration start(Class persistableClass, Hashtable properties)
          Start the migration process of the given Persistable class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ITERATION_MODE

public static final String ITERATION_MODE
It enables the developer to iterate over all registers without update or delete it.

See Also:
Constant Field Values

LAZY_LOAD

public static final String LAZY_LOAD
It drives the migration avoiding or not the loading of Persistable fields

See Also:
Constant Field Values

MIGRATE_FROM_PREVIOUS_1_3_0_VERSION

public static final String MIGRATE_FROM_PREVIOUS_1_3_0_VERSION
It enables the developer to migrate from a version earlier than 1.3.0

See Also:
Constant Field Values
Constructor Detail

MigrationManager

public MigrationManager()
Method Detail

getInstance

public static MigrationManager getInstance()
Returns the current instance of PersistableManager.

Returns:
The current instance of PersistableManager.
Throws:
RuntimeException - DOCUMENT ME!

finish

public abstract void finish(Class persistableClass)
                     throws FloggyException
Finish the whole migration process. At the end it update the layout of fields of the Persistable class being migrated.

Parameters:
persistableClass - The Persistable being migrated.
Throws:
FloggyException - If the enumeration wasn't whole processed.

getNotMigratedClasses

public abstract String[] getNotMigratedClasses()
Retrieves a list with all classes that needs to be migrated.

Returns:
a String array that contains a list of classes that must be migrated.

quickMigration

public abstract void quickMigration(Class persistableClass)
                             throws FloggyException
Execute a quick migration in classes that didn't changed between versions.

Parameters:
persistableClass - The Persistable being migrated.
Throws:
FloggyException - A exception that holds the underling problem.

start

public abstract Enumeration start(Class persistableClass,
                                  Hashtable properties)
                           throws FloggyException
Start the migration process of the given Persistable class.

Parameters:
persistableClass - The Persistable being migrated.
properties - A list of properties that will driven the migration.
Returns:
A enumeration
Throws:
FloggyException - A exception that holds the underling problem.


Copyright © 2006-2011 Floggy Open Source Group. All Rights Reserved.