This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository echobase. See http://git.codelutin.com/echobase.git commit d70c7c55bcd1a1f82fc905099edbce360e4f45fd Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Dec 16 16:00:23 2014 +0100 fixes #6318: Les données spatiales de pêche ne sont pas recalculées --- .../EchoBaseUserTopiaApplicationContext.java | 56 +++++++++++++++------- .../MigrationCallBackForVersion2_7_2.java | 44 +++++++++++++++++ ...migration.workingDb.MigrationCallBackForVersion | 3 +- .../resources/migration/postgis-view-2.7.2.sql | 43 +++++++++++++++++ .../src/main/resources/postgis-view.sql | 6 ++- echobase-domain/src/main/xmi/echobase.properties | 2 +- 6 files changed, 135 insertions(+), 19 deletions(-) diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserTopiaApplicationContext.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserTopiaApplicationContext.java index 063a282..5f694cc 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserTopiaApplicationContext.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserTopiaApplicationContext.java @@ -47,6 +47,8 @@ public class EchoBaseUserTopiaApplicationContext extends AbstractEchoBaseUserTop */ protected boolean spatialStructureFound; + protected boolean init; + public EchoBaseUserTopiaApplicationContext(Properties properties) { super(properties); initInternalSpatialStates(); @@ -60,7 +62,22 @@ public class EchoBaseUserTopiaApplicationContext extends AbstractEchoBaseUserTop @Override public EchoBaseUserTopiaPersistenceContext newPersistenceContext() { + EchoBaseUserTopiaPersistenceContext persistenceContext = newPersistenceContext(true); + return persistenceContext; + + + } + + protected EchoBaseUserTopiaPersistenceContext newPersistenceContext(boolean computeStates) { + + if (!init && computeStates) { + + initInternalSpatialStates(); + + } + EchoBaseUserTopiaPersistenceContext persistenceContext = super.newPersistenceContext(); + persistenceContext.setSpatialSupport(spatialSupport); persistenceContext.setSpatialStructureFound(spatialStructureFound); @@ -82,36 +99,43 @@ public class EchoBaseUserTopiaApplicationContext extends AbstractEchoBaseUserTop public void initInternalSpatialStates() { - EchoBaseUserTopiaPersistenceContext persistenceContext = newPersistenceContext(); + if (!init) { - try { - - spatialSupport = computeSpatialSupport(persistenceContext); + EchoBaseUserTopiaPersistenceContext persistenceContext = newPersistenceContext(false); - if (log.isInfoEnabled()) { - log.info("spatialSupport: " + spatialSupport); - } + try { - if (spatialSupport) { + spatialSupport = computeSpatialSupport(persistenceContext); - spatialStructureFound = computeSpatialStructureFound(persistenceContext); if (log.isInfoEnabled()) { - log.info("spatialStructureFound: " + spatialStructureFound); + log.info("spatialSupport: " + spatialSupport); } - } else { + if (spatialSupport) { - // no spatial support, so no spatial structure - spatialStructureFound = false; + spatialStructureFound = computeSpatialStructureFound(persistenceContext); + if (log.isInfoEnabled()) { + log.info("spatialStructureFound: " + spatialStructureFound); + } - } + } else { + + // no spatial support, so no spatial structure + spatialStructureFound = false; - } finally { + } - persistenceContext.closeContext(); + } finally { + + persistenceContext.closeContext(); + + } + + init = true; } + } private boolean computeSpatialSupport(EchoBaseUserTopiaPersistenceContext persistenceContext) { 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 new file mode 100644 index 0000000..785c459 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_7_2.java @@ -0,0 +1,44 @@ +package fr.ifremer.echobase.persistence.migration.workingDb; + +import fr.ifremer.echobase.entities.EchoBaseUserTopiaPersistenceContext; +import fr.ifremer.echobase.io.EchoBaseIOUtil; +import org.nuiton.topia.persistence.TopiaException; +import org.nuiton.util.Version; + +import java.util.List; + +/** + * Created on 12/16/14. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.7.2 + */ +public class MigrationCallBackForVersion2_7_2 extends MigrationCallBackForVersion { + + public static final String POSTGIS_STRUCTURE_SQL = "/migration/postgis-view-2.7.2.sql"; + + @Override + public Version getVersion() { + return new Version("2.7.2"); + } + + @Override + protected void prepareMigrationScript(EchoBaseUserTopiaPersistenceContext tx, + List<String> queries, + boolean showSql, + boolean showProgression) throws TopiaException { + + boolean spatialAware = tx.isSpatialStructureFound(); + + if (spatialAware) { + + // fix reload TotalSampleView (see https://forge.codelutin.com/issues/6318) + updatePostgis(queries); + } + } + + protected void updatePostgis(List<String> queries) { + queries.add(EchoBaseIOUtil.loadScript(POSTGIS_STRUCTURE_SQL)); + } + +} \ No newline at end of file diff --git a/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion b/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion index da06d13..6b065d1 100644 --- a/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion +++ b/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion @@ -1,4 +1,5 @@ fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_2 fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_5_1 fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_6 -fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_6_1 \ No newline at end of file +fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_6_1 +fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion2_7_2 \ No newline at end of file diff --git a/echobase-domain/src/main/resources/migration/postgis-view-2.7.2.sql b/echobase-domain/src/main/resources/migration/postgis-view-2.7.2.sql new file mode 100644 index 0000000..2ea6670 --- /dev/null +++ b/echobase-domain/src/main/resources/migration/postgis-view-2.7.2.sql @@ -0,0 +1,43 @@ +DROP FUNCTION IF EXISTS echobase_refresh_views() CASCADE; + +CREATE OR REPLACE FUNCTION echobase_refresh_views() + RETURNS VOID AS $$ +BEGIN + RAISE NOTICE 'reload TotalSampleView'; + REFRESH MATERIALIZED VIEW TotalSampleView; + REINDEX INDEX TotalSampleView_idx; + + RAISE NOTICE 'reload cellEsduViewEchotype'; + REFRESH MATERIALIZED VIEW cellEsduViewEchotype; + REINDEX INDEX cellEsduViewEchotype_idx; + + RAISE NOTICE 'reload cellEsduViewSpecies'; + REFRESH MATERIALIZED VIEW cellEsduViewSpecies; + REINDEX INDEX cellEsduViewSpecies_idx; + + RAISE NOTICE 'reload cellEsduViewSpeciesResultGrouped'; + REFRESH MATERIALIZED VIEW cellEsduViewSpeciesResultGrouped; + REINDEX INDEX cellEsduViewSpeciesResultGrouped_idx; + + RAISE NOTICE 'reload cellEsduViewEchotypeNasc'; + REFRESH MATERIALIZED VIEW cellEsduViewEchotypeNasc; + + RAISE NOTICE 'reload cellEsduViewSpeciesBiomass'; + REFRESH MATERIALIZED VIEW cellEsduViewSpeciesBiomass; + REINDEX INDEX cellEsduViewSpeciesBiomass_uidx; + + RAISE NOTICE 'reload cellEsduViewSpeciesAbundance'; + REFRESH MATERIALIZED VIEW cellEsduViewSpeciesAbundance; + REINDEX INDEX cellEsduViewSpeciesAbundance_uidx; + + RAISE NOTICE 'reload cellEsduViewSpeciesMeanLength'; + REFRESH MATERIALIZED VIEW cellEsduViewSpeciesMeanLength; + REINDEX INDEX cellEsduViewSpeciesMeanLength_uidx; + + RAISE NOTICE 'reload cellmapview'; + REFRESH MATERIALIZED VIEW cellmapview; + REINDEX INDEX cellmapview_idx; + REINDEX INDEX cellmapview_uidx; +END +$$ +LANGUAGE 'plpgsql'; \ No newline at end of file diff --git a/echobase-domain/src/main/resources/postgis-view.sql b/echobase-domain/src/main/resources/postgis-view.sql index f58eef9..6107a70 100644 --- a/echobase-domain/src/main/resources/postgis-view.sql +++ b/echobase-domain/src/main/resources/postgis-view.sql @@ -82,7 +82,11 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION echobase_refresh_views() RETURNS VOID AS $$ BEGIN - RAISE NOTICE 'reload cellEsduViewEchotype'; + RAISE NOTICE 'reload TotalSampleView'; + REFRESH MATERIALIZED VIEW TotalSampleView; + REINDEX INDEX TotalSampleView_idx; + + RAISE NOTICE 'reload cellEsduViewEchotype'; REFRESH MATERIALIZED VIEW cellEsduViewEchotype; REINDEX INDEX cellEsduViewEchotype_idx; diff --git a/echobase-domain/src/main/xmi/echobase.properties b/echobase-domain/src/main/xmi/echobase.properties index 8204ea3..d69f770 100644 --- a/echobase-domain/src/main/xmi/echobase.properties +++ b/echobase-domain/src/main/xmi/echobase.properties @@ -22,7 +22,7 @@ model.tagValue.notGenerateToString=true model.tagValue.generateOperatorForDAOHelper=true model.tagValue.constantPrefix=PROPERTY_ -model.tagValue.version=2.6.1 +model.tagValue.version=2.7.2 model.tagValue.noPCS=true model.tagValue.doNotGenerateBooleanGetMethods=true model.tagValue.indexForeignKeys=true -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.