This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository echobase. See http://git.codelutin.com/echobase.git commit e4d47d7d7b4db189ce9171b0dcce851dc47b73c4 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Dec 8 12:06:01 2014 +0100 refs-70 #6054: (ajout des cellules esdu non importées dans les logs et dans le resumé de l'import) --- .../service/importdata/AcousticImportResult.java | 57 ++++++++++++++++ .../service/importdata/AcousticImportService.java | 78 ++++++++++++++++------ .../i18n/echobase-services_en_GB.properties | 1 + .../i18n/echobase-services_fr_FR.properties | 1 + 4 files changed, 117 insertions(+), 20 deletions(-) diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportResult.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportResult.java new file mode 100644 index 0000000..74f291a --- /dev/null +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportResult.java @@ -0,0 +1,57 @@ +package fr.ifremer.echobase.services.service.importdata; + +/* + * #%L + * EchoBase :: Services + * %% + * Copyright (C) 2011 - 2012 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.ImmutableSet; +import fr.ifremer.echobase.entities.ImportLog; +import org.nuiton.topia.persistence.TopiaEntity; +import org.nuiton.topia.service.csv.in.CsvFileImportResult; + +import java.util.HashSet; +import java.util.Set; + +/** + * {@link CsvFileImportResult} with support for ids to keep in the + * {@link ImportLog#getImportId()}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2 + */ +public class AcousticImportResult extends EchoBaseCsvFileImportResult { + + private static final long serialVersionUID = 1L; + + protected final Set<String> notImportedEsduCellIds = new HashSet<String>(); + + public AcousticImportResult(String importFileName) { + super(importFileName); + } + + public <E extends TopiaEntity> void addNotImportedEsduCellId(String id) { + notImportedEsduCellIds.add(id); + } + + public Set<String> getNotImportedEsduCellIds() { + return ImmutableSet.copyOf(notImportedEsduCellIds); + } + +} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportService.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportService.java index 339543d..b98526c 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportService.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/AcousticImportService.java @@ -20,6 +20,7 @@ */ package fr.ifremer.echobase.services.service.importdata; +import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fr.ifremer.echobase.EchoBaseFunctions; @@ -137,7 +138,7 @@ public class AcousticImportService extends AbstractImportDataService<AcousticImp log.info("Starts " + getImportMessage(configuration, inputFile)); } - EchoBaseCsvFileImportResult importResult = newImportResult(inputFile); + AcousticImportResult importResult = newImportResult(inputFile); Map<String, AcousticInstrument> instrumentsById = persistenceService.getEntitiesMap(AcousticInstrument.class, @@ -198,9 +199,9 @@ public class AcousticImportService extends AbstractImportDataService<AcousticImp // can not find correct transit throw new ImportException( l(locale, "echobase.importError.transit.notfound", - voyage.getName(), - startDate, - rowNumber)); + voyage.getName(), + startDate, + rowNumber)); } Transect transect = transit.getTransect(vessel); @@ -209,10 +210,10 @@ public class AcousticImportService extends AbstractImportDataService<AcousticImp // can not find correct transect throw new ImportException( l(locale, "echobase.importError.transect.notfound", - voyage.getName(), - startDate, - vessel.getName(), - rowNumber)); + voyage.getName(), + startDate, + vessel.getName(), + rowNumber)); } AcousticInstrument instrument = row.getAcousticInstrument(); @@ -236,10 +237,10 @@ public class AcousticImportService extends AbstractImportDataService<AcousticImp // can not find correct transect throw new ImportException( l(locale, "echobase.importError.esduCell.notfound", - voyage.getName(), - vessel.getName(), - instrument.getId(), - rowNumber)); + voyage.getName(), + vessel.getName(), + instrument.getId(), + rowNumber)); } String softwareVersion = @@ -303,27 +304,43 @@ public class AcousticImportService extends AbstractImportDataService<AcousticImp } } + int cellType = row.getCellType(); + + String esduCellId = cellDateFormat.format(endDate); + + boolean isEsduCell = cellType == 4; + if (!row.isCellToAdd()) { // dead cell not to be imported - if (log.isDebugEnabled()) { - log.debug("Will not import cell of row " + rowNumber); + + String id = rowNumber + " - " + cellType + " : " + esduCellId; + if (isEsduCell) { + + // keep this fact into import result + if (log.isWarnEnabled()) { + log.warn("Will not import esdu cell of row " + id); + } + importResult.addNotImportedEsduCellId(id); + } else { + + // just a debug log + if (log.isDebugEnabled()) { + log.debug("Will not import cell of row " + id); + } } + continue; } - int cellType = row.getCellType(); - - String esduCellId = cellDateFormat.format(endDate); - DataQuality dataQuality = row.getDataQuality(); - // collect Esdu cellIds only if dataAcquisitions was not created here boolean collectCellIds = !createdDataAcquisitions.contains( dataAcquisition.getTopiaId()); - if (cellType == 4) { + + if (isEsduCell) { if (log.isDebugEnabled()) { log.debug("[row " + rowNumber + "] Esdu cell (" + @@ -407,6 +424,23 @@ public class AcousticImportService extends AbstractImportDataService<AcousticImp } } + @Override + protected String computeResultAndLogBookEntry(AcousticImportConfiguration configuration, + EchoBaseUser user) { + String resultText = super.computeResultAndLogBookEntry(configuration, user); + List<EchoBaseCsvFileImportResult> importResults = configuration.getImportResults(); + if (!importResults.isEmpty()) { + AcousticImportResult acousticImportResult = (AcousticImportResult) importResults.get(0); + Set<String> notImportedCellIds = acousticImportResult.getNotImportedEsduCellIds(); + if (!notImportedCellIds.isEmpty()) { + + // add a log of not imported cells + resultText += "\n\n" + l(getLocale(), "echobase.acousticImport.cellNotImported", Joiner.on("\n").join(notImportedCellIds)); + } + } + return resultText; + } + protected void createEsduCellData(String suffix, Cell cell, Map<String, DataMetadata> dataMetadatas, @@ -711,4 +745,8 @@ public class AcousticImportService extends AbstractImportDataService<AcousticImp return result; } + @Override + protected AcousticImportResult newImportResult(InputFile inputFile) { + return new AcousticImportResult(inputFile.getFileName()); + } } 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 1be7eb2..86b2e28 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 @@ -1,3 +1,4 @@ +echobase.acousticImport.cellNotImported=List of not imported esdu cells \:\n%s echobase.common.biometrySampleFile=BiometrySample file echobase.common.cellMapsFile=Map cells file echobase.common.cellPositionReference.end=End 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 d204869..d7b28bb 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 @@ -1,3 +1,4 @@ +echobase.acousticImport.cellNotImported=Liste des cellules ESDU non importées \:\n%s echobase.common.biometrySampleFile=Fichier de biométries (BiometrySample) echobase.common.cellMapsFile=Fichier des cellules Cartes echobase.common.cellPositionReference.end=Fin -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.