This is an automated email from the git hooks/post-receive script. New change to branch feature/8089-topia3-migration in repository echobase. See http://git.codelutin.com/echobase.git from 9aa9e26 refs: #8089: Migrate to ToPIA 3.0 new 17f78c1 refs #8089: Migrate to ToPIA 3.0 The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 17f78c1585d6afae88784fc9e1cc28dfd9fcad66 Author: Eric Chatellier <chatellier@codelutin.com> Date: Wed Mar 9 15:31:08 2016 +0100 refs #8089: Migrate to ToPIA 3.0 Summary of changes: .../fr/ifremer/echobase/entities/DriverType.java | 12 ++++--- .../EchoBaseUserTopiaPersistenceContext.java | 4 --- .../EchobaseTopiaApplicationContexts.java | 8 +++++ .../workingDb/MigrationCallBackForVersion.java | 42 +++++++++++++++++++--- .../workingDb/MigrationCallBackForVersion2_2.java | 21 +++++------ .../MigrationCallBackForVersion2_5_1.java | 3 +- .../workingDb/MigrationCallBackForVersion2_6.java | 6 ++-- .../MigrationCallBackForVersion2_6_1.java | 3 +- .../MigrationCallBackForVersion2_7_2.java | 10 +++--- .../MigrationCallBackForVersionPostgresql.java} | 13 ++++--- .../main/resources/echobase-workingdb.properties | 2 +- 11 files changed, 77 insertions(+), 47 deletions(-) copy echobase-domain/src/main/java/fr/ifremer/echobase/{I18nAble.java => persistence/migration/workingDb/MigrationCallBackForVersionPostgresql.java} (74%) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/8089-topia3-migration in repository echobase. See http://git.codelutin.com/echobase.git commit 17f78c1585d6afae88784fc9e1cc28dfd9fcad66 Author: Eric Chatellier <chatellier@codelutin.com> Date: Wed Mar 9 15:31:08 2016 +0100 refs #8089: Migrate to ToPIA 3.0 --- .../fr/ifremer/echobase/entities/DriverType.java | 12 ++++--- .../EchoBaseUserTopiaPersistenceContext.java | 4 --- .../EchobaseTopiaApplicationContexts.java | 8 +++++ .../workingDb/MigrationCallBackForVersion.java | 42 +++++++++++++++++++--- .../workingDb/MigrationCallBackForVersion2_2.java | 21 +++++------ .../MigrationCallBackForVersion2_5_1.java | 3 +- .../workingDb/MigrationCallBackForVersion2_6.java | 6 ++-- .../MigrationCallBackForVersion2_6_1.java | 3 +- .../MigrationCallBackForVersion2_7_2.java | 10 +++--- .../MigrationCallBackForVersionPostgresql.java | 35 ++++++++++++++++++ .../main/resources/echobase-workingdb.properties | 2 +- 11 files changed, 104 insertions(+), 42 deletions(-) diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/DriverType.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/DriverType.java index bfb5a1f..bb198d3 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/DriverType.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/DriverType.java @@ -1,5 +1,12 @@ package fr.ifremer.echobase.entities; +import static org.nuiton.i18n.I18n.n; + +import org.hibernate.dialect.H2Dialect; +import org.hibernate.dialect.PostgreSQL82Dialect; + +import fr.ifremer.echobase.I18nAble; + /* * #%L * EchoBase :: Domain @@ -22,11 +29,6 @@ package fr.ifremer.echobase.entities; */ import fr.ifremer.echobase.config.EchoBaseConfiguration; -import fr.ifremer.echobase.I18nAble; -import org.hibernate.dialect.H2Dialect; -import org.hibernate.dialect.PostgreSQL82Dialect; - -import static org.nuiton.i18n.I18n.n; /** * To define a type of driver (h2 or postgres for the moment). diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserTopiaPersistenceContext.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserTopiaPersistenceContext.java index 653f375..6ba711d 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserTopiaPersistenceContext.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserTopiaPersistenceContext.java @@ -22,11 +22,7 @@ package fr.ifremer.echobase.entities; */ import org.hibernate.cfg.Environment; -import org.nuiton.topia.persistence.TopiaIdFactory; import org.nuiton.topia.persistence.internal.AbstractTopiaPersistenceContextConstructorParameter; -import org.nuiton.topia.persistence.internal.HibernateProvider; -import org.nuiton.topia.persistence.internal.TopiaHibernateSessionRegistry; -import org.nuiton.topia.persistence.internal.support.TopiaFiresSupport; public class EchoBaseUserTopiaPersistenceContext extends AbstractEchoBaseUserTopiaPersistenceContext { diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaApplicationContexts.java b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaApplicationContexts.java index 665fa76..87e6e40 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaApplicationContexts.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaApplicationContexts.java @@ -152,6 +152,13 @@ public class EchobaseTopiaApplicationContexts { result.setProperty("configuration.dialect", driverType.getDialectClass().getName()); + // since version 3.0 : can't read configuration inside migration + if (driverType == DriverType.POSTGRESQL) { + result.setProperty("configuration.callback", "fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallbackPostgresql"); + } else { + result.setProperty("configuration.callback", "fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallback"); + } + loadProperties(result, USER_DB_PROPERTIES); reloadProperty(result, Environment.URL, "configuration.url"); @@ -159,6 +166,7 @@ public class EchobaseTopiaApplicationContexts { reloadProperty(result, Environment.PASS, "configuration.password"); reloadProperty(result, Environment.DIALECT, "configuration.dialect"); reloadProperty(result, Environment.DRIVER, "configuration.driver"); + reloadProperty(result, "topia.service.migration.callback", "configuration.callback"); return result; } diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java index 51bbfee..57a7178 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion.java @@ -21,9 +21,9 @@ package fr.ifremer.echobase.persistence.migration.workingDb; * #L% */ -import fr.ifremer.echobase.entities.EchoBaseUserTopiaPersistenceContext; import fr.ifremer.echobase.io.EchoBaseIOUtil; import org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG; +import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -42,9 +42,9 @@ public abstract class MigrationCallBackForVersion extends TopiaMigrationCallback } - protected void addSpecificScript(EchoBaseUserTopiaPersistenceContext tx, String script, List<String> queries) { + protected void addSpecificScript(String script, List<String> queries) { - String scriptPath = getSpecificMigrationPath(tx, script); + String scriptPath = getSpecificMigrationPath(script); queries.add(EchoBaseIOUtil.loadScript(scriptPath)); } @@ -53,11 +53,11 @@ public abstract class MigrationCallBackForVersion extends TopiaMigrationCallback return "/migration/workingDb/" + script; } - protected String getSpecificMigrationPath(EchoBaseUserTopiaPersistenceContext tx, String script) { + protected String getSpecificMigrationPath(String script) { String path; - if (tx.isPostgresql()) { + if (isPostgresql()) { path = getMigrationPath("pg/" + script); @@ -71,4 +71,36 @@ public abstract class MigrationCallBackForVersion extends TopiaMigrationCallback } + /** + * Since 3.0 because configuration is not available inside migration. + * Designed to be overloaded. + * + * @return is postgres + */ + protected boolean isPostgresql() { + return false; + } + + /** + * Since verion 3.0 with topia 3.0, application context is not available anymore in migration classes. + * + * @param sqlSupport topia sql support + * @return {@code true} if spatial support in detected + */ + protected boolean isSpatialStructureFound(TopiaSqlSupport sqlSupport) { + boolean result; + try { + + sqlSupport.executeSql("select count(*) from echobase_cell_spatial;"); + result = true; + + } catch (Exception e) { + + // table not found (or other, ...) + result = false; + + } + + return result; + } } diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_2.java b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_2.java index b2a1c8f..8c9b01c 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_2.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_2.java @@ -21,7 +21,6 @@ package fr.ifremer.echobase.persistence.migration.workingDb; * #L% */ -import fr.ifremer.echobase.entities.EchoBaseUserTopiaPersistenceContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaException; @@ -72,21 +71,17 @@ public class MigrationCallBackForVersion2_2 extends MigrationCallBackForVersion } protected void updatePostgis(TopiaSqlSupport sqlSupport) { - boolean spatialAware = tx.isSpatialStructureFound(); + boolean spatialAware = isSpatialStructureFound(sqlSupport); - try { - if (spatialAware) { - try { - // compute all spatial data - sqlSupport.executeSql("SELECT echobase_compute_all_spatial_data();"); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Could not update spatial datas", e); - } + if (spatialAware) { + try { + // compute all spatial data + sqlSupport.executeSql("SELECT echobase_compute_all_spatial_data();"); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Could not update spatial datas", e); } } - } finally { - tx.rollback(); } } } diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java index fd34919..c6b35d5 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_5_1.java @@ -21,7 +21,6 @@ package fr.ifremer.echobase.persistence.migration.workingDb; * #L% */ -import fr.ifremer.echobase.entities.EchoBaseUserTopiaPersistenceContext; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import org.nuiton.util.version.Version; @@ -48,7 +47,7 @@ public class MigrationCallBackForVersion2_5_1 extends MigrationCallBackForVersio boolean showSql, boolean showProgression) throws TopiaException { - boolean spatialAware = tx.isSpatialStructureFound(); + boolean spatialAware = isSpatialStructureFound(sqlSupport); if (spatialAware) { diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6.java b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6.java index ba3f46d..35f5344 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6.java @@ -33,8 +33,6 @@ import org.nuiton.util.version.Versions; * #L% */ -import fr.ifremer.echobase.entities.EchoBaseUserTopiaPersistenceContext; - /** * Created on 2/26/14. * @@ -54,7 +52,7 @@ public class MigrationCallBackForVersion2_6 extends MigrationCallBackForVersion boolean showSql, boolean showProgression) throws TopiaException { - boolean spatialAware = tx.isSpatialStructureFound(); + boolean spatialAware = isSpatialStructureFound(sqlSupport); if (spatialAware) { @@ -63,7 +61,7 @@ public class MigrationCallBackForVersion2_6 extends MigrationCallBackForVersion } // update datametadata referential (see https://forge.codelutin.com/issues/4583) - updateDataMedataReferential(tx, queries); + updateDataMedataReferential(sqlSupport, queries); } protected void updatePostgis(List<String> queries) { diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6_1.java b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6_1.java index 1dc321f..056da18 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6_1.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6_1.java @@ -28,7 +28,6 @@ import org.nuiton.util.version.Versions; * #L% */ -import fr.ifremer.echobase.entities.EchoBaseUserTopiaPersistenceContext; /** * Created on 4/16/14. @@ -49,7 +48,7 @@ public class MigrationCallBackForVersion2_6_1 extends MigrationCallBackForVersio boolean showSql, boolean showProgression) throws TopiaException { - boolean spatialAware = tx.isSpatialStructureFound(); + boolean spatialAware = isSpatialStructureFound(sqlSupport); if (spatialAware) { diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_7_2.java b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_7_2.java index a1ee642..7e93b71 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_7_2.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_7_2.java @@ -28,8 +28,6 @@ import org.nuiton.util.version.Versions; * #L% */ -import fr.ifremer.echobase.entities.EchoBaseUserTopiaPersistenceContext; - /** * Created on 12/16/14. * @@ -49,7 +47,7 @@ public class MigrationCallBackForVersion2_7_2 extends MigrationCallBackForVersio boolean showSql, boolean showProgression) throws TopiaException { - boolean spatialAware = tx.isSpatialStructureFound(); + boolean spatialAware = isSpatialStructureFound(sqlSupport); if (spatialAware) { @@ -58,7 +56,7 @@ public class MigrationCallBackForVersion2_7_2 extends MigrationCallBackForVersio } // add FileImport entity (see https://forge.codelutin.com/issues/6367) - addFileImportEntity(tx, queries); + addFileImportEntity(queries); } @@ -66,8 +64,8 @@ public class MigrationCallBackForVersion2_7_2 extends MigrationCallBackForVersio addScript("2.7.2-0-postgis-view.sql", queries); } - protected void addFileImportEntity(EchoBaseUserTopiaPersistenceContext tx, List<String> queries) { - addSpecificScript(tx, "2.7.2-1-add-importFile-entity.sql", queries); + protected void addFileImportEntity(List<String> queries) { + addSpecificScript("2.7.2-1-add-importFile-entity.sql", queries); } } \ No newline at end of file diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersionPostgresql.java b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersionPostgresql.java new file mode 100644 index 0000000..62b9bbe --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersionPostgresql.java @@ -0,0 +1,35 @@ +package fr.ifremer.echobase.persistence.migration.workingDb; + +/* + * #%L + * EchoBase :: Domain + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +/** + * Base migration support for a working db. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.1 + */ +public abstract class MigrationCallBackForVersionPostgresql extends MigrationCallBackForVersion { + + protected boolean isPostgresql() { + return true; + } +} diff --git a/echobase-domain/src/main/resources/echobase-workingdb.properties b/echobase-domain/src/main/resources/echobase-workingdb.properties index a94742c..2525cd0 100644 --- a/echobase-domain/src/main/resources/echobase-workingdb.properties +++ b/echobase-domain/src/main/resources/echobase-workingdb.properties @@ -36,6 +36,6 @@ topia.persistence.topiaIdFactoryClassName=org.nuiton.topia.persistence.internal. # Database migration configuration topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine -topia.service.migration.callback=fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallback +topia.service.migration.callback=${configuration.callback} topia.service.migration.showSql=true -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm