org.nuiton.topia.migration
Class TopiaMigrationCallback

java.lang.Object
  extended by org.nuiton.topia.migration.TopiaMigrationCallback

public abstract class TopiaMigrationCallback
extends Object

Default migration call back to use.

Replace deprecated implementation ManualMigrationCallback.

Since:
2.3.4
Version:
$Id: TopiaMigrationCallback.java 2088 2010-07-26 08:44:30Z tchemit $
Author:
tchemit

Constructor Summary
TopiaMigrationCallback()
           
 
Method Summary
abstract  boolean askUser(org.nuiton.util.Version dbVersion, List<org.nuiton.util.Version> versions)
          Hook to ask user if migration can be performed.
 boolean doMigration(TopiaContext ctxt, org.nuiton.util.Version dbVersion, boolean showSql, boolean showProgression, List<org.nuiton.util.Version> versions)
          Tentative de migration depuis la version de la base version la version souhaitee.
 void executeSQL(TopiaContextImplementor tx, boolean showSql, boolean showProgression, String... sqls)
          Executes the given sqls requests.
 void executeSQL(TopiaContextImplementor tx, String... sqls)
           
abstract  org.nuiton.util.Version getApplicationVersion()
           
abstract  org.nuiton.util.Version[] getAvailableVersions()
           
protected  Method getMigrationMethod(org.nuiton.util.Version version)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TopiaMigrationCallback

public TopiaMigrationCallback()
Method Detail

getAvailableVersions

public abstract org.nuiton.util.Version[] getAvailableVersions()
Returns:
the available versions from the call back

getApplicationVersion

public abstract org.nuiton.util.Version getApplicationVersion()
Returns:
the current application version (says the version to use)

askUser

public abstract boolean askUser(org.nuiton.util.Version dbVersion,
                                List<org.nuiton.util.Version> versions)
Hook to ask user if migration can be performed.

Parameters:
dbVersion - the actual db version
versions - the versions to update
Returns:
false if migration is canceled, true otherwise.

doMigration

public boolean doMigration(TopiaContext ctxt,
                           org.nuiton.util.Version dbVersion,
                           boolean showSql,
                           boolean showProgression,
                           List<org.nuiton.util.Version> versions)
Tentative de migration depuis la version de la base version la version souhaitee.

On applique toutes les migrations de version indiquee dans le parametre version.

Pour chaque version, on cherche la methode migrateTo_XXX ou XXX est la version transforme en identifiant java via la methode Version.getValidName() et on l'execute.

Note: pour chaque version a appliquer, on ouvre une nouvelle transaction.

Parameters:
ctxt - topia context de la transaction en cours
dbVersion - database version
showSql - drapeau pour afficher les requete sql
showProgression - drapeau pour afficher la progression
versions - all versions knwon by service @return migration a ggrement
Returns:
true si la migration est accepté, false autrement.

getMigrationMethod

protected Method getMigrationMethod(org.nuiton.util.Version version)
                             throws NoSuchMethodException
Throws:
NoSuchMethodException

executeSQL

public void executeSQL(TopiaContextImplementor tx,
                       String... sqls)
                throws TopiaException
Throws:
TopiaException

executeSQL

public void executeSQL(TopiaContextImplementor tx,
                       boolean showSql,
                       boolean showProgression,
                       String... sqls)
                throws TopiaException
Executes the given sqls requests.

Parameters:
tx - the session
showSql - flag to see sql requests
showProgression - flag to see progession on console
sqls - requests to execute
Throws:
TopiaException - if any pb
Since:
2.3.0


Copyright © 2004-2010 CodeLutin. All Rights Reserved.