branch feature/8170 updated (81dec8c -> c573872)
This is an automated email from the git hooks/post-receive script. New change to branch feature/8170 in repository echobase. See https://gitlab.nuiton.org/codelutin/echobase.git from 81dec8c Can collect ids when creatin data cell new 3055fcc Rename voyage region import data classes new c9211b0 Pouvoir récupérer une espèces new c573872 Voyage result import ok \o/ (See #8170) The 3 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 c57387276a2d7844c808c1f4797f52944fc56382 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Apr 4 18:29:22 2016 +0200 Voyage result import ok \o/ (See #8170) commit c9211b0033af367bee1939c6dbaa76423ad301e6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Apr 4 18:28:50 2016 +0200 Pouvoir récupérer une espèces commit 3055fcc9cfc866aa352d0036e6681ec780df8d0c Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Apr 4 17:00:07 2016 +0200 Rename voyage region import data classes Summary of changes: .../services/service/UserDbPersistenceService.java | 4 + ...VoyageResultsRegionAssociationImportAction.java | 20 ++--- .../actions/VoyageResultsRegionImportAction.java | 20 ++--- .../VoyageResultsRegionResultsImportAction.java | 26 +++--- .../VoyageResultsVoyageEchotypeImportAction.java | 54 +++++++++--- ...oyageResultsVoyageLengthAgeKeyImportAction.java | 34 +++++--- ...geResultsVoyageLengthWeightKeyImportAction.java | 36 +++++--- ...chotypeAndSpeciesCategoryImportExportModel.java | 4 +- .../csv/EsduResultByEchotypeImportExportModel.java | 4 +- ...ltBySpeciesAndAgeCategoryImportExportModel.java | 4 +- ...tBySpeciesAndSizeCategoryImportExportModel.java | 4 +- .../csv/LengthWeightKeyImportExportModel.java | 73 ---------------- .../RegionCellAssociationImportExportModel.java | 68 --------------- .../csv/RegionCellImportExportModel.java | 71 ---------------- .../csv/RegionCellResultImportExportModel.java | 96 ---------------------- ...ultsRegionCellAssociationImportExportModel.java | 68 +++++++++++++++ ...yageResultsRegionCellAssociationImportRow.java} | 10 +-- .../VoyageResultsRegionCellImportExportModel.java | 71 ++++++++++++++++ ....java => VoyageResultsRegionCellImportRow.java} | 10 +-- ...geResultsRegionCellResultImportExportModel.java | 96 ++++++++++++++++++++++ ...=> VoyageResultsRegionCellResultImportRow.java} | 8 +- ...ageResultsVoyageEchotypeImportExportModel.java} | 30 +++---- ...a => VoyageResultsVoyageEchotypeImportRow.java} | 47 +++++++++-- ...esultsVoyageLengthAgeKeyImportExportModel.java} | 22 ++--- ... VoyageResultsVoyageLengthAgeKeyImportRow.java} | 43 +++++++++- ...ultsVoyageLengthWeightKeyImportExportModel.java | 76 +++++++++++++++++ ...yageResultsVoyageLengthWeightKeyImportRow.java} | 40 +++++++-- .../VoyageResultsVoyageImportServiceIT.java | 34 +++++--- ...geResultsVoyageOnlyEchotypeImportServiceIT.java | 12 +-- ...sultsVoyageOnlyLengthAgeKeyImportServiceIT.java | 11 ++- ...tsVoyageOnlyLengthWeightKeyImportServiceIT.java | 11 ++- 31 files changed, 641 insertions(+), 466 deletions(-) delete mode 100644 echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthWeightKeyImportExportModel.java delete mode 100644 echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportExportModel.java delete mode 100644 echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellImportExportModel.java delete mode 100644 echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellResultImportExportModel.java create mode 100644 echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellAssociationImportExportModel.java rename echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/{RegionCellAssociationImportRow.java => VoyageResultsRegionCellAssociationImportRow.java} (81%) create mode 100644 echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellImportExportModel.java rename echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/{RegionCellImportRow.java => VoyageResultsRegionCellImportRow.java} (88%) create mode 100644 echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellResultImportExportModel.java rename echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/{RegionCellResultImportRow.java => VoyageResultsRegionCellResultImportRow.java} (90%) rename echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/{EchotypeImportExportModel.java => VoyageResultsVoyageEchotypeImportExportModel.java} (55%) rename echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/{EchotypeImportRow.java => VoyageResultsVoyageEchotypeImportRow.java} (63%) rename echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/{LengthAgeKeyImportExportModel.java => VoyageResultsVoyageLengthAgeKeyImportExportModel.java} (65%) rename echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/{LengthAgeKeyImportRow.java => VoyageResultsVoyageLengthAgeKeyImportRow.java} (65%) create mode 100644 echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthWeightKeyImportExportModel.java rename echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/{LengthWeightKeyImportRow.java => VoyageResultsVoyageLengthWeightKeyImportRow.java} (69%) -- 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/8170 in repository echobase. See https://gitlab.nuiton.org/codelutin/echobase.git commit 3055fcc9cfc866aa352d0036e6681ec780df8d0c Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Apr 4 17:00:07 2016 +0200 Rename voyage region import data classes --- ...VoyageResultsRegionAssociationImportAction.java | 20 ++--- .../actions/VoyageResultsRegionImportAction.java | 20 ++--- .../VoyageResultsRegionResultsImportAction.java | 26 +++--- ...chotypeAndSpeciesCategoryImportExportModel.java | 4 +- .../csv/EsduResultByEchotypeImportExportModel.java | 4 +- ...ltBySpeciesAndAgeCategoryImportExportModel.java | 4 +- ...tBySpeciesAndSizeCategoryImportExportModel.java | 4 +- .../RegionCellAssociationImportExportModel.java | 68 --------------- .../csv/RegionCellImportExportModel.java | 71 ---------------- .../csv/RegionCellResultImportExportModel.java | 96 ---------------------- ...ultsRegionCellAssociationImportExportModel.java | 68 +++++++++++++++ ...yageResultsRegionCellAssociationImportRow.java} | 10 +-- .../VoyageResultsRegionCellImportExportModel.java | 71 ++++++++++++++++ ....java => VoyageResultsRegionCellImportRow.java} | 10 +-- ...geResultsRegionCellResultImportExportModel.java | 96 ++++++++++++++++++++++ ...=> VoyageResultsRegionCellResultImportRow.java} | 8 +- 16 files changed, 290 insertions(+), 290 deletions(-) diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionAssociationImportAction.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionAssociationImportAction.java index 675c085..1bae3d6 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionAssociationImportAction.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionAssociationImportAction.java @@ -7,8 +7,8 @@ import fr.ifremer.echobase.entities.data.Voyage; import fr.ifremer.echobase.io.InputFile; import fr.ifremer.echobase.services.service.importdata.ImportDataFileResult; import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; -import fr.ifremer.echobase.services.service.importdata.csv.RegionCellAssociationImportExportModel; -import fr.ifremer.echobase.services.service.importdata.csv.RegionCellAssociationImportRow; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsRegionCellAssociationImportExportModel; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsRegionCellAssociationImportRow; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.csv.Import; @@ -22,7 +22,7 @@ import java.util.Map; * @author Tony Chemit - chemit@codelutin.com * @since 4.0 */ -public class VoyageResultsRegionAssociationImportAction extends VoyageResultsImportDataActionSupport<RegionCellAssociationImportRow> { +public class VoyageResultsRegionAssociationImportAction extends VoyageResultsImportDataActionSupport<VoyageResultsRegionCellAssociationImportRow> { /** Logger. */ private static final Log log = LogFactory.getLog(VoyageResultsRegionAssociationImportAction.class); @@ -32,13 +32,13 @@ public class VoyageResultsRegionAssociationImportAction extends VoyageResultsImp } @Override - protected RegionCellAssociationImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { - return RegionCellAssociationImportExportModel.forImport(importDataContext); + protected VoyageResultsRegionCellAssociationImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsRegionCellAssociationImportExportModel.forImport(importDataContext); } @Override - protected RegionCellAssociationImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { - return RegionCellAssociationImportExportModel.forExport(importDataContext); + protected VoyageResultsRegionCellAssociationImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsRegionCellAssociationImportExportModel.forExport(importDataContext); } private final Map<String, String> esduCellDataIdToRegionCellId = new LinkedHashMap<>(); @@ -50,11 +50,11 @@ public class VoyageResultsRegionAssociationImportAction extends VoyageResultsImp log.info("Starts import of Region cells association from file " + inputFile.getFileName()); } - try (Import<RegionCellAssociationImportRow> importer = open()) { + try (Import<VoyageResultsRegionCellAssociationImportRow> importer = open()) { incrementsProgress(); int rowNumber = 0; - for (RegionCellAssociationImportRow row : importer) { + for (VoyageResultsRegionCellAssociationImportRow row : importer) { doFlushTransaction(++rowNumber); @@ -96,7 +96,7 @@ public class VoyageResultsRegionAssociationImportAction extends VoyageResultsImp Cell regionCell = persistenceService.getCell(regionCellId); Preconditions.checkNotNull(regionCell); - RegionCellAssociationImportRow row = RegionCellAssociationImportRow.of(voyage, regionCell, esduCell); + VoyageResultsRegionCellAssociationImportRow row = VoyageResultsRegionCellAssociationImportRow.of(voyage, regionCell, esduCell); addImportedRow(result, row); } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionImportAction.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionImportAction.java index e021356..684001b 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionImportAction.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionImportAction.java @@ -14,8 +14,8 @@ import fr.ifremer.echobase.entities.references.DataQuality; import fr.ifremer.echobase.io.InputFile; import fr.ifremer.echobase.services.service.importdata.ImportDataFileResult; import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; -import fr.ifremer.echobase.services.service.importdata.csv.RegionCellImportExportModel; -import fr.ifremer.echobase.services.service.importdata.csv.RegionCellImportRow; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsRegionCellImportExportModel; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsRegionCellImportRow; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.csv.Import; @@ -29,7 +29,7 @@ import java.util.TreeMap; * @author Tony Chemit - chemit@codelutin.com * @since 4.0 */ -public class VoyageResultsRegionImportAction extends VoyageResultsImportDataActionSupport<RegionCellImportRow> { +public class VoyageResultsRegionImportAction extends VoyageResultsImportDataActionSupport<VoyageResultsRegionCellImportRow> { /** Logger. */ private static final Log log = LogFactory.getLog(VoyageResultsRegionImportAction.class); @@ -39,13 +39,13 @@ public class VoyageResultsRegionImportAction extends VoyageResultsImportDataActi } @Override - protected RegionCellImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { - return RegionCellImportExportModel.forImport(importDataContext); + protected VoyageResultsRegionCellImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsRegionCellImportExportModel.forImport(importDataContext); } @Override - protected RegionCellImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { - return RegionCellImportExportModel.forExport(importDataContext); + protected VoyageResultsRegionCellImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsRegionCellImportExportModel.forExport(importDataContext); } private final Map<String, String> cellDataCoordinateIdToCellId = new TreeMap<>(); @@ -61,13 +61,13 @@ public class VoyageResultsRegionImportAction extends VoyageResultsImportDataActi } Voyage voyage = importDataContext.getVoyage(); - try (Import<RegionCellImportRow> importer = open()) { + try (Import<VoyageResultsRegionCellImportRow> importer = open()) { Cell cell = null; incrementsProgress(); int rowNumber = 0; - for (RegionCellImportRow row : importer) { + for (VoyageResultsRegionCellImportRow row : importer) { doFlushTransaction(++rowNumber); @@ -155,7 +155,7 @@ public class VoyageResultsRegionImportAction extends VoyageResultsImportDataActi String surfaceDataValue = optionalSurfaceData.get().getDataValue(); Preconditions.checkNotNull(coordinateData); - RegionCellImportRow row = RegionCellImportRow.of(voyage, cell, coordinateData, Float.valueOf(surfaceDataValue)); + VoyageResultsRegionCellImportRow row = VoyageResultsRegionCellImportRow.of(voyage, cell, coordinateData, Float.valueOf(surfaceDataValue)); addImportedRow(result, row); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionResultsImportAction.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionResultsImportAction.java index be8dd7a..6536bc1 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionResultsImportAction.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsRegionResultsImportAction.java @@ -10,8 +10,8 @@ import fr.ifremer.echobase.io.InputFile; import fr.ifremer.echobase.services.service.importdata.ImportDataFileResult; import fr.ifremer.echobase.services.service.importdata.ResultCategoryCache; import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; -import fr.ifremer.echobase.services.service.importdata.csv.RegionCellResultImportExportModel; -import fr.ifremer.echobase.services.service.importdata.csv.RegionCellResultImportRow; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsRegionCellResultImportExportModel; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsRegionCellResultImportRow; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.csv.Import; @@ -27,7 +27,7 @@ import java.util.TreeMap; * @author Tony Chemit - chemit@codelutin.com * @since 4.0 */ -public class VoyageResultsRegionResultsImportAction extends VoyageResultsImportDataActionSupport<RegionCellResultImportRow> { +public class VoyageResultsRegionResultsImportAction extends VoyageResultsImportDataActionSupport<VoyageResultsRegionCellResultImportRow> { /** Logger. */ private static final Log log = LogFactory.getLog(VoyageResultsRegionResultsImportAction.class); @@ -36,17 +36,17 @@ public class VoyageResultsRegionResultsImportAction extends VoyageResultsImportD public VoyageResultsRegionResultsImportAction(VoyageResultsImportDataContext importDataContext) { super(importDataContext, importDataContext.getConfiguration().getRegionResultFile()); - metas = importDataContext.getMetas(getInputFile(), RegionCellResultImportExportModel.COLUMN_NAMES_TO_EXCLUDE); + metas = importDataContext.getMetas(getInputFile(), VoyageResultsRegionCellResultImportExportModel.COLUMN_NAMES_TO_EXCLUDE); } @Override - protected RegionCellResultImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { - return RegionCellResultImportExportModel.forImport(importDataContext, metas); + protected VoyageResultsRegionCellResultImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsRegionCellResultImportExportModel.forImport(importDataContext, metas); } @Override - protected RegionCellResultImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { - return RegionCellResultImportExportModel.forExport(importDataContext, metas); + protected VoyageResultsRegionCellResultImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsRegionCellResultImportExportModel.forExport(importDataContext, metas); } @@ -63,11 +63,11 @@ public class VoyageResultsRegionResultsImportAction extends VoyageResultsImportD ResultCategoryCache resultCategoryCache = importDataContext.getResultCategoryCache(); - try (Import<RegionCellResultImportRow> importer = open()) { + try (Import<VoyageResultsRegionCellResultImportRow> importer = open()) { incrementsProgress(); int rowNumber = 0; - for (RegionCellResultImportRow row : importer) { + for (VoyageResultsRegionCellResultImportRow row : importer) { doFlushTransaction(++rowNumber); @@ -117,7 +117,7 @@ public class VoyageResultsRegionResultsImportAction extends VoyageResultsImportD if (log.isInfoEnabled()) { log.info("Cell has changed, flushing " + cellResults.size() + " results for cell: " + cell + " with category " + lastCategory); } - RegionCellResultImportRow row = RegionCellResultImportRow.of(voyage, cell, lastCategory, cellResults); + VoyageResultsRegionCellResultImportRow row = VoyageResultsRegionCellResultImportRow.of(voyage, cell, lastCategory, cellResults); addImportedRow(result, row); @@ -151,7 +151,7 @@ public class VoyageResultsRegionResultsImportAction extends VoyageResultsImportD log.info("Cell result category has changed, flushing " + cellResults.size() + " results for cell: " + cell + " with category " + lastCategory); } - RegionCellResultImportRow row = RegionCellResultImportRow.of(voyage, cell, lastCategory, cellResults); + VoyageResultsRegionCellResultImportRow row = VoyageResultsRegionCellResultImportRow.of(voyage, cell, lastCategory, cellResults); addImportedRow(result, row); @@ -180,7 +180,7 @@ public class VoyageResultsRegionResultsImportAction extends VoyageResultsImportD // flush last cell Cell cell = persistenceService.getCell(lastCellId); - RegionCellResultImportRow row = RegionCellResultImportRow.of(voyage, cell, lastCategory, cellResults); + VoyageResultsRegionCellResultImportRow row = VoyageResultsRegionCellResultImportRow.of(voyage, cell, lastCategory, cellResults); addImportedRow(result, row); } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultByEchotypeAndSpeciesCategoryImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultByEchotypeAndSpeciesCategoryImportExportModel.java index eb31871..de07a4f 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultByEchotypeAndSpeciesCategoryImportExportModel.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultByEchotypeAndSpeciesCategoryImportExportModel.java @@ -57,7 +57,7 @@ public class EsduResultByEchotypeAndSpeciesCategoryImportExportModel extends Ech List<DataMetadata> dataMetadatas) { EsduResultByEchotypeAndSpeciesCategoryImportExportModel model = new EsduResultByEchotypeAndSpeciesCategoryImportExportModel(importDataContext.getCsvSeparator()); - model.newForeignKeyColumn(RegionCellImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); + model.newForeignKeyColumn(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); model.newForeignKeyColumn(EsduResultByEchotypeAndSpeciesCategoryImportRow.PROPERTY_ECHOTYPE, Echotype.class, Echotype.PROPERTY_NAME, importDataContext.getVoyageEchotypesByName()); model.newForeignKeyColumn(Species.PROPERTY_BARACOUDA_CODE, EsduResultByEchotypeAndSpeciesCategoryImportRow.PROPERTY_SPECIES, Species.class, Species.PROPERTY_BARACOUDA_CODE, importDataContext.getSpeciesByBaracoudaCode()); model.newForeignKeyColumn(EsduResultByEchotypeAndSpeciesCategoryImportRow.PROPERTY_SIZE_CATEGORY, SizeCategory.class, SizeCategory.PROPERTY_NAME, importDataContext.getSizeCategoriesByName()); @@ -79,7 +79,7 @@ public class EsduResultByEchotypeAndSpeciesCategoryImportExportModel extends Ech List<DataMetadata> dataMetadatas) { EsduResultByEchotypeAndSpeciesCategoryImportExportModel model = new EsduResultByEchotypeAndSpeciesCategoryImportExportModel(importDataContext.getCsvSeparator()); - model.newColumnForExport(RegionCellImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); + model.newColumnForExport(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); model.newColumnForExport(EsduResultByEchotypeAndSpeciesCategoryImportRow.PROPERTY_ECHOTYPE, EchoBaseCsvUtil.ECHOTYPE_FORMATTER); model.newColumnForExport(Species.PROPERTY_BARACOUDA_CODE, EsduResultByEchotypeAndSpeciesCategoryImportRow.PROPERTY_SPECIES, EchoBaseCsvUtil.SPECIES_FORMATTER); model.newColumnForExport(EsduResultByEchotypeAndSpeciesCategoryImportRow.PROPERTY_SIZE_CATEGORY, EchoBaseCsvUtil.SIZE_CATEGORY_FORMATTER); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultByEchotypeImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultByEchotypeImportExportModel.java index 71a53a4..c44fdf7 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultByEchotypeImportExportModel.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultByEchotypeImportExportModel.java @@ -53,7 +53,7 @@ public class EsduResultByEchotypeImportExportModel extends EchoBaseImportExportM List<DataMetadata> dataMetadatas) { EsduResultByEchotypeImportExportModel model = new EsduResultByEchotypeImportExportModel(importDataContext.getCsvSeparator()); - model.newForeignKeyColumn(RegionCellImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); + model.newForeignKeyColumn(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); model.newForeignKeyColumn(EsduResultByEchotypeImportRow.PROPERTY_ECHOTYPE, Echotype.class, Echotype.PROPERTY_NAME, importDataContext.getVoyageEchotypesByName()); model.newMandatoryColumn(EchoBaseCsvUtil.CELL_NAME, EsduResultByEchotypeImportRow.PROPERTY_CELL, importDataContext.getCellValueParser()); model.newForeignKeyColumn(EsduResultByEchotypeImportRow.PROPERTY_DATA_QUALITY, DataQuality.class, DataQuality.PROPERTY_QUALITY_DATA_FLAG_VALUES, importDataContext.getDataQualitiesByName()); @@ -73,7 +73,7 @@ public class EsduResultByEchotypeImportExportModel extends EchoBaseImportExportM List<DataMetadata> dataMetadatas) { EsduResultByEchotypeImportExportModel model = new EsduResultByEchotypeImportExportModel(importDataContext.getCsvSeparator()); - model.newColumnForExport(RegionCellImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); + model.newColumnForExport(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); model.newColumnForExport(EsduResultByEchotypeImportRow.PROPERTY_ECHOTYPE, EchoBaseCsvUtil.ECHOTYPE_FORMATTER); model.newColumnForExport(EchoBaseCsvUtil.CELL_NAME, EsduResultByEchotypeImportRow.PROPERTY_CELL, importDataContext.getCellValueFormatter()); model.newColumnForExport(EsduResultByEchotypeImportRow.PROPERTY_DATA_QUALITY, EchoBaseCsvUtil.DATA_QUALITY_FORMATTER); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultBySpeciesAndAgeCategoryImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultBySpeciesAndAgeCategoryImportExportModel.java index 97e9877..6b9eb38 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultBySpeciesAndAgeCategoryImportExportModel.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultBySpeciesAndAgeCategoryImportExportModel.java @@ -55,7 +55,7 @@ public class EsduResultBySpeciesAndAgeCategoryImportExportModel extends EchoBase List<DataMetadata> dataMetadatas) { EsduResultBySpeciesAndAgeCategoryImportExportModel model = new EsduResultBySpeciesAndAgeCategoryImportExportModel(importDataContext.getCsvSeparator()); - model.newForeignKeyColumn(RegionCellImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); + model.newForeignKeyColumn(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); model.newMandatoryColumn(EchoBaseCsvUtil.CELL_NAME, EsduResultBySpeciesAndAgeCategoryImportRow.PROPERTY_CELL, importDataContext.getCellValueParser()); model.newMandatoryColumn(EsduResultBySpeciesAndAgeCategoryImportRow.PROPERTY_AGE_CATEGORY); model.newMandatoryColumn(EsduResultBySpeciesAndAgeCategoryImportRow.PROPERTY_AGE_CATEGORY_MEANING); @@ -77,7 +77,7 @@ public class EsduResultBySpeciesAndAgeCategoryImportExportModel extends EchoBase List<DataMetadata> dataMetadatas) { EsduResultBySpeciesAndAgeCategoryImportExportModel model = new EsduResultBySpeciesAndAgeCategoryImportExportModel(importDataContext.getCsvSeparator()); - model.newColumnForExport(RegionCellImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); + model.newColumnForExport(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); model.newColumnForExport(EchoBaseCsvUtil.CELL_NAME, EsduResultBySpeciesAndAgeCategoryImportRow.PROPERTY_CELL, importDataContext.getCellValueFormatter()); model.newColumnForExport(EsduResultBySpeciesAndAgeCategoryImportRow.PROPERTY_AGE_CATEGORY); model.newColumnForExport(EsduResultBySpeciesAndAgeCategoryImportRow.PROPERTY_AGE_CATEGORY_MEANING); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultBySpeciesAndSizeCategoryImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultBySpeciesAndSizeCategoryImportExportModel.java index 88977da..e1dcc52 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultBySpeciesAndSizeCategoryImportExportModel.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EsduResultBySpeciesAndSizeCategoryImportExportModel.java @@ -55,7 +55,7 @@ public class EsduResultBySpeciesAndSizeCategoryImportExportModel extends EchoBas List<DataMetadata> dataMetadatas) { EsduResultBySpeciesAndSizeCategoryImportExportModel model = new EsduResultBySpeciesAndSizeCategoryImportExportModel(importDataContext.getCsvSeparator()); - model.newForeignKeyColumn(RegionCellImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); + model.newForeignKeyColumn(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); model.newMandatoryColumn(EchoBaseCsvUtil.CELL_NAME, EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_CELL, importDataContext.getCellValueParser()); model.newMandatoryColumn(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_SIZE_CATEGORY); model.newMandatoryColumn(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_SIZE_CATEGORY_MEANING); @@ -77,7 +77,7 @@ public class EsduResultBySpeciesAndSizeCategoryImportExportModel extends EchoBas List<DataMetadata> dataMetadatas) { EsduResultBySpeciesAndSizeCategoryImportExportModel model = new EsduResultBySpeciesAndSizeCategoryImportExportModel(importDataContext.getCsvSeparator()); - model.newColumnForExport(RegionCellImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); + model.newColumnForExport(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); model.newColumnForExport(EchoBaseCsvUtil.CELL_NAME, EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_CELL, importDataContext.getCellValueFormatter()); model.newColumnForExport(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_SIZE_CATEGORY); model.newColumnForExport(EsduResultBySpeciesAndSizeCategoryImportRow.PROPERTY_SIZE_CATEGORY_MEANING); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportExportModel.java deleted file mode 100644 index 93f6b71..0000000 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportExportModel.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * #%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% - */ -package fr.ifremer.echobase.services.service.importdata.csv; - -import fr.ifremer.echobase.entities.data.Cell; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; -import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; - -/** - * Model to import cells associations from region cells and esdu cells. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 0.3 - */ -public class RegionCellAssociationImportExportModel extends EchoBaseImportExportModelSupport<RegionCellAssociationImportRow> { - - public static final String HEADER_REGION_NAME = "regionName"; - public static final String HEADER_ESDU_NAME = "esduName"; - - - private RegionCellAssociationImportExportModel(char separator) { - super(separator); - } - - public static RegionCellAssociationImportExportModel forImport(VoyageResultsImportDataContext importDataContext) { - - RegionCellAssociationImportExportModel model = new RegionCellAssociationImportExportModel(importDataContext.getCsvSeparator()); - model.newForeignKeyColumn(RegionCellAssociationImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); - model.newForeignKeyColumn(HEADER_REGION_NAME, RegionCellAssociationImportRow.PROPERTY_REGION_CELL, Cell.class, Cell.PROPERTY_NAME, importDataContext.getVoyageRegionsByName()); - model.newMandatoryColumn(HEADER_ESDU_NAME, RegionCellAssociationImportRow.PROPERTY_ESDU_CELL, importDataContext.newCellValueParser()); - return model; - - } - - public static RegionCellAssociationImportExportModel forExport(VoyageResultsImportDataContext importDataContext) { - - RegionCellAssociationImportExportModel model = new RegionCellAssociationImportExportModel(importDataContext.getCsvSeparator()); - model.newColumnForExport(RegionCellAssociationImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); - model.newColumnForExport(HEADER_REGION_NAME, RegionCellAssociationImportRow.PROPERTY_REGION_CELL, EchoBaseCsvUtil.CELL_FORMATTER); - model.newColumnForExport(HEADER_ESDU_NAME, RegionCellAssociationImportRow.PROPERTY_ESDU_CELL, importDataContext.newCellValueFormatter()); - return model; - - } - - @Override - public RegionCellAssociationImportRow newEmptyInstance() { - return new RegionCellAssociationImportRow(); - } -} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellImportExportModel.java deleted file mode 100644 index f27cbaa..0000000 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellImportExportModel.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * #%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% - */ -package fr.ifremer.echobase.services.service.importdata.csv; - -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.entities.references.CellType; -import fr.ifremer.echobase.entities.references.DataQuality; -import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; -import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; - -/** - * Model to import cells (with type "region"). - * - * @author Tony Chemit - chemit@codelutin.com - * @since 0.3 - */ -public class RegionCellImportExportModel extends EchoBaseImportExportModelSupport<RegionCellImportRow> { - - private RegionCellImportExportModel(char separator) { - super(separator); - } - - public static RegionCellImportExportModel forImport(VoyageResultsImportDataContext importDataContext) { - - RegionCellImportExportModel model = new RegionCellImportExportModel(importDataContext.getCsvSeparator()); - model.newForeignKeyColumn(RegionCellImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); - model.newForeignKeyColumn(RegionCellImportRow.PROPERTY_CELL_TYPE, CellType.class, CellType.PROPERTY_ID, importDataContext.getRegionCellTypesById()); - model.newForeignKeyColumn(RegionCellImportRow.PROPERTY_DATA_QUALITY, DataQuality.class, DataQuality.PROPERTY_QUALITY_DATA_FLAG_VALUES, importDataContext.getDataQualitiesByName()); - model.newMandatoryColumn(RegionCellImportRow.PROPERTY_NAME); - model.newMandatoryColumn("regionEnvCoordinates", RegionCellImportRow.PROPERTY_DATA_COORDINATE); - model.newMandatoryColumn("surface", RegionCellImportRow.PROPERTY_DATA_SURFACE, EchoBaseCsvUtil.PRIMITIVE_FLOAT); - return model; - - } - - public static RegionCellImportExportModel forExport(VoyageResultsImportDataContext importDataContext) { - - RegionCellImportExportModel model = new RegionCellImportExportModel(importDataContext.getCsvSeparator()); - model.newColumnForExport(RegionCellImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); - model.newColumnForExport(RegionCellImportRow.PROPERTY_CELL_TYPE, EchoBaseCsvUtil.CELL_TYPE_FORMATTER); - model.newColumnForExport(RegionCellImportRow.PROPERTY_DATA_QUALITY, EchoBaseCsvUtil.DATA_QUALITY_FORMATTER); - model.newColumnForExport(RegionCellImportRow.PROPERTY_NAME); - model.newColumnForExport("regionEnvCoordinates", RegionCellImportRow.PROPERTY_DATA_COORDINATE); - model.newColumnForExport("surface", RegionCellImportRow.PROPERTY_DATA_SURFACE, EchoBaseCsvUtil.PRIMITIVE_FLOAT); - return model; - - } - - @Override - public RegionCellImportRow newEmptyInstance() { - return new RegionCellImportRow(); - } -} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellResultImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellResultImportExportModel.java deleted file mode 100644 index 7b7afd8..0000000 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellResultImportExportModel.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * #%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% - */ -package fr.ifremer.echobase.services.service.importdata.csv; - -import fr.ifremer.echobase.entities.data.Cell; -import fr.ifremer.echobase.entities.data.Echotype; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.entities.references.DataMetadata; -import fr.ifremer.echobase.entities.references.DataQuality; -import fr.ifremer.echobase.entities.references.SizeCategory; -import fr.ifremer.echobase.entities.references.Species; -import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; -import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; - -import java.util.List; - -/** - * Model to import results of cell of type 'Region'. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 0.3 - */ -public class RegionCellResultImportExportModel extends EchoBaseImportExportModelSupport<RegionCellResultImportRow> { - - public static final String[] COLUMN_NAMES_TO_EXCLUDE = { - EchoBaseCsvUtil.CELL_NAME, - Species.PROPERTY_BARACOUDA_CODE, - RegionCellResultImportRow.PROPERTY_VOYAGE, - RegionCellResultImportRow.PROPERTY_SIZE_CATEGORY, - RegionCellResultImportRow.PROPERTY_ECHOTYPE, - RegionCellResultImportRow.PROPERTY_DATA_QUALITY - }; - - private RegionCellResultImportExportModel(char separator) { - super(separator); - } - - public static RegionCellResultImportExportModel forImport(VoyageResultsImportDataContext importDataContext, List<DataMetadata> dataMetadatas) { - - RegionCellResultImportExportModel model = new RegionCellResultImportExportModel(importDataContext.getCsvSeparator()); - model.newForeignKeyColumn(RegionCellResultImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); - model.newForeignKeyColumn(EchoBaseCsvUtil.CELL_NAME, RegionCellResultImportRow.PROPERTY_CELL, Cell.class, Cell.PROPERTY_NAME, importDataContext.getVoyageRegionsByName()); - model.newForeignKeyColumn(RegionCellResultImportRow.PROPERTY_ECHOTYPE, Echotype.class, Echotype.PROPERTY_NAME, importDataContext.getVoyageEchotypesByName()); - model.newForeignKeyColumn(Species.PROPERTY_BARACOUDA_CODE, RegionCellResultImportRow.PROPERTY_SPECIES, Species.class, Species.PROPERTY_BARACOUDA_CODE, importDataContext.getSpeciesByBaracoudaCode()); - model.newForeignKeyColumn(RegionCellResultImportRow.PROPERTY_SIZE_CATEGORY, SizeCategory.class, SizeCategory.PROPERTY_NAME, importDataContext.getSizeCategoriesByName()); - model.newForeignKeyColumn(RegionCellResultImportRow.PROPERTY_DATA_QUALITY, DataQuality.class, DataQuality.PROPERTY_QUALITY_DATA_FLAG_VALUES, importDataContext.getDataQualitiesByName()); - - for (DataMetadata metadata : dataMetadatas) { - model.newMandatoryColumn( - metadata.getName(), - EchoBaseCsvUtil.newResultValueParser(metadata, false), - EchoBaseCsvUtil.<RegionCellResultImportRow>newResultValueSetter()); - } - return model; - - } - - public static RegionCellResultImportExportModel forExport(VoyageResultsImportDataContext importDataContext, List<DataMetadata> dataMetadatas) { - - RegionCellResultImportExportModel model = new RegionCellResultImportExportModel(importDataContext.getCsvSeparator()); - model.newColumnForExport(RegionCellResultImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); - model.newColumnForExport(EchoBaseCsvUtil.CELL_NAME, RegionCellResultImportRow.PROPERTY_CELL, EchoBaseCsvUtil.CELL_FORMATTER); - model.newColumnForExport(RegionCellResultImportRow.PROPERTY_ECHOTYPE, EchoBaseCsvUtil.ECHOTYPE_FORMATTER); - model.newColumnForExport(Species.PROPERTY_BARACOUDA_CODE, RegionCellResultImportRow.PROPERTY_SPECIES, EchoBaseCsvUtil.SPECIES_FORMATTER); - model.newColumnForExport(RegionCellResultImportRow.PROPERTY_SIZE_CATEGORY, EchoBaseCsvUtil.SIZE_CATEGORY_FORMATTER); - model.newColumnForExport(RegionCellResultImportRow.PROPERTY_DATA_QUALITY, EchoBaseCsvUtil.DATA_QUALITY_FORMATTER); - - addResultsColumns(model, dataMetadatas); - - return model; - - } - - @Override - public RegionCellResultImportRow newEmptyInstance() { - return new RegionCellResultImportRow(); - } -} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellAssociationImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellAssociationImportExportModel.java new file mode 100644 index 0000000..2962618 --- /dev/null +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellAssociationImportExportModel.java @@ -0,0 +1,68 @@ +/* + * #%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% + */ +package fr.ifremer.echobase.services.service.importdata.csv; + +import fr.ifremer.echobase.entities.data.Cell; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; +import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; + +/** + * Model to import cells associations from region cells and esdu cells. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 0.3 + */ +public class VoyageResultsRegionCellAssociationImportExportModel extends EchoBaseImportExportModelSupport<VoyageResultsRegionCellAssociationImportRow> { + + public static final String HEADER_REGION_NAME = "regionName"; + public static final String HEADER_ESDU_NAME = "esduName"; + + + private VoyageResultsRegionCellAssociationImportExportModel(char separator) { + super(separator); + } + + public static VoyageResultsRegionCellAssociationImportExportModel forImport(VoyageResultsImportDataContext importDataContext) { + + VoyageResultsRegionCellAssociationImportExportModel model = new VoyageResultsRegionCellAssociationImportExportModel(importDataContext.getCsvSeparator()); + model.newForeignKeyColumn(VoyageResultsRegionCellAssociationImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); + model.newForeignKeyColumn(HEADER_REGION_NAME, VoyageResultsRegionCellAssociationImportRow.PROPERTY_REGION_CELL, Cell.class, Cell.PROPERTY_NAME, importDataContext.getVoyageRegionsByName()); + model.newMandatoryColumn(HEADER_ESDU_NAME, VoyageResultsRegionCellAssociationImportRow.PROPERTY_ESDU_CELL, importDataContext.newCellValueParser()); + return model; + + } + + public static VoyageResultsRegionCellAssociationImportExportModel forExport(VoyageResultsImportDataContext importDataContext) { + + VoyageResultsRegionCellAssociationImportExportModel model = new VoyageResultsRegionCellAssociationImportExportModel(importDataContext.getCsvSeparator()); + model.newColumnForExport(VoyageResultsRegionCellAssociationImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); + model.newColumnForExport(HEADER_REGION_NAME, VoyageResultsRegionCellAssociationImportRow.PROPERTY_REGION_CELL, EchoBaseCsvUtil.CELL_FORMATTER); + model.newColumnForExport(HEADER_ESDU_NAME, VoyageResultsRegionCellAssociationImportRow.PROPERTY_ESDU_CELL, importDataContext.newCellValueFormatter()); + return model; + + } + + @Override + public VoyageResultsRegionCellAssociationImportRow newEmptyInstance() { + return new VoyageResultsRegionCellAssociationImportRow(); + } +} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportRow.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellAssociationImportRow.java similarity index 81% rename from echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportRow.java rename to echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellAssociationImportRow.java index e2ebe59..3960510 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellAssociationImportRow.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellAssociationImportRow.java @@ -24,12 +24,12 @@ import fr.ifremer.echobase.entities.data.Cell; import fr.ifremer.echobase.entities.data.Voyage; /** - * Bean used as a row for import of {@link RegionCellAssociationImportExportModel}. + * Bean used as a row for import of {@link VoyageResultsRegionCellAssociationImportExportModel}. * * @author Tony Chemit - chemit@codelutin.com * @since 0.3 */ -public class RegionCellAssociationImportRow { +public class VoyageResultsRegionCellAssociationImportRow { public static final String PROPERTY_VOYAGE = "voyage"; public static final String PROPERTY_ESDU_CELL = "esduCell"; @@ -41,15 +41,15 @@ public class RegionCellAssociationImportRow { protected Cell regionCell; - public static RegionCellAssociationImportRow of(Voyage voyage, Cell regionCell, Cell esduCell) { - RegionCellAssociationImportRow row = new RegionCellAssociationImportRow(); + public static VoyageResultsRegionCellAssociationImportRow of(Voyage voyage, Cell regionCell, Cell esduCell) { + VoyageResultsRegionCellAssociationImportRow row = new VoyageResultsRegionCellAssociationImportRow(); row.setVoyage(voyage); row.setRegionCell(regionCell); row.setEsduCell(esduCell); return row; } - public RegionCellAssociationImportRow() { + public VoyageResultsRegionCellAssociationImportRow() { } public Voyage getVoyage() { diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellImportExportModel.java new file mode 100644 index 0000000..b2b0aef --- /dev/null +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellImportExportModel.java @@ -0,0 +1,71 @@ +/* + * #%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% + */ +package fr.ifremer.echobase.services.service.importdata.csv; + +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.entities.references.CellType; +import fr.ifremer.echobase.entities.references.DataQuality; +import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; +import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; + +/** + * Model to import cells (with type "region"). + * + * @author Tony Chemit - chemit@codelutin.com + * @since 0.3 + */ +public class VoyageResultsRegionCellImportExportModel extends EchoBaseImportExportModelSupport<VoyageResultsRegionCellImportRow> { + + private VoyageResultsRegionCellImportExportModel(char separator) { + super(separator); + } + + public static VoyageResultsRegionCellImportExportModel forImport(VoyageResultsImportDataContext importDataContext) { + + VoyageResultsRegionCellImportExportModel model = new VoyageResultsRegionCellImportExportModel(importDataContext.getCsvSeparator()); + model.newForeignKeyColumn(VoyageResultsRegionCellImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); + model.newForeignKeyColumn(VoyageResultsRegionCellImportRow.PROPERTY_CELL_TYPE, CellType.class, CellType.PROPERTY_ID, importDataContext.getRegionCellTypesById()); + model.newForeignKeyColumn(VoyageResultsRegionCellImportRow.PROPERTY_DATA_QUALITY, DataQuality.class, DataQuality.PROPERTY_QUALITY_DATA_FLAG_VALUES, importDataContext.getDataQualitiesByName()); + model.newMandatoryColumn(VoyageResultsRegionCellImportRow.PROPERTY_NAME); + model.newMandatoryColumn("regionEnvCoordinates", VoyageResultsRegionCellImportRow.PROPERTY_DATA_COORDINATE); + model.newMandatoryColumn("surface", VoyageResultsRegionCellImportRow.PROPERTY_DATA_SURFACE, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + return model; + + } + + public static VoyageResultsRegionCellImportExportModel forExport(VoyageResultsImportDataContext importDataContext) { + + VoyageResultsRegionCellImportExportModel model = new VoyageResultsRegionCellImportExportModel(importDataContext.getCsvSeparator()); + model.newColumnForExport(VoyageResultsRegionCellImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); + model.newColumnForExport(VoyageResultsRegionCellImportRow.PROPERTY_CELL_TYPE, EchoBaseCsvUtil.CELL_TYPE_FORMATTER); + model.newColumnForExport(VoyageResultsRegionCellImportRow.PROPERTY_DATA_QUALITY, EchoBaseCsvUtil.DATA_QUALITY_FORMATTER); + model.newColumnForExport(VoyageResultsRegionCellImportRow.PROPERTY_NAME); + model.newColumnForExport("regionEnvCoordinates", VoyageResultsRegionCellImportRow.PROPERTY_DATA_COORDINATE); + model.newColumnForExport("surface", VoyageResultsRegionCellImportRow.PROPERTY_DATA_SURFACE, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + return model; + + } + + @Override + public VoyageResultsRegionCellImportRow newEmptyInstance() { + return new VoyageResultsRegionCellImportRow(); + } +} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellImportRow.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellImportRow.java similarity index 88% rename from echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellImportRow.java rename to echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellImportRow.java index 2cacb38..8b16040 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellImportRow.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellImportRow.java @@ -27,12 +27,12 @@ import fr.ifremer.echobase.entities.references.CellType; import fr.ifremer.echobase.entities.references.DataQuality; /** - * Bean used as a row for import of {@link RegionCellImportExportModel}. + * Bean used as a row for import of {@link VoyageResultsRegionCellImportExportModel}. * * @author Tony Chemit - chemit@codelutin.com * @since 0.3 */ -public class RegionCellImportRow { +public class VoyageResultsRegionCellImportRow { public static final String PROPERTY_NAME = Cell.PROPERTY_NAME; @@ -58,7 +58,7 @@ public class RegionCellImportRow { protected float dataSurface; - public RegionCellImportRow() { + public VoyageResultsRegionCellImportRow() { } public Voyage getVoyage() { @@ -109,8 +109,8 @@ public class RegionCellImportRow { this.dataQuality = dataQuality; } - public static RegionCellImportRow of(Voyage voyage, Cell cell, Data coordinateData, float surfaceDataValue) { - RegionCellImportRow row = new RegionCellImportRow(); + public static VoyageResultsRegionCellImportRow of(Voyage voyage, Cell cell, Data coordinateData, float surfaceDataValue) { + VoyageResultsRegionCellImportRow row = new VoyageResultsRegionCellImportRow(); row.setVoyage(voyage); row.setName(cell.getName()); row.setCellType(cell.getCellType()); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellResultImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellResultImportExportModel.java new file mode 100644 index 0000000..4f7641f --- /dev/null +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellResultImportExportModel.java @@ -0,0 +1,96 @@ +/* + * #%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% + */ +package fr.ifremer.echobase.services.service.importdata.csv; + +import fr.ifremer.echobase.entities.data.Cell; +import fr.ifremer.echobase.entities.data.Echotype; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.entities.references.DataMetadata; +import fr.ifremer.echobase.entities.references.DataQuality; +import fr.ifremer.echobase.entities.references.SizeCategory; +import fr.ifremer.echobase.entities.references.Species; +import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; +import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; + +import java.util.List; + +/** + * Model to import results of cell of type 'Region'. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 0.3 + */ +public class VoyageResultsRegionCellResultImportExportModel extends EchoBaseImportExportModelSupport<VoyageResultsRegionCellResultImportRow> { + + public static final String[] COLUMN_NAMES_TO_EXCLUDE = { + EchoBaseCsvUtil.CELL_NAME, + Species.PROPERTY_BARACOUDA_CODE, + VoyageResultsRegionCellResultImportRow.PROPERTY_VOYAGE, + VoyageResultsRegionCellResultImportRow.PROPERTY_SIZE_CATEGORY, + VoyageResultsRegionCellResultImportRow.PROPERTY_ECHOTYPE, + VoyageResultsRegionCellResultImportRow.PROPERTY_DATA_QUALITY + }; + + private VoyageResultsRegionCellResultImportExportModel(char separator) { + super(separator); + } + + public static VoyageResultsRegionCellResultImportExportModel forImport(VoyageResultsImportDataContext importDataContext, List<DataMetadata> dataMetadatas) { + + VoyageResultsRegionCellResultImportExportModel model = new VoyageResultsRegionCellResultImportExportModel(importDataContext.getCsvSeparator()); + model.newForeignKeyColumn(VoyageResultsRegionCellResultImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); + model.newForeignKeyColumn(EchoBaseCsvUtil.CELL_NAME, VoyageResultsRegionCellResultImportRow.PROPERTY_CELL, Cell.class, Cell.PROPERTY_NAME, importDataContext.getVoyageRegionsByName()); + model.newForeignKeyColumn(VoyageResultsRegionCellResultImportRow.PROPERTY_ECHOTYPE, Echotype.class, Echotype.PROPERTY_NAME, importDataContext.getVoyageEchotypesByName()); + model.newForeignKeyColumn(Species.PROPERTY_BARACOUDA_CODE, VoyageResultsRegionCellResultImportRow.PROPERTY_SPECIES, Species.class, Species.PROPERTY_BARACOUDA_CODE, importDataContext.getSpeciesByBaracoudaCode()); + model.newForeignKeyColumn(VoyageResultsRegionCellResultImportRow.PROPERTY_SIZE_CATEGORY, SizeCategory.class, SizeCategory.PROPERTY_NAME, importDataContext.getSizeCategoriesByName()); + model.newForeignKeyColumn(VoyageResultsRegionCellResultImportRow.PROPERTY_DATA_QUALITY, DataQuality.class, DataQuality.PROPERTY_QUALITY_DATA_FLAG_VALUES, importDataContext.getDataQualitiesByName()); + + for (DataMetadata metadata : dataMetadatas) { + model.newMandatoryColumn( + metadata.getName(), + EchoBaseCsvUtil.newResultValueParser(metadata, false), + EchoBaseCsvUtil.<VoyageResultsRegionCellResultImportRow>newResultValueSetter()); + } + return model; + + } + + public static VoyageResultsRegionCellResultImportExportModel forExport(VoyageResultsImportDataContext importDataContext, List<DataMetadata> dataMetadatas) { + + VoyageResultsRegionCellResultImportExportModel model = new VoyageResultsRegionCellResultImportExportModel(importDataContext.getCsvSeparator()); + model.newColumnForExport(VoyageResultsRegionCellResultImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); + model.newColumnForExport(EchoBaseCsvUtil.CELL_NAME, VoyageResultsRegionCellResultImportRow.PROPERTY_CELL, EchoBaseCsvUtil.CELL_FORMATTER); + model.newColumnForExport(VoyageResultsRegionCellResultImportRow.PROPERTY_ECHOTYPE, EchoBaseCsvUtil.ECHOTYPE_FORMATTER); + model.newColumnForExport(Species.PROPERTY_BARACOUDA_CODE, VoyageResultsRegionCellResultImportRow.PROPERTY_SPECIES, EchoBaseCsvUtil.SPECIES_FORMATTER); + model.newColumnForExport(VoyageResultsRegionCellResultImportRow.PROPERTY_SIZE_CATEGORY, EchoBaseCsvUtil.SIZE_CATEGORY_FORMATTER); + model.newColumnForExport(VoyageResultsRegionCellResultImportRow.PROPERTY_DATA_QUALITY, EchoBaseCsvUtil.DATA_QUALITY_FORMATTER); + + addResultsColumns(model, dataMetadatas); + + return model; + + } + + @Override + public VoyageResultsRegionCellResultImportRow newEmptyInstance() { + return new VoyageResultsRegionCellResultImportRow(); + } +} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellResultImportRow.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellResultImportRow.java similarity index 90% rename from echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellResultImportRow.java rename to echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellResultImportRow.java index 6cbd0e9..65abf87 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/RegionCellResultImportRow.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsRegionCellResultImportRow.java @@ -35,12 +35,12 @@ import java.util.ArrayList; import java.util.List; /** - * Bean used as a row for import of {@link RegionCellResultImportExportModel}. + * Bean used as a row for import of {@link VoyageResultsRegionCellResultImportExportModel}. * * @author Tony Chemit - chemit@codelutin.com * @since 0.3 */ -public class RegionCellResultImportRow implements ResultAble { +public class VoyageResultsRegionCellResultImportRow implements ResultAble { public static final String PROPERTY_NAME = "name"; @@ -130,14 +130,14 @@ public class RegionCellResultImportRow implements ResultAble { this.dataQuality = dataQuality; } - public static RegionCellResultImportRow of(Voyage voyage, Cell cell, Category category, List<Result> result) { + public static VoyageResultsRegionCellResultImportRow of(Voyage voyage, Cell cell, Category category, List<Result> result) { Preconditions.checkNotNull(voyage); Preconditions.checkNotNull(cell); Preconditions.checkNotNull(category); Preconditions.checkNotNull(result); Preconditions.checkArgument(!result.isEmpty()); - RegionCellResultImportRow row = new RegionCellResultImportRow(); + VoyageResultsRegionCellResultImportRow row = new VoyageResultsRegionCellResultImportRow(); row.setVoyage(voyage); row.setCell(cell); row.result.clear(); -- 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/8170 in repository echobase. See https://gitlab.nuiton.org/codelutin/echobase.git commit c9211b0033af367bee1939c6dbaa76423ad301e6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Apr 4 18:28:50 2016 +0200 Pouvoir récupérer une espèces --- .../ifremer/echobase/services/service/UserDbPersistenceService.java | 4 ++++ 1 file changed, 4 insertions(+) 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 709e10c..198ce4c 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 @@ -984,6 +984,10 @@ public class UserDbPersistenceService extends EchoBaseServiceSupport { } + public Species getSpecies(String speciesId) { + return persistenceContext.getSpeciesDao().findByTopiaId(speciesId); + } + private static class CountTableRows extends TopiaSqlQuery<Long> { public final String tableName; -- 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/8170 in repository echobase. See https://gitlab.nuiton.org/codelutin/echobase.git commit c57387276a2d7844c808c1f4797f52944fc56382 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Apr 4 18:29:22 2016 +0200 Voyage result import ok \o/ (See #8170) --- .../VoyageResultsVoyageEchotypeImportAction.java | 54 +++++++++++---- ...oyageResultsVoyageLengthAgeKeyImportAction.java | 34 +++++++--- ...geResultsVoyageLengthWeightKeyImportAction.java | 36 ++++++---- .../csv/LengthWeightKeyImportExportModel.java | 73 --------------------- ...ageResultsVoyageEchotypeImportExportModel.java} | 30 +++++---- ...a => VoyageResultsVoyageEchotypeImportRow.java} | 47 ++++++++++--- ...esultsVoyageLengthAgeKeyImportExportModel.java} | 22 +++---- ... VoyageResultsVoyageLengthAgeKeyImportRow.java} | 43 ++++++++++-- ...ultsVoyageLengthWeightKeyImportExportModel.java | 76 ++++++++++++++++++++++ ...yageResultsVoyageLengthWeightKeyImportRow.java} | 40 ++++++++++-- .../VoyageResultsVoyageImportServiceIT.java | 34 ++++++---- ...geResultsVoyageOnlyEchotypeImportServiceIT.java | 12 ++-- ...sultsVoyageOnlyLengthAgeKeyImportServiceIT.java | 11 ++-- ...tsVoyageOnlyLengthWeightKeyImportServiceIT.java | 11 ++-- 14 files changed, 347 insertions(+), 176 deletions(-) diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageEchotypeImportAction.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageEchotypeImportAction.java index 7f73c68..72502db 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageEchotypeImportAction.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageEchotypeImportAction.java @@ -1,5 +1,6 @@ package fr.ifremer.echobase.services.service.importdata.actions; +import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import fr.ifremer.echobase.entities.EchoBaseUserEntityEnum; @@ -10,13 +11,15 @@ import fr.ifremer.echobase.entities.references.Species; import fr.ifremer.echobase.io.InputFile; import fr.ifremer.echobase.services.service.importdata.ImportDataFileResult; import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; -import fr.ifremer.echobase.services.service.importdata.csv.EchotypeImportExportModel; -import fr.ifremer.echobase.services.service.importdata.csv.EchotypeImportRow; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsVoyageEchotypeImportExportModel; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsVoyageEchotypeImportRow; +import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.csv.Import; import java.util.Collection; +import java.util.LinkedList; /** * Created on 25/03/16. @@ -24,7 +27,7 @@ import java.util.Collection; * @author Tony Chemit - chemit@codelutin.com * @since 4.0 */ -public class VoyageResultsVoyageEchotypeImportAction extends VoyageResultsImportDataActionSupport<EchotypeImportRow> { +public class VoyageResultsVoyageEchotypeImportAction extends VoyageResultsImportDataActionSupport<VoyageResultsVoyageEchotypeImportRow> { /** Logger. */ private static final Log log = LogFactory.getLog(VoyageResultsVoyageEchotypeImportAction.class); @@ -34,15 +37,17 @@ public class VoyageResultsVoyageEchotypeImportAction extends VoyageResultsImport } @Override - protected EchotypeImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { - return EchotypeImportExportModel.forImport(importDataContext); + protected VoyageResultsVoyageEchotypeImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsVoyageEchotypeImportExportModel.forImport(importDataContext); } @Override - protected EchotypeImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { - return EchotypeImportExportModel.forExport(importDataContext); + protected VoyageResultsVoyageEchotypeImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsVoyageEchotypeImportExportModel.forExport(importDataContext); } + private final LinkedList<Pair<String, String>> speciesIdToEchotypeId = new LinkedList<>(); + @Override protected void performImport(VoyageResultsImportDataContext importDataContext, InputFile inputFile, ImportDataFileResult result) { @@ -50,12 +55,12 @@ public class VoyageResultsVoyageEchotypeImportAction extends VoyageResultsImport log.info("Starts import of echotype from file " + inputFile.getFileName()); } - try (Import<EchotypeImportRow> importer = open()) { + try (Import<VoyageResultsVoyageEchotypeImportRow> importer = open()) { incrementsProgress(); int rowNumber = 0; - for (EchotypeImportRow row : importer) { + for (VoyageResultsVoyageEchotypeImportRow row : importer) { doFlushTransaction(++rowNumber); @@ -76,6 +81,8 @@ public class VoyageResultsVoyageEchotypeImportAction extends VoyageResultsImport } + Species species = row.getSpecies(); + if (echotype == null) { // creates it @@ -87,20 +94,25 @@ public class VoyageResultsVoyageEchotypeImportAction extends VoyageResultsImport // collect ids result.addId(EchoBaseUserEntityEnum.Echotype, echotype); + speciesIdToEchotypeId.add(Pair.of(species.getTopiaId(), echotype.getTopiaId())); + } else { - Species species = rowEchotype.getSpecies().iterator().next(); - Species existingSpecie = echotype.getSpeciesByTopiaId(species.getTopiaId()); + Species existingSpecies = echotype.getSpeciesByTopiaId(species.getTopiaId()); - if (existingSpecie == null) { + if (existingSpecies == null) { // add this species echotype.addSpecies(species); + speciesIdToEchotypeId.add(Pair.of(species.getTopiaId(), echotype.getTopiaId())); + } } + addProcessedRow(result, row); + } } @@ -110,7 +122,23 @@ public class VoyageResultsVoyageEchotypeImportAction extends VoyageResultsImport @Override protected void computeImportedExport(VoyageResultsImportDataContext importDataContext, ImportDataFileResult result) { - // TODO + String voyageId = importDataContext.getConfiguration().getVoyageId(); + Voyage voyage = persistenceService.getVoyage(voyageId); + + for (Pair<String, String> speciesIdToEchotypeIdEntry : speciesIdToEchotypeId) { + + String speciesId = speciesIdToEchotypeIdEntry.getKey(); + Species species = persistenceService.getSpecies(speciesId); + Preconditions.checkNotNull(species); + + String echotypeId = speciesIdToEchotypeIdEntry.getValue(); + Echotype echotype = persistenceService.getEchotype(echotypeId); + Preconditions.checkNotNull(echotype); + + VoyageResultsVoyageEchotypeImportRow row = VoyageResultsVoyageEchotypeImportRow.of(voyage, echotype, species); + addImportedRow(result, row); + + } } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageLengthAgeKeyImportAction.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageLengthAgeKeyImportAction.java index 2275704..28fffa0 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageLengthAgeKeyImportAction.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageLengthAgeKeyImportAction.java @@ -1,13 +1,14 @@ package fr.ifremer.echobase.services.service.importdata.actions; +import com.google.common.base.Preconditions; import fr.ifremer.echobase.entities.EchoBaseUserEntityEnum; import fr.ifremer.echobase.entities.data.LengthAgeKey; import fr.ifremer.echobase.entities.data.Voyage; import fr.ifremer.echobase.io.InputFile; import fr.ifremer.echobase.services.service.importdata.ImportDataFileResult; import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; -import fr.ifremer.echobase.services.service.importdata.csv.LengthAgeKeyImportExportModel; -import fr.ifremer.echobase.services.service.importdata.csv.LengthAgeKeyImportRow; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsVoyageLengthAgeKeyImportExportModel; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsVoyageLengthAgeKeyImportRow; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.csv.Import; @@ -18,7 +19,7 @@ import org.nuiton.csv.Import; * @author Tony Chemit - chemit@codelutin.com * @since 4.0 */ -public class VoyageResultsVoyageLengthAgeKeyImportAction extends VoyageResultsImportDataActionSupport<LengthAgeKeyImportRow> { +public class VoyageResultsVoyageLengthAgeKeyImportAction extends VoyageResultsImportDataActionSupport<VoyageResultsVoyageLengthAgeKeyImportRow> { /** Logger. */ private static final Log log = LogFactory.getLog(VoyageResultsVoyageLengthAgeKeyImportAction.class); @@ -28,13 +29,13 @@ public class VoyageResultsVoyageLengthAgeKeyImportAction extends VoyageResultsIm } @Override - protected LengthAgeKeyImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { - return LengthAgeKeyImportExportModel.forImport(importDataContext); + protected VoyageResultsVoyageLengthAgeKeyImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsVoyageLengthAgeKeyImportExportModel.forImport(importDataContext); } @Override - protected LengthAgeKeyImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { - return LengthAgeKeyImportExportModel.forExport(importDataContext); + protected VoyageResultsVoyageLengthAgeKeyImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsVoyageLengthAgeKeyImportExportModel.forExport(importDataContext); } @Override @@ -44,12 +45,12 @@ public class VoyageResultsVoyageLengthAgeKeyImportAction extends VoyageResultsIm log.info("Starts import of lenthAgeKey from file " + inputFile.getFileName()); } - try (Import<LengthAgeKeyImportRow> importer = open()) { + try (Import<VoyageResultsVoyageLengthAgeKeyImportRow> importer = open()) { incrementsProgress(); int rowNumber = 0; - for (LengthAgeKeyImportRow row : importer) { + for (VoyageResultsVoyageLengthAgeKeyImportRow row : importer) { doFlushTransaction(++rowNumber); @@ -64,6 +65,8 @@ public class VoyageResultsVoyageLengthAgeKeyImportAction extends VoyageResultsIm // collect ids result.addId(EchoBaseUserEntityEnum.LengthAgeKey, lengthAgeKey); + addProcessedRow(result, row); + } } @@ -73,7 +76,18 @@ public class VoyageResultsVoyageLengthAgeKeyImportAction extends VoyageResultsIm @Override protected void computeImportedExport(VoyageResultsImportDataContext importDataContext, ImportDataFileResult result) { - // TODO + String voyageId = importDataContext.getConfiguration().getVoyageId(); + Voyage voyage = persistenceService.getVoyage(voyageId); + + for (String lengthAgeKeyId : result.getIds()) { + + LengthAgeKey lengthAgeKey = persistenceService.getLengthAgeKey(lengthAgeKeyId); + Preconditions.checkNotNull(lengthAgeKey); + + VoyageResultsVoyageLengthAgeKeyImportRow row = VoyageResultsVoyageLengthAgeKeyImportRow.of(voyage, lengthAgeKey); + addImportedRow(result, row); + + } } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageLengthWeightKeyImportAction.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageLengthWeightKeyImportAction.java index 2fea52a..10ab485 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageLengthWeightKeyImportAction.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageResultsVoyageLengthWeightKeyImportAction.java @@ -1,15 +1,16 @@ package fr.ifremer.echobase.services.service.importdata.actions; +import com.google.common.base.Preconditions; import fr.ifremer.echobase.entities.EchoBaseUserEntityEnum; import fr.ifremer.echobase.entities.data.LengthWeightKey; import fr.ifremer.echobase.entities.data.Voyage; import fr.ifremer.echobase.entities.references.SpeciesCategory; import fr.ifremer.echobase.io.InputFile; import fr.ifremer.echobase.services.service.importdata.ImportDataFileResult; -import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; import fr.ifremer.echobase.services.service.importdata.SpeciesCategoryCache; -import fr.ifremer.echobase.services.service.importdata.csv.LengthWeightKeyImportExportModel; -import fr.ifremer.echobase.services.service.importdata.csv.LengthWeightKeyImportRow; +import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsVoyageLengthWeightKeyImportExportModel; +import fr.ifremer.echobase.services.service.importdata.csv.VoyageResultsVoyageLengthWeightKeyImportRow; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.csv.Import; @@ -20,7 +21,7 @@ import org.nuiton.csv.Import; * @author Tony Chemit - chemit@codelutin.com * @since 4.0 */ -public class VoyageResultsVoyageLengthWeightKeyImportAction extends VoyageResultsImportDataActionSupport<LengthWeightKeyImportRow> { +public class VoyageResultsVoyageLengthWeightKeyImportAction extends VoyageResultsImportDataActionSupport<VoyageResultsVoyageLengthWeightKeyImportRow> { /** Logger. */ private static final Log log = LogFactory.getLog(VoyageResultsVoyageLengthWeightKeyImportAction.class); @@ -30,13 +31,13 @@ public class VoyageResultsVoyageLengthWeightKeyImportAction extends VoyageResult } @Override - protected LengthWeightKeyImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { - return LengthWeightKeyImportExportModel.forImport(importDataContext); + protected VoyageResultsVoyageLengthWeightKeyImportExportModel createCsvImportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsVoyageLengthWeightKeyImportExportModel.forImport(importDataContext); } @Override - protected LengthWeightKeyImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { - return LengthWeightKeyImportExportModel.forExport(importDataContext); + protected VoyageResultsVoyageLengthWeightKeyImportExportModel createCsvExportModel(VoyageResultsImportDataContext importDataContext) { + return VoyageResultsVoyageLengthWeightKeyImportExportModel.forExport(importDataContext); } @Override @@ -48,11 +49,11 @@ public class VoyageResultsVoyageLengthWeightKeyImportAction extends VoyageResult SpeciesCategoryCache speciesCategoryCache = importDataContext.getSpeciesCategoryCache(); - try (Import<LengthWeightKeyImportRow> importer = open()) { + try (Import<VoyageResultsVoyageLengthWeightKeyImportRow> importer = open()) { incrementsProgress(); int rowNumber = 0; - for (LengthWeightKeyImportRow row : importer) { + for (VoyageResultsVoyageLengthWeightKeyImportRow row : importer) { doFlushTransaction(++rowNumber); Voyage voyage = row.getVoyage(); @@ -74,6 +75,8 @@ public class VoyageResultsVoyageLengthWeightKeyImportAction extends VoyageResult // collect ids result.addId(EchoBaseUserEntityEnum.LengthWeightKey, lengthWeightKey); + addProcessedRow(result, row); + } } @@ -82,7 +85,18 @@ public class VoyageResultsVoyageLengthWeightKeyImportAction extends VoyageResult @Override protected void computeImportedExport(VoyageResultsImportDataContext importDataContext, ImportDataFileResult result) { - // TODO + String voyageId = importDataContext.getConfiguration().getVoyageId(); + Voyage voyage = persistenceService.getVoyage(voyageId); + + for (String lengthWeightKeyId : result.getIds()) { + + LengthWeightKey lengthWeightKey = persistenceService.getLengthWeightKey(lengthWeightKeyId); + Preconditions.checkNotNull(lengthWeightKey); + + VoyageResultsVoyageLengthWeightKeyImportRow row = VoyageResultsVoyageLengthWeightKeyImportRow.of(voyage, lengthWeightKey); + addImportedRow(result, row); + + } } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthWeightKeyImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthWeightKeyImportExportModel.java deleted file mode 100644 index 73e4531..0000000 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthWeightKeyImportExportModel.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * #%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% - */ -package fr.ifremer.echobase.services.service.importdata.csv; - -import fr.ifremer.echobase.entities.data.LengthWeightKey; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.entities.references.SizeCategory; -import fr.ifremer.echobase.entities.references.Species; -import fr.ifremer.echobase.entities.references.Strata; -import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; -import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; - -/** - * Model to import {@link LengthWeightKey}. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 0.3 - */ -public class LengthWeightKeyImportExportModel extends EchoBaseImportExportModelSupport<LengthWeightKeyImportRow> { - - private LengthWeightKeyImportExportModel(char separator) { - super(separator); - } - - public static LengthWeightKeyImportExportModel forImport(VoyageResultsImportDataContext importDataContext) { - - LengthWeightKeyImportExportModel model = new LengthWeightKeyImportExportModel(importDataContext.getCsvSeparator()); - model.newMandatoryColumn("aParameter", LengthWeightKey.PROPERTY_APARAMETER, EchoBaseCsvUtil.PRIMITIVE_FLOAT); - model.newMandatoryColumn("bParameter", LengthWeightKey.PROPERTY_BPARAMETER, EchoBaseCsvUtil.PRIMITIVE_FLOAT); - model.newForeignKeyColumn(LengthWeightKeyImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); - model.newForeignKeyColumn(LengthWeightKeyImportRow.PROPERTY_SIZE_CATEGORY, SizeCategory.class, SizeCategory.PROPERTY_NAME, importDataContext.getSizeCategoriesByName()); - model.newForeignKeyColumn(Species.PROPERTY_BARACOUDA_CODE, LengthWeightKeyImportRow.PROPERTY_SPECIES, Species.class, Species.PROPERTY_BARACOUDA_CODE, importDataContext.getSpeciesByBaracoudaCode()); - model.newForeignKeyColumn(LengthWeightKey.PROPERTY_STRATA, Strata.class, Strata.PROPERTY_NAME, importDataContext.getStratasByName()); - return model; - - } - - public static LengthWeightKeyImportExportModel forExport(VoyageResultsImportDataContext importDataContext) { - - LengthWeightKeyImportExportModel model = new LengthWeightKeyImportExportModel(importDataContext.getCsvSeparator()); - model.newColumnForExport("aParameter", LengthWeightKey.PROPERTY_APARAMETER, EchoBaseCsvUtil.PRIMITIVE_FLOAT); - model.newColumnForExport("bParameter", LengthWeightKey.PROPERTY_BPARAMETER, EchoBaseCsvUtil.PRIMITIVE_FLOAT); - model.newColumnForExport(LengthWeightKeyImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); - model.newColumnForExport(LengthWeightKeyImportRow.PROPERTY_SIZE_CATEGORY, EchoBaseCsvUtil.SIZE_CATEGORY_FORMATTER); - model.newColumnForExport(Species.PROPERTY_BARACOUDA_CODE, LengthWeightKeyImportRow.PROPERTY_SPECIES, EchoBaseCsvUtil.SPECIES_FORMATTER); - model.newColumnForExport(LengthWeightKey.PROPERTY_STRATA, EchoBaseCsvUtil.STRATA_FORMATTER); - return model; - - } - - @Override - public LengthWeightKeyImportRow newEmptyInstance() { - return new LengthWeightKeyImportRow(); - } -} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EchotypeImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageEchotypeImportExportModel.java similarity index 55% rename from echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EchotypeImportExportModel.java rename to echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageEchotypeImportExportModel.java index eeeb6a5..8db503d 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EchotypeImportExportModel.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageEchotypeImportExportModel.java @@ -33,30 +33,32 @@ import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImp * @author Tony Chemit - chemit@codelutin.com * @since 0.3 */ -public class EchotypeImportExportModel extends EchoBaseImportExportModelSupport<EchotypeImportRow> { +public class VoyageResultsVoyageEchotypeImportExportModel extends EchoBaseImportExportModelSupport<VoyageResultsVoyageEchotypeImportRow> { - private EchotypeImportExportModel(char separator) { + public static final String HEADER_ECHOTYPE_NAME = "echotypeName"; + + private VoyageResultsVoyageEchotypeImportExportModel(char separator) { super(separator); } - public static EchotypeImportExportModel forImport(VoyageResultsImportDataContext importDataContext) { + public static VoyageResultsVoyageEchotypeImportExportModel forImport(VoyageResultsImportDataContext importDataContext) { - EchotypeImportExportModel model = new EchotypeImportExportModel(importDataContext.getCsvSeparator()); - model.newMandatoryColumn("echotypeName", Echotype.PROPERTY_NAME); - model.newMandatoryColumn("meaning", Echotype.PROPERTY_MEANING); - model.newForeignKeyColumn(EchotypeImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); + VoyageResultsVoyageEchotypeImportExportModel model = new VoyageResultsVoyageEchotypeImportExportModel(importDataContext.getCsvSeparator()); + model.newMandatoryColumn(HEADER_ECHOTYPE_NAME, Echotype.PROPERTY_NAME); + model.newMandatoryColumn(VoyageResultsVoyageEchotypeImportRow.PROPERTY_MEANING, Echotype.PROPERTY_MEANING); + model.newForeignKeyColumn(VoyageResultsVoyageEchotypeImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); model.newForeignKeyColumn(EchoBaseCsvUtil.DEPTH_STRATUM_ID, Echotype.PROPERTY_DEPTH_STRATUM, DepthStratum.class, DepthStratum.PROPERTY_ID, importDataContext.getDepthStratumsById()); model.newForeignKeyColumn(Species.PROPERTY_BARACOUDA_CODE, Echotype.PROPERTY_SPECIES, Species.class, Species.PROPERTY_BARACOUDA_CODE, importDataContext.getSpeciesByBaracoudaCode()); return model; } - public static EchotypeImportExportModel forExport(VoyageResultsImportDataContext importDataContext) { + public static VoyageResultsVoyageEchotypeImportExportModel forExport(VoyageResultsImportDataContext importDataContext) { - EchotypeImportExportModel model = new EchotypeImportExportModel(importDataContext.getCsvSeparator()); - model.newColumnForExport("echotypeName", Echotype.PROPERTY_NAME); - model.newColumnForExport("meaning", Echotype.PROPERTY_MEANING); - model.newColumnForExport(EchotypeImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); + VoyageResultsVoyageEchotypeImportExportModel model = new VoyageResultsVoyageEchotypeImportExportModel(importDataContext.getCsvSeparator()); + model.newColumnForExport(HEADER_ECHOTYPE_NAME, Echotype.PROPERTY_NAME); + model.newColumnForExport(VoyageResultsVoyageEchotypeImportRow.PROPERTY_MEANING, Echotype.PROPERTY_MEANING); + model.newColumnForExport(VoyageResultsVoyageEchotypeImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); model.newColumnForExport(EchoBaseCsvUtil.DEPTH_STRATUM_ID, Echotype.PROPERTY_DEPTH_STRATUM, EchoBaseCsvUtil.DEPTH_STRATUM_FORMATTER); model.newColumnForExport(Species.PROPERTY_BARACOUDA_CODE, Echotype.PROPERTY_SPECIES, EchoBaseCsvUtil.SPECIES_FORMATTER); return model; @@ -64,7 +66,7 @@ public class EchotypeImportExportModel extends EchoBaseImportExportModelSupport< } @Override - public EchotypeImportRow newEmptyInstance() { - return new EchotypeImportRow(); + public VoyageResultsVoyageEchotypeImportRow newEmptyInstance() { + return new VoyageResultsVoyageEchotypeImportRow(); } } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EchotypeImportRow.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageEchotypeImportRow.java similarity index 63% rename from echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EchotypeImportRow.java rename to echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageEchotypeImportRow.java index 78332a1..ca572d7 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/EchotypeImportRow.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageEchotypeImportRow.java @@ -29,20 +29,35 @@ import fr.ifremer.echobase.entities.references.Species; import java.io.Serializable; /** - * Bean used as a row for import of {@link EchotypeImportExportModel}. + * Bean used as a row for import of {@link VoyageResultsVoyageEchotypeImportExportModel}. * * @author Tony Chemit - chemit@codelutin.com * @since 0.3 */ -public class EchotypeImportRow implements Serializable { +public class VoyageResultsVoyageEchotypeImportRow implements Serializable { - public static final String PROPERTY_VOYAGE = "voyage"; private static final long serialVersionUID = 1L; + + public static final String PROPERTY_MEANING = Echotype.PROPERTY_MEANING; + public static final String PROPERTY_VOYAGE = "voyage"; + protected final Echotype echotype; protected Voyage voyage; + protected Species species; + + public static VoyageResultsVoyageEchotypeImportRow of(Voyage voyage, Echotype echotype, Species species) { + VoyageResultsVoyageEchotypeImportRow row = new VoyageResultsVoyageEchotypeImportRow(echotype); + row.setVoyage(voyage); + row.setSpecies(species); + return row; + } + + public VoyageResultsVoyageEchotypeImportRow() { + this(new EchotypeImpl()); + } - public EchotypeImportRow() { - echotype = new EchotypeImpl(); + public VoyageResultsVoyageEchotypeImportRow(Echotype echotype) { + this.echotype = echotype; } public Voyage getVoyage() { @@ -57,19 +72,35 @@ public class EchotypeImportRow implements Serializable { return echotype; } + public String getName() { + return echotype.getName(); + } + public void setName(String name) { echotype.setName(name); } + public String getMeaning() { + return echotype.getMeaning(); + } + public void setMeaning(String meaning) { echotype.setMeaning(meaning); } - public void setDepthStratum(DepthStratum depthStratum) { - echotype.setDepthStratum(depthStratum); + public Species getSpecies() { + return species; } public void setSpecies(Species species) { - echotype.addSpecies(species); + this.species = species; + } + + public DepthStratum getDepthStratum() { + return echotype.getDepthStratum(); + } + + public void setDepthStratum(DepthStratum depthStratum) { + echotype.setDepthStratum(depthStratum); } } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthAgeKeyImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthAgeKeyImportExportModel.java similarity index 65% rename from echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthAgeKeyImportExportModel.java rename to echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthAgeKeyImportExportModel.java index cca30e2..4148419 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthAgeKeyImportExportModel.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthAgeKeyImportExportModel.java @@ -33,16 +33,16 @@ import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImp * @author Tony Chemit - chemit@codelutin.com * @since 0.3 */ -public class LengthAgeKeyImportExportModel extends EchoBaseImportExportModelSupport<LengthAgeKeyImportRow> { +public class VoyageResultsVoyageLengthAgeKeyImportExportModel extends EchoBaseImportExportModelSupport<VoyageResultsVoyageLengthAgeKeyImportRow> { - private LengthAgeKeyImportExportModel(char separator) { + private VoyageResultsVoyageLengthAgeKeyImportExportModel(char separator) { super(separator); } - public static LengthAgeKeyImportExportModel forImport(VoyageResultsImportDataContext importDataContext) { + public static VoyageResultsVoyageLengthAgeKeyImportExportModel forImport(VoyageResultsImportDataContext importDataContext) { - LengthAgeKeyImportExportModel model = new LengthAgeKeyImportExportModel(importDataContext.getCsvSeparator()); - model.newForeignKeyColumn(LengthAgeKeyImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); + VoyageResultsVoyageLengthAgeKeyImportExportModel model = new VoyageResultsVoyageLengthAgeKeyImportExportModel(importDataContext.getCsvSeparator()); + model.newForeignKeyColumn(VoyageResultsVoyageLengthAgeKeyImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); model.newMandatoryColumn(LengthAgeKey.PROPERTY_AGE, EchoBaseCsvUtil.PRIMITIVE_INTEGER); model.newMandatoryColumn(LengthAgeKey.PROPERTY_PERCENT_AT_AGE, EchoBaseCsvUtil.PRIMITIVE_FLOAT); model.newMandatoryColumn(LengthAgeKey.PROPERTY_LENGTH, EchoBaseCsvUtil.PRIMITIVE_FLOAT); @@ -53,22 +53,22 @@ public class LengthAgeKeyImportExportModel extends EchoBaseImportExportModelSupp } - public static LengthAgeKeyImportExportModel forExport(VoyageResultsImportDataContext importDataContext) { + public static VoyageResultsVoyageLengthAgeKeyImportExportModel forExport(VoyageResultsImportDataContext importDataContext) { - LengthAgeKeyImportExportModel model = new LengthAgeKeyImportExportModel(importDataContext.getCsvSeparator()); - model.newColumnForExport(LengthAgeKeyImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); + VoyageResultsVoyageLengthAgeKeyImportExportModel model = new VoyageResultsVoyageLengthAgeKeyImportExportModel(importDataContext.getCsvSeparator()); + model.newColumnForExport(VoyageResultsVoyageLengthAgeKeyImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); model.newColumnForExport(LengthAgeKey.PROPERTY_AGE, EchoBaseCsvUtil.PRIMITIVE_INTEGER); model.newColumnForExport(LengthAgeKey.PROPERTY_PERCENT_AT_AGE, EchoBaseCsvUtil.PRIMITIVE_FLOAT); model.newColumnForExport(LengthAgeKey.PROPERTY_LENGTH, EchoBaseCsvUtil.PRIMITIVE_FLOAT); model.newColumnForExport(LengthAgeKey.PROPERTY_METADATA); - model.newColumnForExport(LengthAgeKey.PROPERTY_STRATA, EchoBaseCsvUtil.STRATA_FORMATTER); + model.newColumnForExport(LengthAgeKey.PROPERTY_STRATA, LengthAgeKey.PROPERTY_STRATA, EchoBaseCsvUtil.STRATA_FORMATTER); model.newColumnForExport(Species.PROPERTY_BARACOUDA_CODE, LengthAgeKey.PROPERTY_SPECIES, EchoBaseCsvUtil.SPECIES_FORMATTER); return model; } @Override - public LengthAgeKeyImportRow newEmptyInstance() { - return new LengthAgeKeyImportRow(); + public VoyageResultsVoyageLengthAgeKeyImportRow newEmptyInstance() { + return new VoyageResultsVoyageLengthAgeKeyImportRow(); } } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthAgeKeyImportRow.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthAgeKeyImportRow.java similarity index 65% rename from echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthAgeKeyImportRow.java rename to echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthAgeKeyImportRow.java index f231dd9..9fbd2aa 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthAgeKeyImportRow.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthAgeKeyImportRow.java @@ -29,20 +29,31 @@ import fr.ifremer.echobase.entities.references.Strata; import java.io.Serializable; /** - * Bean used as a row for import of {@link LengthAgeKeyImportExportModel}. + * Bean used as a row for import of {@link VoyageResultsVoyageLengthAgeKeyImportExportModel}. * * @author Tony Chemit - chemit@codelutin.com * @since 0.3 */ -public class LengthAgeKeyImportRow implements Serializable { +public class VoyageResultsVoyageLengthAgeKeyImportRow implements Serializable { public static final String PROPERTY_VOYAGE = "voyage"; private static final long serialVersionUID = 1L; + protected final LengthAgeKey lengthAgeKey; protected Voyage voyage; - public LengthAgeKeyImportRow() { - lengthAgeKey = new LengthAgeKeyImpl(); + public static VoyageResultsVoyageLengthAgeKeyImportRow of(Voyage voyage, LengthAgeKey lengthAgeKey) { + VoyageResultsVoyageLengthAgeKeyImportRow row = new VoyageResultsVoyageLengthAgeKeyImportRow(lengthAgeKey); + row.setVoyage(voyage); + return row; + } + + public VoyageResultsVoyageLengthAgeKeyImportRow() { + this(new LengthAgeKeyImpl()); + } + + public VoyageResultsVoyageLengthAgeKeyImportRow(LengthAgeKey lengthAgeKey) { + this.lengthAgeKey = lengthAgeKey; } public LengthAgeKey getLengthAgeKey() { @@ -57,26 +68,50 @@ public class LengthAgeKeyImportRow implements Serializable { this.voyage = voyage; } + public int getAge() { + return lengthAgeKey.getAge(); + } + public void setAge(int age) { lengthAgeKey.setAge(age); } + public float getLength() { + return lengthAgeKey.getLength(); + } + public void setLength(float length) { lengthAgeKey.setLength(length); } + public float getPercentAtAge() { + return lengthAgeKey.getPercentAtAge(); + } + public void setPercentAtAge(float percentAtAge) { lengthAgeKey.setPercentAtAge(percentAtAge); } + public String getMetadata() { + return lengthAgeKey.getMetadata(); + } + public void setMetadata(String metadata) { lengthAgeKey.setMetadata(metadata); } + public Strata getStrata() { + return lengthAgeKey.getStrata(); + } + public void setStrata(Strata strata) { lengthAgeKey.setStrata(strata); } + public Species getSpecies() { + return lengthAgeKey.getSpecies(); + } + public void setSpecies(Species species) { lengthAgeKey.setSpecies(species); } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthWeightKeyImportExportModel.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthWeightKeyImportExportModel.java new file mode 100644 index 0000000..eaa94b5 --- /dev/null +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthWeightKeyImportExportModel.java @@ -0,0 +1,76 @@ +/* + * #%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% + */ +package fr.ifremer.echobase.services.service.importdata.csv; + +import fr.ifremer.echobase.entities.data.LengthWeightKey; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.entities.references.SizeCategory; +import fr.ifremer.echobase.entities.references.Species; +import fr.ifremer.echobase.entities.references.Strata; +import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; +import fr.ifremer.echobase.services.service.importdata.contexts.VoyageResultsImportDataContext; + +/** + * Model to import {@link LengthWeightKey}. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 0.3 + */ +public class VoyageResultsVoyageLengthWeightKeyImportExportModel extends EchoBaseImportExportModelSupport<VoyageResultsVoyageLengthWeightKeyImportRow> { + + public static final String HEADER_A_PARAMETER = "aParameter"; + public static final String HEADER_B_PARAMETER = "bParameter"; + + private VoyageResultsVoyageLengthWeightKeyImportExportModel(char separator) { + super(separator); + } + + public static VoyageResultsVoyageLengthWeightKeyImportExportModel forImport(VoyageResultsImportDataContext importDataContext) { + + VoyageResultsVoyageLengthWeightKeyImportExportModel model = new VoyageResultsVoyageLengthWeightKeyImportExportModel(importDataContext.getCsvSeparator()); + model.newMandatoryColumn(HEADER_A_PARAMETER, LengthWeightKey.PROPERTY_APARAMETER, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + model.newMandatoryColumn(HEADER_B_PARAMETER, LengthWeightKey.PROPERTY_BPARAMETER, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + model.newForeignKeyColumn(VoyageResultsVoyageLengthWeightKeyImportRow.PROPERTY_VOYAGE, Voyage.class, Voyage.PROPERTY_NAME, importDataContext.getVoyagesByName()); + model.newForeignKeyColumn(VoyageResultsVoyageLengthWeightKeyImportRow.PROPERTY_SIZE_CATEGORY, SizeCategory.class, SizeCategory.PROPERTY_NAME, importDataContext.getSizeCategoriesByName()); + model.newForeignKeyColumn(Species.PROPERTY_BARACOUDA_CODE, VoyageResultsVoyageLengthWeightKeyImportRow.PROPERTY_SPECIES, Species.class, Species.PROPERTY_BARACOUDA_CODE, importDataContext.getSpeciesByBaracoudaCode()); + model.newForeignKeyColumn(LengthWeightKey.PROPERTY_STRATA, Strata.class, Strata.PROPERTY_NAME, importDataContext.getStratasByName()); + return model; + + } + + public static VoyageResultsVoyageLengthWeightKeyImportExportModel forExport(VoyageResultsImportDataContext importDataContext) { + + VoyageResultsVoyageLengthWeightKeyImportExportModel model = new VoyageResultsVoyageLengthWeightKeyImportExportModel(importDataContext.getCsvSeparator()); + model.newColumnForExport(HEADER_A_PARAMETER, LengthWeightKey.PROPERTY_APARAMETER, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + model.newColumnForExport(HEADER_B_PARAMETER, LengthWeightKey.PROPERTY_BPARAMETER, EchoBaseCsvUtil.PRIMITIVE_FLOAT); + model.newColumnForExport(VoyageResultsVoyageLengthWeightKeyImportRow.PROPERTY_VOYAGE, EchoBaseCsvUtil.VOYAGE_FORMATTER); + model.newColumnForExport(VoyageResultsVoyageLengthWeightKeyImportRow.PROPERTY_SIZE_CATEGORY, EchoBaseCsvUtil.SIZE_CATEGORY_FORMATTER); + model.newColumnForExport(Species.PROPERTY_BARACOUDA_CODE, VoyageResultsVoyageLengthWeightKeyImportRow.PROPERTY_SPECIES, EchoBaseCsvUtil.SPECIES_FORMATTER); + model.newColumnForExport(LengthWeightKey.PROPERTY_STRATA, EchoBaseCsvUtil.STRATA_FORMATTER); + return model; + + } + + @Override + public VoyageResultsVoyageLengthWeightKeyImportRow newEmptyInstance() { + return new VoyageResultsVoyageLengthWeightKeyImportRow(); + } +} diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthWeightKeyImportRow.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthWeightKeyImportRow.java similarity index 69% rename from echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthWeightKeyImportRow.java rename to echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthWeightKeyImportRow.java index 4427979..ef57446 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/LengthWeightKeyImportRow.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageResultsVoyageLengthWeightKeyImportRow.java @@ -30,24 +30,38 @@ import fr.ifremer.echobase.entities.references.Strata; import java.io.Serializable; /** - * Bean used as a row for import of {@link LengthWeightKeyImportExportModel}. + * Bean used as a row for import of {@link VoyageResultsVoyageLengthWeightKeyImportExportModel}. * * @author Tony Chemit - chemit@codelutin.com * @since 0.3 */ -public class LengthWeightKeyImportRow implements Serializable { +public class VoyageResultsVoyageLengthWeightKeyImportRow implements Serializable { + + private static final long serialVersionUID = 1L; public static final String PROPERTY_VOYAGE = "voyage"; public static final String PROPERTY_SPECIES = "species"; public static final String PROPERTY_SIZE_CATEGORY = "sizeCategory"; - private static final long serialVersionUID = 1L; + protected final LengthWeightKey lengthWeightKey; protected Species species; protected SizeCategory sizeCategory; protected Voyage voyage; - public LengthWeightKeyImportRow() { - lengthWeightKey = new LengthWeightKeyImpl(); + public static VoyageResultsVoyageLengthWeightKeyImportRow of(Voyage voyage, LengthWeightKey lengthWeightKey) { + VoyageResultsVoyageLengthWeightKeyImportRow row = new VoyageResultsVoyageLengthWeightKeyImportRow(lengthWeightKey); + row.setVoyage(voyage); + row.setSpecies(lengthWeightKey.getSpeciesCategory().getSpecies()); + row.setSizeCategory(lengthWeightKey.getSpeciesCategory().getSizeCategory()); + return row; + } + + public VoyageResultsVoyageLengthWeightKeyImportRow(LengthWeightKey lengthWeightKey) { + this.lengthWeightKey = lengthWeightKey; + } + + public VoyageResultsVoyageLengthWeightKeyImportRow() { + this(new LengthWeightKeyImpl()); } public LengthWeightKey getLengthWeightKey() { @@ -78,14 +92,26 @@ public class LengthWeightKeyImportRow implements Serializable { this.voyage = voyage; } - public void setBParameter(float BParameter) { - lengthWeightKey.setBParameter(BParameter); + public float getAParameter() { + return lengthWeightKey.getAParameter(); } public void setAParameter(float AParameter) { lengthWeightKey.setAParameter(AParameter); } + public float getBParameter() { + return lengthWeightKey.getBParameter(); + } + + public void setBParameter(float BParameter) { + lengthWeightKey.setBParameter(BParameter); + } + + public Strata getStrata() { + return lengthWeightKey.getStrata(); + } + public void setStrata(Strata strata) { lengthWeightKey.setStrata(strata); } diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageImportServiceIT.java index e3e2bb2..ed94270 100644 --- a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageImportServiceIT.java +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageImportServiceIT.java @@ -20,6 +20,7 @@ */ package fr.ifremer.echobase.services.service.importdata; +import com.google.common.collect.Iterables; import fr.ifremer.echobase.entities.ImportType; import fr.ifremer.echobase.entities.data.Echotype; import fr.ifremer.echobase.entities.data.LengthAgeKey; @@ -28,7 +29,6 @@ import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; import fr.ifremer.echobase.services.service.importdata.configurations.VoyageResultsImportConfiguration; import java.io.IOException; -import java.util.Set; /** * @author Tony Chemit - chemit@codelutin.com @@ -63,23 +63,33 @@ public class VoyageResultsVoyageImportServiceIT extends VoyageResultsImportServi assertImportCommonData(); assertImportOperations(); assertImportSampleDatas(); - - assertNoEntities(LengthAgeKey.class); - assertNoEntities(LengthWeightKey.class); - assertNoEntities(Echotype.class); + assertNoEntities(LengthAgeKey.class, LengthWeightKey.class, Echotype.class); } @Override protected void assertAfertImport(ImportDataResult<VoyageResultsImportConfiguration> result) throws IOException { - Set<ImportDataFileResult> importDataFileResults = result.getImportResults(); - assertNbIds(importDataFileResults, 0, fixtures.NB_LENGTH_AGE_KEY()); - assertCsvImportResult(importDataFileResults, 0, LengthAgeKey.class, fixtures.NB_LENGTH_AGE_KEY()); - assertNbIds(importDataFileResults, 1, fixtures.NB_LENGTH_WEIGHT_KEY()); - assertCsvImportResult(importDataFileResults, 1, LengthWeightKey.class, fixtures.NB_LENGTH_WEIGHT_KEY()); + { + int nbLengthAgeKey = fixtures.NB_LENGTH_AGE_KEY(); + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 0); + assertCsvImportResultPerEntity(importDataFileResult, LengthAgeKey.class, nbLengthAgeKey, 0, nbLengthAgeKey); + assertCsvImportResult0(importDataFileResult, nbLengthAgeKey); + } + + { + int nbLengthWeightKey = fixtures.NB_LENGTH_WEIGHT_KEY(); + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 1); + assertCsvImportResultPerEntity(importDataFileResult, LengthWeightKey.class, nbLengthWeightKey, 0, nbLengthWeightKey); + assertCsvImportResult0(importDataFileResult, nbLengthWeightKey); + } + + { + int nbEchotype = fixtures.NB_ECHOTYPE(); + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 2); + assertCsvImportResultPerEntity(importDataFileResult, Echotype.class, nbEchotype, 0, nbEchotype); + assertCsvImportResult0(importDataFileResult, nbEchotype); + } - assertNbIds(importDataFileResults, 2, fixtures.NB_ECHOTYPE()); - assertCsvImportResult(importDataFileResults, 2, Echotype.class, fixtures.NB_ECHOTYPE()); } } diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyEchotypeImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyEchotypeImportServiceIT.java index 2b07ade..6e43620 100644 --- a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyEchotypeImportServiceIT.java +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyEchotypeImportServiceIT.java @@ -20,13 +20,13 @@ */ package fr.ifremer.echobase.services.service.importdata; +import com.google.common.collect.Iterables; import fr.ifremer.echobase.entities.ImportType; import fr.ifremer.echobase.entities.data.Echotype; import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; import fr.ifremer.echobase.services.service.importdata.configurations.VoyageResultsImportConfiguration; import java.io.IOException; -import java.util.Set; /** * @author Tony Chemit - chemit@codelutin.com @@ -59,15 +59,17 @@ public class VoyageResultsVoyageOnlyEchotypeImportServiceIT extends VoyageResult assertImportCommonData(); assertImportOperations(); assertImportSampleDatas(); - assertNoEntities(Echotype.class); } @Override protected void assertAfertImport(ImportDataResult<VoyageResultsImportConfiguration> result) throws IOException { - Set<ImportDataFileResult> importDataFileResults = result.getImportResults(); - assertNbIds(importDataFileResults, 0, fixtures.NB_ECHOTYPE()); - assertCsvImportResult(importDataFileResults, 0, Echotype.class, fixtures.NB_ECHOTYPE()); + + int nbEchotype = fixtures.NB_ECHOTYPE(); + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 0); + assertCsvImportResultPerEntity(importDataFileResult, Echotype.class, nbEchotype, 0, nbEchotype); + assertCsvImportResult0(importDataFileResult, nbEchotype); + } } diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyLengthAgeKeyImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyLengthAgeKeyImportServiceIT.java index 445e53f..ce23481 100644 --- a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyLengthAgeKeyImportServiceIT.java +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyLengthAgeKeyImportServiceIT.java @@ -20,13 +20,13 @@ */ package fr.ifremer.echobase.services.service.importdata; +import com.google.common.collect.Iterables; import fr.ifremer.echobase.entities.ImportType; import fr.ifremer.echobase.entities.data.LengthAgeKey; import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; import fr.ifremer.echobase.services.service.importdata.configurations.VoyageResultsImportConfiguration; import java.io.IOException; -import java.util.Set; /** * @author Tony Chemit - chemit@codelutin.com @@ -64,9 +64,12 @@ public class VoyageResultsVoyageOnlyLengthAgeKeyImportServiceIT extends VoyageRe @Override protected void assertAfertImport(ImportDataResult<VoyageResultsImportConfiguration> result) throws IOException { - Set<ImportDataFileResult> importDataFileResults = result.getImportResults(); - assertNbIds(importDataFileResults, 0, fixtures.NB_LENGTH_AGE_KEY()); - assertCsvImportResult(importDataFileResults, 0, LengthAgeKey.class, fixtures.NB_LENGTH_AGE_KEY()); + + int nbLengthAgeKey = fixtures.NB_LENGTH_AGE_KEY(); + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 0); + assertCsvImportResultPerEntity(importDataFileResult, LengthAgeKey.class, nbLengthAgeKey, 0, nbLengthAgeKey); + assertCsvImportResult0(importDataFileResult, nbLengthAgeKey); + } } diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyLengthWeightKeyImportServiceIT.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyLengthWeightKeyImportServiceIT.java index d66a588..ac8d6d8 100644 --- a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyLengthWeightKeyImportServiceIT.java +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/importdata/VoyageResultsVoyageOnlyLengthWeightKeyImportServiceIT.java @@ -20,13 +20,13 @@ */ package fr.ifremer.echobase.services.service.importdata; +import com.google.common.collect.Iterables; import fr.ifremer.echobase.entities.ImportType; import fr.ifremer.echobase.entities.data.LengthWeightKey; import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; import fr.ifremer.echobase.services.service.importdata.configurations.VoyageResultsImportConfiguration; import java.io.IOException; -import java.util.Set; /** * @author Tony Chemit - chemit@codelutin.com @@ -67,9 +67,12 @@ public class VoyageResultsVoyageOnlyLengthWeightKeyImportServiceIT extends Voyag @Override protected void assertAfertImport(ImportDataResult<VoyageResultsImportConfiguration> result) throws IOException { - Set<ImportDataFileResult> importDataFileResults = result.getImportResults(); - assertNbIds(importDataFileResults, 0, fixtures.NB_LENGTH_WEIGHT_KEY()); - assertCsvImportResult(importDataFileResults, 0, LengthWeightKey.class, fixtures.NB_LENGTH_WEIGHT_KEY()); + + int nbLengthWeightKey = fixtures.NB_LENGTH_WEIGHT_KEY(); + ImportDataFileResult importDataFileResult = Iterables.get(result.getImportResults(), 0); + assertCsvImportResultPerEntity(importDataFileResult, LengthWeightKey.class, nbLengthWeightKey, 0, nbLengthWeightKey); + assertCsvImportResult0(importDataFileResult, nbLengthWeightKey); + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm