This is an automated email from the git hooks/post-receive script. New commit to branch feature/2246 in repository echobase. See https://gitlab.nuiton.org/codelutin/echobase.git commit a23905dde41b2fbd383cb388072f791e13eedc01 Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu May 12 15:39:59 2016 +0200 Ne pas autoriser de réimporter les données acoustiques déjà existantes (See #2246) --- .../services/service/UserDbPersistenceService.java | 4 ++ .../DuplicatedElementaryCellException.java | 43 ++++++++++++++++++++++ .../importdata/DuplicatedEsduCellException.java | 43 ++++++++++++++++++++++ .../actions/VoyageAcousticsImportAction.java | 18 ++++++++- .../i18n/echobase-services_en_GB.properties | 2 + .../i18n/echobase-services_fr_FR.properties | 2 + 6 files changed, 111 insertions(+), 1 deletion(-) 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 603c26a..cd6300d 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 @@ -217,6 +217,10 @@ public class UserDbPersistenceService extends EchoBaseServiceSupport { //--- Cell ---------------------------------------------------------------// //------------------------------------------------------------------------// + public boolean containsCellByName(String cellName) { + return persistenceContext.getCellDao().forNameEquals(cellName).exists(); + } + public Cell getCell(String id) { return persistenceContext.getCellDao().forTopiaIdEquals(id).findUnique(); } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/DuplicatedElementaryCellException.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/DuplicatedElementaryCellException.java new file mode 100644 index 0000000..84037f2 --- /dev/null +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/DuplicatedElementaryCellException.java @@ -0,0 +1,43 @@ +package fr.ifremer.echobase.services.service.importdata; + +/* + * #%L + * EchoBase :: Services + * %% + * Copyright (C) 2011 - 2015 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 org.nuiton.csv.ImportRuntimeException; + +import java.util.Locale; + +import static org.nuiton.i18n.I18n.l; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 4.0 + */ +public class DuplicatedElementaryCellException extends ImportRuntimeException { + + private static final long serialVersionUID = 1L; + + public DuplicatedElementaryCellException(Locale locale, int rowNumber, String esduCellId) { + super(l(locale, "echobase.importError.duplicate.elementaryCell", rowNumber, esduCellId)); + } +} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/DuplicatedEsduCellException.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/DuplicatedEsduCellException.java new file mode 100644 index 0000000..a37d5aa --- /dev/null +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/DuplicatedEsduCellException.java @@ -0,0 +1,43 @@ +package fr.ifremer.echobase.services.service.importdata; + +/* + * #%L + * EchoBase :: Services + * %% + * Copyright (C) 2011 - 2015 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 org.nuiton.csv.ImportRuntimeException; + +import java.util.Locale; + +import static org.nuiton.i18n.I18n.l; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 4.0 + */ +public class DuplicatedEsduCellException extends ImportRuntimeException { + + private static final long serialVersionUID = 1L; + + public DuplicatedEsduCellException(Locale locale, int rowNumber, String esduCellId) { + super(l(locale, "echobase.importError.duplicate.esduCell", rowNumber, esduCellId)); + } +} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageAcousticsImportAction.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageAcousticsImportAction.java index 5c3a5f4..8b9d3ac 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageAcousticsImportAction.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageAcousticsImportAction.java @@ -23,6 +23,7 @@ import fr.ifremer.echobase.entities.references.DataQuality; import fr.ifremer.echobase.entities.references.Vessel; import fr.ifremer.echobase.io.InputFile; import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; +import fr.ifremer.echobase.services.service.importdata.DuplicatedEsduCellException; import fr.ifremer.echobase.services.service.importdata.ElementaryCellWithoutDepthEndException; import fr.ifremer.echobase.services.service.importdata.EsduCellNotFoundException; import fr.ifremer.echobase.services.service.importdata.EsduCellWithDepthEndFilledException; @@ -259,6 +260,12 @@ public class VoyageAcousticsImportAction extends VoyageAcousticsImportDataAction log.debug("[row " + rowNumber + "] Esdu cell (" + esduCellId + ")"); } + // check name does not exist + boolean exists = persistenceService.containsCellByName(esduCellId); + if (exists) { + throw new DuplicatedEsduCellException(getLocale(), rowNumber, esduCellId); + } + // this is a esdu cell row // create esdu cell @@ -294,6 +301,15 @@ public class VoyageAcousticsImportAction extends VoyageAcousticsImportDataAction String elementaryCellId = cellNum + (surface ? "S" : "B"); + // check name does not exist + boolean exists = persistenceService.containsCellByName(elementaryCellId); + if (exists) { + //FIXME Revoir ça (See #2246) + if (log.isErrorEnabled()) { + log.error("Duplicated ElementaryCellException: " + rowNumber + " → " + elementaryCellId); + } +// throw new DuplicatedElementaryCellException(getLocale(), rowNumber, elementaryCellId); + } if (log.isTraceEnabled()) { log.trace("[row " + rowNumber + "] elementary cell (" + elementaryCellId + ")"); } @@ -791,7 +807,7 @@ public class VoyageAcousticsImportAction extends VoyageAcousticsImportDataAction private final DataMetadata numberOfSamplesEchoIntegratedDataMetadata; private final DataMetadata depthRefSurfaceStartDataMetadata; private final DataMetadata depthRefSurfaceEndDataMetadata; -// private final DataMetadata depthRefBottomStartDataMetadata; + // private final DataMetadata depthRefBottomStartDataMetadata; private final DataMetadata depthRefBottomEndDataMetadata; public DataMetadataProvider(VoyageAcousticsImportDataContext importDataContext) { diff --git a/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties b/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties index 81df9de..44c82be 100644 --- a/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties +++ b/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties @@ -32,6 +32,8 @@ echobase.common.voyageFile=Voyage data file echobase.exportError.toFile=An error occured while exporting file %s \:%s echobase.importError.can.only.import.one.voyage.atime=Impossible to import more that one voyage at a time echobase.importError.dataMetadata.notFound=Metadata column %s missing (existing values \:%s) +echobase.importError.duplicate.esduCell=ESDU cell named «%s» already exists in database. +echobase.importError.duplicate.elementaryCell=Elementary cell named «%s» already exists in database. echobase.importError.duplicate.gearMetataValue=A gear meta data (type «%s») value on engin «%s» for operation with id «%s», on startum «%s» - vessel «%s» on voyage «%s» already exists in database. echobase.importError.duplicate.operation=An operation with id «%s», on startum «%s» - vessel «%s» on voyage «%s» already exists in database. echobase.importError.duplicate.operationMetataValue=An operation meta data (type «%s») value for operation with id «%s», on startum «%s» - vessel «%s» on voyage «%s» already exists in database. diff --git a/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties b/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties index 049310c..6e8c3e9 100644 --- a/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties +++ b/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties @@ -35,6 +35,8 @@ echobase.importError.dataMetadata.notFound=Colonne de métadonnées nommée %s n echobase.importError.duplicate.gearMetataValue=La mise en œuvre (type %s) de l'engin «%s» (opération d'identifiant «%s» sur la strate «%s» - navire «%s» et sur la marée nommée «%s») existe déjà dans la base. echobase.importError.duplicate.operation=L'opération d'identifiant «%s» sur la strate «%s» - navire «%s» et sur la marée nommée «%s» existe déjà dans la base. echobase.importError.duplicate.operationMetataValue=La donnée (type %s) (opération d'identifiant «%s» sur la strate «%s» - navire «%s» et sur la marée nommée «%s») existe déjà dans la base. +echobase.importError.duplicate.esduCell=La cellule ESDU (ligne %s) d'identifiant «%s» existe déjà en base. +echobase.importError.duplicate.elementaryCell=La cellule élémentaire (ligne %s) d'identifiant «%s» existe déjà en base. echobase.importError.duplicate.sample=L'opération %s ne peut pas contenir deux échantillons de même type %s, espèce %s et classe de taille %s echobase.importError.duplicate.subSamble=Le subs-sample (classe de taille %s, catégorie %s, opération %s) existe déjà dans la base. echobase.importError.duplicate.transect=Le transect nommé «%s» sur la marée nommée «%s» existe déjà dans la base. -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.