org.nuiton.topia.migration
Class TopiaMigrationEngine

java.lang.Object
  extended by org.nuiton.topia.migration.TopiaMigrationEngine
All Implemented Interfaces:
TopiaService, TopiaMigrationService

public class TopiaMigrationEngine
extends Object
implements TopiaMigrationService

Le moteur de migration proposé par topia. Il est basé sur un AbstractTopiaMigrationCallback qui donne la version de l'application, les version de mises à jour disponibles.

Le call back offre aussi les commandes sql à passer pour chaque version de mise à jour.

FIXME Finir cette documentation

Since:
2.3.4
Version:
$Id: TopiaMigrationEngine.java 2245 2011-04-14 12:47:09Z tchemit $
Author:
tchemit

Field Summary
protected  AbstractTopiaMigrationCallback callback
          CallbackHandler list (initialise en pre-init)
protected  TopiaContextListener contextListener
          delegate context listener.
protected  boolean dbEmpty
          A flag to know if none of the dealed entities tables exists in db.
protected  boolean dbNotVersioned
          Drapeau pour savoir si la base est versionnée ou non
protected  org.nuiton.util.Version dbVersion
          Version courante de la base (initialise en pre-init)
protected  boolean init
          Un drapeau pour savoir si le service a bien ete initialise (i.e a bien fini la methode preInit)
protected  org.hibernate.cfg.Configuration legacyVersionConfiguration
          Configuration hibernate ne mappant que l'entite version de l'ancien systeme de migration (initialise en pre-init)
