Author: tchemit Date: 2014-02-27 17:43:28 +0100 (Thu, 27 Feb 2014) New Revision: 959 Url: http://codelutin.com/projects/echobase/repository/revisions/959 Log: fixes #4583: Mettre ?\195?\160 jour le r?\195?\169f?\195?\169rentiel Added: trunk/echobase-domain/src/main/data/ trunk/echobase-domain/src/main/data/echobase-referentiel.echobase Modified: trunk/echobase-domain/pom.xml trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6.java trunk/echobase-domain/src/main/resources/migration/postgis-view-2.6.sql Modified: trunk/echobase-domain/pom.xml =================================================================== --- trunk/echobase-domain/pom.xml 2014-02-27 16:42:36 UTC (rev 958) +++ trunk/echobase-domain/pom.xml 2014-02-27 16:43:28 UTC (rev 959) @@ -13,6 +13,12 @@ <name>EchoBase :: Domain</name> <description>EchoBase domain module</description> + <properties> + <redmine.releaseFiles> + ${project.build.directory}/echobase-referentiel-${project.version}.echobase + </redmine.releaseFiles> + </properties> + <build> <plugins> @@ -219,4 +225,47 @@ </dependencies> + <profiles> + + <profile> + <id>copy-referential</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + + <build> + <defaultGoal>generate-resources</defaultGoal> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>copy referential</id> + <phase>generate-resources</phase> + <inherited>false</inherited> + <configuration> + <tasks> + <echo message="copy echobase referential" /> + <copy verbose="true" + failonerror="false" + overwrite="true" + file="${project.basedir}/src/main/data/echobase-referentiel.echobase" + tofile="${project.build.directory}/echobase-referentiel-${project.version}.echobase"/> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + </profile> + + </profiles> </project> Added: trunk/echobase-domain/src/main/data/echobase-referentiel.echobase =================================================================== (Binary files differ) Property changes on: trunk/echobase-domain/src/main/data/echobase-referentiel.echobase ___________________________________________________________________ Added: svn:mime-type + application/zip Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6.java 2014-02-27 16:42:36 UTC (rev 958) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallBackForVersion2_6.java 2014-02-27 16:43:28 UTC (rev 959) @@ -1,10 +1,38 @@ package fr.ifremer.echobase.persistence.migration.workingDb; +/* + * #%L + * EchoBase :: Domain + * $Id$ + * $HeadURL:$ + * %% + * Copyright (C) 2011 - 2014 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% + */ + import fr.ifremer.echobase.entities.EchoBaseUserTopiaPersistenceContext; import fr.ifremer.echobase.io.EchoBaseIOUtil; import org.nuiton.topia.persistence.TopiaException; +import org.nuiton.topia.persistence.support.TopiaSqlQuery; import org.nuiton.util.Version; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.List; /** @@ -32,12 +60,60 @@ if (spatialAware) { - // repass postgis scripts (http://forge.codelutin.com/issues/4018) + // add new postigs view (see https://forge.codelutin.com/issues/4194) updatePostgis(queries); } + + // update datametadata referential (see https://forge.codelutin.com/issues/4583) + updateDataMedataReferential(tx, queries); } protected void updatePostgis(List<String> queries) { queries.add(EchoBaseIOUtil.loadScript(POSTGIS_VIEW_SQL)); } + + protected void updateDataMedataReferential(EchoBaseUserTopiaPersistenceContext tx, List<String> queries) { + + String dataId; + dataId = tx.getSqlSupport().findSingleResult(new GetdataMetadataSqlQuery("meanMapcellBiomass")); + if (dataId == null) { + // add it + queries.add("INSERT INTO datametadata (topiaId,topiaversion, topiacreatedate, addOffset, comment, fillValue, longName, name, scaleFactor, units, validMax, validMin) VALUES('fr.ifremer.echobase.entities.references.DataMetadata#4443610280597#0.9322615025965290', 0, '2014-02-27 17:01:48.355', 0.0, 'Mean biomass averaged in a grid map cell using a block averaging procedure', 0, 'Mean biomass in map cell', 'meanMapcellBiomass', 1.0, 'tons', 999999999, 0);"); + } + + dataId = tx.getSqlSupport().findSingleResult(new GetdataMetadataSqlQuery("stdevMapcellBiomass")); + if (dataId == null) { + // add it + queries.add("INSERT INTO datametadata (topiaId,topiaversion, topiacreatedate, addOffset, comment, fillValue, longName, name, scaleFactor, units, validMax, validMin) VALUES('fr.ifremer.echobase.entities.references.DataMetadata#4443610280597#0.9322615025965291', 0, '2014-02-27 17:01:48.355', 0.0, 'Biomass standard deviation in a grid map cell produced from a block averaging procedure', 0, 'Biomass standard deviation in map cell', 'stdevMapcellBiomass', 1.0, 'tons', 999999999, 0);"); + } + + dataId = tx.getSqlSupport().findSingleResult(new GetdataMetadataSqlQuery("NsampleMapcell")); + if (dataId == null) { + // add it + queries.add("INSERT INTO datametadata (topiaId,topiaversion, topiacreatedate, addOffset, comment, fillValue, longName, name, scaleFactor, units, validMax, validMin) VALUES('fr.ifremer.echobase.entities.references.DataMetadata#4443610280597#0.9322615025965292', 0, '2014-02-27 17:01:48.355', 0.0, 'No. of data samples in a grid map cell in a block averaging procedure', 0, 'No. of samples in map cell', 'NsampleMapcell', 1.0, 'tons', 999999999, 0);"); + } + } + + private static class GetdataMetadataSqlQuery extends TopiaSqlQuery<String> { + + private final String dataName; + + private GetdataMetadataSqlQuery(String dataName) { + this.dataName = dataName; + } + + @Override + public PreparedStatement prepareQuery(Connection connection) throws SQLException { + String hql = "SELECT topiaid FROM datametadata " + + "WHERE name = ?"; + PreparedStatement result = connection.prepareStatement(hql); + result.setString(1, dataName); + return result; + } + + @Override + public String prepareResult(ResultSet set) throws SQLException { + return set.getString(1); + } + } } \ No newline at end of file Modified: trunk/echobase-domain/src/main/resources/migration/postgis-view-2.6.sql =================================================================== --- trunk/echobase-domain/src/main/resources/migration/postgis-view-2.6.sql 2014-02-27 16:42:36 UTC (rev 958) +++ trunk/echobase-domain/src/main/resources/migration/postgis-view-2.6.sql 2014-02-27 16:43:28 UTC (rev 959) @@ -1,3 +1,25 @@ +--- +-- #%L +-- EchoBase :: Domain +-- $Id:$ +-- $HeadURL:$ +-- %% +-- Copyright (C) 2011 - 2014 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% +--- ----------------------------------------------------------------------------------------------------------------------- ---- DROP EXISTING VIEW - INDEX - FUNCTION - TRIGGER ------------------------------------------------------------------ -----------------------------------------------------------------------------------------------------------------------