Package org.nuiton.topia.migration
Class TopiaMigrationEngine
java.lang.Object
org.nuiton.topia.migration.TopiaMigrationEngine
- All Implemented Interfaces:
TopiaService,TopiaMigrationService
public class TopiaMigrationEngine extends java.lang.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$
- Author:
- tchemit
-
Field Summary
Fields Modifier and Type Field Description protected AbstractTopiaMigrationCallbackcallbackCallbackHandler list (initialise en pre-init)protected TopiaContextListenercontextListenerdelegate context listener.protected booleandbEmptyA flag to know if none of the dealed entities tables exists in db.protected booleandbNotVersionedDrapeau pour savoir si la base est versionnée ou nonprotected org.nuiton.version.VersiondbVersionVersion courante de la base (initialise en pre-init)protected booleaninitUn drapeau pour savoir si le service a bien ete initialise (i.e a bien fini la methode preInit)protected booleanmigrateOnInitUn drapeau pour effectuer la migration au demarrage (initialise en pre-init)protected TopiaContextImplementorrootContexttopia root context (initialise en pre-init)protected booleanshowProgressionUn drapeau pour afficher la progression des requetes sql executeesprotected booleanshowSqlUn drapeau pour afficher les requetes sql executeesprotected TMSVersionPersistertmsVersionPersisterPour enregistrer les version en base (initialise en pre-init)protected TopiaTransactionVetoabletransactionVetoabledelgate transaction listenerprotected booleanversionDetectedA flag to check if version was detected in database.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
Constructors Constructor Description TopiaMigrationEngine() -
Method Summary
Modifier and Type Method Description protected voidcheckInit()protected booleandetectDbEmpty()Detects if there is some schema existing for at least one of the dealed entity of the underlying db context.protected voiddetectDbVersion()voiddoMigrateSchema()protected java.util.List<org.nuiton.version.Version>filterVersions(java.util.Set<org.nuiton.version.Version> versions, org.nuiton.version.Version min, org.nuiton.version.Version max, boolean includeMin, boolean includeMax)Filter versions.java.lang.Class<?>[]getPersistenceClasses()protected java.lang.StringgetSafeParameter(java.util.Properties config, java.lang.String key)java.lang.StringgetServiceName()protected org.nuiton.version.VersiongetVersion(boolean versionTableExist, java.lang.String tableName)booleanmigrateSchema()booleanpostInit(TopiaContextImplementor context)booleanpreInit(TopiaContextImplementor context)protected voidsaveApplicationVersion()Enregistre la version donnee en base avec creation de la table si elle n'existe pas.
-
Field Details
-
tmsVersionPersister
Pour enregistrer les version en base (initialise en pre-init) -
dbVersion
protected org.nuiton.version.Version dbVersionVersion courante de la base (initialise en pre-init) -
dbNotVersioned
protected boolean dbNotVersionedDrapeau pour savoir si la base est versionnée ou non -
dbEmpty
protected boolean dbEmptyA flag to know if none of the dealed entities tables exists in db.- Since:
- 2.5.3
-
migrateOnInit
protected boolean migrateOnInitUn drapeau pour effectuer la migration au demarrage (initialise en pre-init) -
callback
CallbackHandler list (initialise en pre-init) -
rootContext
topia root context (initialise en pre-init) -
init
protected boolean initUn drapeau pour savoir si le service a bien ete initialise (i.e a bien fini la methode preInit) -
versionDetected
protected boolean versionDetectedA flag to check if version was detected in database. This flag is set totrueat the end of methoddetectDbVersion(). -
showSql
protected boolean showSqlUn drapeau pour afficher les requetes sql executees -
showProgression
protected boolean showProgressionUn drapeau pour afficher la progression des requetes sql executees -
contextListener
delegate context listener. -
transactionVetoable
delgate transaction listener
-
-
Constructor Details
-
TopiaMigrationEngine
public TopiaMigrationEngine()
-
-
Method Details
-
getPersistenceClasses
public java.lang.Class<?>[] getPersistenceClasses()- Specified by:
getPersistenceClassesin interfaceTopiaService
-
getServiceName
public java.lang.String getServiceName()- Specified by:
getServiceNamein interfaceTopiaService
-
preInit
- Specified by:
preInitin interfaceTopiaService
-
postInit
- Specified by:
postInitin interfaceTopiaService
-
doMigrateSchema
- Throws:
MigrationServiceException
-
migrateSchema
- Specified by:
migrateSchemain interfaceTopiaMigrationService- 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() -
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:
trueif there is no schema for any of the dealed entities,falseotherwise.- Since:
- 2.5.3
-
getVersion
protected org.nuiton.version.Version getVersion(boolean versionTableExist, java.lang.String tableName) -
getSafeParameter
protected java.lang.String getSafeParameter(java.util.Properties config, java.lang.String key) -
checkInit
protected void checkInit() -
filterVersions
protected java.util.List<org.nuiton.version.Version> filterVersions(java.util.Set<org.nuiton.version.Version> versions, org.nuiton.version.Version min, org.nuiton.version.Version max, boolean includeMin, boolean includeMax)Filter versions.- Parameters:
versions- versions to filtermin- min version to acceptmax- max version to acceptincludeMin- flag to include min versionincludeMax- flag to include max version- Returns:
- versions between min and max
-