protected  boolean legacyVersionTableExist
          Un drapeau pour savoir si la table version (de l'ancien service Manual) existe en base (initialise en pre-init)
protected  boolean migrateOnInit
          Un drapeau pour effectuer la migration au demarrage (initialise en pre-init)
protected  TopiaContextImplementor rootContext
          topia root context (initialise en pre-init)
protected  boolean showProgression
          Un drapeau pour afficher la progression des requetes sql executees
protected  boolean showSql
          Un drapeau pour afficher les requetes sql executees
protected  TopiaTransactionVetoable transactionVetoable
          delgate transaction listener
protected  org.hibernate.cfg.Configuration versionConfiguration
          Configuration hibernate ne mappant que l'entite version (initialise en pre-init)
protected  boolean versionDetected
          A flag to check if version was detected in database.
protected  boolean versionTableExist
          Un drapeau pour savoir si la table version existe en base (initialise en pre-init)
 
Fields inherited from interface org.nuiton.topia.migration.TopiaMigrationService
MIGRATION_CALLBACK, MIGRATION_MIGRATE_ON_INIT, MIGRATION_SHOW_PROGRESSION, MIGRATION_SHOW_SQL, SERVICE_NAME, TOPIA_SERVICE_NAME
 
Constructor Summary
TopiaMigrationEngine()
           
 
Method Summary
protected  void checkInit()
           
protected  org.hibernate.cfg.Configuration creaHibernateConfiguration(org.hibernate.cfg.Configuration configuration)
          Deprecated. since 2.5.3, prefer to use the method createHibernateConfiguration(Configuration)
protected  org.hibernate.cfg.Configuration createHibernateConfiguration(org.hibernate.cfg.Configuration configuration)
          Creates the hibernate configuration to be used by the service.
protected  boolean detectDbEmpty()
          Detects if there is some schema existing for at least one of the dealed entity of the underlying db context.
protected  void detectDbVersion()
          Recupere depuis la base les états internes du service :

versionTableExist dbVersion dbEmpty

 void doMigrateSchema()
           
 Class<?>[] getPersistenceClasses()
           
protected  String getSafeParameter(Properties config, String key)
           
 String getServiceName()
           
protected  org.nuiton.util.Version getVersion(boolean versionTableExist, String tableName)
           
 boolean migrateSchema()
           
 boolean postInit(TopiaContextImplementor context)
           
 boolean preInit(TopiaContextImplementor context)
           
protected  void saveApplicationVersion()
          Enregistre la version donnee en base avec creation de la table si elle n'existe pas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionConfiguration

protected org.hibernate.cfg.Configuration versionConfiguration
Configuration hibernate ne mappant que l'entite version (initialise en pre-init)


versionTableExist

protected boolean versionTableExist
Un drapeau pour savoir si la table version existe en base (initialise en pre-init)


legacyVersionConfiguration

protected org.hibernate.cfg.Configuration legacyVersionConfiguration
Configuration hibernate ne mappant que l'entite version de l'ancien systeme de migration (initialise en pre-init)


legacyVersionTableExist

protected boolean legacyVersionTableExist
Un drapeau pour savoir si la table version (de l'ancien service Manual) existe en base (initialise en pre-init)


dbVersion

protected org.nuiton.util.Version dbVersion
Version courante de la base (initialise en pre-init)


dbNotVersioned

protected boolean dbNotVersioned
Drapeau pour savoir si la base est versionnée ou non


dbEmpty

protected boolean dbEmpty
A flag to know if none of the dealed entities tables exists in db.

Since:
2.5.3

migrateOnInit

protected boolean migrateOnInit
Un drapeau pour effectuer la migration au demarrage (initialise en pre-init)


callback

protected AbstractTopiaMigrationCallback callback
CallbackHandler list (initialise en pre-init)


rootContext

protected TopiaContextImplementor rootContext
topia root context (initialise en pre-init)


init

protected boolean init
Un drapeau pour savoir si le service a bien ete initialise (i.e a bien fini la methode preInit)


versionDetected

protected boolean versionDetected
A flag to check if version was detected in database.

This flag is set to true at the end of method detectDbVersion().


showSql

protected boolean showSql
Un drapeau pour afficher les requetes sql executees


showProgression

protected boolean showProgression
Un drapeau pour afficher la progression des requetes sql executees


contextListener

protected final TopiaContextListener contextListener
delegate context listener.


transactionVetoable

protected final TopiaTransactionVetoable transactionVetoable
delgate transaction listener

Constructor Detail

TopiaMigrationEngine

public TopiaMigrationEngine()
Method Detail

getPersistenceClasses

public Class<?>[] getPersistenceClasses()
Specified by:
getPersistenceClasses in interface TopiaService

getServiceName

public String getServiceName()
Specified by:
getServiceName in interface TopiaService

preInit

public boolean preInit(TopiaContextImplementor context)
Specified by:
preInit in interface TopiaService

postInit

public boolean postInit(TopiaContextImplementor context)
Specified by:
postInit in interface TopiaService

doMigrateSchema

public void doMigrateSchema()
                     throws MigrationServiceException
Throws:
MigrationServiceException

migrateSchema

public boolean migrateSchema()
                      throws MigrationServiceException
Specified by:
migrateSchema in interface TopiaMigrationService
Throws:
MigrationServiceException

saveApplicationVersion

protected void saveApplicationVersion()
Enregistre la version donnee en base avec creation de la table si elle n'existe pas.


detectDbVersion

protected void detectDbVersion()
Recupere depuis la base les états internes du service :


detectDbEmpty

protected boolean detectDbEmpty()
Detects if there is some schema existing for at least one of the dealed entity of the underlying db context.

Returns:
true if there is no schema for any of the dealed entities, false otherwise.
Since:
2.5.3

getVersion

protected org.nuiton.util.Version getVersion(boolean versionTableExist,
                                             String tableName)

getSafeParameter

protected String getSafeParameter(Properties config,
                                  String key)

checkInit

protected void checkInit()

creaHibernateConfiguration

@Deprecated
protected org.hibernate.cfg.Configuration creaHibernateConfiguration(org.hibernate.cfg.Configuration configuration)
Deprecated. since 2.5.3, prefer to use the method createHibernateConfiguration(Configuration)

Creates the hibernate configuration to be used by the service.

Parameters:
configuration - the incoming hibernate configuration
Returns:
the complete configuration usable by the service

createHibernateConfiguration

protected org.hibernate.cfg.Configuration createHibernateConfiguration(org.hibernate.cfg.Configuration configuration)
Creates the hibernate configuration to be used by the service.

Parameters:
configuration - the incoming hibernate configuration
Returns:
the complete configuration usable by the service
Since:
2.5.3


Copyright © 2004-2011 CodeLutin. All Rights Reserved.