Author: tchemit Date: 2014-01-22 22:32:46 +0100 (Wed, 22 Jan 2014) New Revision: 929 Url: http://forge.codelutin.com/projects/echobase/repository/revisions/929 Log: refs #4194: Visualisation des donn?\195?\169es spatiales (preparation de la configuration) Removed: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/CellPoint.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialData.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialDataCache.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/AbstractGetVoyage.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GeoJsonObject.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetSpatialData.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageEchotype.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageSpecies.java Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CellTopiaDao.java trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialConfiguration.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/UserDbPersistenceService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageDataMetadata.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialData.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialModel.java trunk/echobase-ui/src/main/resources/config/struts-spatial.xml trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialData-validation.xml trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/showData.jsp trunk/echobase-ui/src/main/webapp/js/gridHelper.js Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java 2014-01-22 21:32:46 UTC (rev 929) @@ -26,7 +26,6 @@ import fr.ifremer.echobase.entities.ImportLog; import fr.ifremer.echobase.entities.ImportType; import fr.ifremer.echobase.entities.data.Cell; -import fr.ifremer.echobase.entities.spatial.CellPoint; import fr.ifremer.echobase.entities.data.DataProcessing; import fr.ifremer.echobase.entities.data.Echotype; import fr.ifremer.echobase.entities.data.Operation; @@ -333,13 +332,6 @@ } }; - public static final Function<CellPoint,String> CELL_POINT_CELL_ID_FUNCTION = new Function<CellPoint, String>() { - @Override - public String apply(CellPoint input) { - return input.getCellId(); - } - }; - public static String getSpeciesCategoryKey(Species species, SizeCategory sizeCategory, SexCategory sexCategory) { String key = species.getBaracoudaCode(); if (sizeCategory != null) { Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CellTopiaDao.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CellTopiaDao.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/CellTopiaDao.java 2014-01-22 21:32:46 UTC (rev 929) @@ -23,10 +23,7 @@ * #L% */ -import com.google.common.collect.Lists; import fr.ifremer.echobase.csv.CellValueParser; -import fr.ifremer.echobase.entities.references.CellType; -import fr.ifremer.echobase.entities.spatial.CellPoint; import org.nuiton.csv.ValueParser; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlQuery; @@ -39,21 +36,6 @@ public class CellTopiaDao extends AbstractCellTopiaDao<Cell> { - public List<CellPoint> getVoyageCellPoints(Voyage voyage, CellType cellType) { - - List<CellPoint> result = Lists.newArrayList(); - - String voyageId = voyage.getTopiaId(); - String cellTypeId = cellType == null ? null : cellType.getTopiaId(); - - TopiaSqlQuery<CellPoint> queryPoint = newLatLongSqlQuery(voyageId, cellTypeId); - TopiaSqlQuery<CellPoint> queryPoint3D = newLatLongDepthSqlQuery(voyageId, cellTypeId); - - result.addAll(topiaSqlSupport.findMultipleResult(queryPoint)); - result.addAll(topiaSqlSupport.findMultipleResult(queryPoint3D)); - return result; - } - public long countVoyageOrphanCells(Voyage voyage) { TopiaSqlQuery<Long> query = newCountVoyageOrphanCellsQuery(voyage); Long result = topiaSqlSupport.findSingleResult(query); @@ -83,49 +65,6 @@ return new CellValueParser(voyage, this); } - protected TopiaSqlQuery<CellPoint> newLatLongSqlQuery(final String voyageId, final String cellTypeId) { - return new TopiaSqlQuery<CellPoint>() { - @Override - public PreparedStatement prepareQuery(Connection connection) throws SQLException { - - PreparedStatement ps = connection.prepareStatement("SELECT cellId, ST_Y(ST_ASTEXT(coordinate)), ST_X(ST_ASTEXT(coordinate)) FROM echobase_cell_spatial WHERE coordinate IS NOT NULL AND voyageId = ? AND celltypeid = ?"); - ps.setString(1, voyageId); - ps.setString(2, cellTypeId); - return ps; - } - - @Override - public CellPoint prepareResult(ResultSet set) throws SQLException { - String cellId = set.getString(1); - Double latitude = set.getDouble(2); - Double longitude = set.getDouble(3); - return new CellPoint(cellId, latitude, longitude, 0d); - } - }; - } - - protected TopiaSqlQuery<CellPoint> newLatLongDepthSqlQuery(final String voyageId, final String cellTypeId) { - return new TopiaSqlQuery<CellPoint>() { - @Override - public PreparedStatement prepareQuery(Connection connection) throws SQLException { - - PreparedStatement ps = connection.prepareStatement("SELECT cellId, ST_Y(ST_ASTEXT(coordinate3D)), ST_X(ST_ASTEXT(coordinate3D)) , ST_Y(ST_ASTEXT(coordinate3D)) FROM echobase_cell_spatial WHERE coordinate3D IS NOT NULL AND voyageId = ? AND celltypeid = ?"); - ps.setString(1, voyageId); - ps.setString(2, cellTypeId); - return ps; - } - - @Override - public CellPoint prepareResult(ResultSet set) throws SQLException { - String cellId = set.getString(1); - Double latitude = set.getDouble(2); - Double longitude = set.getDouble(3); - Double depth = set.getDouble(4); - return new CellPoint(cellId, latitude, longitude, depth); - } - }; - } - protected TopiaSqlQuery<Long> newCountVoyageOrphanCellsQuery(final Voyage voyage) { return new TopiaSqlQuery<Long>() { @Override Deleted: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/CellPoint.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/CellPoint.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/CellPoint.java 2014-01-22 21:32:46 UTC (rev 929) @@ -1,64 +0,0 @@ -package fr.ifremer.echobase.entities.spatial; - -/* - * #%L - * EchoBase :: Domain - * $Id$ - * $HeadURL$ - * %% - * 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 java.io.Serializable; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public class CellPoint implements Serializable { - - private static final long serialVersionUID = 1L; - - protected final String cellId; - - protected final double x, y, z; - - public CellPoint(String cellId, double x, double y, double z) { - this.cellId = cellId; - this.x = x; - this.y = y; - this.z = z; - } - - public String getCellId() { - return cellId; - } - - public double getX() { - return x; - } - - public double getY() { - return y; - } - - public double getZ() { - return z; - } -} Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialConfiguration.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialConfiguration.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialConfiguration.java 2014-01-22 21:32:46 UTC (rev 929) @@ -23,6 +23,8 @@ * #L% */ +import org.apache.commons.lang3.StringUtils; + import java.io.Serializable; /** @@ -41,18 +43,48 @@ /** Selected voyage id (can't be null). */ protected String voyageId; - /** Selected data metadata id (can't be null). */ - protected String dataMetadataId; + protected String dataMetadataIdForEsduData; - /** Selected data cell type id (can't be null). */ - protected String cellTypeId; + protected String dataMetadataIdForEsduResult; - /** Selected species id (can be null). */ - protected String speciesId; + protected String dataMetadataIdForMapData; - /** Selected echotype id (can be null). */ - protected String echotypeId; + protected String dataMetadataIdForMapResult; + protected boolean showOperationLayer; + + protected boolean showCellEsduDataLayer; + + protected boolean showCellEsduResultLayer; + + protected boolean showCellMapDataLayer; + + protected boolean showCellMapResultLayer; + + public boolean isAtLeastOneLayerSelected() { + return showOperationLayer || + showCellEsduDataLayer || + showCellEsduResultLayer || + showCellMapDataLayer || + showCellMapResultLayer; + } + + public boolean isEsduDataLayerSane() { + return !showCellEsduDataLayer || StringUtils.isNotBlank(dataMetadataIdForEsduData); + } + + public boolean isEsduResultLayerSane() { + return !showCellEsduResultLayer || StringUtils.isNotBlank(dataMetadataIdForEsduResult); + } + + public boolean isMapDataLayerSane() { + return !showCellMapDataLayer || StringUtils.isNotBlank(dataMetadataIdForMapData); + } + + public boolean isMapResultLayerSane() { + return !showCellMapResultLayer || StringUtils.isNotBlank(dataMetadataIdForMapResult); + } + public String getJdbcUrl() { return jdbcUrl; } @@ -69,61 +101,75 @@ this.voyageId = voyageId; } - public String getDataMetadataId() { - return dataMetadataId; + public String getDataMetadataIdForEsduData() { + return dataMetadataIdForEsduData; } - public void setDataMetadataId(String dataMetadataId) { - this.dataMetadataId = dataMetadataId; + public void setDataMetadataIdForEsduData(String dataMetadataIdForEsduData) { + this.dataMetadataIdForEsduData = dataMetadataIdForEsduData; } - public String getCellTypeId() { - return cellTypeId; + public String getDataMetadataIdForEsduResult() { + return dataMetadataIdForEsduResult; } - public void setCellTypeId(String cellTypeId) { - this.cellTypeId = cellTypeId; + public void setDataMetadataIdForEsduResult(String dataMetadataIdForEsduResult) { + this.dataMetadataIdForEsduResult = dataMetadataIdForEsduResult; } - public String getSpeciesId() { - return speciesId; + public String getDataMetadataIdForMapData() { + return dataMetadataIdForMapData; } - public void setSpeciesId(String speciesId) { - this.speciesId = speciesId; + public void setDataMetadataIdForMapData(String dataMetadataIdForMapData) { + this.dataMetadataIdForMapData = dataMetadataIdForMapData; } - public String getEchotypeId() { - return echotypeId; + public String getDataMetadataIdForMapResult() { + return dataMetadataIdForMapResult; } - public void setEchotypeId(String echotypeId) { - this.echotypeId = echotypeId; + public void setDataMetadataIdForMapResult(String dataMetadataIdForMapResult) { + this.dataMetadataIdForMapResult = dataMetadataIdForMapResult; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof SpatialConfiguration)) return false; + public boolean isShowOperationLayer() { + return showOperationLayer; + } - SpatialConfiguration that = (SpatialConfiguration) o; + public void setShowOperationLayer(boolean showOperationLayer) { + this.showOperationLayer = showOperationLayer; + } - return !(jdbcUrl != null ? !jdbcUrl.equals(that.jdbcUrl) : that.jdbcUrl != null) && - !(dataMetadataId != null ? !dataMetadataId.equals(that.dataMetadataId) : that.dataMetadataId != null) && - !(cellTypeId != null ? !cellTypeId.equals(that.cellTypeId) : that.cellTypeId!= null) && - !(echotypeId != null ? !echotypeId.equals(that.echotypeId) : that.echotypeId != null) && - !(speciesId != null ? !speciesId.equals(that.speciesId) : that.speciesId != null) && - !(voyageId != null ? !voyageId.equals(that.voyageId) : that.voyageId != null); + public boolean isShowCellEsduDataLayer() { + return showCellEsduDataLayer; } - @Override - public int hashCode() { - int result = jdbcUrl == null ? 0 : jdbcUrl.hashCode(); - result = 31 * result + (voyageId == null ? 0 : voyageId.hashCode()); - result = 31 * result + (dataMetadataId == null ? 0 : dataMetadataId.hashCode()); - result = 31 * result + (cellTypeId == null ? 0 : cellTypeId.hashCode()); - result = 31 * result + (speciesId == null ? 0 : speciesId.hashCode()); - result = 31 * result + (echotypeId == null ? 0 : echotypeId.hashCode()); - return result; + public void setShowCellEsduDataLayer(boolean showCellEsduDataLayer) { + this.showCellEsduDataLayer = showCellEsduDataLayer; } + + public boolean isShowCellEsduResultLayer() { + return showCellEsduResultLayer; + } + + public void setShowCellEsduResultLayer(boolean showCellEsduResultLayer) { + this.showCellEsduResultLayer = showCellEsduResultLayer; + } + + public boolean isShowCellMapDataLayer() { + return showCellMapDataLayer; + } + + public void setShowCellMapDataLayer(boolean showCellMapDataLayer) { + this.showCellMapDataLayer = showCellMapDataLayer; + } + + public boolean isShowCellMapResultLayer() { + return showCellMapResultLayer; + } + + public void setShowCellMapResultLayer(boolean showCellMapResultLayer) { + this.showCellMapResultLayer = showCellMapResultLayer; + } } \ No newline at end of file Deleted: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialData.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialData.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialData.java 2014-01-22 21:32:46 UTC (rev 929) @@ -1,82 +0,0 @@ -package fr.ifremer.echobase.entities.spatial; - -/* - * #%L - * EchoBase :: Domain - * $Id$ - * $HeadURL$ - * %% - * 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.data.Cell; -import fr.ifremer.echobase.entities.data.Result; -import fr.ifremer.echobase.entities.references.DataMetadata; - -import java.io.Serializable; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public class SpatialData implements Serializable { - - private static final long serialVersionUID = 1L; - - protected CellPoint point; - - protected Result result; - - public void setPoint(CellPoint point) { - this.point = point; - } - - public void setResult(Result result) { - this.result = result; - } - - public double getLatitude() { - return point.getY(); - } - - public double getLongitude() { - return point.getX(); - } - - public double getDepth() { - return point.getZ(); - } - - public DataMetadata getDataMetadata() { - return result.getDataMetadata(); - } - - public Serializable getDataValue() { - return result.getResultValue(); - } - - public String getId() { - return result.getTopiaId(); - } - - public Cell getCell() { - return result.getCell(); - } -} Deleted: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialDataCache.java =================================================================== --- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialDataCache.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/spatial/SpatialDataCache.java 2014-01-22 21:32:46 UTC (rev 929) @@ -1,95 +0,0 @@ -package fr.ifremer.echobase.entities.spatial; - -/* - * #%L - * EchoBase :: Domain - * $Id$ - * $HeadURL$ - * %% - * 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.collect.Maps; -import com.google.common.collect.Sets; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.Serializable; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public class SpatialDataCache implements Serializable { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = LogFactory.getLog(SpatialDataCache.class); - - protected final Map<SpatialConfiguration, Set<SpatialData>> cache = - Maps.newHashMap(); - - - public Set<SpatialData> get(SpatialConfiguration configuration) { - return cache.get(configuration); - } - - public void put(SpatialConfiguration configuration, Set<SpatialData> data) { - cache.put(configuration, Collections.unmodifiableSet(data)); - } - - public void onDbChanged(String jdbcUrl) { - - if (log.isInfoEnabled()) { - log.info("Revoking spatial data cache for db: " + jdbcUrl); - } - - Set<SpatialConfiguration> keys = Sets.newHashSet(cache.keySet()); - for (SpatialConfiguration key : keys) { - if (jdbcUrl.equals(key.getJdbcUrl())) { - cache.remove(key); - } - } - } - - public void onVoyageChanged(String jdbcUrl, String voyageId) { - - if (log.isInfoEnabled()) { - log.info("Revoking spatial data cache for db/voyage: " + jdbcUrl + - "/" + voyageId); - } - - Set<SpatialConfiguration> keys = Sets.newHashSet(cache.keySet()); - for (SpatialConfiguration key : keys) { - if (jdbcUrl.equals(key.getJdbcUrl()) && - voyageId.equals(key.getVoyageId())) { - cache.remove(key); - } - } - } - - public void clear() { - cache.clear(); - } - -} Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/UserDbPersistenceService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/UserDbPersistenceService.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/UserDbPersistenceService.java 2014-01-22 21:32:46 UTC (rev 929) @@ -63,7 +63,6 @@ import fr.ifremer.echobase.entities.references.Species; import fr.ifremer.echobase.entities.references.SpeciesCategory; import fr.ifremer.echobase.entities.references.Vessel; -import fr.ifremer.echobase.entities.spatial.CellPoint; import fr.ifremer.echobase.services.EchoBaseServiceSupport; import org.nuiton.csv.ValueParser; import org.nuiton.topia.persistence.TopiaDao; @@ -202,10 +201,6 @@ return persistenceContext.getCellDao().getVoyageCellIds(voyage); } - public List<CellPoint> getVoyageCellPoints(Voyage voyage, CellType cellType) { - return persistenceContext.getCellDao().getVoyageCellPoints(voyage, cellType); - } - public ValueParser<Cell> newCellValueParser(Voyage voyage) { return persistenceContext.getCellDao().newCellValueParser(voyage); } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/service/spatial/SpatialService.java 2014-01-22 21:32:46 UTC (rev 929) @@ -23,40 +23,15 @@ * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import fr.ifremer.echobase.EchoBaseFunctions; import fr.ifremer.echobase.EchoBaseTechnicalException; -import fr.ifremer.echobase.entities.data.Category; -import fr.ifremer.echobase.entities.data.Echotype; -import fr.ifremer.echobase.entities.data.Result; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.entities.references.CellType; -import fr.ifremer.echobase.entities.references.DataMetadata; -import fr.ifremer.echobase.entities.references.Species; -import fr.ifremer.echobase.entities.spatial.CellPoint; -import fr.ifremer.echobase.entities.spatial.SpatialConfiguration; -import fr.ifremer.echobase.entities.spatial.SpatialData; import fr.ifremer.echobase.io.EchoBaseIOUtil; import fr.ifremer.echobase.services.EchoBaseServiceSupport; import fr.ifremer.echobase.services.service.UserDbPersistenceService; -import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.topia.persistence.TopiaEntities; import org.nuiton.util.TimeLog; import javax.inject.Inject; -import java.util.List; -import java.util.Map; -import java.util.Set; /** * Spatial service. @@ -78,12 +53,6 @@ @Inject private UserDbPersistenceService persistenceService; -// @Override -// public void setServiceContext(EchoBaseServiceContext serviceContext) { -// super.setServiceContext(serviceContext); -// persistenceService = serviceContext.newService(UserDbPersistenceService.class); -// } - public void addSpatialSupport() { // add spatial structure @@ -96,59 +65,6 @@ persistenceService.commit(); } - public Set<SpatialData> getSpatialData(SpatialConfiguration model) { - - Set<SpatialData> result; - - String voyageId = model.getVoyageId(); - - String dataMetadataId = model.getDataMetadataId(); - String cellTypeId = model.getCellTypeId(); - - String speciesId = model.getSpeciesId(); - String echotypeId = model.getEchotypeId(); - - Voyage voyage = persistenceService.getVoyage(voyageId); - - Preconditions.checkNotNull( - voyage, - "Could not find voyage with id " + voyageId); - - DataMetadata dataMetadata = - persistenceService.getDataMetadata(dataMetadataId); - - Preconditions.checkNotNull( - dataMetadata, - "Could not find dataMetadata with id " + dataMetadataId); - - CellType cellType = - persistenceService.getCellType(cellTypeId); - - Preconditions.checkNotNull( - cellType, - "Could not find cellType with id " + cellTypeId); - - Optional<Species> species = - persistenceService.getOptionalSpecies(speciesId); - - Optional<Echotype> echotype = - persistenceService.getOptionalEchotype(echotypeId); - - List<Predicate<Category>> predicates = Lists.newArrayList(); - if (species.isPresent()) { - predicates.add(newSpeciesCategoryPredicate(species.get())); - } - if (echotype.isPresent()) { - predicates.add(newEchotypeCategoryPredicate(echotype.get())); - } - - Predicate<Category> acceptPredicate = Predicates.or(predicates); - - result = getSpatialData(voyage, dataMetadata, cellType, acceptPredicate); - - return result; - } - protected void executeSqlScript(String scriptPath) { // get sql script @@ -166,88 +82,7 @@ } } - protected Set<SpatialData> getSpatialData(Voyage voyage, - DataMetadata requiredDataMetadata, - CellType cellType, - Predicate<Category> acceptPredicate) { - long s0 = TimeLog.getTime(); - - // get possible category - List<String> categoryIds = Lists.newArrayList( - Iterables.transform(persistenceService.getCategories(acceptPredicate), - TopiaEntities.getTopiaIdFunction())); - - - boolean filterByCategory = CollectionUtils.isNotEmpty(categoryIds); - - // get all cell with spatial points - List<CellPoint> voyageCellPoints = persistenceService.getVoyageCellPoints(voyage, cellType); - - int nbCells = voyageCellPoints.size(); - s0 = TILE_LOG.log(s0, String.format("Get cell points (%s)", nbCells)); - - final Map<String, CellPoint> cellPointById = Maps.uniqueIndex(voyageCellPoints, EchoBaseFunctions.CELL_POINT_CELL_ID_FUNCTION); - - Set<String> cellIds = Sets.newHashSet(cellPointById.keySet()); - - s0 = TILE_LOG.log(s0, String.format("Get cell points list and map (%s)", nbCells)); - - List<Result> results; - - if (filterByCategory) { - results = persistenceService.getAllWithCategoryCellAndDataMetadata( - cellIds, - requiredDataMetadata, - categoryIds); - } else { - results = persistenceService.getAllWithNoCategoryCellAndDataMetadata( - cellIds, - requiredDataMetadata); - } - - - s0 = TILE_LOG.log(s0, String.format("Get all matching results (%s)", results.size())); - - Set<SpatialData> result = Sets.newHashSet( - Iterables.transform( - results, new Function<Result, SpatialData>() { - @Override - public SpatialData apply(Result input) { - SpatialData data = new SpatialData(); - data.setResult(input); - CellPoint cellPoint = cellPointById.get(input.getCell().getTopiaId()); - data.setPoint(cellPoint); - return data; - } - })); - - TILE_LOG.log(s0, String.format("Loaded %s result of cell points (%s)", result.size(), nbCells)); - - return result; - } - - - protected Predicate<Category> newSpeciesCategoryPredicate(final Species species) { - Predicate<Category> speciesPredicate = new Predicate<Category>() { - @Override - public boolean apply(Category input) { - return input.getSpeciesCategory() != null && species.equals(input.getSpeciesCategory().getSpecies()); - } - }; - return speciesPredicate; - } - - protected Predicate<Category> newEchotypeCategoryPredicate(final Echotype echotype) { - Predicate<Category> speciesPredicate = new Predicate<Category>() { - @Override - public boolean apply(Category input) { - return echotype.equals(input.getEchotype()); - } - }; - return speciesPredicate; - } - public boolean isSpatialAware() { boolean result = persistenceService.isSpatialAware(); return result; Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/AbstractGetVoyage.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/AbstractGetVoyage.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/AbstractGetVoyage.java 2014-01-22 21:32:46 UTC (rev 929) @@ -1,90 +0,0 @@ -package fr.ifremer.echobase.ui.actions.spatial; - -/* - * #%L - * EchoBase :: UI - * $Id$ - * $HeadURL$ - * %% - * 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.Preconditions; -import com.google.common.collect.Maps; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.services.service.UserDbPersistenceService; -import fr.ifremer.echobase.services.service.spatial.SpatialService; -import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; -import org.apache.commons.lang3.StringUtils; - -import javax.inject.Inject; -import java.util.Map; - -/** - * Abstract action to obtain some data linked with a given voyage id. - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public abstract class AbstractGetVoyage extends EchoBaseActionSupport { - - private static final long serialVersionUID = 1L; - - /** Selected voyage id. */ - protected String voyageId; - - public void setVoyageId(String voyageId) { - this.voyageId = voyageId; - } - - /** Universe of result. */ - protected Map<String, String> data; - - protected abstract Map<String, String> buildData(SpatialService service, - Voyage voyage); - - public abstract Map<String, String> getData(); - - @Override - public String execute() throws Exception { - - if (StringUtils.isEmpty(voyageId)) { - data = Maps.newLinkedHashMap(); - - } else { - - Voyage voyage = userDbPersistenceService.getVoyage(voyageId); - - Preconditions.checkNotNull( - voyage, - "Could not find voyage with id " + voyageId); - - data = buildData(spatialService, voyage); - } - - return SUCCESS; - } - - //------------------------------------------------------------------------// - //-- Injected objects // - //------------------------------------------------------------------------// - - @Inject - protected transient UserDbPersistenceService userDbPersistenceService; - @Inject - protected transient SpatialService spatialService; -} \ No newline at end of file Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GeoJsonObject.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GeoJsonObject.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GeoJsonObject.java 2014-01-22 21:32:46 UTC (rev 929) @@ -1,153 +0,0 @@ -package fr.ifremer.echobase.ui.actions.spatial; - -/* - * #%L - * EchoBase :: UI - * $Id$ - * $HeadURL$ - * %% - * 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.Preconditions; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public class GeoJsonObject implements Serializable { - - private static final long serialVersionUID = 1L; - - - public static GeoJsonObjectBuilder newBuilder(String type) { - return new GeoJsonObjectBuilder(type); - } - - public static class GeoJsonObjectBuilder { - - GeoJsonObject result = new GeoJsonObject(); - - GeoJsonFeature feature; - - public GeoJsonObjectBuilder(String type) { - result.type = type; - } - - public GeoJsonObjectBuilder newFeature(String type, - String id, - String geometryType) { - feature = new GeoJsonFeature(type, id); - result.features.add(feature); - feature.geometry = new GeoJsonGeometry(geometryType); - return this; - } - - public GeoJsonObjectBuilder addFeatureProperty(String key, Serializable value) { - Preconditions.checkNotNull(feature, "No feature (use before newFeature method)"); - feature.getProperties().put(key, value); - return this; - } - - public GeoJsonObjectBuilder addFeatureGeometryPoint(double latitude, double longitude) { - Preconditions.checkNotNull(feature, "No feature (use before newFeature method)"); - feature.geometry.coordinates = new double[]{latitude, longitude}; - return this; - } - - public GeoJsonObject flush() { - return result; - } - } - - protected String type; - - protected final List<GeoJsonFeature> features = Lists.newArrayList(); - - public String getType() { - return type; - } - - public List<GeoJsonFeature> getFeatures() { - return features; - } - - public static class GeoJsonFeature implements Serializable { - - private static final long serialVersionUID = 1L; - - protected String type; - - protected String id; - - protected final Map<String, Serializable> properties = - Maps.newLinkedHashMap(); - - protected GeoJsonGeometry geometry; - - public GeoJsonFeature(String type, String id) { - this.type = type; - this.id = id; - } - - public String getType() { - return type; - } - - public String getId() { - return id; - } - - public Map<String, Serializable> getProperties() { - return properties; - } - - public GeoJsonGeometry getGeometry() { - return geometry; - } - } - - public static class GeoJsonGeometry implements Serializable { - - private static final long serialVersionUID = 1L; - - protected String type; - - protected double[] coordinates; - - public GeoJsonGeometry(String type) { - this.type = type; - } - - public String getType() { - return type; - } - - public double[] getCoordinates() { - return coordinates; - } - } - -} Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetSpatialData.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetSpatialData.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetSpatialData.java 2014-01-22 21:32:46 UTC (rev 929) @@ -1,80 +0,0 @@ -package fr.ifremer.echobase.ui.actions.spatial; - -/* - * #%L - * EchoBase :: UI - * $Id$ - * $HeadURL$ - * %% - * 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.SpatialData; -import fr.ifremer.echobase.services.service.spatial.SpatialService; -import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; - -import javax.inject.Inject; -import java.util.Set; - -/** - * Obtain all spatial data used for a given voyage. - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public class GetSpatialData extends EchoBaseActionSupport { - - private static final long serialVersionUID = 1L; - - protected final ShowSpatialModel model = new ShowSpatialModel(); - - protected GeoJsonObject data; - - public ShowSpatialModel getModel() { - return model; - } - - public GeoJsonObject getData() { - return data; - } - - @Override - public String execute() throws Exception { - - Set<SpatialData> spatialData = spatialService.getSpatialData(model); - - GeoJsonObject.GeoJsonObjectBuilder builder = - GeoJsonObject.newBuilder("Feature"); - - for (SpatialData s : spatialData) { - builder.newFeature("Feature", s.getId(), "Point") - .addFeatureProperty("name", s.getCell().getName()) - .addFeatureProperty(s.getDataMetadata().getName(), s.getDataValue()) - .addFeatureGeometryPoint(s.getLongitude(), s.getLatitude()); - } - data = builder.flush(); - - return SUCCESS; - } - - //------------------------------------------------------------------------// - //-- Injected objects // - //------------------------------------------------------------------------// - - @Inject - protected transient SpatialService spatialService; -} \ No newline at end of file Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageDataMetadata.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageDataMetadata.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageDataMetadata.java 2014-01-22 21:32:46 UTC (rev 929) @@ -23,10 +23,16 @@ * #L% */ +import com.google.common.base.Preconditions; +import com.google.common.collect.Maps; import fr.ifremer.echobase.entities.data.Voyage; import fr.ifremer.echobase.entities.references.DataMetadata; +import fr.ifremer.echobase.services.service.UserDbPersistenceService; import fr.ifremer.echobase.services.service.spatial.SpatialService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.lang3.StringUtils; +import javax.inject.Inject; import java.util.Map; /** @@ -35,19 +41,51 @@ * @author tchemit <chemit@codelutin.com> * @since 2.2 */ -public class GetVoyageDataMetadata extends AbstractGetVoyage { +public class GetVoyageDataMetadata extends EchoBaseActionSupport { private static final long serialVersionUID = 1L; - @Override + /** Selected voyage id. */ + protected String voyageId; + + /** Universe of result. */ + protected Map<String, String> data; + + public void setVoyageId(String voyageId) { + this.voyageId = voyageId; + } + public Map<String, String> getData() { return data; } @Override - protected Map<String, String> buildData(SpatialService service, - Voyage voyage) { - Map<String, String> result = userDbPersistenceService.loadSortAndDecorate(DataMetadata.class); - return result; + public String execute() throws Exception { + + if (StringUtils.isEmpty(voyageId)) { + data = Maps.newLinkedHashMap(); + + } else { + + Voyage voyage = userDbPersistenceService.getVoyage(voyageId); + + Preconditions.checkNotNull( + voyage, + "Could not find voyage with id " + voyageId); + + data = userDbPersistenceService.loadSortAndDecorate(DataMetadata.class); + } + + return SUCCESS; } + + //------------------------------------------------------------------------// + //-- Injected objects // + //------------------------------------------------------------------------// + + @Inject + protected transient UserDbPersistenceService userDbPersistenceService; + + @Inject + protected transient SpatialService spatialService; } \ No newline at end of file Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageEchotype.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageEchotype.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageEchotype.java 2014-01-22 21:32:46 UTC (rev 929) @@ -1,54 +0,0 @@ -package fr.ifremer.echobase.ui.actions.spatial; - -/* - * #%L - * EchoBase :: UI - * $Id$ - * $HeadURL$ - * %% - * 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.data.Echotype; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.services.service.spatial.SpatialService; - -import java.util.Map; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public class GetVoyageEchotype extends AbstractGetVoyage { - - private static final long serialVersionUID = 1L; - - @Override - public Map<String, String> getData() { - return data; - } - - @Override - protected Map<String, String> buildData(SpatialService service, - Voyage voyage) { - - Map<String, String> result = userDbPersistenceService.loadSortAndDecorate(Echotype.class); - return result; - } -} Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageSpecies.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageSpecies.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/GetVoyageSpecies.java 2014-01-22 21:32:46 UTC (rev 929) @@ -1,54 +0,0 @@ -package fr.ifremer.echobase.ui.actions.spatial; - -/* - * #%L - * EchoBase :: UI - * $Id$ - * $HeadURL$ - * %% - * 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.data.Voyage; -import fr.ifremer.echobase.entities.references.Species; -import fr.ifremer.echobase.services.service.spatial.SpatialService; - -import java.util.Map; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 2.2 - */ -public class GetVoyageSpecies extends AbstractGetVoyage { - - private static final long serialVersionUID = 1L; - - @Override - public Map<String, String> getData() { - return data; - } - - @Override - protected Map<String, String> buildData(SpatialService service, - Voyage voyage) { - - Map<String, String> result = userDbPersistenceService.loadSortAndDecorate(Species.class); - return result; - } -} Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialData.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialData.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialData.java 2014-01-22 21:32:46 UTC (rev 929) @@ -26,7 +26,6 @@ import com.opensymphony.xwork2.Preparable; import com.opensymphony.xwork2.interceptor.annotations.InputConfig; import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.entities.references.CellType; import fr.ifremer.echobase.services.service.UserDbPersistenceService; import fr.ifremer.echobase.services.service.spatial.SpatialService; import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; @@ -59,13 +58,6 @@ return voyages; } - /** Universe of existing cell types. */ - protected Map<String, String> cellTypes; - - public Map<String, String> getCellTypes() { - return cellTypes; - } - public boolean isCanAddSpatial() { return canAddSpatial; } @@ -73,7 +65,6 @@ @Override public void prepare() throws Exception { voyages = userDbPersistenceService.loadSortAndDecorate(Voyage.class); - cellTypes = userDbPersistenceService.loadSortAndDecorate(CellType.class); model.setJdbcUrl(getServiceContext().getUserDbUrl()); model.setWithSpatial(spatialService.isSpatialAware()); @@ -104,6 +95,7 @@ @Inject protected transient UserDbPersistenceService userDbPersistenceService; + @Inject protected transient SpatialService spatialService; } Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialModel.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialModel.java 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialModel.java 2014-01-22 21:32:46 UTC (rev 929) @@ -24,10 +24,8 @@ */ import fr.ifremer.echobase.entities.spatial.SpatialConfiguration; -import fr.ifremer.echobase.entities.spatial.SpatialData; import java.io.Serializable; -import java.util.Set; /** * TODO @@ -40,11 +38,6 @@ private static final long serialVersionUID = 1L; /** - * Loaded spatial data. - */ - protected Set<SpatialData> spatialData; - - /** * Can we use spatial data (means is the database is spatial?). */ protected boolean withSpatial; Modified: trunk/echobase-ui/src/main/resources/config/struts-spatial.xml =================================================================== --- trunk/echobase-ui/src/main/resources/config/struts-spatial.xml 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/resources/config/struts-spatial.xml 2014-01-22 21:32:46 UTC (rev 929) @@ -70,9 +70,9 @@ <result>/WEB-INF/jsp/spatial/showDataMap.jsp</result> </action> - <!-- Get json data --> - <action name="get*" - class="fr.ifremer.echobase.ui.actions.spatial.Get{1}"> + <!-- Get medata for the selected voyage --> + <action name="getVoyageDataMetadata" + class="fr.ifremer.echobase.ui.actions.spatial.GetVoyageDataMetadata"> <interceptor-ref name="basicStackLogguedWithdb"/> <result type="json"/> </action> Modified: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialData-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialData-validation.xml 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/spatial/ShowSpatialData-validation.xml 2014-01-22 21:32:46 UTC (rev 929) @@ -30,39 +30,39 @@ </field-validator> </field> - <field name="model.dataMetadataId"> - <field-validator type="nrequiredstring"> - <message key="echobase.error.showData.dataMetadata.required"/> + <field name="model.showOperationLayer"> + <field-validator type="fieldexpression"> + <param name="expression"><![CDATA[model.atLeastOneLayerSelected]]></param> + <message key="echobase.error.showData.noLayer.selected"/> </field-validator> </field> - <field name="model.cellTypeId"> - <field-validator type="nrequiredstring"> - <message key="echobase.error.showData.cellType.required"/> + <field name="model.dataMetadataIdForEsduData"> + <field-validator type="fieldexpression"> + <param name="expression"><![CDATA[ model.esduDataLayerSane ]]></param> + <message key="echobase.error.showData.dataMetadataIdForLayer.required"/> </field-validator> </field> - <field name="model.echotypeId"> + <field name="model.dataMetadataIdForEsduResult"> <field-validator type="fieldexpression"> - <param name="expression"> - <![CDATA[ - !(model.echotypeId == null && model.speciesId == null) - ]]> - </param> - <message key="echobase.error.showData.echoTypeOrSpecies.required"/> + <param name="expression"><![CDATA[ model.esduResultLayerSane ]]></param> + <message key="echobase.error.showData.dataMetadataIdForLayer.required"/> </field-validator> </field> - <field name="model.speciesId"> + <field name="model.dataMetadataIdForMapData"> <field-validator type="fieldexpression"> - <param name="expression"> - <![CDATA[ - !(model.echotypeId == null && model.speciesId == null) - ]]> - </param> - <message key="echobase.error.showData.echoTypeOrSpecies.required"/> + <param name="expression"><![CDATA[ model.mapDataLayerSane ]]></param> + <message key="echobase.error.showData.dataMetadataIdForLayer.required"/> </field-validator> </field> + <field name="model.dataMetadataIdForMapResult"> + <field-validator type="fieldexpression"> + <param name="expression"><![CDATA[ model.mapResultLayerSane ]]></param> + <message key="echobase.error.showData.dataMetadataIdForLayer.required"/> + </field-validator> + </field> </validators> \ No newline at end of file Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties =================================================================== --- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2014-01-22 21:32:46 UTC (rev 929) @@ -67,6 +67,10 @@ echobase.common.dataCentre=Data center echobase.common.dataCentreEmail=Data center email echobase.common.dataMetadata=Data Metadata +echobase.common.dataMetadata.forEsduDataLayer=Data Metadata for Esdu - Data layer +echobase.common.dataMetadata.forEsduResultLayer=Data Metadata for Esdu - Result layer +echobase.common.dataMetadata.forMapDataLayer=Data Metadata for Map - Data layer +echobase.common.dataMetadata.forMapResultLayer=Data Metadata for Map - Result layer echobase.common.dataProcessing=DataProcessing echobase.common.dataProcessingNotes=Data processing notes echobase.common.datum=Datum @@ -136,6 +140,11 @@ echobase.common.processingTemplate=Data processing template echobase.common.project=Project echobase.common.resultLabel=Results label +echobase.common.showCellEsduDataLayer= +echobase.common.showCellEsduResultLayer= +echobase.common.showCellMapDataLayer= +echobase.common.showCellMapResultLayer= +echobase.common.showOperationLayer= echobase.common.soundSpeedCalculationsER60=Sound speed calculations method (ER60 instrument) echobase.common.soundSpeedCalculationsME70=Sound speed calculation method (ME70 instrument) echobase.common.sounderConstant=Sounder constant (if relevant) @@ -229,7 +238,9 @@ echobase.error.required.password=Password is required echobase.error.showData.cellType.required=CellType required echobase.error.showData.dataMetadata.required=DataMetadata required +echobase.error.showData.dataMetadataIdForLayer.required=Il faut sélectionner la méta-donnée à utiliser sur la couche echobase.error.showData.echoTypeOrSpecies.required=Echotype or (and) Species is required +echobase.error.showData.noLayer.selected=Aucune couche de présentation sélectionnée echobase.error.showData.voyage.required=Voyage required echobase.error.warlocation.notFound=Database .war file not found at location %s echobase.error.workingDbConfiguration.couldNotConnect=Could not connect to database (%s) Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties =================================================================== --- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2014-01-22 21:32:46 UTC (rev 929) @@ -67,6 +67,10 @@ echobase.common.dataCentre=Centre de données echobase.common.dataCentreEmail=Courriel du centre de données echobase.common.dataMetadata=Type de donnée +echobase.common.dataMetadata.forEsduDataLayer=Méta data à utiliser pour la couche Esdu - Data +echobase.common.dataMetadata.forEsduResultLayer=Méta data à utiliser pour la couche Esdu - Result +echobase.common.dataMetadata.forMapDataLayer=Méta data à utiliser pour la couche Map - Data +echobase.common.dataMetadata.forMapResultLayer=Méta data à utiliser pour la couche Map - Result echobase.common.dataProcessing=DataProcessing echobase.common.dataProcessingNotes=Notes sur le pré-traitement des données echobase.common.datum=Référenciel @@ -136,6 +140,11 @@ echobase.common.processingTemplate=Intitulé de la méthode de pré-traitement des données echobase.common.project=Projet echobase.common.resultLabel=Intitulé des résultats +echobase.common.showCellEsduDataLayer=Voir la couche Esdu - Data +echobase.common.showCellEsduResultLayer=Voir la couche Esdu - Result +echobase.common.showCellMapDataLayer=Voir la couche Map - Data +echobase.common.showCellMapResultLayer=Voir la couche Map - Result +echobase.common.showOperationLayer=Voir la couche Operation echobase.common.soundSpeedCalculationsER60=Méthode de calcul de la célérité du son (ER60) echobase.common.soundSpeedCalculationsME70=Méthode de calcul de la célérité du son (ME70) echobase.common.sounderConstant=Constante sondeur (si besoin) @@ -229,7 +238,9 @@ echobase.error.required.password=Le mot de passe est obligatoire echobase.error.showData.cellType.required=La sélection d'un type de cellule est obligatoire echobase.error.showData.dataMetadata.required=La sélection d'un type de donnée est obligatoire +echobase.error.showData.dataMetadataIdForLayer.required=Il faut sélectionner la méta-donnée à utiliser sur la couche echobase.error.showData.echoTypeOrSpecies.required=La sélection d'un echotype ou (et) d'une espèces est obligatoire +echobase.error.showData.noLayer.selected=Aucune couche de présentation sélectionnée echobase.error.showData.voyage.required=La sélection d'une campagne est obligatoire echobase.error.warlocation.notFound=L'application n'a pas été trouvée à l'emplacement suivant %s echobase.error.workingDbConfiguration.couldNotConnect=Impossible de se connecter (%s) Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/showData.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/showData.jsp 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/spatial/showData.jsp 2014-01-22 21:32:46 UTC (rev 929) @@ -40,43 +40,82 @@ $.autoSelectVoyageAndDataMetadata( getVoyage, - $('[name="model.dataMetadataId"]'), + $('[name="model.dataMetadataIdForEsduData"]'), '<s:url action="getVoyageDataMetadata" namespace="/spatial"/>', '<s:property value="model.voyageId"/>', - '<s:property value="model.dataMetadataId"/>' + '<s:property value="model.dataMetadataIdForEsduData"/>' ); - $.autoSelectVoyageAndSpecies( + $.autoSelectVoyageAndDataMetadata( getVoyage, - $('[name="model.speciesId"]'), - '<s:url action="getVoyageSpecies" namespace="/spatial"/>', + $('[name="model.dataMetadataIdForEsduResult"]'), + '<s:url action="getVoyageDataMetadata" namespace="/spatial"/>', '<s:property value="model.voyageId"/>', - '<s:property value="model.speciesId"/>' + '<s:property value="model.dataMetadataIdForEsduResult"/>' ); - $.autoSelectVoyageAndEchotype( + $.autoSelectVoyageAndDataMetadata( getVoyage, - $('[name="model.echotypeId"]'), - '<s:url action="getVoyageEchotype" namespace="/spatial"/>', + $('[name="model.dataMetadataIdForMapData"]'), + '<s:url action="getVoyageDataMetadata" namespace="/spatial"/>', '<s:property value="model.voyageId"/>', - '<s:property value="model.echotypeId"/>' + '<s:property value="model.dataMetadataIdForMapData"/>' ); + $.autoSelectVoyageAndDataMetadata( + getVoyage, + $('[name="model.dataMetadataIdForMapResult"]'), + '<s:url action="getVoyageDataMetadata" namespace="/spatial"/>', + '<s:property value="model.voyageId"/>', + '<s:property value="model.dataMetadataIdForMapResult"/>' + ); + + $.showSpatialLayer("model.showCellEsduDataLayer", "cellEsduDataLayer", "model.dataMetadataIdForEsduData", <s:property value="model.showCellEsduDataLayer"/>); + $.showSpatialLayer("model.showCellEsduResultLayer", "cellEsduResultLayer", "model.dataMetadataIdForEsduResult", <s:property value="model.showCellEsduResultLayer"/>); + $.showSpatialLayer("model.showCellMapDataLayer", "cellMapDataLayer", "model.dataMetadataIdForMapData", <s:property value="model.showCellMapDataLayer"/>); + $.showSpatialLayer("model.showCellMapResultLayer", "cellMapResultLayer", "model.dataMetadataIdForMapResult", <s:property value="model.showCellMapResultLayer"/>); + + var showOptions = function(show) { + + var config = $('#withSelectedVoyage'); + + if (show!='') { + config.show(); + } else { + config.hide(); + } + }; + + getVoyage.change(function () { + showOptions(this.value); + }); + + showOptions('<s:property value="model.voyageId"/>'); + + <s:if test="model.withData"> + + console.info("LOAD DATA!"); + /* jQuery.get( '<s:url action="displaySpatial" namespace="/spatial"/>', { "model.voyageId": '<s:property value="model.voyageId"/>', - "model.dataMetadataId": '<s:property value="model.dataMetadataId"/>', - "model.cellTypeId": '<s:property value="model.cellTypeId"/>', - "model.speciesId": '<s:property value="model.speciesId"/>', - "model.echotypeId": '<s:property value="model.echotypeId"/>' + "model.dataMetadataIdForEsduData": '<s:property value="model.dataMetadataIdForEsduData"/>', + "model.dataMetadataIdForEsduResult": '<s:property value="model.dataMetadataIdForEsduResult"/>', + "model.dataMetadataIdForMapData": '<s:property value="model.dataMetadataIdForMapData"/>', + "model.dataMetadataIdForMapResult": '<s:property value="model.dataMetadataIdForMapResult"/>', + "model.showOperationLayer": '<s:property value="model.showOperationLayer"/>', + "model.showCellEsduDataLayer": '<s:property value="model.showCellEsduDataLayer"/>', + "model.showCellEsduResultLayer": '<s:property value="model.showCellEsduResultLayer"/>', + "model.showCellMapDataLayer": '<s:property value="model.showCellMapDataLayer"/>', + "model.showCellMapResultLayer": '<s:property value="model.showCellMapResultLayer"/>' }, function (result) { // inject result $('#dataPanel').html(result); - }); + });*/ </s:if> }); </script> @@ -99,22 +138,38 @@ label='%{getText("echobase.common.voyage")}' list="voyages" headerKey="" headerValue=""/> - <sj:select key="model.dataMetadataId" requiredLabel="true" - label='%{getText("echobase.common.dataMetadata")}' - headerKey="" headerValue=""/> + <div id="withSelectedVoyage"> + <s:checkbox key="model.showOperationLayer" label='%{getText("echobase.common.showOperationLayer")}'/> - <s:select key="model.cellTypeId" requiredLabel="true" - label='%{getText("echobase.common.cellType")}' - list="cellTypes" headerKey="" headerValue=""/> + <s:checkbox key="model.showCellEsduDataLayer" label='%{getText("echobase.common.showCellEsduDataLayer")}'/> + <div class="cellEsduDataLayer"> + <sj:select key="model.dataMetadataIdForEsduData" requiredLabel="true" + label='%{getText("echobase.common.dataMetadata.forEsduDataLayer")}' + headerKey="" headerValue=""/> + </div> - <sj:select key="model.speciesId" requiredLabel="false" - label='%{getText("echobase.common.species")}' - headerKey="" headerValue=""/> + <s:checkbox key="model.showCellEsduResultLayer" label='%{getText("echobase.common.showCellEsduResultLayer")}'/> + <div class="cellEsduResultLayer"> + <sj:select key="model.dataMetadataIdForEsduResult" requiredLabel="true" + label='%{getText("echobase.common.dataMetadata.forEsduResultLayer")}' + headerKey="" headerValue=""/> + </div> - <sj:select key="model.echotypeId" requiredLabel="false" - label='%{getText("echobase.common.echotype")}' - headerKey="" headerValue=""/> + <s:checkbox key="model.showCellMapDataLayer" label='%{getText("echobase.common.showCellMapDataLayer")}'/> + <div class="cellMapDataLayer"> + <sj:select key="model.dataMetadataIdForMapData" requiredLabel="true" + label='%{getText("echobase.common.dataMetadata.forMapDataLayer")}' + headerKey="" headerValue=""/> + </div> + <s:checkbox key="model.showCellMapResultLayer" label='%{getText("echobase.common.showCellMapResultLayer")}'/> + <div class="cellMapResultLayer"> + <sj:select key="model.dataMetadataIdForMapResult" requiredLabel="true" + label='%{getText("echobase.common.dataMetadata.forMapResultLayer")}' + headerKey="" headerValue=""/> + </div> + </div> + <s:hidden key="model.withData" label=' '/> <s:hidden key="model.withSpatial" label=' '/> Modified: trunk/echobase-ui/src/main/webapp/js/gridHelper.js =================================================================== --- trunk/echobase-ui/src/main/webapp/js/gridHelper.js 2014-01-22 14:01:35 UTC (rev 928) +++ trunk/echobase-ui/src/main/webapp/js/gridHelper.js 2014-01-22 21:32:46 UTC (rev 929) @@ -304,35 +304,24 @@ } }, - // auto-selection des voyages - species - autoSelectVoyageAndEchotype: function (voyageSelectBox, echotypeSelectBox, getUrl, voyageId, echotypeId) { + // affichage ou non des options d'un layer spatial + showSpatialLayer: function (checkboxId, configCssClass, selectBoxId, defaultValue) { - voyageSelectBox.change({echotypeSelectBox: echotypeSelectBox, - getUrl: getUrl}, function (event) { - - $.updateSelectBoxContent(event.data.getUrl, - {voyageId: this.value}, - 'data', - event.data.echotypeSelectBox - ); + var f = function(show) { + var config = $('[class~="' + configCssClass + '"]'); + var selectBox = $('[name="' + selectBoxId + '"]') + if (show) { + selectBox.removeAttr('disabled'); + config.show(); + } else { + selectBox.attr('disabled', true); + config.hide(); + } + }; + $('[name="' + checkboxId + '"]').change(function () { + f($(this).is(':checked')); }); - - if (voyageId) { - - voyageSelectBox.change(voyageId); - - $.updateSelectBoxContent(getUrl, - {voyageId: voyageId}, - 'data', - echotypeSelectBox, function () { - - if (echotypeId) { - - echotypeSelectBox.val(echotypeId); - } - } - ); - } + f(!!defaultValue); } }); @@ -384,8 +373,8 @@ autoSelectVoyageAndSpecies: function (voyageSelectBox, speciesSelectBox, getUrl, voyageId, speciesId) { return $(document).autoSelectVoyageAndSpecies(voyageSelectBox, speciesSelectBox, getUrl, voyageId, speciesId); }, - autoSelectVoyageAndEchotype: function (voyageSelectBox, echotypeSelectBox, getUrl, voyageId, echotypeId) { - return $(document).autoSelectVoyageAndEchotype(voyageSelectBox, echotypeSelectBox, getUrl, voyageId, echotypeId); + showSpatialLayer: function (checkboxId, configCssClass, selectBoxId, defaultValue) { + return $(document).showSpatialLayer(checkboxId, configCssClass, selectBoxId, defaultValue); } }); })(jQuery);