branch feature/6271 created (now 90014ce)
This is an automated email from the git hooks/post-receive script. New change to branch feature/6271 in repository echobase. See http://git.codelutin.com/echobase.git at 90014ce utilisation nuiton-utils 3.0-rc-8 et nuiton-config 3.0-rc-2 This branch includes the following new commits: new 209e549 fixes #6269: Problème de chargement de l'écran spatial sur l'application embarquée new 12577fc fixes #6269: Problème de chargement de l'écran spatial sur l'application embarquée new 31ade09 ajout lien sur doc d'install de lizmap new 90014ce utilisation nuiton-utils 3.0-rc-8 et nuiton-config 3.0-rc-2 The 4 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 209e5491f800d839c8e988aea09423a957011f0c Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Dec 15 15:46:33 2014 +0100 fixes #6269: Problème de chargement de l'écran spatial sur l'application embarquée commit 12577fc21b5e25ee9163806a20cf590a99076596 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Dec 15 16:14:57 2014 +0100 fixes #6269: Problème de chargement de l'écran spatial sur l'application embarquée commit 31ade094760bc897d9ea4f819cebdc15f04c1faa Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Dec 15 19:33:46 2014 +0100 ajout lien sur doc d'install de lizmap commit 90014ce63dbb5dce5e3930b84a4ff7e8082f4d72 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Dec 15 20:30:11 2014 +0100 utilisation nuiton-utils 3.0-rc-8 et nuiton-config 3.0-rc-2 -- 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/6271 in repository echobase. See http://git.codelutin.com/echobase.git commit 209e5491f800d839c8e988aea09423a957011f0c Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Dec 15 15:46:33 2014 +0100 fixes #6269: Problème de chargement de l'écran spatial sur l'application embarquée --- .../EchoBaseUserTopiaApplicationContext.java | 126 +++++++ .../services/service/spatial/GisService.java | 10 + .../service/spatial/SpatialDataService.java | 141 ++++++++ .../services/service/spatial/SpatialService.java | 386 --------------------- .../echobase/ui/actions/spatial/ShowMap.java | 36 -- 5 files changed, 277 insertions(+), 422 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 new file mode 100644 index 0000000..2c9a4b2 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserTopiaApplicationContext.java @@ -0,0 +1,126 @@ +package fr.ifremer.echobase.entities; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.hibernate.cfg.Environment; + +import java.util.Map; +import java.util.Properties; + +public class EchoBaseUserTopiaApplicationContext extends AbstractEchoBaseUserTopiaApplicationContext { + + /** Logger. */ + private static final Log log = LogFactory.getLog(EchoBaseUserTopiaApplicationContext.class); + + /** + * Is database has spatial support? + * + * @since 2.8 + */ + protected boolean spatialSupport; + + /** + * Is database spatial structures are found? + * + * @since 2.8 + */ + protected boolean spatialStructureFound; + + public EchoBaseUserTopiaApplicationContext(Properties properties) { + super(properties); + initInternalSpatialStates(); + } + + public EchoBaseUserTopiaApplicationContext(Map<String, String> configuration) { + super(configuration); + initInternalSpatialStates(); + } + + @Override + public EchoBaseUserTopiaPersistenceContext newPersistenceContext() { + + EchoBaseUserTopiaPersistenceContext persistenceContext = super.newPersistenceContext(); + persistenceContext.setSpatialSupport(spatialSupport); + persistenceContext.setSpatialStructureFound(spatialStructureFound); + + return persistenceContext; + + } + + public boolean isSpatialStructureFound() { + return spatialStructureFound; + } + + public boolean isSpatialSupport() { + return spatialSupport; + } + + public void initInternalSpatialStates() { + + EchoBaseUserTopiaPersistenceContext persistenceContext = newPersistenceContext(); + + try { + + spatialSupport = computeSpatialSupport(persistenceContext); + + if (log.isInfoEnabled()) { + log.info("spatialSupport: " + spatialSupport); + } + + if (spatialSupport) { + + spatialStructureFound = computeSpatialStructureFound(persistenceContext); + if (log.isInfoEnabled()) { + log.info("spatialStructureFound: " + spatialStructureFound); + } + + } else { + + // no spatial support, so no spatial structure + spatialStructureFound = false; + + } + + } finally { + + persistenceContext.closeContext(); + + } + + } + + private boolean computeSpatialSupport(EchoBaseUserTopiaPersistenceContext persistenceContext) { + + String dialect = persistenceContext.getHibernateSupport().getHibernateConfiguration().getProperty(Environment.DIALECT); + boolean result = DriverType.POSTGRESQL.getDialectClass().getName().equals(dialect); + return result; + + + } + + private boolean computeSpatialStructureFound(EchoBaseUserTopiaPersistenceContext persistenceContext) { + + boolean result; + try { + + persistenceContext.getSqlSupport().executeSql("select count(*) from echobase_cell_spatial;"); + result = true; + + } catch (Exception e) { + + // table not found (or other, ...) + result = false; + + // rollback (otherwise transaction will stay dirty) + persistenceContext.rollback(); + + } + + return result; + + } + + public void setSpatialStructureFound(boolean spatialStructureFound) { + this.spatialStructureFound = spatialStructureFound; + } +} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/GisService.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/GisService.java new file mode 100644 index 0000000..60af56e --- /dev/null +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/GisService.java @@ -0,0 +1,10 @@ +package fr.ifremer.echobase.services.service.spatial; + +/** + * Created on 12/15/14. + * + * @author Tony Chemit - chemit@codelutin.com + * @since XXX + */ +public class GisService { +} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialDataService.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialDataService.java new file mode 100644 index 0000000..6132501 --- /dev/null +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialDataService.java @@ -0,0 +1,141 @@ +package fr.ifremer.echobase.services.service.spatial; + +/* + * #%L + * EchoBase :: Services + * %% + * Copyright (C) 2011 - 2013 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.EchoBaseTechnicalException; +import fr.ifremer.echobase.entities.EchoBaseUserPersistenceContext; +import fr.ifremer.echobase.io.EchoBaseIOUtil; +import fr.ifremer.echobase.services.EchoBaseServiceSupport; +import fr.ifremer.echobase.services.service.UserDbPersistenceService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.TimeLog; + +import javax.inject.Inject; + +/** + * Spatial service. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.2 + */ +public class SpatialDataService extends EchoBaseServiceSupport { + + /** Logger. */ + private static final Log log = LogFactory.getLog(SpatialDataService.class); + + public static final TimeLog TILE_LOG = new TimeLog(SpatialDataService.class); + + public static final String POSTGIS_STRUCTURE_SQL = "/postgis-structure.sql"; + + public static final String POSTGIS_VIEW_SQL = "/postgis-view.sql"; + + @Inject + private UserDbPersistenceService persistenceService; + + @Inject + private EchoBaseUserPersistenceContext persistenceContext; + + public void addSpatialSupport() { + + // add spatial structure + executeSqlScript(POSTGIS_STRUCTURE_SQL); + + // add spatial views + executeSqlScript(POSTGIS_VIEW_SQL); + + // do commit + persistenceService.commit(); + + persistenceService.setSpatialStructureFound(); + + } + + /** + * To update the {@code echobase_cell_spatial} table from the filled + * table {@code echobase_cell_sptaial_temp}. + * + * @since 2.2 + */ + public void updatePostgisTable() { + + if (persistenceContext.isSpatialStructureFound()) { + + // try the update only for postgresql + try { + if (log.isInfoEnabled()) { + log.info("Will try to compute operation spatial data from temp table..."); + } + persistenceService.executeSQL("SELECT echobase_fill_operation_spatial_table();"); + if (log.isInfoEnabled()) { + log.info("Will try to compute cell spatial data from temp table..."); + } + persistenceService.executeSQL("SELECT echobase_fill_cell_spatial_table();"); + persistenceService.commit(); + } catch (Exception e) { + throw new EchoBaseTechnicalException("Could not compute spatial data", e); + } + } + } + + + /** + * To update all posgis materialized views.. + * + * @since 2.6 + */ + public void updatePostgisViews() { + + if (persistenceContext.isSpatialStructureFound()) { + + // try the update only for postgresql + try { + if (log.isInfoEnabled()) { + log.info("Will try to refresh all spatial views..."); + } + persistenceService.executeSQL("SELECT echobase_refresh_views();"); + persistenceService.commit(); + } catch (Exception e) { + throw new EchoBaseTechnicalException("Could not refresh spatial views", e); + } + } + } + + protected void executeSqlScript(String scriptPath) { + + // get sql script + String sql = EchoBaseIOUtil.loadScript(scriptPath); + + if (log.isInfoEnabled()) { + log.info("Will execute sql file " + scriptPath); + } + + try { + persistenceService.executeSQL(sql); + } catch (Exception e) { + throw new EchoBaseTechnicalException( + "Could not execute sql file " + scriptPath, e); + } + } + + +} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java deleted file mode 100644 index 4e58a46..0000000 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java +++ /dev/null @@ -1,386 +0,0 @@ -package fr.ifremer.echobase.services.service.spatial; - -/* - * #%L - * EchoBase :: Services - * %% - * Copyright (C) 2011 - 2013 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 com.google.common.base.Charsets; -import com.google.common.base.Preconditions; -import fr.ifremer.echobase.EchoBaseTechnicalException; -import fr.ifremer.echobase.entities.WorkingDbConfiguration; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.io.EchoBaseIOUtil; -import fr.ifremer.echobase.persistence.JdbcConfiguration; -import fr.ifremer.echobase.services.EchoBaseServiceSupport; -import fr.ifremer.echobase.services.service.UserDbPersistenceService; -import fr.ifremer.echobase.services.service.workingDb.WorkingDbConfigurationService; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.HierarchicalINIConfiguration; -import org.apache.commons.configuration.SubnodeConfiguration; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.TimeLog; - -import javax.inject.Inject; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Scanner; - -/** - * Spatial service. - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public class SpatialService extends EchoBaseServiceSupport { - - /** Logger. */ - private static final Log log = LogFactory.getLog(SpatialService.class); - - public static final TimeLog TILE_LOG = new TimeLog(SpatialService.class); - - public static final String POSTGIS_STRUCTURE_SQL = "/postgis-structure.sql"; - - public static final String POSTGIS_VIEW_SQL = "/postgis-view.sql"; - - public static final String[] TEMPLATE_MARKUP = {"{{dbname}}", "{{host}}", "{{port}}", "{{userName}}", "{{password}}", "{{voyageName}}", "{{voyageId}}", "{{resourcesPath}}" }; - - public static final String START_JDBC_URL = "jdbc:postgresql://"; - - @Inject - private UserDbPersistenceService persistenceService; - - @Inject - private WorkingDbConfigurationService workingDbConfigurationService; - - - public void addSpatialSupport() { - - // add spatial structure - executeSqlScript(POSTGIS_STRUCTURE_SQL); - - // add spatial views - executeSqlScript(POSTGIS_VIEW_SQL); - - // do commit - persistenceService.commit(); - } - - protected void executeSqlScript(String scriptPath) { - - // get sql script - String sql = EchoBaseIOUtil.loadScript(scriptPath); - - if (log.isInfoEnabled()) { - log.info("Will execute sql file " + scriptPath); - } - - try { - persistenceService.executeSQL(sql); - } catch (Exception e) { - throw new EchoBaseTechnicalException( - "Could not execute sql file " + scriptPath, e); - } - } - - - public boolean isSpatialAware() { - boolean result = persistenceService.isSpatialAware(); - return result; - } - - public boolean isPostgresql() { - boolean result = persistenceService.isPostgresql(); - return result; - } - - /** - * To update the {@code echobase_cell_spatial} table from the filled - * table {@code echobase_cell_sptaial_temp}. - * - * @since 2.2 - */ - public void updatePostgisTable() { - - if (isSpatialAware()) { - - // try the update only for postgresql - try { - if (log.isInfoEnabled()) { - log.info("Will try to compute operation spatial data from temp table..."); - } - persistenceService.executeSQL("SELECT echobase_fill_operation_spatial_table();"); - if (log.isInfoEnabled()) { - log.info("Will try to compute cell spatial data from temp table..."); - } - persistenceService.executeSQL("SELECT echobase_fill_cell_spatial_table();"); - persistenceService.commit(); - } catch (Exception e) { - throw new EchoBaseTechnicalException("Could not compute spatial data", e); - } - } - } - - /** - * To update all posgis materialized views.. - * - * @since 2.6 - */ - public void updatePostgisViews() { - - if (isSpatialAware()) { - - // try the update only for postgresql - try { - if (log.isInfoEnabled()) { - log.info("Will try to refresh all spatial views..."); - } - persistenceService.executeSQL("SELECT echobase_refresh_views();"); - persistenceService.commit(); - } catch (Exception e) { - throw new EchoBaseTechnicalException("Could not refresh spatial views", e); - } - } - } - - - /** - * Generate maps files for this database. - * @param conf data base connexion configuration - * @return Name of repository maps - */ - public String generateMaps(JdbcConfiguration conf) { - - WorkingDbConfiguration workingDbConfiguration - = workingDbConfigurationService.getWorkingDbConfigurationByUrl(conf.getUrl()); - - File lizmapTarget = getConfiguration().getLizmapTarget(); - - File lizmapConfig = getConfiguration().getLizmapConfig(); - - String lizmapJdbcUrl = getConfiguration().getLizmapJdbcUrl(); - - if (!lizmapTarget.isDirectory()) { - throw new EchoBaseTechnicalException("Map target (" + lizmapTarget.getAbsolutePath() + ") is not directory"); - } - - String repositoryName = getRepositoryName(conf); - File repository = new File(lizmapTarget, repositoryName); - - if (!repository.isDirectory()) { - repository.mkdir(); - } - - // Add repository in Lizmap - - try { - HierarchicalINIConfiguration lizmapIni = new HierarchicalINIConfiguration(lizmapConfig); - SubnodeConfiguration section = lizmapIni.getSection("repository:" + repositoryName); - section.setProperty("label", workingDbConfiguration.getDescription()); - section.setProperty("path", repository.getAbsolutePath() + "/"); - lizmapIni.save(new FileWriter(lizmapConfig)); - - } catch (ConfigurationException e) { - throw new EchoBaseTechnicalException("Could not load Lizmap config", e); - } catch (IOException e) { - throw new EchoBaseTechnicalException("Could not save Lizmap config", e); - } - - // Add authorization - Connection connection = null; - Statement statement = null; - - try { - connection = DriverManager.getConnection(lizmapJdbcUrl); - statement = connection.createStatement(); - statement.execute("INSERT OR REPLACE INTO jacl2_rights " + - "(id_aclsbj, id_aclgrp, id_aclres, canceled) " + - "VALUES " + - "('lizmap.repositories.view', '__anonymous', '" + repositoryName + "', 0);"); - statement.execute("INSERT OR REPLACE INTO jacl2_rights " + - "(id_aclsbj, id_aclgrp, id_aclres, canceled) " + - "VALUES " + - "('lizmap.repositories.view', 'admins', '" + repositoryName + "', 0);"); - - } catch (SQLException e) { - throw new EchoBaseTechnicalException("Could not create rights in lizmap", e); - } finally { - try { - if (statement != null) { - statement.close(); - } - if (connection != null) { - connection.close(); - } - } catch (SQLException e) { - throw new EchoBaseTechnicalException("Could not create rights in lizmap", e); - } - } - - - for (Voyage voyage : persistenceService.getAllVoyages()) { - generateMap(conf, voyage, repository); - } - - return repositoryName; - } - - protected String getRepositoryName(JdbcConfiguration conf) { - - String url = conf.getUrl(); - - int hostIndex = START_JDBC_URL.length() - 1; - int portIndex = url.indexOf(':', hostIndex); - int dbnameIndex = url.indexOf("/", portIndex); - - String dbname = url.substring(dbnameIndex + 1); - String host = url.substring(hostIndex + 1, portIndex); - String port = url.substring(portIndex + 1, dbnameIndex); - - String repository = host + port + dbname; - - repository = StringUtils.replaceEach(repository, new String[]{"-", "."}, new String[]{"", ""}); - - return repository; - } - - /** - * Generate map files for this database and this voyage. - * @param conf data base connexion configuration - * @param voyage voyage for this map - * @param repository Lizmap repository - * @return Name of project map - */ - protected String generateMap (JdbcConfiguration conf, Voyage voyage, File repository) { - Preconditions.checkNotNull(conf); - Preconditions.checkNotNull(voyage); - - String project = voyage.getName(); - - String[] templateValues = getTemplateValues(conf, voyage); - - generateMapFile(getConfiguration().getQgisTemplate(), repository, project, templateValues); - - generateMapFile(getConfiguration().getLizmapTemplate(), repository, project, templateValues); - - return project; - - } - - /** - * Generate file from template and values - * @param template file template to used - * @param repository lizmap repository - * @param project project name - * @param templateValues values to used in the template - * @return file generated - */ - protected File generateMapFile(File template, File repository, String project, String[] templateValues) { - - String name = template.getName(); - name = project + name.substring(name.indexOf(".")); - - File target = new File(repository, name); - - if (!target.isFile()) { - - Scanner scanner = null; - BufferedWriter bufferedWriter = null; - try { - scanner = new Scanner(template, Charsets.UTF_8.name()); - - bufferedWriter = new BufferedWriter(new FileWriter(target)); - - String line; - - while(scanner.hasNextLine() ) { - line = scanner.nextLine(); - line = StringUtils.replaceEach(line, TEMPLATE_MARKUP, templateValues); - bufferedWriter.write(line); - bufferedWriter.newLine(); - } - } catch (FileNotFoundException e) { - throw new EchoBaseTechnicalException(e); - } catch (IOException e) { - throw new EchoBaseTechnicalException(e); - } finally { - scanner.close(); - if (bufferedWriter != null) { - try { - bufferedWriter.close(); - } catch (IOException e) { - throw new EchoBaseTechnicalException(e); - } - } - } - } - - return target; - - } - - /** - * Extract data value to used in template - * @param conf data base connexion configuration - * @param voyage voyage for this map - * @return values table - */ - protected String[] getTemplateValues(JdbcConfiguration conf, Voyage voyage) { - - String[] templateValues = new String[TEMPLATE_MARKUP.length]; - - String url = conf.getUrl(); - if (!url.startsWith(START_JDBC_URL)) { - throw new EchoBaseTechnicalException("JDBC URL '" + url + "' is no reference to a Postrges database"); - } - - int hostIndex = START_JDBC_URL.length() - 1; - int portIndex = url.indexOf(':', hostIndex); - int dbnameIndex = url.indexOf("/", portIndex); - - // dbname - templateValues[0] = url.substring(dbnameIndex + 1); - // host - templateValues[1] = url.substring(hostIndex + 1, portIndex); - // port - templateValues[2] = url.substring(portIndex + 1, dbnameIndex); - // userName - templateValues[3] = conf.getLogin(); - // password - templateValues[4] = conf.getPassword(); - // voyage name - templateValues[5] = voyage.getName(); - // voyage id - templateValues[6] = voyage.getTopiaId(); - // ressourcesPath - templateValues[7] = getConfiguration().getQgisResources().getAbsolutePath(); - - return templateValues; - } - -} diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowMap.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowMap.java deleted file mode 100644 index 346ee7f..0000000 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowMap.java +++ /dev/null @@ -1,36 +0,0 @@ -package fr.ifremer.echobase.ui.actions.spatial; - -/* - * #%L - * EchoBase :: UI - * %% - * Copyright (C) 2011 - 2013 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.ui.actions.EchoBaseActionSupport; - -/** - * To display only the spatial data map. - * <p/> - * This action will be reused to raster spatial data maps. - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public class ShowMap extends EchoBaseActionSupport { - -} -- 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/6271 in repository echobase. See http://git.codelutin.com/echobase.git commit 12577fc21b5e25ee9163806a20cf590a99076596 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Dec 15 16:14:57 2014 +0100 fixes #6269: Problème de chargement de l'écran spatial sur l'application embarquée --- .../entities/EchoBaseUserPersistenceContext.java | 19 +- .../EchoBaseUserTopiaApplicationContext.java | 7 +- .../EchoBaseUserTopiaPersistenceContext.java | 48 ++-- .../workingDb/MigrationCallBackForVersion2_2.java | 2 +- .../MigrationCallBackForVersion2_5_1.java | 2 +- .../workingDb/MigrationCallBackForVersion2_6.java | 2 +- .../MigrationCallBackForVersion2_6_1.java | 2 +- .../services/service/UserDbPersistenceService.java | 15 +- .../importdata/AbstractImportDataService.java | 6 +- .../services/service/importdb/ImportDbService.java | 14 +- .../services/service/spatial/GisService.java | 281 ++++++++++++++++++++- .../service/spatial/SpatialDataService.java | 2 +- .../echobase/ui/EchoBaseApplicationContext.java | 27 +- .../echobase/ui/actions/dbeditor/DeleteEntity.java | 4 +- .../echobase/ui/actions/dbeditor/SaveEntity.java | 6 +- .../actions/importData/AbstractLaunchImport.java | 7 +- .../echobase/ui/actions/removeData/Delete.java | 6 +- .../ui/actions/spatial/RefreshSpatialViews.java | 6 +- .../ifremer/echobase/ui/actions/spatial/Show.java | 103 ++++++-- .../ui/actions/spatial/ShowSpatialModel.java | 64 ----- .../echobase/ui/actions/workingDb/AddSpatial.java | 6 +- .../echobase/ui/actions/workingDb/Information.java | 30 ++- .../src/main/resources/config/struts-spatial.xml | 9 - .../resources/i18n/echobase-ui_en_GB.properties | 4 + .../resources/i18n/echobase-ui_fr_FR.properties | 4 + .../src/main/webapp/WEB-INF/jsp/spatial/show.jsp | 88 ++++--- .../webapp/WEB-INF/jsp/workingDb/information.jsp | 16 +- 27 files changed, 562 insertions(+), 218 deletions(-) diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserPersistenceContext.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserPersistenceContext.java index a4bb646..444b578 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserPersistenceContext.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/EchoBaseUserPersistenceContext.java @@ -21,8 +21,8 @@ package fr.ifremer.echobase.entities; * #L% */ -import org.nuiton.topia.persistence.support.TopiaHibernateSupport; import org.nuiton.topia.persistence.TopiaPersistenceContext; +import org.nuiton.topia.persistence.support.TopiaHibernateSupport; import org.nuiton.topia.persistence.support.TopiaSqlSupport; /** @@ -33,9 +33,22 @@ import org.nuiton.topia.persistence.support.TopiaSqlSupport; */ public interface EchoBaseUserPersistenceContext extends TopiaPersistenceContext, EchoBaseUserTopiaDaoSupplier { - boolean isPostgresql(); + /** + * @return {@code true} if db support spatial features, {@code false} otherwise. + * @since 2.8 + */ + boolean isSpatialSupport(); + + /** + * @return {@code true} if db have spatial structures, {@code false} otherwise. + * @since 2.8 + */ + boolean isSpatialStructureFound(); + + void setSpatialSupport(boolean spatialSupport); + + void setSpatialStructureFound(boolean spatialStructureFound); - boolean isSpatialAware(); String getUrl(); 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 2c9a4b2..d4b65fe 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 @@ -55,6 +55,10 @@ public class EchoBaseUserTopiaApplicationContext extends AbstractEchoBaseUserTop return spatialSupport; } + public void setSpatialStructureFound(boolean spatialStructureFound) { + this.spatialStructureFound = spatialStructureFound; + } + public void initInternalSpatialStates() { EchoBaseUserTopiaPersistenceContext persistenceContext = newPersistenceContext(); @@ -120,7 +124,4 @@ public class EchoBaseUserTopiaApplicationContext extends AbstractEchoBaseUserTop } - public void setSpatialStructureFound(boolean spatialStructureFound) { - this.spatialStructureFound = spatialStructureFound; - } } 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 809f70a..0313149 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,41 +22,49 @@ package fr.ifremer.echobase.entities; */ import org.hibernate.cfg.Environment; -import org.nuiton.topia.persistence.support.TopiaListenableSupport; +import org.nuiton.topia.persistence.TopiaIdFactory; import org.nuiton.topia.persistence.internal.HibernateProvider; import org.nuiton.topia.persistence.internal.TopiaHibernateSessionRegistry; -import org.nuiton.topia.persistence.TopiaIdFactory; +import org.nuiton.topia.persistence.support.TopiaListenableSupport; public class EchoBaseUserTopiaPersistenceContext extends AbstractEchoBaseUserTopiaPersistenceContext { + /** + * Is database has spatial support? + * + * @since 2.8 + */ + protected boolean spatialSupport; + + /** + * Is database spatial structures are found? + * + * @since 2.8 + */ + protected boolean spatialStructureFound; + public EchoBaseUserTopiaPersistenceContext(HibernateProvider hibernateProvider, TopiaListenableSupport listenableSupport, TopiaIdFactory topiaIdFactory, TopiaHibernateSessionRegistry sessionRegistry) { super(hibernateProvider, listenableSupport, topiaIdFactory, sessionRegistry); } @Override - public boolean isPostgresql() { - String dialect = getHibernateSupport().getHibernateConfiguration().getProperty(Environment.DIALECT); - - return DriverType.POSTGRESQL.getDialectClass().getName().equals(dialect); + public boolean isSpatialSupport() { + return spatialSupport; } @Override - public boolean isSpatialAware() { - boolean result = isPostgresql(); + public void setSpatialSupport(boolean spatialSupport) { + this.spatialSupport = spatialSupport; + } - if (result) { + @Override + public boolean isSpatialStructureFound() { + return spatialStructureFound; + } - // on pg db, check there is now a echobase_spatial_cell - try { - getSqlSupport().executeSql("select count(*) from echobase_cell_spatial;"); - } catch (Exception e) { - // table not found (or other, ...) - result = false; - // rollback (otherwise transaction will stay dirty) - rollback(); - } - } - return result; + @Override + public void setSpatialStructureFound(boolean spatialStructureFound) { + this.spatialStructureFound = spatialStructureFound; } @Override 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 732eee4..8e956a8 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 @@ -71,7 +71,7 @@ public class MigrationCallBackForVersion2_2 extends MigrationCallBackForVersion } protected void updatePostgis(EchoBaseUserTopiaPersistenceContext tx) { - boolean spatialAware = tx.isSpatialAware(); + boolean spatialAware = tx.isSpatialStructureFound(); try { if (spatialAware) { 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 9054d50..8dfd646 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 @@ -51,7 +51,7 @@ public class MigrationCallBackForVersion2_5_1 extends MigrationCallBackForVersio boolean showSql, boolean showProgression) throws TopiaException { - boolean spatialAware = tx.isSpatialAware(); + boolean spatialAware = tx.isSpatialStructureFound(); 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 49be158..d47a06d 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 @@ -54,7 +54,7 @@ public class MigrationCallBackForVersion2_6 extends MigrationCallBackForVersion boolean showSql, boolean showProgression) throws TopiaException { - boolean spatialAware = tx.isSpatialAware(); + boolean spatialAware = tx.isSpatialStructureFound(); if (spatialAware) { 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 185dbec..e6f63b9 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 @@ -49,7 +49,7 @@ public class MigrationCallBackForVersion2_6_1 extends MigrationCallBackForVersio boolean showSql, boolean showProgression) throws TopiaException { - boolean spatialAware = tx.isSpatialAware(); + boolean spatialAware = tx.isSpatialStructureFound(); if (spatialAware) { diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/UserDbPersistenceService.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/UserDbPersistenceService.java index 0c4a35a..644a18c 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/UserDbPersistenceService.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/UserDbPersistenceService.java @@ -92,6 +92,13 @@ public class UserDbPersistenceService extends EchoBaseServiceSupport { @Inject private DecoratorService decoratorService; + public void setSpatialStructureFound() { + + persistenceContext.setSpatialStructureFound(true); + serviceContext.getEchoBaseUserApplicationContext().setSpatialStructureFound(true); + + } + //------------------------------------------------------------------------// //--- AgeCategory --------------------------------------------------------// //------------------------------------------------------------------------// @@ -771,14 +778,6 @@ public class UserDbPersistenceService extends EchoBaseServiceSupport { return persistenceContext.getSqlSupport().findMultipleResult(sqlQuery); } - public boolean isPostgresql() { - return persistenceContext.isPostgresql(); - } - - public boolean isSpatialAware() { - return persistenceContext.isSpatialAware(); - } - public boolean isIdExists(String id) { try { boolean result = getDAOFromId(id).forTopiaIdEquals(id).exists(); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataService.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataService.java index 3a8fdf7..123327d 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataService.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AbstractImportDataService.java @@ -43,7 +43,7 @@ import fr.ifremer.echobase.entities.references.SpeciesCategory; import fr.ifremer.echobase.io.InputFile; import fr.ifremer.echobase.services.EchoBaseServiceSupport; import fr.ifremer.echobase.services.service.UserDbPersistenceService; -import fr.ifremer.echobase.services.service.spatial.SpatialService; +import fr.ifremer.echobase.services.service.spatial.SpatialDataService; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -88,7 +88,7 @@ public abstract class AbstractImportDataService<M extends AbstractImportConfigur protected UserDbPersistenceService persistenceService; @Inject - private SpatialService spatialService; + private SpatialDataService spatialDataService; public final String doImport(M configuration, EchoBaseUser user) throws ImportException { @@ -115,7 +115,7 @@ public abstract class AbstractImportDataService<M extends AbstractImportConfigur persistenceService.commit(); // update sql spatial data - spatialService.updatePostgisTable(); + spatialDataService.updatePostgisTable(); s0 = TIME_LOG.log(s0, "postgis update"); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/ImportDbService.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/ImportDbService.java index a32d668..2a18376 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/ImportDbService.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdb/ImportDbService.java @@ -22,12 +22,13 @@ package fr.ifremer.echobase.services.service.importdb; import fr.ifremer.echobase.EchoBaseTechnicalException; import fr.ifremer.echobase.entities.EchoBaseUser; +import fr.ifremer.echobase.entities.EchoBaseUserPersistenceContext; import fr.ifremer.echobase.services.EchoBaseServiceSupport; import fr.ifremer.echobase.services.service.importdata.ImportException; import fr.ifremer.echobase.services.service.importdb.strategy.AbstractImportDbStrategy; import fr.ifremer.echobase.services.service.importdb.strategy.FreeImportDbStrategy; import fr.ifremer.echobase.services.service.importdb.strategy.ReferentialImportDbStrategy; -import fr.ifremer.echobase.services.service.spatial.SpatialService; +import fr.ifremer.echobase.services.service.spatial.SpatialDataService; import org.nuiton.topia.persistence.TopiaException; import javax.inject.Inject; @@ -42,7 +43,10 @@ import java.io.IOException; public class ImportDbService extends EchoBaseServiceSupport { @Inject - private SpatialService spatialService; + private EchoBaseUserPersistenceContext persistenceContext; + + @Inject + private SpatialDataService spatialDataService; public void doImport(ImportDbConfiguration model, EchoBaseUser user) throws ImportException { @@ -71,11 +75,11 @@ public class ImportDbService extends EchoBaseServiceSupport { throw new ImportException("Could not import db", e); } - if (ImportDbMode.REFERENTIAL != importDbMode && - spatialService.isSpatialAware()) { + if (ImportDbMode.REFERENTIAL != importDbMode && persistenceContext.isSpatialStructureFound()) { // let's update postgis table - spatialService.updatePostgisTable(); + spatialDataService.updatePostgisTable(); + } } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/GisService.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/GisService.java index 60af56e..55c3380 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/GisService.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/GisService.java @@ -1,10 +1,287 @@ package fr.ifremer.echobase.services.service.spatial; +import com.google.common.base.Charsets; +import com.google.common.base.Preconditions; +import fr.ifremer.echobase.EchoBaseTechnicalException; +import fr.ifremer.echobase.entities.WorkingDbConfiguration; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.io.EchoBaseIOUtil; +import fr.ifremer.echobase.persistence.JdbcConfiguration; +import fr.ifremer.echobase.services.EchoBaseServiceSupport; +import fr.ifremer.echobase.services.service.UserDbPersistenceService; +import fr.ifremer.echobase.services.service.workingDb.WorkingDbConfigurationService; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.HierarchicalINIConfiguration; +import org.apache.commons.configuration.SubnodeConfiguration; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.inject.Inject; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Scanner; + /** + * Gis Service (to interact with a gis system). + * * Created on 12/15/14. * * @author Tony Chemit - chemit@codelutin.com - * @since XXX + * @since 2.8 */ -public class GisService { +public class GisService extends EchoBaseServiceSupport { + + /** Logger. */ + private static final Log log = LogFactory.getLog(GisService.class); + + public static final String[] TEMPLATE_MARKUP = {"{{dbname}}", "{{host}}", "{{port}}", "{{userName}}", "{{password}}", "{{voyageName}}", "{{voyageId}}", "{{resourcesPath}}"}; + + public static final String START_JDBC_URL = "jdbc:postgresql://"; + + @Inject + private WorkingDbConfigurationService workingDbConfigurationService; + + @Inject + private UserDbPersistenceService persistenceService; + + /** + * Generate maps files for this database. + * + * @param conf data base connexion configuration + */ + public void generateMaps(JdbcConfiguration conf) { + + File lizmapTarget = getConfiguration().getLizmapTarget(); + + if (!lizmapTarget.isDirectory()) { + throw new EchoBaseTechnicalException("Map target (" + lizmapTarget.getAbsolutePath() + ") is not directory"); + } + + String repositoryName = getRepositoryName(conf); + + File repository = new File(lizmapTarget, repositoryName); + EchoBaseIOUtil.forceMkdir(repository); + + // Add repository in Lizmap config + updateLizmapConfigFile(conf, repositoryName, repository); + + // Add authorization in Lizmap database + updateLizmapAuthorizations(repositoryName); + + for (Voyage voyage : persistenceService.getAllVoyages()) { + generateMap(conf, voyage, repository); + } + + } + + public String getRepositoryUrl(JdbcConfiguration conf) { + + String repositoryName = getRepositoryName(conf); + String repositoryUrl = getConfiguration().getLizmapUrl() + "?" + "repository=" + repositoryName; + return repositoryUrl; + + } + + protected void updateLizmapConfigFile(JdbcConfiguration conf, String repositoryName, File repository) { + + WorkingDbConfiguration workingDbConfiguration + = workingDbConfigurationService.getWorkingDbConfigurationByUrl(conf.getUrl()); + + File lizmapConfig = getConfiguration().getLizmapConfig(); + + try { + + HierarchicalINIConfiguration lizmapIni = new HierarchicalINIConfiguration(lizmapConfig); + SubnodeConfiguration section = lizmapIni.getSection("repository:" + repositoryName); + section.setProperty("label", workingDbConfiguration.getDescription()); + section.setProperty("path", repository.getAbsolutePath() + "/"); + lizmapIni.save(new FileWriter(lizmapConfig)); + + } catch (ConfigurationException e) { + throw new EchoBaseTechnicalException("Could not load Lizmap config", e); + } catch (IOException e) { + throw new EchoBaseTechnicalException("Could not save Lizmap config", e); + } + + } + + public void updateLizmapAuthorizations(String repositoryName) { + + String lizmapJdbcUrl = getConfiguration().getLizmapJdbcUrl(); + Connection connection = null; + Statement statement = null; + + try { + connection = DriverManager.getConnection(lizmapJdbcUrl); + statement = connection.createStatement(); + statement.execute("INSERT OR REPLACE INTO jacl2_rights " + + "(id_aclsbj, id_aclgrp, id_aclres, canceled) " + + "VALUES " + + "('lizmap.repositories.view', '__anonymous', '" + repositoryName + "', 0);"); + statement.execute("INSERT OR REPLACE INTO jacl2_rights " + + "(id_aclsbj, id_aclgrp, id_aclres, canceled) " + + "VALUES " + + "('lizmap.repositories.view', 'admins', '" + repositoryName + "', 0);"); + + } catch (SQLException e) { + throw new EchoBaseTechnicalException("Could not create rights in lizmap", e); + } finally { + try { + if (statement != null) { + statement.close(); + } + if (connection != null) { + connection.close(); + } + } catch (SQLException e) { + throw new EchoBaseTechnicalException("Could not create rights in lizmap", e); + } + } + } + + protected String getRepositoryName(JdbcConfiguration conf) { + + String url = conf.getUrl(); + + int hostIndex = START_JDBC_URL.length() - 1; + int portIndex = url.indexOf(':', hostIndex); + int dbnameIndex = url.indexOf("/", portIndex); + + String dbname = url.substring(dbnameIndex + 1); + String host = url.substring(hostIndex + 1, portIndex); + String port = url.substring(portIndex + 1, dbnameIndex); + + String repository = host + port + dbname; + + repository = StringUtils.replaceEach(repository, new String[]{"-", "."}, new String[]{"", ""}); + + return repository; + } + + /** + * Generate map files for this database and this voyage. + * + * @param conf data base connexion configuration + * @param voyage voyage for this map + * @param repository Lizmap repository + * @return Name of project map + */ + protected String generateMap(JdbcConfiguration conf, Voyage voyage, File repository) { + Preconditions.checkNotNull(conf); + Preconditions.checkNotNull(voyage); + + String project = voyage.getName(); + + String[] templateValues = getTemplateValues(conf, voyage); + + generateMapFile(getConfiguration().getQgisTemplate(), repository, project, templateValues); + + generateMapFile(getConfiguration().getLizmapTemplate(), repository, project, templateValues); + + return project; + + } + + /** + * Generate file from template and values + * + * @param template file template to used + * @param repository lizmap repository + * @param project project name + * @param templateValues values to used in the template + * @return file generated + */ + protected File generateMapFile(File template, File repository, String project, String[] templateValues) { + + String name = template.getName(); + name = project + name.substring(name.indexOf(".")); + + File target = new File(repository, name); + + if (!target.isFile()) { + + Scanner scanner = null; + BufferedWriter bufferedWriter = null; + try { + scanner = new Scanner(template, Charsets.UTF_8.name()); + + bufferedWriter = new BufferedWriter(new FileWriter(target)); + + String line; + + while (scanner.hasNextLine()) { + line = scanner.nextLine(); + line = StringUtils.replaceEach(line, TEMPLATE_MARKUP, templateValues); + bufferedWriter.write(line); + bufferedWriter.newLine(); + } + } catch (FileNotFoundException e) { + throw new EchoBaseTechnicalException(e); + } catch (IOException e) { + throw new EchoBaseTechnicalException(e); + } finally { + scanner.close(); + if (bufferedWriter != null) { + try { + bufferedWriter.close(); + } catch (IOException e) { + throw new EchoBaseTechnicalException(e); + } + } + } + } + + return target; + + } + + /** + * Extract data value to used in template + * + * @param conf data base connexion configuration + * @param voyage voyage for this map + * @return values table + */ + protected String[] getTemplateValues(JdbcConfiguration conf, Voyage voyage) { + + String[] templateValues = new String[TEMPLATE_MARKUP.length]; + + String url = conf.getUrl(); + if (!url.startsWith(START_JDBC_URL)) { + throw new EchoBaseTechnicalException("JDBC URL '" + url + "' is no reference to a Postrges database"); + } + + int hostIndex = START_JDBC_URL.length() - 1; + int portIndex = url.indexOf(':', hostIndex); + int dbnameIndex = url.indexOf("/", portIndex); + + // dbname + templateValues[0] = url.substring(dbnameIndex + 1); + // host + templateValues[1] = url.substring(hostIndex + 1, portIndex); + // port + templateValues[2] = url.substring(portIndex + 1, dbnameIndex); + // userName + templateValues[3] = conf.getLogin(); + // password + templateValues[4] = conf.getPassword(); + // voyage name + templateValues[5] = voyage.getName(); + // voyage id + templateValues[6] = voyage.getTopiaId(); + // ressourcesPath + templateValues[7] = getConfiguration().getQgisResources().getAbsolutePath(); + + return templateValues; + + } + } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialDataService.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialDataService.java index 6132501..676df49 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialDataService.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialDataService.java @@ -33,7 +33,7 @@ import org.nuiton.util.TimeLog; import javax.inject.Inject; /** - * Spatial service. + * Spatial data service : to manage spatial data of a user database. * * @author tchemit <chemit@codelutin.com> * @since 2.2 diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java index 780da84..b4f5c11 100644 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java +++ b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java @@ -98,6 +98,11 @@ public class EchoBaseApplicationContext { /** Set of all loggued user sessions to be close at shutdown time. */ protected Set<EchoBaseSession> sessions; + /** + * Is application has gis support. + */ + protected boolean gisSupport; + public static EchoBaseApplicationContext getApplicationContext(ActionContext actionContext) { Map<String, Object> application = actionContext.getApplication(); EchoBaseApplicationContext result = @@ -169,6 +174,10 @@ public class EchoBaseApplicationContext { session.close(); } + public boolean isGisSupport() { + return gisSupport; + } + public void init() { // init I18n @@ -222,7 +231,19 @@ public class EchoBaseApplicationContext { throw new TopiaException("Could not extract files (drivers + embedded war)", e); } - initLizamp(); + File lizmapConfig = getConfiguration().getLizmapConfig(); + + gisSupport = lizmapConfig.exists(); + + if (gisSupport) { + + //TODO Check lizmap instance is reachable + + initGisFiles(); + + } + + } public EchoBaseConfiguration getConfiguration() { @@ -423,7 +444,7 @@ public class EchoBaseApplicationContext { } } - protected void initLizamp() { + protected void initGisFiles() { try { if (!configuration.getQgisTemplate().exists()) { URL qgisTemplateUrl = EchoBaseApplicationContext.class.getResource(QGIS_TEMPLATE); @@ -447,7 +468,7 @@ public class EchoBaseApplicationContext { configuration.getLizmapTarget().mkdirs(); } } catch (IOException e) { - throw new EchoBaseTechnicalException("Could not create lizmap files", e); + throw new EchoBaseTechnicalException("Could not create gis support files", e); } } diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DeleteEntity.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DeleteEntity.java index 06275e5..30f6532 100644 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DeleteEntity.java +++ b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DeleteEntity.java @@ -24,7 +24,7 @@ package fr.ifremer.echobase.ui.actions.dbeditor; import fr.ifremer.echobase.EchoBaseTechnicalException; import fr.ifremer.echobase.entities.EchoBaseUserEntityEnum; import fr.ifremer.echobase.services.service.DbEditorService; -import fr.ifremer.echobase.services.service.spatial.SpatialService; +import fr.ifremer.echobase.services.service.spatial.SpatialDataService; import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; import javax.inject.Inject; @@ -80,5 +80,5 @@ public class DeleteEntity extends EchoBaseActionSupport { protected transient DbEditorService dbEditorService; @Inject - protected transient SpatialService spatialService; + protected transient SpatialDataService spatialDataService; } diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java index 4552e41..91912f2 100644 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java +++ b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java @@ -22,8 +22,8 @@ package fr.ifremer.echobase.ui.actions.dbeditor; import com.google.common.collect.Maps; import fr.ifremer.echobase.entities.EchoBaseUserEntityEnum; +import fr.ifremer.echobase.entities.EchoBaseUserPersistenceContext; import fr.ifremer.echobase.services.service.DbEditorService; -import fr.ifremer.echobase.services.service.spatial.SpatialService; import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; import org.apache.struts2.interceptor.ParameterAware; import org.nuiton.topia.persistence.TopiaEntity; @@ -90,7 +90,7 @@ public class SaveEntity extends EchoBaseActionSupport implements ParameterAware properties, getEchoBaseSession().getUser()); - if (spatialService.isSpatialAware()) { + if (persistenceContext.isSpatialStructureFound()) { addFlashMessage(t("echobase.info.reload.spatialData")); } @@ -112,6 +112,6 @@ public class SaveEntity extends EchoBaseActionSupport implements ParameterAware protected transient DbEditorService dbEditorService; @Inject - protected transient SpatialService spatialService; + protected transient EchoBaseUserPersistenceContext persistenceContext; } diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/AbstractLaunchImport.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/AbstractLaunchImport.java index 0bd1913..f6fa2b4 100644 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/AbstractLaunchImport.java +++ b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/AbstractLaunchImport.java @@ -20,10 +20,9 @@ */ package fr.ifremer.echobase.ui.actions.importData; +import fr.ifremer.echobase.entities.EchoBaseUserPersistenceContext; import fr.ifremer.echobase.services.service.importdata.AbstractImportConfiguration; import fr.ifremer.echobase.services.service.importdata.AbstractImportDataService; -import fr.ifremer.echobase.services.service.importdb.ImportDbMode; -import fr.ifremer.echobase.services.service.spatial.SpatialService; import fr.ifremer.echobase.ui.actions.AbstractWaitAndExecAction; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -44,7 +43,7 @@ public class AbstractLaunchImport<M extends AbstractImportConfiguration, S exten private static final Log log = LogFactory.getLog(AbstractLaunchImport.class); @Inject - protected transient SpatialService spatialService; + protected transient EchoBaseUserPersistenceContext persistenceContext; protected AbstractLaunchImport(Class<M> modelType, Class<S> serviceType) { super(modelType, serviceType); @@ -88,7 +87,7 @@ public class AbstractLaunchImport<M extends AbstractImportConfiguration, S exten @Override protected void closeAction(M model) throws Exception { destroyModel(model); - if (spatialService.isSpatialAware()) { + if (persistenceContext.isSpatialStructureFound()) { addFlashMessage(t("echobase.info.reload.spatialData")); } } diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java index 543c52d..8aa70d0 100644 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java +++ b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java @@ -21,9 +21,9 @@ package fr.ifremer.echobase.ui.actions.removeData; * #L% */ +import fr.ifremer.echobase.entities.EchoBaseUserPersistenceContext; import fr.ifremer.echobase.services.service.removedata.RemoveDataConfiguration; import fr.ifremer.echobase.services.service.removedata.RemoveDataService; -import fr.ifremer.echobase.services.service.spatial.SpatialService; import fr.ifremer.echobase.ui.actions.AbstractWaitAndExecAction; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -44,7 +44,7 @@ public class Delete extends AbstractWaitAndExecAction<RemoveDataConfiguration, R private static final Log log = LogFactory.getLog(Delete.class); @Inject - protected transient SpatialService spatialService; + protected transient EchoBaseUserPersistenceContext persistenceContext; public Delete() { super(RemoveDataConfiguration.class, RemoveDataService.class); @@ -88,7 +88,7 @@ public class Delete extends AbstractWaitAndExecAction<RemoveDataConfiguration, R protected void closeAction(RemoveDataConfiguration model) throws Exception { destroyModel(model); - if (spatialService.isSpatialAware()) { + if (persistenceContext.isSpatialStructureFound()) { addFlashMessage(t("echobase.info.reload.spatialData")); } } diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/RefreshSpatialViews.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/RefreshSpatialViews.java index 73e75f1..debd6eb 100644 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/RefreshSpatialViews.java +++ b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/RefreshSpatialViews.java @@ -21,7 +21,7 @@ package fr.ifremer.echobase.ui.actions.spatial; * #L% */ -import fr.ifremer.echobase.services.service.spatial.SpatialService; +import fr.ifremer.echobase.services.service.spatial.SpatialDataService; import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; import javax.inject.Inject; @@ -37,12 +37,12 @@ public class RefreshSpatialViews extends EchoBaseActionSupport { private static final long serialVersionUID = 1L; @Inject - protected transient SpatialService spatialService; + protected transient SpatialDataService spatialDataService; @Override public String execute() throws Exception { - spatialService.updatePostgisViews(); + spatialDataService.updatePostgisViews(); return SUCCESS; } diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/Show.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/Show.java index 784b32c..e396e76 100644 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/Show.java +++ b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/Show.java @@ -21,8 +21,9 @@ package fr.ifremer.echobase.ui.actions.spatial; * #L% */ +import fr.ifremer.echobase.entities.EchoBaseUserPersistenceContext; import fr.ifremer.echobase.persistence.JdbcConfiguration; -import fr.ifremer.echobase.services.service.spatial.SpatialService; +import fr.ifremer.echobase.services.service.spatial.GisService; import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -42,50 +43,102 @@ public class Show extends EchoBaseActionSupport { private static final Log log = LogFactory.getLog(Show.class); @Inject - protected transient SpatialService spatialService; + protected transient GisService gisService; - protected final ShowSpatialModel model = new ShowSpatialModel(); + @Inject + protected transient EchoBaseUserPersistenceContext userPersistenceContext; - public ShowSpatialModel getModel() { - return model; - } + /** + * Is current db support spatial data? Means db is pg. + */ + protected boolean spatialSupport; + + /** + * Is current db has spatial structures filled ? + */ + protected boolean spatialStructureFound; - protected boolean canAddSpatial; + /** + * Is application has gis support? Means lizmap is installed. + */ + protected boolean gisSupport; - protected String lizmapRepository; + /** + * Url to access to gis. + */ + protected String lizmapUrl; public String getLizmapUrl() { - String url = getServiceContext().getConfiguration().getLizmapUrl() + "?" + - "repository=" + lizmapRepository; - return url; + return lizmapUrl; } - public String getLizmapRepository() { - return lizmapRepository; + public boolean isSpatialStructureFound() { + return spatialStructureFound; } - public boolean isCanAddSpatial() { - return canAddSpatial; + public boolean isSpatialSupport() { + return spatialSupport; + } + + public boolean isGisSupport() { + return gisSupport; } @Override public String execute() throws Exception { - JdbcConfiguration dbConf = getEchoBaseSession().getWorkingDbConfiguration(); + spatialSupport = userPersistenceContext.isSpatialSupport(); - lizmapRepository = spatialService.generateMaps(dbConf); + if (spatialSupport) { - if (log.isInfoEnabled()) { - log.info("Loading spatial view for repository: " + lizmapRepository); - } + if (log.isInfoEnabled()) { + log.info("Db has spatial supports"); + } + + spatialStructureFound = userPersistenceContext.isSpatialStructureFound(); + + if (spatialStructureFound) { + + if (log.isInfoEnabled()) { + log.info("Spatial structure found."); + } + + gisSupport = getEchoBaseApplicationContext().isGisSupport(); + + if (gisSupport) { + + // prepare gis - model.setJdbcUrl(getServiceContext().getUserDbUrl()); - model.setWithSpatial(spatialService.isSpatialAware()); + JdbcConfiguration dbConf = getEchoBaseSession().getWorkingDbConfiguration(); + + // generate or update gis data + gisService.generateMaps(dbConf); + + // get gis data access url + lizmapUrl = gisService.getRepositoryUrl(dbConf); + + if (log.isInfoEnabled()) { + log.info("Gis url access: " + lizmapUrl); + } + + } else { + + if (log.isInfoEnabled()) { + log.info("Application does not support gis features."); + } + + } + + } + } else { + + if (log.isInfoEnabled()) { + log.info("Db has no spatial support."); + } + } - // can add postgis if working db is postgresql and has still no echobase - // spatial db - canAddSpatial = !model.isWithSpatial() && spatialService.isPostgresql(); return SUCCESS; + } } diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialModel.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialModel.java deleted file mode 100644 index 301cdca..0000000 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialModel.java +++ /dev/null @@ -1,64 +0,0 @@ -package fr.ifremer.echobase.ui.actions.spatial; - -/* - * #%L - * EchoBase :: UI - * %% - * Copyright (C) 2011 - 2013 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.spatial.SpatialConfiguration; - -import java.io.Serializable; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public class ShowSpatialModel extends SpatialConfiguration implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * Can we use spatial data (means is the database is spatial?). - */ - protected boolean withSpatial; - - /** - * Can we collect spatial data (means is the configuration filled enough ?). - */ - protected boolean withData; - - public boolean isWithSpatial() { - return withSpatial; - } - - public void setWithSpatial(boolean withSpatial) { - this.withSpatial = withSpatial; - } - - public boolean isWithData() { - return withData; - } - - public void setWithData(boolean withData) { - this.withData = withData; - } - -} diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/AddSpatial.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/AddSpatial.java index 8d8c458..7d4e064 100644 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/AddSpatial.java +++ b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/AddSpatial.java @@ -21,7 +21,7 @@ package fr.ifremer.echobase.ui.actions.workingDb; * #L% */ -import fr.ifremer.echobase.services.service.spatial.SpatialService; +import fr.ifremer.echobase.services.service.spatial.SpatialDataService; import javax.inject.Inject; @@ -40,7 +40,7 @@ public class AddSpatial extends AbstractWorkingDbAction { @Override public String execute() throws Exception { - spatialService.addSpatialSupport(); + spatialDataService.addSpatialSupport(); addFlashMessage(t("echobase.info.workingDbconfiguration.spatialStructureAdded")); return SUCCESS; @@ -51,5 +51,5 @@ public class AddSpatial extends AbstractWorkingDbAction { //------------------------------------------------------------------------// @Inject - protected transient SpatialService spatialService; + protected transient SpatialDataService spatialDataService; } diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/Information.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/Information.java index 87d0b93..a167006 100644 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/Information.java +++ b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/workingDb/Information.java @@ -42,9 +42,10 @@ public class Information extends EchoBaseActionSupport { protected String pilotVersion; - protected boolean canAddSpatial; + protected boolean spatialSupport; + protected boolean spatialStructureFound; - protected boolean spatialAware; + protected boolean canAddSpatial; public JdbcConfiguration getDbConfiguration() { return dbConfiguration; @@ -54,12 +55,16 @@ public class Information extends EchoBaseActionSupport { return pilotVersion; } - public boolean isCanAddSpatial() { - return canAddSpatial; + public boolean isSpatialStructureFound() { + return spatialStructureFound; + } + + public boolean isSpatialSupport() { + return spatialSupport; } - public boolean isSpatialAware() { - return spatialAware; + public boolean isCanAddSpatial() { + return canAddSpatial; } @Override @@ -76,14 +81,15 @@ public class Information extends EchoBaseActionSupport { dbConfiguration.getLogin(), dbConfiguration.getPassword()); - pilotVersion = - dbConfiguration.getDriverType().getPilotVersion(configuration); + pilotVersion = dbConfiguration.getDriverType().getPilotVersion(configuration); + + spatialSupport = db.isSpatialSupport(); + + spatialStructureFound = db.isSpatialStructureFound(); - spatialAware = db.isSpatialAware(); + // can add spatial struture ? + canAddSpatial = spatialSupport && !spatialStructureFound; - // can add postgis if working db is postgresql and has still no echobase - // spatial db - canAddSpatial = !spatialAware && db.isPostgresql(); return SUCCESS; } diff --git a/echobase-ui/src/main/resources/config/struts-spatial.xml b/echobase-ui/src/main/resources/config/struts-spatial.xml index 8d7d8d5..3c85db1 100644 --- a/echobase-ui/src/main/resources/config/struts-spatial.xml +++ b/echobase-ui/src/main/resources/config/struts-spatial.xml @@ -32,15 +32,6 @@ <result>/WEB-INF/jsp/spatial/show.jsp</result> </action> - <!-- show spatial map from the given selected data --> - <action name="showMap" - class="fr.ifremer.echobase.ui.actions.spatial.ShowMap"> - <interceptor-ref name="prepareParamsStackLogguedWithDb"/> - <result type="redirect"> - <param name="location">%{lizmapUrl}</param> - </result> - </action> - <!-- Add echobase spatial tables, functions and triggers to working db --> <action name="addSpatial" class="fr.ifremer.echobase.ui.actions.workingDb.AddSpatial"> diff --git a/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties b/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties index 955a24f..a7f102f 100644 --- a/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties +++ b/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties @@ -153,6 +153,7 @@ echobase.common.soundSpeedCalculationsME70=Sound speed calculation method (ME70 echobase.common.sounderConstant=Sounder constant (if relevant) echobase.common.source=Source echobase.common.spatialAware=Is database spatial aware ? +echobase.common.spatialStructureFound= echobase.common.startEndDate=Start - End date echobase.common.startEndPort=Start - End port echobase.common.subSampleFile= @@ -370,8 +371,11 @@ echobase.menu.removeData=Remove data echobase.menu.showSpatialData=Show spatial data echobase.menu.users=Manage users echobase.menu.viewData=Display data +echobase.message.application.no.gis.support= echobase.message.clickToShowImportDefail=Click to show import detail echobase.message.createEmbedded.result=Portable application was successful in %s. +echobase.message.db.no.spatial.structure= +echobase.message.db.no.spatial.support= echobase.message.download.link=If download did not start by itself, you can start it manually from this link\: echobase.message.exportCoser.result=Coser Export was successful (file %s) in %s. echobase.message.exportDb.result=Export of database (mode %s) was successful (file %s) in %s. diff --git a/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties b/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties index a757f8c..41da923 100644 --- a/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties +++ b/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties @@ -153,6 +153,7 @@ echobase.common.soundSpeedCalculationsME70=Méthode de calcul de la célérité echobase.common.sounderConstant=Constante sondeur (si besoin) echobase.common.source=Source echobase.common.spatialAware=Base spatialisée ? +echobase.common.spatialStructureFound=Base spatialisée ? echobase.common.startEndDate=Date de début - fin echobase.common.startEndPort=Port de départ - arrivé echobase.common.subSampleFile= @@ -373,8 +374,11 @@ echobase.menu.removeData=Supprimer des données echobase.menu.showSpatialData=Voir les données spatiales echobase.menu.users=Gérer les utilisateurs echobase.menu.viewData=Visualiser les données +echobase.message.application.no.gis.support=L'application n'a pas de support de visualisation spatiale. Consulter la documentation d'installation. echobase.message.clickToShowImportDefail=Cliquer pour obtenir les détails de l'import echobase.message.createEmbedded.result=La création de l'application embarqué a réussi en %s +echobase.message.db.no.spatial.structure=La base de travail que vous utilisez n'est pas spatialisée. +echobase.message.db.no.spatial.support=La base de travail que vous utilisez ne possède pas de support spatiale. echobase.message.download.link=Si le téléchargement n'a pas démarré automatiquement, suivez ce lien \: echobase.message.exportCoser.result=L'export Coser a réussi (fichier %s) en %s echobase.message.exportDb.result=L'export de la base (mode %s) a réussi (fichier %s) en %s diff --git a/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/show.jsp b/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/show.jsp index ce4a5a2..7a57bba 100644 --- a/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/show.jsp +++ b/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/show.jsp @@ -22,50 +22,74 @@ <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sj" uri="/struts-jquery-tags" %> <title> - <s:text name="echobase.title.show.spatial"/> + <s:text name="echobase.title.show.spatial"/> </title> -<script type="text/javascript" - src="<s:url value='/js/gridHelper.js' />"></script> +<s:if test="spatialSupport"> -<s:if test="model.withSpatial"> + <%--Db supports spatial features --%> - <s:form namespace="/spatial" method="POST" enctype="multipart/form-data"> + <s:if test="spatialStructureFound"> - <div class="toolbar"> - <ul class="toolbar floatRight"> - <li> - <s:submit action='refreshSpatialViews' key="echobase.action.reloadSpatialData"/> - </li> - </ul> - </div> - </s:form> + <%-- db has spatial structures --%> + <s:form namespace="/spatial"> + <div class="toolbar"> + <ul class="toolbar floatRight"> + <li> + <s:submit action='refreshSpatialViews' key="echobase.action.reloadSpatialData"/> + </li> + </ul> + </div> + </s:form> - <iframe id="spatialViewContent" src="${lizmapUrl}"></iframe> + <s:if test="gisSupport"> -</div> + <%-- Application has gis support --%> + <iframe id="spatialViewContent" src="${lizmapUrl}"></iframe> + </s:if> + <s:else> -</s:if> -<s:else> + <%-- Application has no gis support --%> + <p> + <s:text name="echobase.message.application.no.gis.support"/> + </p> + </s:else> - <p> - <s:text name="echobase.message.no.spatial.database.support"/> - </p> + </s:if> + <s:else> - <s:if test="canAddSpatial"> - <br/> - <s:form id="createForm" namespace="/spatial"> - <ul class="toolbar floatLeft"> + <%--db is not spatialized--%> + <p> + <s:text name="echobase.message.db.no.spatial.structure"/> + </p> - <li> - <s:submit theme="simple" action="addSpatial" - key="echobase.action.workingDbconfiguration.addSpatial"/> - </li> + <br/> + <s:form namespace="/spatial"> + <div class="toolbar"> + <ul class="toolbar floatRight"> + <li> + <s:submit action='addSpatial' key="echobase.action.workingDbconfiguration.addSpatial"/> + </li> + </ul> + </div> + <%--<ul class="toolbar floatLeft">--%> + <%--<li>--%> + <%--<s:submit theme="simple" action="addSpatial"--%> + <%--key="echobase.action.workingDbconfiguration.addSpatial"/>--%> + <%--</li>--%> + <%--</ul>--%> + </s:form> - </ul> - </s:form> - </s:if> -</s:else> + </s:else> + +</s:if> +<s:else> + <%--Db has no spatial support --%> + <p> + <s:text name="echobase.message.db.no.spatial.support"/> + </p> + +</s:else> diff --git a/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/information.jsp b/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/information.jsp index 4bf072b..5f6f36b 100644 --- a/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/information.jsp +++ b/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/information.jsp @@ -45,14 +45,18 @@ label='%{getText("echobase.common.jdbcLogin")} (*)'/> <s:textfield key="dbConfiguration.password" cssClass="autoSelect" readonly="true" label='%{getText("echobase.common.jdbcPassword")} (*)'/> - <s:textfield key="dbConfiguration.driverType.driverClass.name" - cssClass="autoSelect" readonly="true" + <s:textfield key="dbConfiguration.driverType.driverClass.name" cssClass="autoSelect" readonly="true" label='%{getText("echobase.common.jdbcDriver")} (*)'/> - <s:label key="pilotVersion" - label='%{getText("echobase.common.pilotVersion")}'/> + <s:label key="pilotVersion" label='%{getText("echobase.common.pilotVersion")}'/> + + <s:if test="spatialSupport"> + <s:checkbox key="spatialStructureFound" disabled="true" + label='%{getText("echobase.common.spatialStructureFound")}'/> + </s:if> + <s:else> + <s:label label='%{getText("echobase.common.spatialStructureFound")}' value='%{getText("echobase.message.db.no.spatial.support")}'/> + </s:else> - <s:checkbox key="spatialAware" disabled="true" - label='%{getText("echobase.common.spatialAware")}'/> <br/> <div class="cleanBoth help"> -- 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/6271 in repository echobase. See http://git.codelutin.com/echobase.git commit 31ade094760bc897d9ea4f819cebdc15f04c1faa Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Dec 15 19:33:46 2014 +0100 ajout lien sur doc d'install de lizmap --- .../src/main/resources/i18n/echobase-ui_en_GB.properties | 1 + .../src/main/resources/i18n/echobase-ui_fr_FR.properties | 3 ++- echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/show.jsp | 12 +++++------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties b/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties index a7f102f..a4f801a 100644 --- a/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties +++ b/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties @@ -379,6 +379,7 @@ echobase.message.db.no.spatial.support= echobase.message.download.link=If download did not start by itself, you can start it manually from this link\: echobase.message.exportCoser.result=Coser Export was successful (file %s) in %s. echobase.message.exportDb.result=Export of database (mode %s) was successful (file %s) in %s. +echobase.message.gis.install= echobase.message.importData.result=Data import successful in %s \:\n%s echobase.message.no.row.selected=No data selected echobase.message.no.spatial.database.support=The working db you are using is not compatible with postgis 2. diff --git a/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties b/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties index 41da923..1c92268 100644 --- a/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties +++ b/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties @@ -374,7 +374,7 @@ echobase.menu.removeData=Supprimer des données echobase.menu.showSpatialData=Voir les données spatiales echobase.menu.users=Gérer les utilisateurs echobase.menu.viewData=Visualiser les données -echobase.message.application.no.gis.support=L'application n'a pas de support de visualisation spatiale. Consulter la documentation d'installation. +echobase.message.application.no.gis.support=L'application de visualisation des données spatiales n'est pas installée. echobase.message.clickToShowImportDefail=Cliquer pour obtenir les détails de l'import echobase.message.createEmbedded.result=La création de l'application embarqué a réussi en %s echobase.message.db.no.spatial.structure=La base de travail que vous utilisez n'est pas spatialisée. @@ -382,6 +382,7 @@ echobase.message.db.no.spatial.support=La base de travail que vous utilisez ne p echobase.message.download.link=Si le téléchargement n'a pas démarré automatiquement, suivez ce lien \: echobase.message.exportCoser.result=L'export Coser a réussi (fichier %s) en %s echobase.message.exportDb.result=L'export de la base (mode %s) a réussi (fichier %s) en %s +echobase.message.gis.install=Consulter la documentation d'installation. echobase.message.importData.result=Import de données réussi en %s \:\n%s echobase.message.no.row.selected=Aucune donnée sélectionnée echobase.message.no.spatial.database.support=La base de travail que vous utilisez ne possède pas de support spatiale. diff --git a/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/show.jsp b/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/show.jsp index 7a57bba..af2c3da 100644 --- a/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/show.jsp +++ b/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/show.jsp @@ -51,9 +51,13 @@ <s:else> <%-- Application has no gis support --%> - <p> + <p class="fontsize11"> <s:text name="echobase.message.application.no.gis.support"/> + <s:a href="%{getDocumentation('install.html', 'Visualisation_des_donnes_spatialises')}" target='#doc'> + <s:text name="echobase.message.gis.install"/> + </s:a> </p> + </s:else> </s:if> @@ -73,12 +77,6 @@ </li> </ul> </div> - <%--<ul class="toolbar floatLeft">--%> - <%--<li>--%> - <%--<s:submit theme="simple" action="addSpatial"--%> - <%--key="echobase.action.workingDbconfiguration.addSpatial"/>--%> - <%--</li>--%> - <%--</ul>--%> </s:form> </s:else> -- 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/6271 in repository echobase. See http://git.codelutin.com/echobase.git commit 90014ce63dbb5dce5e3930b84a4ff7e8082f4d72 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Dec 15 20:30:11 2014 +0100 utilisation nuiton-utils 3.0-rc-8 et nuiton-config 3.0-rc-2 --- .../main/java/fr/ifremer/echobase/config/EchoBaseConfiguration.java | 2 +- .../java/fr/ifremer/echobase/config/EchoBaseConfigurationOption.java | 2 +- .../fr/ifremer/echobase/ui/actions/embeddedApplication/Configure.java | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/config/EchoBaseConfiguration.java b/echobase-domain/src/main/java/fr/ifremer/echobase/config/EchoBaseConfiguration.java index 1c3c1f3..82c5edc 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/config/EchoBaseConfiguration.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/config/EchoBaseConfiguration.java @@ -30,7 +30,7 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.config.ApplicationConfig; import org.nuiton.config.ArgumentsParserException; import org.nuiton.util.FileUtil; -import org.nuiton.util.Version; +import org.nuiton.util.version.Version; import java.io.File; import java.io.IOException; diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/config/EchoBaseConfigurationOption.java b/echobase-domain/src/main/java/fr/ifremer/echobase/config/EchoBaseConfigurationOption.java index 1c6599b..b416afb 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/config/EchoBaseConfigurationOption.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/config/EchoBaseConfigurationOption.java @@ -21,7 +21,7 @@ package fr.ifremer.echobase.config; import org.nuiton.config.ConfigOptionDef; -import org.nuiton.util.Version; +import org.nuiton.util.version.Version; import java.io.File; import java.net.URL; diff --git a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/embeddedApplication/Configure.java b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/embeddedApplication/Configure.java index 40c3b2d..d7d51c1 100644 --- a/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/embeddedApplication/Configure.java +++ b/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/embeddedApplication/Configure.java @@ -29,7 +29,7 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.FileUtil; -import org.nuiton.util.Version; +import org.nuiton.util.version.Version; import java.io.File; import java.io.IOException; diff --git a/pom.xml b/pom.xml index 4b731b5..028bd16 100644 --- a/pom.xml +++ b/pom.xml @@ -134,7 +134,7 @@ <!-- libraries version --> <topiaVersion>3.0-beta-3</topiaVersion> - <nuitonUtilsVersion>3.0-rc-2</nuitonUtilsVersion> + <nuitonUtilsVersion>3.0-rc-8</nuitonUtilsVersion> <nuitonI18nVersion>3.3</nuitonI18nVersion> <nuitonWebVersion>1.16</nuitonWebVersion> <!--<struts2Version>2.3.20</struts2Version>--> @@ -252,7 +252,7 @@ <dependency> <groupId>org.nuiton</groupId> <artifactId>nuiton-config</artifactId> - <version>3.0-alpha-2</version> + <version>3.0-rc-2</version> </dependency> <dependency> <groupId>org.nuiton</groupId> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm