Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
February 2015
- 2 participants
- 95 discussions
11/98: nettoyage export generique et debut d'implatation de l'import generique
by codelutin.com scm 16 Feb '15
by codelutin.com scm 16 Feb '15
16 Feb '15
This is an automated email from the git hooks/post-receive script.
New commit to branch develop in repository tutti.
See http://git.codelutin.com/tutti.git
commit 17d0b679f464bd13a97ca2aa2402d30711a835b2
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Fri Feb 6 09:42:36 2015 +0100
nettoyage export generique et debut d'implatation de l'import generique
---
.../export/generic/GlobalExportContext.java | 145 +++++------
.../export/generic/GlobalImportContext.java | 109 +++++++++
.../export/generic/OperationExportContext.java | 99 +++++++-
.../service/export/generic/TuttiExportService.java | 89 ++++---
.../generic/csv/AccidentalCatchExportModel.java | 167 -------------
.../export/generic/csv/AccidentalCatchModel.java | 208 ++++++++++++++++
...CatchExportRow.java => AccidentalCatchRow.java} | 2 +-
.../csv/{CatchExportModel.java => CatchModel.java} | 253 ++++++++++++-------
.../csv/{CatchExportRow.java => CatchRow.java} | 10 +-
.../generic/csv/GearCaracteristicExportModel.java | 74 ------
.../export/generic/csv/GearCaracteristicModel.java | 123 ++++++++++
...ticExportRow.java => GearCaracteristicRow.java} | 18 +-
.../csv/IndividualObservationExportModel.java | 145 -----------
.../generic/csv/IndividualObservationModel.java | 193 +++++++++++++++
...xportRow.java => IndividualObservationRow.java} | 2 +-
...tterExportModel.java => MarineLitterModel.java} | 96 ++++++--
...neLitterExportRow.java => MarineLitterRow.java} | 2 +-
.../export/generic/csv/OperationExportModel.java | 143 -----------
.../service/export/generic/csv/OperationModel.java | 269 +++++++++++++++++++++
.../{OperationExportRow.java => OperationRow.java} | 95 +++++++-
.../export/generic/csv/ParameterExportModel.java | 92 -------
.../service/export/generic/csv/ParameterModel.java | 143 +++++++++++
.../{ParameterExportRow.java => ParameterRow.java} | 2 +-
.../export/generic/csv/SpeciesExportModel.java | 53 ++--
.../export/generic/csv/SurveyExportModel.java | 68 ------
.../service/export/generic/csv/SurveyModel.java | 119 +++++++++
.../csv/{SurveyExportRow.java => SurveyRow.java} | 58 ++++-
27 files changed, 1816 insertions(+), 961 deletions(-)
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GlobalExportContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GlobalExportContext.java
index fece275..1b92764 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GlobalExportContext.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GlobalExportContext.java
@@ -7,27 +7,27 @@ import com.google.common.io.Files;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.TuttiCsvUtil;
-import fr.ifremer.tutti.service.export.generic.csv.AccidentalCatchExportModel;
-import fr.ifremer.tutti.service.export.generic.csv.AccidentalCatchExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.CatchExportModel;
-import fr.ifremer.tutti.service.export.generic.csv.CatchExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.GearCaracteristicExportModel;
-import fr.ifremer.tutti.service.export.generic.csv.GearCaracteristicExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.IndividualObservationExportModel;
-import fr.ifremer.tutti.service.export.generic.csv.IndividualObservationExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.MarineLitterExportModel;
-import fr.ifremer.tutti.service.export.generic.csv.MarineLitterExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.OperationExportModel;
-import fr.ifremer.tutti.service.export.generic.csv.OperationExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.ParameterExportModel;
-import fr.ifremer.tutti.service.export.generic.csv.ParameterExportRow;
+import fr.ifremer.tutti.service.csv.TuttiRepeatableExport;
+import fr.ifremer.tutti.service.export.generic.csv.AccidentalCatchModel;
+import fr.ifremer.tutti.service.export.generic.csv.AccidentalCatchRow;
+import fr.ifremer.tutti.service.export.generic.csv.CatchModel;
+import fr.ifremer.tutti.service.export.generic.csv.CatchRow;
+import fr.ifremer.tutti.service.export.generic.csv.GearCaracteristicModel;
+import fr.ifremer.tutti.service.export.generic.csv.GearCaracteristicRow;
+import fr.ifremer.tutti.service.export.generic.csv.IndividualObservationModel;
+import fr.ifremer.tutti.service.export.generic.csv.IndividualObservationRow;
+import fr.ifremer.tutti.service.export.generic.csv.MarineLitterModel;
+import fr.ifremer.tutti.service.export.generic.csv.MarineLitterRow;
+import fr.ifremer.tutti.service.export.generic.csv.OperationModel;
+import fr.ifremer.tutti.service.export.generic.csv.OperationRow;
+import fr.ifremer.tutti.service.export.generic.csv.ParameterModel;
+import fr.ifremer.tutti.service.export.generic.csv.ParameterRow;
import fr.ifremer.tutti.service.export.generic.csv.SpeciesExportModel;
import fr.ifremer.tutti.service.export.generic.csv.SpeciesExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.SurveyExportModel;
-import fr.ifremer.tutti.service.export.generic.csv.SurveyExportRow;
+import fr.ifremer.tutti.service.export.generic.csv.SurveyModel;
+import fr.ifremer.tutti.service.export.generic.csv.SurveyRow;
import org.apache.commons.io.IOUtils;
import org.nuiton.jaxx.application.ApplicationTechnicalException;
@@ -44,11 +44,11 @@ import java.util.Map;
import static org.nuiton.i18n.I18n.t;
/**
-* Created on 2/5/15.
-*
-* @author Tony Chemit - chemit(a)codelutin.com
-* @since 3.13
-*/
+ * Created on 2/5/15.
+ *
+ * @author Tony Chemit - chemit(a)codelutin.com
+ * @since 3.13
+ */
public class GlobalExportContext implements Closeable {
File protocolFile;
@@ -97,43 +97,45 @@ public class GlobalExportContext implements Closeable {
BufferedWriter speciesWriter;
- SurveyExportModel surveyModel;
+ SurveyModel surveyModel;
- GearCaracteristicExportModel gearCaracteristicsModel;
+ GearCaracteristicModel gearCaracteristicsModel;
- OperationExportModel operationModel;
+ OperationModel operationModel;
- MarineLitterExportModel marineLitterModel;
+ MarineLitterModel marineLitterModel;
- ParameterExportModel parameterModel;
+ ParameterModel parameterModel;
- CatchExportModel catchModel;
+ CatchModel catchModel;
- AccidentalCatchExportModel accidentalCatchModel;
+ AccidentalCatchModel accidentalCatchModel;
- IndividualObservationExportModel individualObservationModel;
+ IndividualObservationModel individualObservationModel;
SpeciesExportModel speciesModel;
final Map<String, SpeciesExportRow> speciesToExport = Maps.newTreeMap();
- TuttiCsvUtil.TuttiRepeatableExport<SurveyExportRow> surveyExport;
+ TuttiRepeatableExport<SurveyRow> surveyExport;
- TuttiCsvUtil.TuttiRepeatableExport<GearCaracteristicExportRow> gearCaracteristicsExport;
+ TuttiRepeatableExport<GearCaracteristicRow> gearCaracteristicsExport;
- TuttiCsvUtil.TuttiRepeatableExport<OperationExportRow> operationExport;
+ TuttiRepeatableExport<OperationRow> operationExport;
- TuttiCsvUtil.TuttiRepeatableExport<MarineLitterExportRow> marineLitterExport;
+ TuttiRepeatableExport<MarineLitterRow> marineLitterExport;
- TuttiCsvUtil.TuttiRepeatableExport<ParameterExportRow> parameterExport;
+ TuttiRepeatableExport<ParameterRow> parameterExport;
- TuttiCsvUtil.TuttiRepeatableExport<CatchExportRow> catchExport;
+ TuttiRepeatableExport<CatchRow> catchExport;
- TuttiCsvUtil.TuttiRepeatableExport<AccidentalCatchExportRow> accidentalCatchExport;
+ TuttiRepeatableExport<AccidentalCatchRow> accidentalCatchExport;
- TuttiCsvUtil.TuttiRepeatableExport<IndividualObservationExportRow> individualObservationExport;
+ TuttiRepeatableExport<IndividualObservationRow> individualObservationExport;
- TuttiCsvUtil.TuttiRepeatableExport<SpeciesExportRow> speciesExport;
+ TuttiRepeatableExport<SpeciesExportRow> speciesExport;
+
+ private final SampleCategoryModel sampleCategoryModel;
Map<String, Species> speciesById;
@@ -142,12 +144,9 @@ public class GlobalExportContext implements Closeable {
GlobalExportContext(File basedir,
char csvSeparator,
DecoratorService decoratorService,
- Caracteristic weightMeasuredCaracteristic,
- Caracteristic deadOrAliveCaracteristic,
- Caracteristic genderCaracteristic,
- Caracteristic pmfmIdCaracteristic,
SampleCategoryModel sampleCategoryModel,
Map<String, Species> speciesById) {
+ this.sampleCategoryModel = sampleCategoryModel;
this.speciesById = speciesById;
try {
@@ -191,51 +190,21 @@ public class GlobalExportContext implements Closeable {
throw new ApplicationTechnicalException(t("tutti.service.export.context.error"), e);
}
- surveyModel = new SurveyExportModel(csvSeparator);
-
- gearCaracteristicsModel = new GearCaracteristicExportModel(
- csvSeparator, decoratorService);
-
- operationModel =
- new OperationExportModel(
- csvSeparator,
- decoratorService.getDecoratorByType(Vessel.class));
-
- parameterModel = new ParameterExportModel(
- csvSeparator, decoratorService);
-
- marineLitterModel = new MarineLitterExportModel(csvSeparator);
- catchModel = new CatchExportModel(csvSeparator,
- sampleCategoryModel,
- decoratorService);
- accidentalCatchModel = new AccidentalCatchExportModel(
- csvSeparator,
- deadOrAliveCaracteristic,
- genderCaracteristic,
- weightMeasuredCaracteristic,
- pmfmIdCaracteristic);
- individualObservationModel = new IndividualObservationExportModel(
- csvSeparator,
- weightMeasuredCaracteristic,
- pmfmIdCaracteristic);
-
- speciesModel = new SpeciesExportModel(
- csvSeparator);
+ surveyModel = SurveyModel.forExport(csvSeparator);
+ gearCaracteristicsModel = GearCaracteristicModel.forExport(csvSeparator, decoratorService);
+ operationModel = OperationModel.forExport(csvSeparator, decoratorService);
+ parameterModel = ParameterModel.forExport(csvSeparator, decoratorService);
+ marineLitterModel = MarineLitterModel.forExport(csvSeparator);
+ catchModel = CatchModel.forExport(csvSeparator, sampleCategoryModel, decoratorService);
+ accidentalCatchModel = AccidentalCatchModel.forExport(csvSeparator);
+ individualObservationModel = IndividualObservationModel.forExport(csvSeparator);
+ speciesModel = SpeciesExportModel.forExport(csvSeparator);
surveyExport = TuttiCsvUtil.newRepeatableExport(surveyModel);
-
- gearCaracteristicsExport = TuttiCsvUtil.newRepeatableExport(
- gearCaracteristicsModel);
-
- operationExport = TuttiCsvUtil.newRepeatableExport(
- operationModel);
-
- parameterExport = TuttiCsvUtil.newRepeatableExport(
- parameterModel);
-
- marineLitterExport = TuttiCsvUtil.newRepeatableExport(
- marineLitterModel);
-
+ gearCaracteristicsExport = TuttiCsvUtil.newRepeatableExport(gearCaracteristicsModel);
+ operationExport = TuttiCsvUtil.newRepeatableExport(operationModel);
+ parameterExport = TuttiCsvUtil.newRepeatableExport(parameterModel);
+ marineLitterExport = TuttiCsvUtil.newRepeatableExport(marineLitterModel);
catchExport = TuttiCsvUtil.newRepeatableExport(catchModel);
accidentalCatchExport = TuttiCsvUtil.newRepeatableExport(accidentalCatchModel);
individualObservationExport = TuttiCsvUtil.newRepeatableExport(individualObservationModel);
@@ -289,4 +258,8 @@ public class GlobalExportContext implements Closeable {
});
return result;
}
+
+ public SampleCategoryModel getSampleCategoryModel() {
+ return sampleCategoryModel;
+ }
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GlobalImportContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GlobalImportContext.java
new file mode 100644
index 0000000..3af0423
--- /dev/null
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/GlobalImportContext.java
@@ -0,0 +1,109 @@
+package fr.ifremer.tutti.service.export.generic;
+
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.csv.CaracteristicParser;
+import fr.ifremer.tutti.service.csv.FishingOperationLocationParser;
+import fr.ifremer.tutti.service.csv.FishingOperationStrataParser;
+import fr.ifremer.tutti.service.csv.FishingOperationSubStrataParser;
+import fr.ifremer.tutti.service.csv.GearParser;
+import fr.ifremer.tutti.service.csv.HarbourParser;
+import fr.ifremer.tutti.service.csv.ListPersonParser;
+import fr.ifremer.tutti.service.csv.ListVesselParser;
+import fr.ifremer.tutti.service.csv.ProgramParser;
+import fr.ifremer.tutti.service.csv.SpeciesParser;
+import fr.ifremer.tutti.service.csv.VesselParser;
+
+/**
+ * Created on 2/5/15.
+ *
+ * @author Tony Chemit - chemit(a)codelutin.com
+ * @since 3.13
+ */
+public class GlobalImportContext {
+
+ private final VesselParser vesselParser;
+
+ private final ProgramParser programParser;
+
+ private final HarbourParser harbourParser;
+
+ private final GearParser mandatoryGearParser;
+
+ private final GearParser optionalGearParser;
+
+ private final ListPersonParser listPersonParser;
+
+ private final CaracteristicParser caracteristicParser;
+
+ private final FishingOperationStrataParser fishingOperationStrataParser;
+
+ private final FishingOperationSubStrataParser fishingOperationSubStrataParser;
+
+ private final FishingOperationLocationParser fishingOperationLocationParser;
+ private final ListVesselParser listVesselParser;
+ private final SpeciesParser speciesParser;
+
+ public GlobalImportContext(PersistenceService persistenceService, Program program) {
+ this.vesselParser = new VesselParser(persistenceService);
+ this.programParser = new ProgramParser(persistenceService);
+ this.harbourParser = new HarbourParser(persistenceService);
+ this.listPersonParser = new ListPersonParser(persistenceService);
+ this.mandatoryGearParser = new GearParser(persistenceService, true);
+ this.optionalGearParser = new GearParser(persistenceService, false);
+ this.caracteristicParser = new CaracteristicParser(persistenceService);
+ this.fishingOperationStrataParser = new FishingOperationStrataParser(persistenceService, program.getZone().getId());
+ this.fishingOperationSubStrataParser = new FishingOperationSubStrataParser(persistenceService, program.getZone().getId());
+ this.fishingOperationLocationParser = new FishingOperationLocationParser(persistenceService, program.getZone().getId());
+ this.listVesselParser = new ListVesselParser(persistenceService);
+ this.speciesParser = new SpeciesParser(persistenceService);
+ }
+
+ public VesselParser getVesselParser() {
+ return vesselParser;
+ }
+
+ public ProgramParser getProgramParser() {
+ return programParser;
+ }
+
+ public HarbourParser getHarbourParser() {
+ return harbourParser;
+ }
+
+ public ListPersonParser getListPersonParser() {
+ return listPersonParser;
+ }
+
+ public GearParser getMandatoryGearParser() {
+ return mandatoryGearParser;
+ }
+
+ public GearParser getOptionalGearParser() {
+ return optionalGearParser;
+ }
+
+ public CaracteristicParser getCaracteristicParser() {
+ return caracteristicParser;
+ }
+
+ public FishingOperationStrataParser getFishingOperationStrataParser() {
+ return fishingOperationStrataParser;
+ }
+
+ public FishingOperationSubStrataParser getFishingOperationSubStrataParser() {
+ return fishingOperationSubStrataParser;
+ }
+
+ public FishingOperationLocationParser getFishingOperationLocationParser() {
+ return fishingOperationLocationParser;
+ }
+
+ public ListVesselParser getListVesselParser() {
+ return listVesselParser;
+ }
+
+ public SpeciesParser getSpeciesParser() {
+ return speciesParser;
+ }
+}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportContext.java
index ed18610..028302f 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportContext.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/OperationExportContext.java
@@ -1,16 +1,26 @@
package fr.ifremer.tutti.service.export.generic;
+import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.catches.WeightComputingService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.List;
+
/**
* Created on 2/5/15.
*
@@ -22,7 +32,9 @@ public class OperationExportContext {
/** Logger. */
private static final Log log = LogFactory.getLog(OperationExportContext.class);
- protected final FishingOperation operation;
+ private final Cruise cruise;
+
+ private final FishingOperation operation;
private final CatchBatch catchBatch;
@@ -32,14 +44,46 @@ public class OperationExportContext {
private BatchContainer<BenthosBatch> rootBenthosBatch;
+ private List<IndividualObservationBatch> individualObservations;
+
+ private List<AccidentalBatch> accidentalBatches;
+
private boolean withCatchBatch;
- public OperationExportContext(FishingOperation operation, PersistenceService persistenceService, WeightComputingService weightComputingService) {
+ private final PersistenceService persistenceService;
+
+ protected final Caracteristic weightMeasuredCaracteristic;
+
+ protected final Caracteristic pmfmIdCaracteristic;
+
+ protected final Caracteristic deadOrAliveCaracteristic;
+
+ protected final Caracteristic genderCaracteristic;
+
+ private final SampleCategoryModel sampleCategoryModel;
+ public OperationExportContext(Cruise cruise,
+ FishingOperation operation,
+ PersistenceService persistenceService,
+ WeightComputingService weightComputingService,
+ SampleCategoryModel sampleCategoryModel,
+ Caracteristic weightMeasuredCaracteristic,
+ Caracteristic pmfmIdCaracteristic,
+ Caracteristic deadOrAliveCaracteristic,
+ Caracteristic genderCaracteristic) {
+ this.cruise = cruise;
this.operation = operation;
+ this.sampleCategoryModel = sampleCategoryModel;
+ this.persistenceService = persistenceService;
+ this.weightMeasuredCaracteristic = weightMeasuredCaracteristic;
+ this.pmfmIdCaracteristic = pmfmIdCaracteristic;
+ this.deadOrAliveCaracteristic = deadOrAliveCaracteristic;
+ this.genderCaracteristic = genderCaracteristic;
String operationId = operation.getId();
+ accidentalBatches = persistenceService.getAllAccidentalBatch(operation.getId());
+
withCatchBatch = persistenceService.isFishingOperationWithCatchBatch(operationId);
if (withCatchBatch) {
@@ -77,6 +121,9 @@ public class OperationExportContext {
if (!withError) {
weightComputingService.computeCatchBatchWeights(catchBatch, rootSpeciesBatch, rootBenthosBatch, rootMarineLitterBatch);
}
+
+ individualObservations = persistenceService.getAllIndividualObservationBatch(operation.getId());
+
} else {
if (log.isWarnEnabled()) {
log.warn("Skip fishing operation " + operationId + " since no catchBatch associated.");
@@ -89,6 +136,14 @@ public class OperationExportContext {
}
+ public Cruise getCruise() {
+ return cruise;
+ }
+
+ public FishingOperation getOperation() {
+ return operation;
+ }
+
public CatchBatch getCatchBatch() {
return catchBatch;
}
@@ -108,4 +163,44 @@ public class OperationExportContext {
public boolean isWithCatchBatch() {
return withCatchBatch;
}
+
+ public List<IndividualObservationBatch> getIndividualObservations() {
+ return individualObservations;
+ }
+
+ public Caracteristic getWeightMeasuredCaracteristic() {
+ return weightMeasuredCaracteristic;
+ }
+
+ public Caracteristic getPmfmIdCaracteristic() {
+ return pmfmIdCaracteristic;
+ }
+
+ public Caracteristic getDeadOrAliveCaracteristic() {
+ return deadOrAliveCaracteristic;
+ }
+
+ public Caracteristic getGenderCaracteristic() {
+ return genderCaracteristic;
+ }
+
+ public List<AccidentalBatch> getAccidentalBatches() {
+ return accidentalBatches;
+ }
+
+ public boolean isVracBatch(SpeciesAbleBatch batch) {
+ return persistenceService.isVracBatch(batch);
+ }
+
+ public List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String id) {
+ return persistenceService.getAllBenthosBatchFrequency(id);
+ }
+
+ public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String id) {
+ return persistenceService.getAllSpeciesBatchFrequency(id);
+ }
+
+ public SampleCategoryModel getSampleCategoryModel() {
+ return sampleCategoryModel;
+ }
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java
index d975cc4..9ed9bd1 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java
@@ -48,15 +48,15 @@ import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.TuttiServiceContext;
import fr.ifremer.tutti.service.catches.WeightComputingService;
-import fr.ifremer.tutti.service.export.generic.csv.AccidentalCatchExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.CatchExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.GearCaracteristicExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.IndividualObservationExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.MarineLitterExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.OperationExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.ParameterExportRow;
+import fr.ifremer.tutti.service.export.generic.csv.AccidentalCatchRow;
+import fr.ifremer.tutti.service.export.generic.csv.CatchRow;
+import fr.ifremer.tutti.service.export.generic.csv.GearCaracteristicRow;
+import fr.ifremer.tutti.service.export.generic.csv.IndividualObservationRow;
+import fr.ifremer.tutti.service.export.generic.csv.MarineLitterRow;
+import fr.ifremer.tutti.service.export.generic.csv.OperationRow;
+import fr.ifremer.tutti.service.export.generic.csv.ParameterRow;
import fr.ifremer.tutti.service.export.generic.csv.SpeciesExportRow;
-import fr.ifremer.tutti.service.export.generic.csv.SurveyExportRow;
+import fr.ifremer.tutti.service.export.generic.csv.SurveyRow;
import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
import fr.ifremer.tutti.service.referential.ReferentialTemporaryGearService;
import fr.ifremer.tutti.service.referential.ReferentialTemporaryPersonService;
@@ -74,6 +74,7 @@ import org.nuiton.jaxx.application.ApplicationTechnicalException;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -417,10 +418,6 @@ public class TuttiExportService extends AbstractTuttiService {
return new GlobalExportContext(basedir,
';',
decoratorService,
- weightMeasuredCaracteristic,
- deadOrAliveCaracteristic,
- genderCaracteristic,
- pmfmIdCaracteristic,
context.getSampleCategoryModel(),
speciesById);
@@ -530,8 +527,10 @@ public class TuttiExportService extends AbstractTuttiService {
try {
- List<SurveyExportRow> rows = Lists.newArrayList();
- exportContext.surveyModel.prepareRows(rows, cruise, country);
+ List<SurveyRow> rows = new ArrayList<>();
+ SurveyRow surveyRow = exportContext.surveyModel.getDataToExport(cruise, country);
+ rows.add(surveyRow);
+
exportContext.surveyExport.write(rows, exportContext.surveyWriter);
} catch (Exception e) {
throw new ApplicationTechnicalException(t("tutti.service.export.survey.error"), e);
@@ -541,7 +540,7 @@ public class TuttiExportService extends AbstractTuttiService {
protected void exportGearCaracteristics(GlobalExportContext exportContext, Cruise cruise) {
try {
- List<GearCaracteristicExportRow> rows = Lists.newArrayList();
+ List<GearCaracteristicRow> rows = Lists.newArrayList();
for (Gear gear : cruise.getGear()) {
@@ -550,12 +549,14 @@ public class TuttiExportService extends AbstractTuttiService {
Gear gearWithCaracteristics = Gears.newGear(gear);
gearWithCaracteristics.setCaracteristics(caracteristics);
- exportContext.gearCaracteristicsModel.prepareRows(rows, cruise, gearWithCaracteristics);
+ List<GearCaracteristicRow> dataToExport = exportContext.gearCaracteristicsModel.getDataToExport(cruise, gearWithCaracteristics);
+ rows.addAll(dataToExport);
+
}
exportContext.gearCaracteristicsExport.write(rows, exportContext.gearCaracteristicsWriter);
} catch (Exception e) {
- throw new ApplicationTechnicalException(t("tutti.service.export.survey.error"), e);
+ throw new ApplicationTechnicalException(t("tutti.service.export.gearCaracteristics.error"), e);
}
}
@@ -563,13 +564,15 @@ public class TuttiExportService extends AbstractTuttiService {
try {
- List<OperationExportRow> rows = Lists.newArrayList();
+ List<OperationRow> rows = Lists.newArrayList();
for (FishingOperation operation : operations) {
- OperationExportContext operationContext = getOperationContext(operation);
+ OperationExportContext operationContext = getOperationContext(exportContext, cruise, operation);
CatchBatch catchBatch = operationContext.getCatchBatch();
- exportContext.operationModel.prepareRows(rows, cruise, operation, catchBatch);
+ OperationRow operationRow = exportContext.operationModel.getDataToExport(cruise, operation, catchBatch);
+ rows.add(operationRow);
+
}
exportContext.operationExport.write(rows, exportContext.operationWriter);
@@ -583,8 +586,7 @@ public class TuttiExportService extends AbstractTuttiService {
try {
for (FishingOperation operation : operations) {
- List<ParameterExportRow> rows = Lists.newArrayList();
- exportContext.parameterModel.prepareRows(rows, cruise, operation);
+ List<ParameterRow> rows = exportContext.parameterModel.getDataToExport(cruise, operation);
exportContext.parameterExport.write(rows, exportContext.parameterWriter);
}
@@ -598,14 +600,13 @@ public class TuttiExportService extends AbstractTuttiService {
try {
for (FishingOperation operation : operations) {
- OperationExportContext operationContext = getOperationContext(operation);
+ OperationExportContext operationContext = getOperationContext(exportContext, cruise, operation);
boolean withCatchBatch = operationContext.isWithCatchBatch();
if (!withCatchBatch) {
continue;
}
- List<MarineLitterExportRow> rows = Lists.newArrayList();
- exportContext.marineLitterModel.prepareRows(persistenceService, rows, cruise, operation);
+ List<MarineLitterRow> rows = exportContext.marineLitterModel.getDataToExport(operationContext);
exportContext.marineLitterExport.write(rows, exportContext.marineLitterWriter);
}
@@ -619,14 +620,13 @@ public class TuttiExportService extends AbstractTuttiService {
try {
for (FishingOperation operation : operations) {
- OperationExportContext operationContext = getOperationContext(operation);
+ OperationExportContext operationContext = getOperationContext(exportContext, cruise, operation);
boolean withCatchBatch = operationContext.isWithCatchBatch();
if (!withCatchBatch) {
continue;
}
- List<IndividualObservationExportRow> rows = Lists.newArrayList();
- exportContext.individualObservationModel.prepareRows(persistenceService, rows, cruise, operation);
+ List<IndividualObservationRow> rows = exportContext.individualObservationModel.getDataToExport(operationContext);
exportContext.speciesModel.prepareIndividualRows(exportContext, rows);
exportContext.individualObservationExport.write(rows, exportContext.individualObservationWriter);
}
@@ -640,8 +640,10 @@ public class TuttiExportService extends AbstractTuttiService {
try {
for (FishingOperation operation : operations) {
- List<AccidentalCatchExportRow> rows = Lists.newArrayList();
- exportContext.accidentalCatchModel.prepareRows(persistenceService, rows, cruise, operation);
+
+ OperationExportContext operationContext = getOperationContext(exportContext, cruise, operation);
+
+ List<AccidentalCatchRow> rows = exportContext.accidentalCatchModel.getDataToExport(operationContext);
exportContext.speciesModel.prepareAccidentalRows(exportContext, rows);
exportContext.accidentalCatchExport.write(rows, exportContext.accidentalCatchWriter);
}
@@ -656,14 +658,14 @@ public class TuttiExportService extends AbstractTuttiService {
for (FishingOperation operation : operations) {
- OperationExportContext operationContext = getOperationContext(operation);
+ OperationExportContext operationContext = getOperationContext(exportContext, cruise, operation);
boolean withCatchBatch = operationContext.isWithCatchBatch();
if (!withCatchBatch) {
continue;
}
- exportCatch(exportContext, cruise, operation, operationContext);
+ exportCatch(exportContext, operationContext);
}
@@ -672,7 +674,7 @@ public class TuttiExportService extends AbstractTuttiService {
}
}
- protected void exportCatch(GlobalExportContext exportContext, Cruise cruise, FishingOperation operation, OperationExportContext operationContext) throws Exception {
+ protected void exportCatch(GlobalExportContext exportContext, OperationExportContext operationContext) throws Exception {
CatchBatch catchBatch = operationContext.getCatchBatch();
@@ -680,8 +682,9 @@ public class TuttiExportService extends AbstractTuttiService {
BatchContainer<BenthosBatch> rootBenthosBatch = operationContext.getRootBenthosBatch();
- // Warning! This will also add the survey code to bathc species
- exportContext.speciesModel.prepareBatchRows(exportContext, rootSpeciesBatch, rootBenthosBatch);
+ // Warning! This will also add the survey code to batch species
+ exportContext.speciesModel.prepareSpeciesBatchRows(exportContext, rootSpeciesBatch);
+ exportContext.speciesModel.prepareBenthosBatchRows(exportContext, rootBenthosBatch);
Float totalWeight = Numbers.getValueOrComputedValue(
catchBatch.getCatchTotalWeight(),
@@ -725,15 +728,9 @@ public class TuttiExportService extends AbstractTuttiService {
log.debug(message);
}
- List<CatchExportRow> rows = Lists.newArrayList();
- exportContext.catchModel.prepareRows(persistenceService,
- rows,
- cruise,
- operation,
- rootSpeciesBatch,
- rootBenthosBatch,
- speciesCatchRaisingFactor,
- benthosCatchRaisingFactor);
+ List<CatchRow> rows = exportContext.catchModel.getDataToExport(operationContext,
+ speciesCatchRaisingFactor,
+ benthosCatchRaisingFactor);
exportContext.catchExport.write(rows, exportContext.catchWriter);
@@ -752,7 +749,7 @@ public class TuttiExportService extends AbstractTuttiService {
protected Map<String, OperationExportContext> operationContexts = Maps.newTreeMap();
- protected OperationExportContext getOperationContext(FishingOperation operation) {
+ protected OperationExportContext getOperationContext(GlobalExportContext exportContext, Cruise cruise, FishingOperation operation) {
String operationId = operation.getId();
@@ -760,7 +757,7 @@ public class TuttiExportService extends AbstractTuttiService {
if (result == null) {
// create it
- result = new OperationExportContext(operation, persistenceService, weightComputingService);
+ result = new OperationExportContext(cruise, operation, persistenceService, weightComputingService, exportContext.getSampleCategoryModel(), weightMeasuredCaracteristic, pmfmIdCaracteristic, deadOrAliveCaracteristic, genderCaracteristic);
operationContexts.put(operationId, result);
}
return result;
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchExportModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchExportModel.java
deleted file mode 100644
index d70bd9e..0000000
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchExportModel.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package fr.ifremer.tutti.service.export.generic.csv;
-
-/*
- * #%L
- * Tutti :: Service
- * %%
- * Copyright (C) 2012 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.MapUtils;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.2
- */
-public class AccidentalCatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<AccidentalCatchExportRow> {
-
- protected final Caracteristic caracteristicDeadOrAliveSize;
-
- protected final Caracteristic caracteristicGender;
-
- protected final Caracteristic caracteristicWeight;
-
- protected final Caracteristic caracteristicPmfmId;
-
- public AccidentalCatchExportModel(
- char separator,
- Caracteristic caracteristicDeadOrAliveSize,
- Caracteristic caracteristicGender,
- Caracteristic caracteristicWeight,
- Caracteristic caracteristicPmfmId) {
- super(separator);
-
- this.caracteristicDeadOrAliveSize = caracteristicDeadOrAliveSize;
- this.caracteristicGender = caracteristicGender;
- this.caracteristicWeight = caracteristicWeight;
- this.caracteristicPmfmId = caracteristicPmfmId;
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
- newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
-
- newColumnForExport("BatchId", AccidentalCatchExportRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("ReferenceTaxonId", AccidentalBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("ReferenceTaxonName", AccidentalBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
- newColumnForExport("Commentaire", AccidentalBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_FORMATTER);
- newColumnForExport("CaracteristicId", AccidentalCatchExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
- newColumnForExport("CaracteristicValue", AccidentalCatchExportRow.PROPERTY_CARACTERISTIC_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- }
-
- public void prepareRows(PersistenceService persistenceService,
- List<AccidentalCatchExportRow> rows,
- Cruise cruise,
- FishingOperation operation) {
-
- List<AccidentalBatch> observations =
- persistenceService.getAllAccidentalBatch(operation.getId());
-
- if (CollectionUtils.isNotEmpty(observations)) {
- for (AccidentalBatch child : observations) {
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicDeadOrAliveSize,
- child.getDeadOrAlive());
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicGender,
- child.getGender());
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicWeight,
- child.getWeight());
-
- if (child.getLengthStepCaracteristic() != null) {
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicPmfmId,
- child.getLengthStepCaracteristic().getIdAsInt());
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- child.getLengthStepCaracteristic(),
- child.getSize());
- }
-
- CaracteristicMap caracteristics = child.getCaracteristics();
- if (MapUtils.isNotEmpty(caracteristics)) {
- for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- entry.getKey(),
- entry.getValue());
- }
- }
- }
- }
- }
-
- private void addCaracteristicRow(List<AccidentalCatchExportRow> rows,
- Cruise cruise,
- FishingOperation operation,
- AccidentalBatch child,
- Caracteristic caracteristic,
- Serializable caracteristicValue) {
- if (caracteristicValue != null) {
-
- AccidentalCatchExportRow row = new AccidentalCatchExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setBatch(child);
- row.setCaracteristic(caracteristic);
- row.setCaracteristicValue(caracteristicValue);
- rows.add(row);
- }
- }
-}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchModel.java
new file mode 100644
index 0000000..578641c
--- /dev/null
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchModel.java
@@ -0,0 +1,208 @@
+package fr.ifremer.tutti.service.export.generic.csv;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * %%
+ * Copyright (C) 2012 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Cruises;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import fr.ifremer.tutti.service.csv.AbstractTuttiImportExportModel;
+import fr.ifremer.tutti.service.export.generic.GlobalImportContext;
+import fr.ifremer.tutti.service.export.generic.OperationExportContext;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.2
+ */
+public class AccidentalCatchModel extends AbstractTuttiImportExportModel<AccidentalCatchRow> {
+
+ public static AccidentalCatchModel forExport(char separator) {
+
+ AccidentalCatchModel exportModel = new AccidentalCatchModel(separator);
+ exportModel.forExport();
+ return exportModel;
+
+ }
+
+ public static AccidentalCatchModel forImport(char separator, GlobalImportContext globalImportContext) {
+
+ AccidentalCatchModel importModel = new AccidentalCatchModel(separator);
+ importModel.forImport(globalImportContext);
+ return importModel;
+
+ }
+
+ @Override
+ public AccidentalCatchRow newEmptyInstance() {
+
+ AccidentalCatchRow row = new AccidentalCatchRow();
+ row.setCruise(Cruises.newCruise());
+ return row;
+
+ }
+
+ public List<AccidentalCatchRow> getDataToExport(OperationExportContext operationExportContext) {
+
+ List<AccidentalCatchRow> rows = new ArrayList<>();
+
+ List<AccidentalBatch> accidentalBatches = operationExportContext.getAccidentalBatches();
+
+ if (CollectionUtils.isNotEmpty(accidentalBatches)) {
+ for (AccidentalBatch accidentalBatch : accidentalBatches) {
+
+ addAccidentalBatch(operationExportContext, rows, accidentalBatch);
+
+ }
+
+ }
+
+ return rows;
+
+ }
+
+ protected void addAccidentalBatch(OperationExportContext operationExportContext, List<AccidentalCatchRow> rows, AccidentalBatch accidentalBatch) {
+
+ addCaracteristicRow(operationExportContext,
+ rows,
+ accidentalBatch,
+ operationExportContext.getDeadOrAliveCaracteristic(),
+ accidentalBatch.getDeadOrAlive());
+
+ addCaracteristicRow(operationExportContext,
+ rows,
+ accidentalBatch,
+ operationExportContext.getGenderCaracteristic(),
+ accidentalBatch.getGender());
+
+ addCaracteristicRow(operationExportContext,
+ rows,
+ accidentalBatch,
+ operationExportContext.getWeightMeasuredCaracteristic(),
+ accidentalBatch.getWeight());
+
+ if (accidentalBatch.getLengthStepCaracteristic() != null) {
+ addCaracteristicRow(operationExportContext,
+ rows,
+ accidentalBatch,
+ operationExportContext.getPmfmIdCaracteristic(),
+ accidentalBatch.getLengthStepCaracteristic().getIdAsInt());
+
+ addCaracteristicRow(operationExportContext,
+ rows,
+ accidentalBatch,
+ accidentalBatch.getLengthStepCaracteristic(),
+ accidentalBatch.getSize());
+ }
+
+ CaracteristicMap caracteristics = accidentalBatch.getCaracteristics();
+ if (MapUtils.isNotEmpty(caracteristics)) {
+ for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
+ addCaracteristicRow(operationExportContext,
+ rows,
+ accidentalBatch,
+ entry.getKey(),
+ entry.getValue());
+ }
+ }
+
+ }
+
+ protected void addCaracteristicRow(OperationExportContext operationExportContext,
+ List<AccidentalCatchRow> rows,
+ AccidentalBatch accidentalBatch,
+ Caracteristic caracteristic,
+ Serializable caracteristicValue) {
+ if (caracteristicValue != null) {
+
+ AccidentalCatchRow row = new AccidentalCatchRow();
+ row.setCruise(operationExportContext.getCruise());
+ row.setFishingOperation(operationExportContext.getOperation());
+ row.setBatch(accidentalBatch);
+ row.setCaracteristic(caracteristic);
+ row.setCaracteristicValue(caracteristicValue);
+ rows.add(row);
+ }
+ }
+
+ protected AccidentalCatchModel(char separator) {
+ super(separator);
+
+ }
+
+ protected void forExport() {
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
+ newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+
+ newColumnForExport("BatchId", AccidentalCatchRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("ReferenceTaxonId", AccidentalBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("ReferenceTaxonName", AccidentalBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
+ newColumnForExport("Commentaire", AccidentalBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+ newColumnForExport("CaracteristicId", AccidentalCatchRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
+ newColumnForExport("CaracteristicValue", AccidentalCatchRow.PROPERTY_CARACTERISTIC_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+
+ }
+
+ protected void forImport(GlobalImportContext globalImportContext) {
+
+ newMandatoryColumn("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newMandatoryColumn("Serie", Cruise.PROPERTY_PROGRAM, globalImportContext.getProgramParser());
+ newMandatoryColumn("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+
+ newMandatoryColumn("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newMandatoryColumn("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newMandatoryColumn("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newMandatoryColumn("Engin", FishingOperation.PROPERTY_GEAR, globalImportContext.getOptionalGearParser());
+
+ //FIXME What can we do with that ?
+ newMandatoryColumn("BatchId", AccidentalCatchRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+
+ newMandatoryColumn("ReferenceTaxonId", AccidentalBatch.PROPERTY_SPECIES, globalImportContext.getSpeciesParser());
+// newMandatoryColumn("ReferenceTaxonName", AccidentalBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
+ newMandatoryColumn("Commentaire", AccidentalBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+ newMandatoryColumn("CaracteristicId", AccidentalCatchRow.PROPERTY_CARACTERISTIC, globalImportContext.getCaracteristicParser());
+ newMandatoryColumn("CaracteristicValue", AccidentalCatchRow.PROPERTY_CARACTERISTIC_VALUE);
+
+ }
+}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchExportRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchRow.java
similarity index 98%
rename from tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchExportRow.java
rename to tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchRow.java
index 49d1ae9..7d968d2 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchExportRow.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/AccidentalCatchRow.java
@@ -40,7 +40,7 @@ import java.util.Date;
* @author tchemit <chemit(a)codelutin.com>
* @since 2.2
*/
-public class AccidentalCatchExportRow implements Serializable {
+public class AccidentalCatchRow implements Serializable {
public static final String PROPERTY_BATCH = "batch";
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchExportModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchModel.java
similarity index 65%
rename from tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchExportModel.java
rename to tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchModel.java
index 26b6aa9..d8cfcb5 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchExportModel.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchModel.java
@@ -26,6 +26,7 @@ import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Cruises;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
@@ -36,14 +37,17 @@ import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.TuttiCsvUtil;
+import fr.ifremer.tutti.service.csv.AbstractTuttiImportExportModel;
+import fr.ifremer.tutti.service.export.generic.GlobalImportContext;
+import fr.ifremer.tutti.service.export.generic.OperationExportContext;
import fr.ifremer.tutti.util.Numbers;
import fr.ifremer.tutti.util.Weights;
import org.apache.commons.collections4.CollectionUtils;
import org.nuiton.jaxx.application.ApplicationTechnicalException;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -52,78 +56,55 @@ import java.util.List;
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<CatchExportRow> {
+public class CatchModel extends AbstractTuttiImportExportModel<CatchRow> {
public static final String WEIGHT_OR_VOL_TYPE = "Poids";
- protected SampleCategoryModel sampleCategoryModel;
+ public static CatchModel forExport(char separator, SampleCategoryModel sampleCategoryModel, DecoratorService decoratorService) {
- public CatchExportModel(char separator,
- SampleCategoryModel sampleCategoryModel,
- DecoratorService decoratorService) {
- super(separator);
- this.sampleCategoryModel = sampleCategoryModel;
+ CatchModel exportModel = new CatchModel(separator);
+ exportModel.forExport(sampleCategoryModel, decoratorService);
+ return exportModel;
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
- newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
- newColumnForExport("Code_Taxon", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.INTEGER);
- newColumnForExport("Code_Espece_Campagne", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_SURVEY_CODE);
- newColumnForExport("Nom_scientifique", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
- newColumnForExport("Commentaire", SpeciesBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_FORMATTER);
+ }
- for (SampleCategoryModelEntry entry : sampleCategoryModel.getCategory()) {
+ public static CatchModel forImport(char separator, SampleCategoryModel sampleCategoryModel, GlobalImportContext globalImportContext) {
- String headerPrefix = entry.getCode();
- int categoryOrder = entry.getOrder();
- String categoryName = CatchExportRow.SAMPLE_CATEGORY;
- newIndexNullableColumnForExport(headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- newIndexNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName, categoryOrder, ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER);
- newIndexNullableColumnForExport("Tot_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT);
- newIndexNullableColumnForExport("Ech_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT);
- newIndexNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE);
- newNullableColumnForExport("Unite_Volume_Poids_" + headerPrefix, CatchExportRow.BATCH_WEIGHT_UNIT);
- }
+ CatchModel importModel = new CatchModel(separator);
+ importModel.forImport(sampleCategoryModel, globalImportContext);
+ return importModel;
- // mensuration
+ }
+
+ @Override
+ public CatchRow newEmptyInstance() {
+
+ CatchRow row = new CatchRow(false, false);
+ row.setCruise(Cruises.newCruise());
+ return row;
- newNullableColumnForExport("Code_Longueur", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_ID);
- newNullableColumnForExportByDecorator("Libelle_Longueur", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
- newNullableColumnForExport("Taille", CatchExportRow.FREQUENCY_LENGTH_STEP, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("NumOrdre_Taille_H2", CatchExportRow.FREQUENCY_RANK_ORDER, TuttiCsvUtil.INTEGER);
- newNullableColumnForExport("Poids_Classe_Taille", CatchExportRow.FREQUENCY_WEIGHT, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Unite_Taille", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_UNIT);
- newNullableColumnForExport("Precision_Mesure", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_PRECISION, TuttiCsvUtil.FLOAT);
- newNullableColumnForExport("Nbr", CatchExportRow.BATCH_NUMBER, TuttiCsvUtil.INTEGER);
-
- newColumnForExport("Poids_Reference", CatchExportRow.REFERENCE_WEIGHT, TuttiCsvUtil.PRIMITIVE_FLOAT);
- newColumnForExport("Coef_Elev_Espece_Capture", CatchExportRow.RAISING_FACTOR, TuttiCsvUtil.PRIMITIVE_FLOAT);
- newColumnForExport("Coef_Final_Elevation", CatchExportRow.FINAL_RAISING_FACTOR, TuttiCsvUtil.PRIMITIVE_FLOAT);
}
- public void prepareRows(PersistenceService persistenceService,
- List<CatchExportRow> rows,
- Cruise cruise,
- FishingOperation operation,
- BatchContainer<SpeciesBatch> rootSpeciesBatch,
- BatchContainer<BenthosBatch> rootBenthosBatch,
- Float speciesCatchRaisingFactor,
- Float benthosCatchRaisingFactor) {
+ public List<CatchRow> getDataToExport(OperationExportContext operationExportContext,
+ Float speciesCatchRaisingFactor,
+ Float benthosCatchRaisingFactor) {
+
+ List<CatchRow> rows = new ArrayList<>();
- Caracteristic weightMeasuredCaracteristic = persistenceService.getWeightMeasuredCaracteristic();
+ BatchContainer<SpeciesBatch> rootSpeciesBatch = operationExportContext.getRootSpeciesBatch();
+
+ BatchContainer<BenthosBatch> rootBenthosBatch = operationExportContext.getRootBenthosBatch();
+
+ Caracteristic weightMeasuredCaracteristic = operationExportContext.getWeightMeasuredCaracteristic();
String batchWeightUnit = weightMeasuredCaracteristic.getUnit();
for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) {
- boolean vracBatch = persistenceService.isVracBatch(speciesBatch);
+ boolean vracBatch = operationExportContext.isVracBatch(speciesBatch);
- CatchExportRow row = new CatchExportRow(vracBatch, false);
- row.setCruise(cruise);
- row.setFishingOperation(operation);
+ CatchRow row = new CatchRow(vracBatch, false);
+ row.setCruise(operationExportContext.getCruise());
+ row.setFishingOperation(operationExportContext.getOperation());
row.setSpecies(speciesBatch.getSpecies());
row.setBatchWeightUnit(batchWeightUnit);
@@ -141,7 +122,7 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
float totalBatchWeight = batchWeight == null ? 0 : raisingFactor * batchWeight;
- addSpeciesBatch(persistenceService,
+ addSpeciesBatch(operationExportContext,
row,
rows,
speciesBatch,
@@ -151,11 +132,11 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
for (BenthosBatch benthosBatch : rootBenthosBatch.getChildren()) {
- boolean vracBatch = persistenceService.isVracBatch(benthosBatch);
+ boolean vracBatch = operationExportContext.isVracBatch(benthosBatch);
- CatchExportRow row = new CatchExportRow(vracBatch, true);
- row.setCruise(cruise);
- row.setFishingOperation(operation);
+ CatchRow row = new CatchRow(vracBatch, true);
+ row.setCruise(operationExportContext.getCruise());
+ row.setFishingOperation(operationExportContext.getOperation());
row.setSpecies(benthosBatch.getSpecies());
row.setBatchWeightUnit(batchWeightUnit);
@@ -173,7 +154,7 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
float totalBatchWeight = batchWeight == null ? 0 : raisingFactor * batchWeight;
- addBenthosBatch(persistenceService,
+ addBenthosBatch(operationExportContext,
row,
rows,
benthosBatch,
@@ -184,7 +165,7 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
// compute final raising factor
// see http://forge.codelutin.com/issues/4135
// see http://forge.codelutin.com/issues/5110
- for (CatchExportRow row : rows) {
+ for (CatchRow row : rows) {
float finalRaisingFactor;
@@ -220,11 +201,14 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
}
row.setFinalRaisingFactor(finalRaisingFactor);
}
+
+ return rows;
+
}
- protected void addSpeciesBatch(PersistenceService persistenceService,
- CatchExportRow currentRow,
- List<CatchExportRow> rows,
+ protected void addSpeciesBatch(OperationExportContext operationExportContext,
+ CatchRow currentRow,
+ List<CatchRow> rows,
SpeciesBatch speciesBatch,
float totalBatchWeight) {
@@ -235,7 +219,8 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
Integer rankOrder = speciesBatch.getRankOrder();
- addBatchSampleCategory(currentRow,
+ addBatchSampleCategory(operationExportContext.getSampleCategoryModel(),
+ currentRow,
speciesBatch.getSampleCategoryId(),
speciesBatch.getSampleCategoryValue(),
speciesBatch.getSampleCategoryWeight(),
@@ -249,13 +234,13 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
// on a leaf, get frequencies
List<SpeciesBatchFrequency> speciesBatchFrequency =
- persistenceService.getAllSpeciesBatchFrequency(speciesBatch.getId());
+ operationExportContext.getAllSpeciesBatchFrequency(speciesBatch.getId());
if (CollectionUtils.isEmpty(speciesBatchFrequency)) {
// no frequency
- CatchExportRow row = currentRow.copy();
+ CatchRow row = currentRow.copy();
// Get reference weight
@@ -296,7 +281,7 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
}
for (SpeciesBatchFrequency batchFrequency : speciesBatchFrequency) {
- CatchExportRow row = currentRow.copy();
+ CatchRow row = currentRow.copy();
row.setSpeciesFrequency(batchFrequency);
rows.add(row);
@@ -318,8 +303,8 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
for (SpeciesBatch childBatch : speciesBatch.getChildBatchs()) {
// always use a copy, otherwise sample categories can be shared by brothers
- CatchExportRow childRow = currentRow.copy();
- addSpeciesBatch(persistenceService,
+ CatchRow childRow = currentRow.copy();
+ addSpeciesBatch(operationExportContext,
childRow,
rows,
childBatch,
@@ -343,9 +328,9 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
}
}
- protected void addBenthosBatch(PersistenceService persistenceService,
- CatchExportRow currentRow,
- List<CatchExportRow> rows,
+ protected void addBenthosBatch(OperationExportContext operationExportContext,
+ CatchRow currentRow,
+ List<CatchRow> rows,
BenthosBatch benthosBatch,
float totalBatchWeight) {
@@ -367,7 +352,8 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
rankOrder += 1000;
}
- addBatchSampleCategory(currentRow,
+ addBatchSampleCategory(operationExportContext.getSampleCategoryModel(),
+ currentRow,
benthosBatch.getSampleCategoryId(),
benthosBatch.getSampleCategoryValue(),
benthosBatch.getSampleCategoryWeight(),
@@ -381,13 +367,13 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
// on a leaf, get frequencies
List<BenthosBatchFrequency> benthosBatchFrequency =
- persistenceService.getAllBenthosBatchFrequency(benthosBatch.getId());
+ operationExportContext.getAllBenthosBatchFrequency(benthosBatch.getId());
if (CollectionUtils.isEmpty(benthosBatchFrequency)) {
// no frequency
- CatchExportRow row = currentRow.copy();
+ CatchRow row = currentRow.copy();
// Get reference weight
@@ -428,7 +414,7 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
}
for (BenthosBatchFrequency batchFrequency : benthosBatchFrequency) {
- CatchExportRow row = currentRow.copy();
+ CatchRow row = currentRow.copy();
row.setBenthosFrequency(batchFrequency);
rows.add(row);
@@ -450,8 +436,8 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
for (BenthosBatch childBatch : benthosBatch.getChildBatchs()) {
// always use a copy, otherwise sample categories can be shared by brothers
- CatchExportRow childRow = currentRow.copy();
- addBenthosBatch(persistenceService,
+ CatchRow childRow = currentRow.copy();
+ addBenthosBatch(operationExportContext,
childRow,
rows,
childBatch,
@@ -471,14 +457,13 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
}
}
- protected void setRaisingFactor(CatchExportRow row,
- float totalBatchWeight,
- Float referenceWeight) {
+ protected void setRaisingFactor(CatchRow row, float totalBatchWeight, Float referenceWeight) {
row.setReferenceWeight(referenceWeight);
row.setRaisingFactor(referenceWeight == null ? 1.0f : (totalBatchWeight / referenceWeight));
}
- protected void addBatchSampleCategory(CatchExportRow currentRow,
+ protected void addBatchSampleCategory(SampleCategoryModel sampleCategoryModel,
+ CatchRow currentRow,
Integer sampleCategoryId,
Serializable sampleCategoryValue,
Float sampleCategoryWeight,
@@ -490,8 +475,7 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
ExportSampleCategory<Serializable> sampleCategory =
new ExportSampleCategory<>();
- SampleCategoryModelEntry categoryById =
- sampleCategoryModel.getCategoryById(sampleCategoryId);
+ SampleCategoryModelEntry categoryById = sampleCategoryModel.getCategoryById(sampleCategoryId);
sampleCategory.setCategoryDef(categoryById);
sampleCategory.setCategoryValue(sampleCategoryValue);
sampleCategory.setCategoryWeight(sampleCategoryWeight);
@@ -503,4 +487,99 @@ public class CatchExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<Catc
currentRow.addSampleCategory(sampleCategory);
}
+
+ protected CatchModel(char separator) {
+ super(separator);
+ }
+
+ protected void forExport(SampleCategoryModel sampleCategoryModel, DecoratorService decoratorService) {
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
+ newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newColumnForExport("Code_Taxon", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Code_Espece_Campagne", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_SURVEY_CODE);
+ newColumnForExport("Nom_scientifique", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
+ newColumnForExport("Commentaire", SpeciesBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+
+ for (SampleCategoryModelEntry entry : sampleCategoryModel.getCategory()) {
+
+ String headerPrefix = entry.getCode();
+ int categoryOrder = entry.getOrder();
+ String categoryName = CatchRow.SAMPLE_CATEGORY;
+ newIndexNullableColumnForExport(headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ newIndexNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName, categoryOrder, ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER);
+ newIndexNullableColumnForExport("Tot_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT);
+ newIndexNullableColumnForExport("Ech_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT);
+// newIndexNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE);
+ newNullableColumnForExport("Unite_Volume_Poids_" + headerPrefix, CatchRow.BATCH_WEIGHT_UNIT);
+ }
+
+ // mensuration
+
+ newNullableColumnForExport("Code_Longueur", CatchRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_ID);
+ newNullableColumnForExportByDecorator("Libelle_Longueur", CatchRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
+ newNullableColumnForExport("Taille", CatchRow.FREQUENCY_LENGTH_STEP, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("NumOrdre_Taille_H2", CatchRow.FREQUENCY_RANK_ORDER, TuttiCsvUtil.INTEGER);
+ newNullableColumnForExport("Poids_Classe_Taille", CatchRow.FREQUENCY_WEIGHT, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Unite_Taille", CatchRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_UNIT);
+ newNullableColumnForExport("Precision_Mesure", CatchRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_PRECISION, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Nbr", CatchRow.BATCH_NUMBER, TuttiCsvUtil.INTEGER);
+
+ newColumnForExport("Poids_Reference", CatchRow.REFERENCE_WEIGHT, TuttiCsvUtil.PRIMITIVE_FLOAT);
+ newColumnForExport("Coef_Elev_Espece_Capture", CatchRow.RAISING_FACTOR, TuttiCsvUtil.PRIMITIVE_FLOAT);
+ newColumnForExport("Coef_Final_Elevation", CatchRow.FINAL_RAISING_FACTOR, TuttiCsvUtil.PRIMITIVE_FLOAT);
+
+ }
+
+ protected void forImport(SampleCategoryModel sampleCategoryModel, GlobalImportContext globalImportContext) {
+
+ newMandatoryColumn("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newMandatoryColumn("Serie", Cruise.PROPERTY_PROGRAM, globalImportContext.getProgramParser());
+ newMandatoryColumn("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+
+ newMandatoryColumn("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newMandatoryColumn("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newMandatoryColumn("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newMandatoryColumn("Engin", FishingOperation.PROPERTY_GEAR, globalImportContext.getOptionalGearParser());
+
+ newMandatoryColumn("Code_Taxon", SpeciesBatch.PROPERTY_SPECIES, globalImportContext.getSpeciesParser());
+// newColumnForExport("Code_Espece_Campagne", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_SURVEY_CODE);
+// newColumnForExport("Nom_scientifique", SpeciesBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
+ newMandatoryColumn("Commentaire", SpeciesBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+
+ //FIXME
+ for (SampleCategoryModelEntry entry : sampleCategoryModel.getCategory()) {
+
+ String headerPrefix = entry.getCode();
+ int categoryOrder = entry.getOrder();
+ String categoryName = CatchRow.SAMPLE_CATEGORY;
+ newIndexNullableColumnForExport(headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+ newIndexNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName, categoryOrder, ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER);
+ newIndexNullableColumnForExport("Tot_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT);
+ newIndexNullableColumnForExport("Ech_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT);
+// newIndexNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE);
+// newNullableColumnForExport("Unite_Volume_Poids_" + headerPrefix, CatchRow.BATCH_WEIGHT_UNIT);
+ }
+
+ // mensuration
+
+ newNullableColumnForExport("Code_Longueur", CatchRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_ID);
+// newNullableColumnForExportByDecorator("Libelle_Longueur", CatchRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
+ newNullableColumnForExport("Taille", CatchRow.FREQUENCY_LENGTH_STEP, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("NumOrdre_Taille_H2", CatchRow.FREQUENCY_RANK_ORDER, TuttiCsvUtil.INTEGER);
+ newNullableColumnForExport("Poids_Classe_Taille", CatchRow.FREQUENCY_WEIGHT, TuttiCsvUtil.FLOAT);
+// newNullableColumnForExport("Unite_Taille", CatchRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_UNIT);
+// newNullableColumnForExport("Precision_Mesure", CatchRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_PRECISION, TuttiCsvUtil.FLOAT);
+ newNullableColumnForExport("Nbr", CatchRow.BATCH_NUMBER, TuttiCsvUtil.INTEGER);
+
+// newColumnForExport("Poids_Reference", CatchRow.REFERENCE_WEIGHT, TuttiCsvUtil.PRIMITIVE_FLOAT);
+// newColumnForExport("Coef_Elev_Espece_Capture", CatchRow.RAISING_FACTOR, TuttiCsvUtil.PRIMITIVE_FLOAT);
+// newColumnForExport("Coef_Final_Elevation", CatchRow.FINAL_RAISING_FACTOR, TuttiCsvUtil.PRIMITIVE_FLOAT);
+
+ }
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchExportRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchRow.java
similarity index 96%
rename from tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchExportRow.java
rename to tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchRow.java
index 4581879..67ced1c 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchExportRow.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/CatchRow.java
@@ -47,12 +47,12 @@ import java.util.List;
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class CatchExportRow implements Serializable {
+public class CatchRow implements Serializable {
private static final long serialVersionUID = 1L;
/** Logger. */
- private static final Log log = LogFactory.getLog(CatchExportRow.class);
+ private static final Log log = LogFactory.getLog(CatchRow.class);
public static final String FREQUENCY_LENGTH_STEP = "frequency.lengthStep";
@@ -106,7 +106,7 @@ public class CatchExportRow implements Serializable {
protected final List<String> comment = new ArrayList<>();
- public CatchExportRow(boolean vrac, boolean benthosRow) {
+ public CatchRow(boolean vrac, boolean benthosRow) {
this.vrac = vrac;
this.benthosRow = benthosRow;
}
@@ -239,8 +239,8 @@ public class CatchExportRow implements Serializable {
return benthosRow;
}
- public CatchExportRow copy() {
- CatchExportRow result = new CatchExportRow(vrac, benthosRow);
+ public CatchRow copy() {
+ CatchRow result = new CatchRow(vrac, benthosRow);
result.setCruise(cruise);
result.setFishingOperation(fishingOperation);
result.sampleCategory.addAll(sampleCategory);
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicExportModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicExportModel.java
deleted file mode 100644
index 5532159..0000000
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicExportModel.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package fr.ifremer.tutti.service.export.generic.csv;
-
-/*
- * #%L
- * Tutti :: Service
- * %%
- * Copyright (C) 2012 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-/**
- * To export gear caracteristics.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.3.2
- */
-public class GearCaracteristicExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<GearCaracteristicExportRow> {
-
- public GearCaracteristicExportModel(char separator, DecoratorService decoratorService) {
- super(separator);
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Engin", GearCaracteristicExportRow.PROPERTY_GEAR, Gear.PROPERTY_NAME);
- newColumnForExport("Code_PMFM", GearCaracteristicExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
- newColumnForExportByDecorator("Libelle_PMFM", GearCaracteristicExportRow.PROPERTY_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
- newColumnForExport("Valeur", GearCaracteristicExportRow.PROPERTY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- }
-
- public void prepareRows(List<GearCaracteristicExportRow> rows, Cruise cruise,
- Gear gear) {
- CaracteristicMap caracteristics = gear.getCaracteristics();
- if (caracteristics != null) {
- for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
- Caracteristic caracteristic = entry.getKey();
- Serializable value = entry.getValue();
- GearCaracteristicExportRow row = new GearCaracteristicExportRow();
- row.setCruise(cruise);
- row.setGear(gear);
- row.setCaracteristic(caracteristic);
- row.setValue(value);
- rows.add(row);
- }
- }
- }
-
-}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicModel.java
new file mode 100644
index 0000000..9235fa6
--- /dev/null
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicModel.java
@@ -0,0 +1,123 @@
+package fr.ifremer.tutti.service.export.generic.csv;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * %%
+ * Copyright (C) 2012 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Cruises;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import fr.ifremer.tutti.service.csv.AbstractTuttiImportExportModel;
+import fr.ifremer.tutti.service.export.generic.GlobalImportContext;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * To export gear caracteristics.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.3.2
+ */
+public class GearCaracteristicModel extends AbstractTuttiImportExportModel<GearCaracteristicRow> {
+
+ public static GearCaracteristicModel forExport(char separator, DecoratorService decoratorService) {
+
+ GearCaracteristicModel exportModel = new GearCaracteristicModel(separator);
+ exportModel.forExport(decoratorService);
+ return exportModel;
+
+ }
+
+ public static GearCaracteristicModel forImport(char separator, GlobalImportContext globalImportContext) {
+
+ GearCaracteristicModel importModel = new GearCaracteristicModel(separator);
+ importModel.forImport(globalImportContext);
+ return importModel;
+
+ }
+
+ protected GearCaracteristicModel(char separator) {
+ super(separator);
+ }
+
+ protected void forExport(DecoratorService decoratorService) {
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newColumnForExport("Engin", GearCaracteristicRow.PROPERTY_GEAR, Gear.PROPERTY_NAME);
+ newColumnForExport("Code_PMFM", GearCaracteristicRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
+ newColumnForExportByDecorator("Libelle_PMFM", GearCaracteristicRow.PROPERTY_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
+ newColumnForExport("Valeur", GearCaracteristicRow.PROPERTY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+
+ }
+
+ protected void forImport(GlobalImportContext globalImportContext) {
+
+ newMandatoryColumn("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newMandatoryColumn("Serie", Cruise.PROPERTY_PROGRAM, globalImportContext.getProgramParser());
+ newMandatoryColumn("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+
+ newMandatoryColumn("Engin", GearCaracteristicRow.PROPERTY_GEAR, globalImportContext.getMandatoryGearParser());
+ newMandatoryColumn("Code_PMFM", GearCaracteristicRow.PROPERTY_CARACTERISTIC, globalImportContext.getCaracteristicParser());
+ newMandatoryColumn("Valeur", GearCaracteristicRow.PROPERTY_VALUE);
+
+ }
+
+ public List<GearCaracteristicRow> getDataToExport(Cruise cruise, Gear gear) {
+
+ List<GearCaracteristicRow> rows = new ArrayList<>();
+ CaracteristicMap caracteristics = gear.getCaracteristics();
+ if (caracteristics != null) {
+ for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
+ Caracteristic caracteristic = entry.getKey();
+ Serializable value = entry.getValue();
+ GearCaracteristicRow row = new GearCaracteristicRow();
+ row.setCruise(cruise);
+ row.setGear(gear);
+ row.setCaracteristic(caracteristic);
+ row.setValue(value);
+ rows.add(row);
+ }
+ }
+
+ return rows;
+
+ }
+
+ @Override
+ public GearCaracteristicRow newEmptyInstance() {
+
+ GearCaracteristicRow row = new GearCaracteristicRow();
+ Cruise cruise = Cruises.newCruise();
+ row.setCruise(cruise);
+ return row;
+
+ }
+}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicExportRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicRow.java
similarity index 85%
rename from tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicExportRow.java
rename to tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicRow.java
index 8ac6ad7..08ca9b2 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicExportRow.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/GearCaracteristicRow.java
@@ -36,7 +36,7 @@ import java.util.Date;
* @author tchemit <chemit(a)codelutin.com>
* @since 2.3.2
*/
-public class GearCaracteristicExportRow implements Serializable {
+public class GearCaracteristicRow implements Serializable {
private static final long serialVersionUID = 1L;
@@ -70,6 +70,22 @@ public class GearCaracteristicExportRow implements Serializable {
this.value = value;
}
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public void setBeginDate(Date beginDate) {
+ cruise.setBeginDate(beginDate);
+ }
+
+ public void setSurveyPart(String surveyPart) {
+ cruise.setSurveyPart(surveyPart);
+ }
+
+ public void setProgram(Program program) {
+ cruise.setProgram(program);
+ }
+
public Date getBeginDate() {
return cruise.getBeginDate();
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationExportModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationExportModel.java
deleted file mode 100644
index bc74240..0000000
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationExportModel.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package fr.ifremer.tutti.service.export.generic.csv;
-
-/*
- * #%L
- * Tutti :: Service
- * %%
- * Copyright (C) 2012 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.MapUtils;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Model of a individual observation export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.1
- */
-public class IndividualObservationExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<IndividualObservationExportRow> {
-
- protected final Caracteristic caracteristicWeight;
-
- protected final Caracteristic caracteristicPmfmId;
-
- public IndividualObservationExportModel(
- char separator,
- Caracteristic caracteristicWeight,
- Caracteristic caracteristicPmfmId) {
- super(separator);
-
- this.caracteristicWeight = caracteristicWeight;
- this.caracteristicPmfmId = caracteristicPmfmId;
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
- newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
-
- newColumnForExport("BatchId", IndividualObservationExportRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("ReferenceTaxonId", IndividualObservationBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("ReferenceTaxonName", IndividualObservationBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
- newColumnForExport("Commentaire", IndividualObservationBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_FORMATTER);
- newColumnForExport("CaracteristicId", IndividualObservationExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
- newColumnForExport("CaracteristicValue", IndividualObservationExportRow.PROPERTY_CARACTERISTIC_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- }
-
- public void prepareRows(PersistenceService persistenceService,
- List<IndividualObservationExportRow> rows,
- Cruise cruise,
- FishingOperation operation) {
-
- List<IndividualObservationBatch> observations =
- persistenceService.getAllIndividualObservationBatch(operation.getId());
-
- if (CollectionUtils.isNotEmpty(observations)) {
- for (IndividualObservationBatch child : observations) {
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicWeight,
- child.getWeight());
-
- if (child.getLengthStepCaracteristic() != null) {
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- caracteristicPmfmId,
- child.getLengthStepCaracteristic().getIdAsInt());
-
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- child.getLengthStepCaracteristic(),
- child.getSize());
- }
-
- CaracteristicMap caracteristics = child.getCaracteristics();
- if (MapUtils.isNotEmpty(caracteristics)) {
- for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
- addCaracteristicRow(rows,
- cruise,
- operation,
- child,
- entry.getKey(),
- entry.getValue());
- }
- }
- }
- }
- }
-
- private void addCaracteristicRow(List<IndividualObservationExportRow> rows,
- Cruise cruise,
- FishingOperation operation,
- IndividualObservationBatch child,
- Caracteristic caracteristic,
- Serializable caracteristicValue) {
- if (caracteristicValue != null) {
-
- IndividualObservationExportRow row = new IndividualObservationExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setBatch(child);
- row.setCaracteristic(caracteristic);
- row.setCaracteristicValue(caracteristicValue);
- rows.add(row);
- }
- }
-}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationModel.java
new file mode 100644
index 0000000..b5d7d41
--- /dev/null
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationModel.java
@@ -0,0 +1,193 @@
+package fr.ifremer.tutti.service.export.generic.csv;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * %%
+ * Copyright (C) 2012 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Cruises;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import fr.ifremer.tutti.service.csv.AbstractTuttiImportExportModel;
+import fr.ifremer.tutti.service.export.generic.GlobalImportContext;
+import fr.ifremer.tutti.service.export.generic.OperationExportContext;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Model of a individual observation export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0.1
+ */
+public class IndividualObservationModel extends AbstractTuttiImportExportModel<IndividualObservationRow> {
+
+ public static IndividualObservationModel forExport(char separator) {
+
+ IndividualObservationModel exportModel = new IndividualObservationModel(separator);
+ exportModel.forExport();
+ return exportModel;
+
+ }
+
+ public static IndividualObservationModel forImport(char separator, GlobalImportContext globalImportContext) {
+
+ IndividualObservationModel importModel = new IndividualObservationModel(separator);
+ importModel.forImport(globalImportContext);
+ return importModel;
+
+ }
+
+ @Override
+ public IndividualObservationRow newEmptyInstance() {
+
+ IndividualObservationRow row = new IndividualObservationRow();
+ row.setCruise(Cruises.newCruise());
+ return row;
+
+ }
+
+ public List<IndividualObservationRow> getDataToExport(OperationExportContext operationExportContext) {
+
+ List<IndividualObservationRow> rows = new ArrayList<>();
+ List<IndividualObservationBatch> individualObservations = operationExportContext.getIndividualObservations();
+
+ if (CollectionUtils.isNotEmpty(individualObservations)) {
+ for (IndividualObservationBatch child : individualObservations) {
+
+ addIndividualObservationBatch(operationExportContext, rows, child);
+ }
+ }
+
+ return rows;
+
+ }
+
+ protected void addIndividualObservationBatch(OperationExportContext operationExportContext,
+ List<IndividualObservationRow> rows,
+ IndividualObservationBatch child) {
+
+ addCaracteristicRow(operationExportContext,
+ rows,
+ child,
+ operationExportContext.getWeightMeasuredCaracteristic(),
+ child.getWeight());
+
+ if (child.getLengthStepCaracteristic() != null) {
+ addCaracteristicRow(operationExportContext,
+ rows,
+ child,
+ operationExportContext.getPmfmIdCaracteristic(),
+ child.getLengthStepCaracteristic().getIdAsInt());
+
+ addCaracteristicRow(operationExportContext,
+ rows,
+ child,
+ child.getLengthStepCaracteristic(),
+ child.getSize());
+ }
+
+ CaracteristicMap caracteristics = child.getCaracteristics();
+ if (MapUtils.isNotEmpty(caracteristics)) {
+ for (Map.Entry<Caracteristic, Serializable> entry : caracteristics.entrySet()) {
+ addCaracteristicRow(operationExportContext,
+ rows,
+ child,
+ entry.getKey(),
+ entry.getValue());
+ }
+ }
+ }
+
+ protected void addCaracteristicRow(OperationExportContext operationExportContext,
+ List<IndividualObservationRow> rows,
+ IndividualObservationBatch child,
+ Caracteristic caracteristic,
+ Serializable caracteristicValue) {
+ if (caracteristicValue != null) {
+
+ IndividualObservationRow row = new IndividualObservationRow();
+ row.setCruise(operationExportContext.getCruise());
+ row.setFishingOperation(operationExportContext.getOperation());
+ row.setBatch(child);
+ row.setCaracteristic(caracteristic);
+ row.setCaracteristicValue(caracteristicValue);
+ rows.add(row);
+ }
+ }
+
+ protected IndividualObservationModel(char separator) {
+ super(separator);
+ }
+
+ protected void forExport() {
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
+ newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+
+ newColumnForExport("BatchId", IndividualObservationRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("ReferenceTaxonId", IndividualObservationBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("ReferenceTaxonName", IndividualObservationBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
+ newColumnForExport("Commentaire", IndividualObservationBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+ newColumnForExport("CaracteristicId", IndividualObservationRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
+ newColumnForExport("CaracteristicValue", IndividualObservationRow.PROPERTY_CARACTERISTIC_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+
+ }
+
+ protected void forImport(GlobalImportContext globalImportContext) {
+
+ newMandatoryColumn("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newMandatoryColumn("Serie", Cruise.PROPERTY_PROGRAM, globalImportContext.getProgramParser());
+ newMandatoryColumn("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+
+ newMandatoryColumn("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newMandatoryColumn("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newMandatoryColumn("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newMandatoryColumn("Engin", FishingOperation.PROPERTY_GEAR, globalImportContext.getOptionalGearParser());
+
+ //FIXME What can we do with that ?
+ newMandatoryColumn("BatchId", IndividualObservationRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+
+ newMandatoryColumn("ReferenceTaxonId", IndividualObservationBatch.PROPERTY_SPECIES, globalImportContext.getSpeciesParser());
+// newMandatoryColumn("ReferenceTaxonName", IndividualObservationBatch.PROPERTY_SPECIES + "." + Species.PROPERTY_NAME);
+ newMandatoryColumn("Commentaire", IndividualObservationBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+ newMandatoryColumn("CaracteristicId", IndividualObservationRow.PROPERTY_CARACTERISTIC, globalImportContext.getCaracteristicParser());
+ newMandatoryColumn("CaracteristicValue", IndividualObservationRow.PROPERTY_CARACTERISTIC_VALUE);
+
+ }
+
+}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationExportRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationRow.java
similarity index 98%
rename from tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationExportRow.java
rename to tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationRow.java
index cb2123f..85fa2a8 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationExportRow.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/IndividualObservationRow.java
@@ -40,7 +40,7 @@ import java.util.Date;
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0.1
*/
-public class IndividualObservationExportRow implements Serializable {
+public class IndividualObservationRow implements Serializable {
public static final String PROPERTY_BATCH = "batch";
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterExportModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterModel.java
similarity index 50%
rename from tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterExportModel.java
rename to tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterModel.java
index 5ebea80..3c22c72 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterExportModel.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterModel.java
@@ -24,14 +24,18 @@ package fr.ifremer.tutti.service.export.generic.csv;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Cruises;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.TuttiCsvUtil;
+import fr.ifremer.tutti.service.csv.AbstractTuttiImportExportModel;
+import fr.ifremer.tutti.service.export.generic.GlobalImportContext;
+import fr.ifremer.tutti.service.export.generic.OperationExportContext;
import org.apache.commons.collections4.CollectionUtils;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -40,43 +44,93 @@ import java.util.List;
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0.1
*/
-public class MarineLitterExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<MarineLitterExportRow> {
+public class MarineLitterModel extends AbstractTuttiImportExportModel<MarineLitterRow> {
- public MarineLitterExportModel(char separator) {
+ public static MarineLitterModel forExport(char separator) {
+
+ MarineLitterModel exportModel = new MarineLitterModel(separator);
+ exportModel.forExport();
+ return exportModel;
+
+ }
+
+ public static MarineLitterModel forImport(char separator, GlobalImportContext globalImportContext) {
+
+ MarineLitterModel importModel = new MarineLitterModel(separator);
+ importModel.forImport(globalImportContext);
+ return importModel;
+
+ }
+
+ @Override
+ public MarineLitterRow newEmptyInstance() {
+
+ MarineLitterRow row = new MarineLitterRow();
+ row.setCruise(Cruises.newCruise());
+ return row;
+
+ }
+
+ public List<MarineLitterRow> getDataToExport(OperationExportContext operationExportContext) {
+
+ List<MarineLitterRow> rows = new ArrayList<>();
+
+ BatchContainer<MarineLitterBatch> rootMarineLitterBatch = operationExportContext.getRootMarineLitterBatch();
+
+ List<MarineLitterBatch> children = rootMarineLitterBatch.getChildren();
+ if (CollectionUtils.isNotEmpty(children)) {
+ for (MarineLitterBatch child : children) {
+ MarineLitterRow row = new MarineLitterRow();
+ row.setCruise(operationExportContext.getCruise());
+ row.setFishingOperation(operationExportContext.getOperation());
+ row.setBatch(child);
+ rows.add(row);
+ }
+ }
+
+ return rows;
+
+ }
+
+ protected MarineLitterModel(char separator) {
super(separator);
+ }
+
+ protected void forExport() {
newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
+
newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
newColumnForExport("MarineLitterCategory", MarineLitterBatch.PROPERTY_MARINE_LITTER_CATEGORY, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
newColumnForExport("MarineLitterSizeCategory", MarineLitterBatch.PROPERTY_MARINE_LITTER_SIZE_CATEGORY, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
newColumnForExport("Number", MarineLitterBatch.PROPERTY_NUMBER, TuttiCsvUtil.INTEGER);
newColumnForExport("Weight", MarineLitterBatch.PROPERTY_WEIGHT, TuttiCsvUtil.FLOAT);
- newColumnForExport("Commentaire", MarineLitterBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_FORMATTER);
+ newColumnForExport("Commentaire", MarineLitterBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+
}
- public void prepareRows(PersistenceService persistenceService,
- List<MarineLitterExportRow> rows,
- Cruise cruise,
- FishingOperation operation) {
+ protected void forImport(GlobalImportContext globalImportContext) {
- BatchContainer<MarineLitterBatch> rootMarineLitterBatch =
- persistenceService.getRootMarineLitterBatch(operation.getId());
+ newMandatoryColumn("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newMandatoryColumn("Serie", Cruise.PROPERTY_PROGRAM, globalImportContext.getProgramParser());
+ newMandatoryColumn("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+
+ newMandatoryColumn("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newMandatoryColumn("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newMandatoryColumn("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newMandatoryColumn("Engin", FishingOperation.PROPERTY_GEAR, globalImportContext.getOptionalGearParser());
+
+ newMandatoryColumn("MarineLitterCategory", MarineLitterBatch.PROPERTY_MARINE_LITTER_CATEGORY, globalImportContext.getCaracteristicParser());
+ newMandatoryColumn("MarineLitterSizeCategory", MarineLitterBatch.PROPERTY_MARINE_LITTER_SIZE_CATEGORY, globalImportContext.getCaracteristicParser());
+ newMandatoryColumn("Number", MarineLitterBatch.PROPERTY_NUMBER, TuttiCsvUtil.INTEGER);
+ newMandatoryColumn("Weight", MarineLitterBatch.PROPERTY_WEIGHT, TuttiCsvUtil.FLOAT);
+ newMandatoryColumn("Commentaire", MarineLitterBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
- List<MarineLitterBatch> children = rootMarineLitterBatch.getChildren();
- if (CollectionUtils.isNotEmpty(children)) {
- for (MarineLitterBatch child : children) {
- MarineLitterExportRow row = new MarineLitterExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setBatch(child);
- rows.add(row);
- }
- }
}
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterExportRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterRow.java
similarity index 98%
rename from tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterExportRow.java
rename to tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterRow.java
index 8c720fd..a78accd 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterExportRow.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/MarineLitterRow.java
@@ -39,7 +39,7 @@ import java.util.Date;
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0.1
*/
-public class MarineLitterExportRow implements Serializable {
+public class MarineLitterRow implements Serializable {
public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight";
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationExportModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationExportModel.java
deleted file mode 100644
index f3ab656..0000000
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationExportModel.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package fr.ifremer.tutti.service.export.generic.csv;
-
-/*
- * #%L
- * Tutti :: Service
- * %%
- * Copyright (C) 2012 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-import org.nuiton.decorator.Decorator;
-
-import java.util.List;
-
-/**
- * Model of a operation export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class OperationExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<OperationExportRow> {
-
- public OperationExportModel(char separator, Decorator<Vessel> vesselDecorator) {
- super(separator);
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
-
- newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
- newColumnForExport("Navire", FishingOperation.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
- newColumnForExport("DateDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
- newColumnForExport("LatDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LATITUDE, TuttiCsvUtil.FLOAT);
- newColumnForExport("LongDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LONGITUDE, TuttiCsvUtil.FLOAT);
- newColumnForExport("DateFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
- newColumnForExport("LatFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_LATITUDE, TuttiCsvUtil.FLOAT);
- newColumnForExport("LongFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_LONGITUDE, TuttiCsvUtil.FLOAT);
- newColumnForExport("Duree", OperationExportRow.PROPERTY_DURATION);
- newColumnForExport("Strate", FishingOperation.PROPERTY_STRATA, TuttiLocation.PROPERTY_NAME, "NA");
- newColumnForExport("Sous_Strate", FishingOperation.PROPERTY_SUB_STRATA, TuttiLocation.PROPERTY_NAME, "NA");
- newColumnForExport("Localite", FishingOperation.PROPERTY_LOCATION, TuttiLocation.PROPERTY_NAME, "NA");
- newColumnForExport("Validite_OP", FishingOperation.PROPERTY_FISHING_OPERATION_VALID, TuttiCsvUtil.BOOLEAN);
- newColumnForExport("Rectiligne", FishingOperation.PROPERTY_FISHING_OPERATION_RECTILIGNE, TuttiCsvUtil.BOOLEAN);
- newColumnForExport("Distance", FishingOperation.PROPERTY_TRAWL_DISTANCE, TuttiCsvUtil.INTEGER_NULL_TO_9);
- newColumnForExport("Saisisseur", FishingOperation.PROPERTY_RECORDER_PERSON, TuttiCsvUtil.LIST_PERSON_FORMATTER);
- newColumnForExport("Navire_Associe", FishingOperation.PROPERTY_SECONDARY_VESSEL, TuttiCsvUtil.newListVesselFormatter(vesselDecorator));
- newColumnForExport("Commentaire", FishingOperation.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_FORMATTER);
-
- newNullableColumnForExport("Poids_Total", OperationExportRow.PROPERTY_CATCH_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Vrac", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Vrac_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_HorsVrac", OperationExportRow.PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_HorsVrac_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Non_Trie", OperationExportRow.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Non_Trie_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Tremis", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Tremis_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Carroussel", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Carroussel_Calcule", OperationExportRow.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece", OperationExportRow.PROPERTY_SPECIES_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Espece_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece_Vrac", OperationExportRow.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Espece_Vrac_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece_Vrac_Trie", OperationExportRow.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Espece_Vrac_Trie_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece_HorsVrac", OperationExportRow.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Espece_HorsVrac_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece_Inerte_Trie", OperationExportRow.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Espece_Inerte_Trie_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Espece_Vivant_non_detaille_trie", OperationExportRow.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Espece_Vivant_non_detaille_trie_Calcule", OperationExportRow.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos", OperationExportRow.PROPERTY_BENTHOS_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Benthos_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos_Vrac", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Benthos_Vrac_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos_Vrac_Trie", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Benthos_Vrac_Trie_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos_HorsVrac", OperationExportRow.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Benthos_HorsVrac_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos_Inerte_Trie", OperationExportRow.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Benthos_Inerte_Trie_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Benthos_Vivant_non_detaille_trie", OperationExportRow.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule", OperationExportRow.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
-
- newNullableColumnForExport("Poids_Total_Macro_Dechet", OperationExportRow.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
- newNullableColumnForExport("Poids_Total_Macro_Dechet_Calcule", OperationExportRow.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
- }
-
- public void prepareRows(List<OperationExportRow> rows,
- Cruise cruise,
- FishingOperation operation,
- CatchBatch catchBatch) {
-
- OperationExportRow row = new OperationExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setCatchBatch(catchBatch);
- rows.add(row);
-
- }
-}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationModel.java
new file mode 100644
index 0000000..5091209
--- /dev/null
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationModel.java
@@ -0,0 +1,269 @@
+package fr.ifremer.tutti.service.export.generic.csv;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * %%
+ * Copyright (C) 2012 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatchs;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Cruises;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperations;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import fr.ifremer.tutti.service.csv.AbstractTuttiImportExportModel;
+import fr.ifremer.tutti.service.export.generic.GlobalImportContext;
+import org.nuiton.decorator.Decorator;
+
+/**
+ * Model of a operation export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class OperationModel extends AbstractTuttiImportExportModel<OperationRow> {
+
+ public static OperationModel forExport(char separator, DecoratorService decoratorService) {
+
+ OperationModel exportModel = new OperationModel(separator);
+ exportModel.forExport(decoratorService);
+ return exportModel;
+
+ }
+
+ public static OperationModel forImport(char separator, GlobalImportContext globalImportContext) {
+
+ OperationModel importModel = new OperationModel(separator);
+ importModel.forImport(globalImportContext);
+ return importModel;
+
+ }
+
+ public OperationRow getDataToExport(Cruise cruise, FishingOperation operation, CatchBatch catchBatch) {
+
+ OperationRow row = new OperationRow();
+ row.setCruise(cruise);
+ row.setFishingOperation(operation);
+ row.setCatchBatch(catchBatch);
+
+ return row;
+
+ }
+
+
+ @Override
+ public OperationRow newEmptyInstance() {
+
+ OperationRow row = new OperationRow();
+ row.setCruise(Cruises.newCruise());
+ row.setFishingOperation(FishingOperations.newFishingOperation());
+ row.setCatchBatch(CatchBatchs.newCatchBatch());
+ return row;
+
+ }
+
+ protected OperationModel(char separator) {
+ super(separator);
+
+ }
+
+ protected void forExport(DecoratorService decoratorService) {
+
+ Decorator<Vessel> vesselDecorator = decoratorService.getDecoratorByType(Vessel.class);
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newColumnForExport("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME);
+ newColumnForExport("Navire", FishingOperation.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
+ newColumnForExport("DateDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newColumnForExport("LatDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LATITUDE, TuttiCsvUtil.FLOAT);
+ newColumnForExport("LongDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LONGITUDE, TuttiCsvUtil.FLOAT);
+ newColumnForExport("DateFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newColumnForExport("LatFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_LATITUDE, TuttiCsvUtil.FLOAT);
+ newColumnForExport("LongFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_LONGITUDE, TuttiCsvUtil.FLOAT);
+ newColumnForExport("Duree", OperationRow.PROPERTY_DURATION);
+ newColumnForExport("Strate", FishingOperation.PROPERTY_STRATA, TuttiLocation.PROPERTY_NAME, "NA");
+ newColumnForExport("Sous_Strate", FishingOperation.PROPERTY_SUB_STRATA, TuttiLocation.PROPERTY_NAME, "NA");
+ newColumnForExport("Localite", FishingOperation.PROPERTY_LOCATION, TuttiLocation.PROPERTY_NAME, "NA");
+ newColumnForExport("Validite_OP", FishingOperation.PROPERTY_FISHING_OPERATION_VALID, TuttiCsvUtil.BOOLEAN);
+ newColumnForExport("Rectiligne", FishingOperation.PROPERTY_FISHING_OPERATION_RECTILIGNE, TuttiCsvUtil.BOOLEAN);
+ newColumnForExport("Distance", FishingOperation.PROPERTY_TRAWL_DISTANCE, TuttiCsvUtil.INTEGER_NULL_TO_9);
+ newColumnForExport("Saisisseur", FishingOperation.PROPERTY_RECORDER_PERSON, TuttiCsvUtil.LIST_PERSON_FORMATTER);
+ newColumnForExport("Navire_Associe", FishingOperation.PROPERTY_SECONDARY_VESSEL, TuttiCsvUtil.newListVesselFormatter(vesselDecorator));
+ newColumnForExport("Commentaire", FishingOperation.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+
+ newNullableColumnForExport("Poids_Total", OperationRow.PROPERTY_CATCH_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Vrac", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Vrac_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_HorsVrac", OperationRow.PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_HorsVrac_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Non_Trie", OperationRow.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Non_Trie_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Tremis", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Tremis_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Carroussel", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Carroussel_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece", OperationRow.PROPERTY_SPECIES_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Espece_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece_Vrac", OperationRow.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Espece_Vrac_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece_Vrac_Trie", OperationRow.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Espece_Vrac_Trie_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece_HorsVrac", OperationRow.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Espece_HorsVrac_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece_Inerte_Trie", OperationRow.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Espece_Inerte_Trie_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Espece_Vivant_non_detaille_trie", OperationRow.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Espece_Vivant_non_detaille_trie_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos", OperationRow.PROPERTY_BENTHOS_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Benthos_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos_Vrac", OperationRow.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Benthos_Vrac_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos_Vrac_Trie", OperationRow.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Benthos_Vrac_Trie_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos_HorsVrac", OperationRow.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Benthos_HorsVrac_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos_Inerte_Trie", OperationRow.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Benthos_Inerte_Trie_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Benthos_Vivant_non_detaille_trie", OperationRow.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newNullableColumnForExport("Poids_Total_Macro_Dechet", OperationRow.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+ newNullableColumnForExport("Poids_Total_Macro_Dechet_Calcule", OperationRow.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ }
+
+ protected void forImport(GlobalImportContext globalImportContext) {
+
+ newMandatoryColumn("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newMandatoryColumn("Serie", Cruise.PROPERTY_PROGRAM, globalImportContext.getProgramParser());
+ newMandatoryColumn("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+
+ newMandatoryColumn("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newMandatoryColumn("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newMandatoryColumn("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newMandatoryColumn("Engin", FishingOperation.PROPERTY_GEAR, globalImportContext.getOptionalGearParser());
+
+ newMandatoryColumn("Navire", FishingOperation.PROPERTY_VESSEL, globalImportContext.getVesselParser());
+ newMandatoryColumn("DateDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newMandatoryColumn("LatDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LATITUDE, TuttiCsvUtil.FLOAT);
+ newMandatoryColumn("LongDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LONGITUDE, TuttiCsvUtil.FLOAT);
+ newMandatoryColumn("DateFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newMandatoryColumn("LatFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_LATITUDE, TuttiCsvUtil.FLOAT);
+ newMandatoryColumn("LongFin", FishingOperation.PROPERTY_GEAR_SHOOTING_END_LONGITUDE, TuttiCsvUtil.FLOAT);
+// newColumnForExport("Duree", OperationRow.PROPERTY_DURATION);
+ newMandatoryColumn("Strate", FishingOperation.PROPERTY_STRATA, globalImportContext.getFishingOperationStrataParser());
+ newMandatoryColumn("Sous_Strate", FishingOperation.PROPERTY_SUB_STRATA, globalImportContext.getFishingOperationSubStrataParser());
+ newMandatoryColumn("Localite", FishingOperation.PROPERTY_LOCATION, globalImportContext.getFishingOperationLocationParser());
+ newMandatoryColumn("Validite_OP", FishingOperation.PROPERTY_FISHING_OPERATION_VALID, TuttiCsvUtil.BOOLEAN);
+ newMandatoryColumn("Rectiligne", FishingOperation.PROPERTY_FISHING_OPERATION_RECTILIGNE, TuttiCsvUtil.BOOLEAN);
+ newMandatoryColumn("Distance", FishingOperation.PROPERTY_TRAWL_DISTANCE, TuttiCsvUtil.INTEGER_NULL_TO_9);
+ newMandatoryColumn("Saisisseur", FishingOperation.PROPERTY_RECORDER_PERSON, globalImportContext.getListPersonParser());
+ newMandatoryColumn("Navire_Associe", FishingOperation.PROPERTY_SECONDARY_VESSEL, globalImportContext.getListVesselParser());
+ newMandatoryColumn("Commentaire", FishingOperation.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+
+ newMandatoryColumn("Poids_Total", OperationRow.PROPERTY_CATCH_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newNullableColumnForExport("Poids_Total_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Vrac", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Vrac_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_HorsVrac", OperationRow.PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_HorsVrac_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Non_Trie", OperationRow.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Non_Trie_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Tremis", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Tremis_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_TREMIS_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Carroussel", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Carroussel_Calcule", OperationRow.PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Espece", OperationRow.PROPERTY_SPECIES_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Espece_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Espece_Vrac", OperationRow.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Espece_Vrac_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Espece_Vrac_Trie", OperationRow.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Espece_Vrac_Trie_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Espece_HorsVrac", OperationRow.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Espece_HorsVrac_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Espece_Inerte_Trie", OperationRow.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Espece_Inerte_Trie_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Espece_Vivant_non_detaille_trie", OperationRow.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Espece_Vivant_non_detaille_trie_Calcule", OperationRow.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Benthos", OperationRow.PROPERTY_BENTHOS_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Benthos_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Benthos_Vrac", OperationRow.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Benthos_Vrac_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Benthos_Vrac_Trie", OperationRow.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Benthos_Vrac_Trie_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Benthos_HorsVrac", OperationRow.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Benthos_HorsVrac_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Benthos_Inerte_Trie", OperationRow.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Benthos_Inerte_Trie_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Benthos_Vivant_non_detaille_trie", OperationRow.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newMandatoryColumn("Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule", OperationRow.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ newMandatoryColumn("Poids_Total_Macro_Dechet", OperationRow.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT, TuttiCsvUtil.WEIGHT_NULL_TO_9);
+// newNullableColumnForExport("Poids_Total_Macro_Dechet_Calcule", OperationRow.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT_COMPUTED, TuttiCsvUtil.BOOLEAN);
+
+ }
+}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationExportRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationRow.java
similarity index 85%
rename from tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationExportRow.java
rename to tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationRow.java
index ced47dd..b2cd0d8 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationExportRow.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/OperationRow.java
@@ -45,7 +45,7 @@ import java.util.List;
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class OperationExportRow implements Serializable {
+public class OperationRow implements Serializable {
public static final String PROPERTY_DURATION = "duration";
@@ -73,7 +73,6 @@ public class OperationExportRow implements Serializable {
public static final String PROPERTY_CATCH_TOTAL_REJECTED_WEIGHT_COMPUTED = "catchTotalRejectedWeightComputed";
-
public static final String PROPERTY_SPECIES_TOTAL_WEIGHT = "speciesTotalWeight";
public static final String PROPERTY_SPECIES_TOTAL_WEIGHT_COMPUTED = "speciesTotalWeightComputed";
@@ -146,6 +145,98 @@ public class OperationExportRow implements Serializable {
this.catchBatch = catchBatch;
}
+ public void setBeginDate(Date beginDate) {
+ cruise.setBeginDate(beginDate);
+ }
+
+ public void setSurveyPart(String surveyPart) {
+ cruise.setSurveyPart(surveyPart);
+ }
+
+ public void setProgram(Program program) {
+ cruise.setProgram(program);
+ }
+
+ public void setFishingOperationNumber(Integer fishingOperationNumber) {
+ fishingOperation.setFishingOperationNumber(fishingOperationNumber);
+ }
+
+ public void setStationNumber(String stationNumber) {
+ fishingOperation.setStationNumber(stationNumber);
+ }
+
+ public void setMultirigAggregation(String multirigAggregation) {
+ fishingOperation.setMultirigAggregation(multirigAggregation);
+ }
+
+ public void setSubStrata(TuttiLocation subStrata) {
+ fishingOperation.setSubStrata(subStrata);
+ }
+
+ public void setStrata(TuttiLocation strata) {
+ fishingOperation.setStrata(strata);
+ }
+
+ public void setVessel(Vessel vessel) {
+ fishingOperation.setVessel(vessel);
+ }
+
+ public void setGear(Gear gear) {
+ fishingOperation.setGear(gear);
+ }
+
+ public void setRecorderPerson(List<Person> recorderPerson) {
+ fishingOperation.setRecorderPerson(recorderPerson);
+ }
+
+ public void setLocation(TuttiLocation location) {
+ fishingOperation.setLocation(location);
+ }
+
+ public void setSecondaryVessel(List<Vessel> secondaryVessel) {
+ fishingOperation.setSecondaryVessel(secondaryVessel);
+ }
+
+ public void setComment(String comment) {
+ fishingOperation.setComment(comment);
+ }
+
+ public void setFishingOperationValid(Boolean fishingOperationValid) {
+ fishingOperation.setFishingOperationValid(fishingOperationValid);
+ }
+
+ public void setTrawlDistance(Integer trawlDistance) {
+ fishingOperation.setTrawlDistance(trawlDistance);
+ }
+
+ public void setFishingOperationRectiligne(boolean fishingOperationRectiligne) {
+ fishingOperation.setFishingOperationRectiligne(fishingOperationRectiligne);
+ }
+
+ public void setGearShootingEndDate(Date gearShootingEndDate) {
+ fishingOperation.setGearShootingEndDate(gearShootingEndDate);
+ }
+
+ public void setGearShootingEndLongitude(Float gearShootingEndLongitude) {
+ fishingOperation.setGearShootingEndLongitude(gearShootingEndLongitude);
+ }
+
+ public void setGearShootingEndLatitude(Float gearShootingEndLatitude) {
+ fishingOperation.setGearShootingEndLatitude(gearShootingEndLatitude);
+ }
+
+ public void setGearShootingStartDate(Date gearShootingStartDate) {
+ fishingOperation.setGearShootingStartDate(gearShootingStartDate);
+ }
+
+ public void setGearShootingStartLongitude(Float gearShootingStartLongitude) {
+ fishingOperation.setGearShootingStartLongitude(gearShootingStartLongitude);
+ }
+
+ public void setGearShootingStartLatitude(Float gearShootingStartLatitude) {
+ fishingOperation.setGearShootingStartLatitude(gearShootingStartLatitude);
+ }
+
public Date getBeginDate() {
return cruise.getBeginDate();
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterExportModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterExportModel.java
deleted file mode 100644
index c5238f1..0000000
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterExportModel.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package fr.ifremer.tutti.service.export.generic.csv;
-
-/*
- * #%L
- * Tutti :: Service
- * %%
- * Copyright (C) 2012 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Model of a parameter export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class ParameterExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<ParameterExportRow> {
-
- public ParameterExportModel(char separator, DecoratorService decoratorService) {
- super(separator);
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
- newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
- newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
-
- newColumnForExport("Code_PMFM", ParameterExportRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
- newColumnForExportByDecorator("Libelle_PMFM", ParameterExportRow.PROPERTY_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
- newColumnForExport("Valeur", ParameterExportRow.PROPERTY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
- }
-
- public void prepareRows(List<ParameterExportRow> rows,
- Cruise cruise,
- FishingOperation operation) {
-
- CaracteristicMap gearUseFeatures = operation.getGearUseFeatures();
- if (gearUseFeatures != null) {
- for (Map.Entry<Caracteristic, Serializable> entry : gearUseFeatures.entrySet()) {
- Caracteristic caracteristic = entry.getKey();
-
- ParameterExportRow row = new ParameterExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setCaracteristic(caracteristic);
- row.setValue(entry.getValue());
- rows.add(row);
- }
- }
- CaracteristicMap vesselUseFeatures = operation.getVesselUseFeatures();
- if (vesselUseFeatures != null) {
- for (Map.Entry<Caracteristic, Serializable> entry : vesselUseFeatures.entrySet()) {
- Caracteristic caracteristic = entry.getKey();
-
- ParameterExportRow row = new ParameterExportRow();
- row.setCruise(cruise);
- row.setFishingOperation(operation);
- row.setCaracteristic(caracteristic);
- row.setValue(entry.getValue());
- rows.add(row);
- }
- }
- }
-
-}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterModel.java
new file mode 100644
index 0000000..c7265ef
--- /dev/null
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterModel.java
@@ -0,0 +1,143 @@
+package fr.ifremer.tutti.service.export.generic.csv;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * %%
+ * Copyright (C) 2012 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Cruises;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import fr.ifremer.tutti.service.csv.AbstractTuttiImportExportModel;
+import fr.ifremer.tutti.service.export.generic.GlobalImportContext;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Model of a parameter export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class ParameterModel extends AbstractTuttiImportExportModel<ParameterRow> {
+
+ public static ParameterModel forExport(char separator, DecoratorService decoratorService) {
+
+ ParameterModel exportModel = new ParameterModel(separator);
+ exportModel.forExport(decoratorService);
+ return exportModel;
+
+ }
+
+ public static ParameterModel forImport(char separator, GlobalImportContext globalImportContext) {
+
+ ParameterModel importModel = new ParameterModel(separator);
+ importModel.forImport(globalImportContext);
+ return importModel;
+
+ }
+
+ @Override
+ public ParameterRow newEmptyInstance() {
+
+ ParameterRow row = new ParameterRow();
+ row.setCruise(Cruises.newCruise());
+ return row;
+
+ }
+
+ public List<ParameterRow> getDataToExport(Cruise cruise, FishingOperation operation) {
+
+ List<ParameterRow> rows = new ArrayList<>();
+
+ CaracteristicMap gearUseFeatures = operation.getGearUseFeatures();
+ if (gearUseFeatures != null) {
+ addCaracteristicMap(rows, cruise, operation, gearUseFeatures);
+ }
+
+ CaracteristicMap vesselUseFeatures = operation.getVesselUseFeatures();
+ if (vesselUseFeatures != null) {
+ addCaracteristicMap(rows, cruise, operation, vesselUseFeatures);
+ }
+
+ return rows;
+
+ }
+
+ protected void addCaracteristicMap(List<ParameterRow> rows, Cruise cruise, FishingOperation operation, CaracteristicMap caracteristicMap) {
+
+ for (Map.Entry<Caracteristic, Serializable> entry : caracteristicMap.entrySet()) {
+
+ ParameterRow row = new ParameterRow();
+ row.setCruise(cruise);
+ row.setFishingOperation(operation);
+ row.setCaracteristic(entry.getKey());
+ row.setValue(entry.getValue());
+ rows.add(row);
+
+ }
+
+ }
+
+ protected ParameterModel(char separator) {
+ super(separator);
+ }
+
+ protected void forExport(DecoratorService decoratorService) {
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newColumnForExport("Code_station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+
+ newColumnForExport("Code_PMFM", ParameterRow.PROPERTY_CARACTERISTIC, Caracteristic.PROPERTY_ID);
+ newColumnForExportByDecorator("Libelle_PMFM", ParameterRow.PROPERTY_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
+ newColumnForExport("Valeur", ParameterRow.PROPERTY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
+
+ }
+
+ protected void forImport(GlobalImportContext globalImportContext) {
+
+ newMandatoryColumn("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newMandatoryColumn("Serie", Cruise.PROPERTY_PROGRAM, globalImportContext.getProgramParser());
+ newMandatoryColumn("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+
+ newMandatoryColumn("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
+ newMandatoryColumn("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
+ newMandatoryColumn("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
+ newMandatoryColumn("Engin", FishingOperation.PROPERTY_GEAR, globalImportContext.getOptionalGearParser());
+
+ newMandatoryColumn("Code_PMFM", ParameterRow.PROPERTY_CARACTERISTIC, globalImportContext.getCaracteristicParser());
+// newMandatoryColumn("Libelle_PMFM", ParameterRow.PROPERTY_CARACTERISTIC, decoratorService.getDecoratorByType(Caracteristic.class));
+ newMandatoryColumn("Valeur", ParameterRow.PROPERTY_VALUE);
+
+ }
+
+}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterExportRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterRow.java
similarity index 97%
rename from tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterExportRow.java
rename to tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterRow.java
index 348e3f6..fbe6850 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterExportRow.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/ParameterRow.java
@@ -36,7 +36,7 @@ import java.util.Date;
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class ParameterExportRow implements Serializable {
+public class ParameterRow implements Serializable {
private static final long serialVersionUID = 1L;
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SpeciesExportModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SpeciesExportModel.java
index 5126def..a430065 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SpeciesExportModel.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SpeciesExportModel.java
@@ -27,6 +27,7 @@ import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.TuttiCsvUtil;
+import fr.ifremer.tutti.service.csv.AbstractTuttiExportModel;
import fr.ifremer.tutti.service.export.generic.GlobalExportContext;
import java.util.List;
@@ -37,40 +38,62 @@ import java.util.List;
* @author tchemit <chemit(a)codelutin.com>
* @since 2.3
*/
-public class SpeciesExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<SpeciesExportRow> {
+public class SpeciesExportModel extends AbstractTuttiExportModel<SpeciesExportRow> {
+
+ public static SpeciesExportModel forExport(char separator) {
+
+ SpeciesExportModel exportModel = new SpeciesExportModel(separator);
+ exportModel.forExport();
+ return exportModel;
- public SpeciesExportModel(char separator) {
- super(separator);
- newColumnForExport("Id", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
- newColumnForExport("Code_Rubin", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_REF_TAX_CODE);
- newColumnForExport("Nom_Scientifique", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_NAME);
- newColumnForExport("Code_campagne", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_SURVEY_CODE);
}
- public void prepareBatchRows(GlobalExportContext exportContext,
- BatchContainer<SpeciesBatch> rootSpeciesBatch,
- BatchContainer<BenthosBatch> rootBenthosBatch) {
+ public void prepareSpeciesBatchRows(GlobalExportContext exportContext,
+ BatchContainer<SpeciesBatch> rootSpeciesBatch) {
for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) {
-
exportContext.addSpecies(speciesBatch.getSpecies());
}
+
+ }
+
+ public void prepareBenthosBatchRows(GlobalExportContext exportContext,
+ BatchContainer<BenthosBatch> rootBenthosBatch) {
+
for (BenthosBatch benthosBatch : rootBenthosBatch.getChildren()) {
exportContext.addSpecies(benthosBatch.getSpecies());
}
+
}
public void prepareIndividualRows(GlobalExportContext exportContext,
- List<IndividualObservationExportRow> rows) {
- for (IndividualObservationExportRow row : rows) {
+ List<IndividualObservationRow> rows) {
+
+ for (IndividualObservationRow row : rows) {
exportContext.addSpecies(row.getSpecies());
}
+
}
public void prepareAccidentalRows(GlobalExportContext exportContext,
- List<AccidentalCatchExportRow> rows) {
- for (AccidentalCatchExportRow row : rows) {
+ List<AccidentalCatchRow> rows) {
+
+ for (AccidentalCatchRow row : rows) {
exportContext.addSpecies(row.getSpecies());
}
+
+ }
+
+ protected SpeciesExportModel(char separator) {
+ super(separator);
+ }
+
+ protected void forExport() {
+
+ newColumnForExport("Id", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_REFERENCE_TAXON_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
+ newColumnForExport("Code_Rubin", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_REF_TAX_CODE);
+ newColumnForExport("Nom_Scientifique", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_NAME);
+ newColumnForExport("Code_campagne", SpeciesExportRow.SPECIES + "." + Species.PROPERTY_SURVEY_CODE);
+
}
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyExportModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyExportModel.java
deleted file mode 100644
index a2c7d5b..0000000
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyExportModel.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package fr.ifremer.tutti.service.export.generic.csv;
-
-/*
- * #%L
- * Tutti :: Service
- * %%
- * Copyright (C) 2012 - 2014 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
-
-import java.util.List;
-
-/**
- * Model of a survey export.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class SurveyExportModel extends TuttiCsvUtil.AbstractTuttiExportModel<SurveyExportRow> {
-
- public SurveyExportModel(char separator) {
- super(separator);
-
- newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
- newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
- newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
- newColumnForExport("Pays", SurveyExportRow.PROPERTY_COUNTRY);
- newColumnForExport("Zone_Etude", Program.PROPERTY_ZONE, TuttiLocation.PROPERTY_NAME);
- newColumnForExport("Campagne", Cruise.PROPERTY_NAME);
- newColumnForExport("Id_Sismer", SurveyExportRow.PROPERTY_ID_SISMER);
- newColumnForExport("Date_Deb_Campagne", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
- newColumnForExport("Port_Deb_Campagne", Cruise.PROPERTY_DEPARTURE_LOCATION, TuttiLocation.PROPERTY_NAME);
- newColumnForExport("Date_Fin_Campagne", Cruise.PROPERTY_END_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
- newColumnForExport("Port_Fin_Campagne", Cruise.PROPERTY_RETURN_LOCATION, TuttiLocation.PROPERTY_NAME);
- newColumnForExport("Chef_Mission", Cruise.PROPERTY_HEAD_OF_MISSION, TuttiCsvUtil.LIST_PERSON_FORMATTER);
- newColumnForExport("Resp_Salle_Tri", Cruise.PROPERTY_HEAD_OF_SORT_ROOM, TuttiCsvUtil.LIST_PERSON_FORMATTER);
- newColumnForExport("Commentaire", Cruise.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_FORMATTER);
- }
-
- public void prepareRows(List<SurveyExportRow> rows,
- Cruise cruise,
- TuttiLocation country) {
- SurveyExportRow row = new SurveyExportRow();
- row.setCruise(cruise);
- row.setCountry(country);
- rows.add(row);
- }
-}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyModel.java
new file mode 100644
index 0000000..1d0d74e
--- /dev/null
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyModel.java
@@ -0,0 +1,119 @@
+package fr.ifremer.tutti.service.export.generic.csv;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * %%
+ * Copyright (C) 2012 - 2014 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Cruises;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.service.TuttiCsvUtil;
+import fr.ifremer.tutti.service.csv.AbstractTuttiImportExportModel;
+import fr.ifremer.tutti.service.export.generic.GlobalImportContext;
+
+/**
+ * Model of a survey export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class SurveyModel extends AbstractTuttiImportExportModel<SurveyRow> {
+
+ public static SurveyModel forExport(char separator) {
+
+ SurveyModel exportModel = new SurveyModel(separator);
+ exportModel.forExport();
+ return exportModel;
+
+ }
+
+ public static SurveyModel forImport(char separator, GlobalImportContext globalImportContext) {
+
+ SurveyModel importModel = new SurveyModel(separator);
+ importModel.forImport(globalImportContext);
+ return importModel;
+
+ }
+
+ public SurveyRow getDataToExport(Cruise cruise, TuttiLocation country) {
+
+ SurveyRow row = new SurveyRow();
+ row.setCruise(cruise);
+ row.setCountry(country);
+ return row;
+
+ }
+
+ protected SurveyModel(char separator) {
+ super(separator);
+ }
+
+ protected void forExport() {
+
+ newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
+ newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+ newColumnForExport("Navire", Cruise.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
+ newColumnForExport("Pays", SurveyRow.PROPERTY_COUNTRY, TuttiLocation.PROPERTY_NAME);
+ newColumnForExport("Zone_Etude", Program.PROPERTY_ZONE, TuttiLocation.PROPERTY_NAME);
+ newColumnForExport("Campagne", Cruise.PROPERTY_NAME);
+ newColumnForExport("Id_Sismer", SurveyRow.PROPERTY_ID_SISMER);
+ newColumnForExport("Date_Deb_Campagne", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newColumnForExport("Port_Deb_Campagne", Cruise.PROPERTY_DEPARTURE_LOCATION, TuttiLocation.PROPERTY_NAME);
+ newColumnForExport("Date_Fin_Campagne", Cruise.PROPERTY_END_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newColumnForExport("Port_Fin_Campagne", Cruise.PROPERTY_RETURN_LOCATION, TuttiLocation.PROPERTY_NAME);
+ newColumnForExport("Chef_Mission", Cruise.PROPERTY_HEAD_OF_MISSION, TuttiCsvUtil.LIST_PERSON_FORMATTER);
+ newColumnForExport("Resp_Salle_Tri", Cruise.PROPERTY_HEAD_OF_SORT_ROOM, TuttiCsvUtil.LIST_PERSON_FORMATTER);
+ newColumnForExport("Commentaire", Cruise.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+
+ }
+
+ protected void forImport(GlobalImportContext globalImportContext) {
+
+ newMandatoryColumn("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
+ newMandatoryColumn("Serie", Cruise.PROPERTY_PROGRAM, globalImportContext.getProgramParser());
+ newMandatoryColumn("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
+
+ newMandatoryColumn("Navire", Cruise.PROPERTY_VESSEL, globalImportContext.getVesselParser());
+ newMandatoryColumn("Campagne", Cruise.PROPERTY_NAME);
+ newMandatoryColumn("Id_Sismer", SurveyRow.PROPERTY_ID_SISMER);
+ newMandatoryColumn("Date_Deb_Campagne", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newMandatoryColumn("Port_Deb_Campagne", Cruise.PROPERTY_DEPARTURE_LOCATION, globalImportContext.getHarbourParser());
+ newMandatoryColumn("Date_Fin_Campagne", Cruise.PROPERTY_END_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
+ newMandatoryColumn("Port_Fin_Campagne", Cruise.PROPERTY_RETURN_LOCATION, globalImportContext.getHarbourParser());
+ newMandatoryColumn("Chef_Mission", Cruise.PROPERTY_HEAD_OF_MISSION, globalImportContext.getListPersonParser());
+ newMandatoryColumn("Resp_Salle_Tri", Cruise.PROPERTY_HEAD_OF_SORT_ROOM, globalImportContext.getListPersonParser());
+ newMandatoryColumn("Commentaire", Cruise.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
+
+ }
+
+ @Override
+ public SurveyRow newEmptyInstance() {
+
+ Cruise cruise = Cruises.newCruise();
+ SurveyRow surveyRow = new SurveyRow();
+ surveyRow.setCruise(cruise);
+ return surveyRow;
+
+ }
+
+}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyExportRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyRow.java
similarity index 68%
rename from tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyExportRow.java
rename to tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyRow.java
index fbe996d..36a17ba 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyExportRow.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/csv/SurveyRow.java
@@ -39,7 +39,7 @@ import java.util.List;
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
*/
-public class SurveyExportRow implements Serializable {
+public class SurveyRow implements Serializable {
private static final long serialVersionUID = 1L;
@@ -67,6 +67,58 @@ public class SurveyExportRow implements Serializable {
return cruise.getProgram();
}
+ public void setDepartureLocation(TuttiLocation departureLocation) {
+ cruise.setDepartureLocation(departureLocation);
+ }
+
+ public void setReturnLocation(TuttiLocation returnLocation) {
+ cruise.setReturnLocation(returnLocation);
+ }
+
+ public void setProgram(Program program) {
+ cruise.setProgram(program);
+ }
+
+ public void setName(String name) {
+ cruise.setName(name);
+ }
+
+ public void setSurveyPart(String surveyPart) {
+ cruise.setSurveyPart(surveyPart);
+ }
+
+ public void setHeadOfMission(List<Person> headOfMission) {
+ cruise.setHeadOfMission(headOfMission);
+ }
+
+ public void setMultirigNumber(Integer multirigNumber) {
+ cruise.setMultirigNumber(multirigNumber);
+ }
+
+ public void setHeadOfSortRoom(List<Person> headOfSortRoom) {
+ cruise.setHeadOfSortRoom(headOfSortRoom);
+ }
+
+ public void setEndDate(Date endDate) {
+ cruise.setEndDate(endDate);
+ }
+
+ public void setGear(List<GearWithOriginalRankOrder> gear) {
+ cruise.setGear(gear);
+ }
+
+ public void setComment(String comment) {
+ cruise.setComment(comment);
+ }
+
+ public void setBeginDate(Date beginDate) {
+ cruise.setBeginDate(beginDate);
+ }
+
+ public void setVessel(Vessel vessel) {
+ cruise.setVessel(vessel);
+ }
+
public String getSurveyPart() {
return cruise.getSurveyPart();
}
@@ -79,8 +131,8 @@ public class SurveyExportRow implements Serializable {
return cruise.getVessel();
}
- public String getCountry() {
- return country.getLabel();
+ public TuttiLocation getCountry() {
+ return country;
}
public String getName() {
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
10/98: introduction du paquetage tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/csv
by codelutin.com scm 16 Feb '15
by codelutin.com scm 16 Feb '15
16 Feb '15
This is an automated email from the git hooks/post-receive script.
New commit to branch develop in repository tutti.
See http://git.codelutin.com/tutti.git
commit 5eff240d4115ea326d8bc0d676370c432342e5c6
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Fri Feb 6 09:41:32 2015 +0100
introduction du paquetage tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/csv
---
.../java/fr/ifremer/tutti/service/bigfin/csv/BigfinDataRowModel.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/csv/BigfinDataRowModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/csv/BigfinDataRowModel.java
index 6c378ef..e32f61e 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/csv/BigfinDataRowModel.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/csv/BigfinDataRowModel.java
@@ -27,10 +27,10 @@ package fr.ifremer.tutti.service.bigfin.csv;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.entities.referential.Speciess;
-import fr.ifremer.tutti.service.TuttiCsvUtil;
import fr.ifremer.tutti.service.bigfin.signs.Sex;
import fr.ifremer.tutti.service.bigfin.signs.Size;
import fr.ifremer.tutti.service.bigfin.signs.VracHorsVrac;
+import fr.ifremer.tutti.service.csv.AbstractTuttiImportModel;
import org.apache.commons.lang3.StringUtils;
import org.nuiton.csv.Common;
import org.nuiton.csv.ValueParser;
@@ -43,7 +43,7 @@ import java.util.Map;
* @author Kevin Morin (Code Lutin)
* @since 3.8
*/
-public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<BigfinDataRow> {
+public class BigfinDataRowModel extends AbstractTuttiImportModel<BigfinDataRow> {
public BigfinDataRowModel(Map<String, Species> speciesBySurveyCode, Map<Integer, SpeciesBatch> speciesBatchesById) {
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
09/98: ajout des methodes getAllGears et getAllVessel sur PersistenceService
by codelutin.com scm 16 Feb '15
by codelutin.com scm 16 Feb '15
16 Feb '15
This is an automated email from the git hooks/post-receive script.
New commit to branch develop in repository tutti.
See http://git.codelutin.com/tutti.git
commit 844ccd4ba3238ddb19347b08d57b012530b52fd8
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Fri Feb 6 09:40:55 2015 +0100
ajout des methodes getAllGears et getAllVessel sur PersistenceService
---
.../fr/ifremer/tutti/service/PersistenceService.java | 12 ++++++++++++
.../referential/ReferentialTemporaryGearService.java | 7 ++-----
.../referential/ReferentialTemporaryVesselService.java | 6 ++----
.../swing/action/OpenReplaceTemporaryGearUIAction.java | 3 +--
.../action/OpenReplaceTemporaryVesselUIAction.java | 3 +--
.../ManageTemporaryReferentialUIHandler.java | 17 ++++-------------
6 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
index a7ce38b..59e208d 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
@@ -775,6 +775,12 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer
//-- Referential methods --//
//------------------------------------------------------------------------//
+ public List<Vessel> getAllVessel() {
+ List<Vessel> targetList = Lists.newArrayList(getAllFishingVessel());
+ targetList.addAll(getAllScientificVessel());
+ return targetList;
+ }
+
@Override
public List<Vessel> getAllScientificVessel() {
return driver.getAllScientificVessel();
@@ -845,6 +851,12 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer
return driver.getLocation(id);
}
+ public List<Gear> getAllGear() {
+ List<Gear> targetList = Lists.newArrayList(getAllScientificGear());
+ targetList.addAll(getAllFishingGear());
+ return targetList;
+ }
+
@Override
public List<Gear> getAllScientificGear() {
return driver.getAllScientificGear();
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryGearService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryGearService.java
index 9985612..d01ac79 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryGearService.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryGearService.java
@@ -49,7 +49,6 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -85,8 +84,7 @@ public class ReferentialTemporaryGearService extends AbstractTuttiService {
}
// get all vessel names
- List<Gear> allGears = new ArrayList<>(persistenceService.getAllFishingGear());
- allGears.addAll(persistenceService.getAllScientificGear());
+ List<Gear> allGears = Lists.newArrayList(persistenceService.getAllGear());
ImportRequestResult<Gear, Integer> requestResult = processImportFile(file, allGears);
@@ -130,8 +128,7 @@ public class ReferentialTemporaryGearService extends AbstractTuttiService {
if (log.isInfoEnabled()) {
log.info("Getting all gears from database");
}
- List<Gear> targetList = Lists.newArrayList(persistenceService.getAllFishingGear());
- targetList.addAll(persistenceService.getAllScientificGear());
+ List<Gear> targetList = Lists.newArrayList(persistenceService.getAllGear());
if (log.isInfoEnabled()) {
log.info("Got " + targetList.size() + " gears");
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryVesselService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryVesselService.java
index 3bf60de..ba17c75 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryVesselService.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryVesselService.java
@@ -84,8 +84,7 @@ public class ReferentialTemporaryVesselService extends AbstractTuttiService {
}
// get all vessels
- List<Vessel> existingVessels = Lists.newArrayList(persistenceService.getAllFishingVessel());
- existingVessels.addAll(persistenceService.getAllScientificVessel());
+ List<Vessel> existingVessels = Lists.newArrayList(persistenceService.getAllVessel());
ImportRequestResult<Vessel, String> requestResult = processImportFile(file, existingVessels);
@@ -122,8 +121,7 @@ public class ReferentialTemporaryVesselService extends AbstractTuttiService {
if (log.isInfoEnabled()) {
log.info("Getting all vessels from database");
}
- List<Vessel> targetList = Lists.newArrayList(persistenceService.getAllFishingVessel());
- targetList.addAll(persistenceService.getAllScientificVessel());
+ List<Vessel> targetList = Lists.newArrayList(persistenceService.getAllVessel());
if (log.isInfoEnabled()) {
log.info("Got " + targetList.size() + " vessels");
}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenReplaceTemporaryGearUIAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenReplaceTemporaryGearUIAction.java
index 90f4790..0f025c0 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenReplaceTemporaryGearUIAction.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenReplaceTemporaryGearUIAction.java
@@ -71,8 +71,7 @@ public class OpenReplaceTemporaryGearUIAction extends AbstractOpenReplaceTempora
@Override
protected List<Gear> getTargetList(PersistenceService persistenceService) {
- List<Gear> targetList = Lists.newArrayList(persistenceService.getAllFishingGear());
- targetList.addAll(persistenceService.getAllScientificGear());
+ List<Gear> targetList = Lists.newArrayList(persistenceService.getAllGear());
return targetList;
}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenReplaceTemporaryVesselUIAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenReplaceTemporaryVesselUIAction.java
index ebee1ab..863bacf 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenReplaceTemporaryVesselUIAction.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenReplaceTemporaryVesselUIAction.java
@@ -71,8 +71,7 @@ public class OpenReplaceTemporaryVesselUIAction extends AbstractOpenReplaceTempo
@Override
protected List<Vessel> getTargetList(PersistenceService persistenceService) {
- List<Vessel> targetList = Lists.newArrayList(persistenceService.getAllFishingVessel());
- targetList.addAll(persistenceService.getAllScientificVessel());
+ List<Vessel> targetList = Lists.newArrayList(persistenceService.getAllVessel());
return targetList;
}
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ManageTemporaryReferentialUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ManageTemporaryReferentialUIHandler.java
index 29e8434..63cadac 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ManageTemporaryReferentialUIHandler.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ManageTemporaryReferentialUIHandler.java
@@ -26,7 +26,6 @@ import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import jaxx.runtime.validator.swing.SwingValidator;
@@ -39,7 +38,6 @@ import javax.swing.JComboBox;
import javax.swing.JComponent;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -63,24 +61,17 @@ public class ManageTemporaryReferentialUIHandler extends AbstractTuttiUIHandler<
super.beforeInit(ui);
ManageTemporaryReferentialUIModel model = new ManageTemporaryReferentialUIModel();
- PersistenceService persistenceService = getContext().getPersistenceService();
- List<Species> temporarySpecies = new ArrayList<Species>(persistenceService.getAllSpecies());
- temporarySpecies = persistenceService.retainTemporarySpeciesList(temporarySpecies);
+ List<Species> temporarySpecies = getContext().getReferentialTemporarySpeciesService().getTemporarySpeciess();
model.setNbTemporarySpecies(temporarySpecies.size());
- List<Vessel> temporaryVessels = new ArrayList<Vessel>(persistenceService.getAllFishingVessel());
- temporaryVessels.addAll(persistenceService.getAllScientificVessel());
- temporaryVessels = persistenceService.retainTemporaryVesselList(temporaryVessels);
+ List<Vessel> temporaryVessels = getContext().getReferentialTemporaryVesselService().getTemporaryVessels();
model.setNbTemporaryVessels(temporaryVessels.size());
- List<Gear> temporaryGears = new ArrayList<Gear>(persistenceService.getAllFishingGear());
- temporaryGears.addAll(persistenceService.getAllScientificGear());
- temporaryGears = persistenceService.retainTemporaryGearList(temporaryGears);
+ List<Gear> temporaryGears = getContext().getReferentialTemporaryGearService().getTemporaryGears();
model.setNbTemporaryGears(temporaryGears.size());
- List<Person> temporaryPersons = new ArrayList<Person>(persistenceService.getAllPerson());
- temporaryPersons = persistenceService.retainTemporaryPersonList(temporaryPersons);
+ List<Person> temporaryPersons = getContext().getReferentialTemporaryPersonService().getTemporaryPersons();
model.setNbTemporaryPersons(temporaryPersons.size());
ui.setContextValue(model);
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
This is an automated email from the git hooks/post-receive script.
New commit to branch develop in repository tutti.
See http://git.codelutin.com/tutti.git
commit de12bb09ef5772dc6dba69af2dd627edb070d628
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Fri Feb 6 09:39:41 2015 +0100
ajout de methodes utilitaires sur les entities
---
.../tutti/persistence/entities/data/Programs.java | 21 ++++++++++++++
.../persistence/entities/referential/Gears.java | 8 ++++++
.../persistence/entities/referential/Persons.java | 8 ++++++
.../entities/referential/TuttiLocations.java | 33 ++++++++++++++++++++++
.../persistence/entities/referential/Vessels.java | 19 +++++++++++++
5 files changed, 89 insertions(+)
diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/Programs.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/Programs.java
new file mode 100644
index 0000000..819e1b6
--- /dev/null
+++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/Programs.java
@@ -0,0 +1,21 @@
+package fr.ifremer.tutti.persistence.entities.data;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Maps;
+
+import java.util.List;
+import java.util.Map;
+
+public class Programs extends AbstractPrograms {
+
+ public static Map<String, Program> splitByName(List<Program> programs) {
+ return Maps.uniqueIndex(programs, GET_NAME);
+ }
+
+ public static final Function<Program, String> GET_NAME = new Function<Program, String>() {
+ @Override
+ public String apply(Program input) {
+ return input.getName();
+ }
+ };
+}
diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Gears.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Gears.java
index 9382d1e..3cc4a4a 100644
--- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Gears.java
+++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Gears.java
@@ -28,10 +28,18 @@ package fr.ifremer.tutti.persistence.entities.referential;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
+import com.google.common.collect.Maps;
+
+import java.util.List;
+import java.util.Map;
public class Gears extends AbstractGears {
+ public static Map<String, Gear> splitByName(List<Gear> gears) {
+ return Maps.uniqueIndex(gears, GET_NAME);
+ }
+
public static final Predicate<Gear> IS_FISHING_GEAR = new Predicate<Gear>() {
public boolean apply(Gear input) {
diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Persons.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Persons.java
index 68abb6e..5a0365c 100644
--- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Persons.java
+++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Persons.java
@@ -27,8 +27,12 @@ package fr.ifremer.tutti.persistence.entities.referential;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
+import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
+import java.util.List;
+import java.util.Map;
+
public class Persons extends AbstractPersons {
/**
@@ -47,6 +51,10 @@ public class Persons extends AbstractPersons {
}
+ public static Map<String, Person> splitByFullName(List<Person> persons) {
+ return Maps.uniqueIndex(persons, GET_FULL_NAME);
+ }
+
public static final Predicate<Person> IS_TEMPORARY = new Predicate<Person>() {
@Override
public boolean apply(Person input) {
diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/TuttiLocations.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/TuttiLocations.java
new file mode 100644
index 0000000..1c701eb
--- /dev/null
+++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/TuttiLocations.java
@@ -0,0 +1,33 @@
+package fr.ifremer.tutti.persistence.entities.referential;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Maps;
+
+import java.util.List;
+import java.util.Map;
+
+public class TuttiLocations extends AbstractTuttiLocations {
+
+ public static Map<String, TuttiLocation> splitByLabel(List<TuttiLocation> tuttiLocations) {
+ return Maps.uniqueIndex(tuttiLocations, GET_LABEL);
+ }
+
+ public static Map<String, TuttiLocation> splitByName(List<TuttiLocation> tuttiLocations) {
+ return Maps.uniqueIndex(tuttiLocations, GET_NAME);
+ }
+
+ public static final Function<TuttiLocation, String> GET_LABEL = new Function<TuttiLocation, String>() {
+ @Override
+ public String apply(TuttiLocation input) {
+ return input.getLabel();
+ }
+ };
+
+ public static final Function<TuttiLocation, String> GET_NAME = new Function<TuttiLocation, String>() {
+ @Override
+ public String apply(TuttiLocation input) {
+ return input.getName();
+ }
+ };
+
+}
diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Vessels.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Vessels.java
index be0feb0..d91161f 100644
--- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Vessels.java
+++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/Vessels.java
@@ -27,10 +27,22 @@ package fr.ifremer.tutti.persistence.entities.referential;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
+import com.google.common.collect.Maps;
import fr.ifremer.adagio.core.dao.technical.hibernate.TemporaryDataHelper;
+import java.util.List;
+import java.util.Map;
+
public class Vessels extends AbstractVessels {
+ public static Map<String, Vessel> splitByRegistrationCode(List<Vessel> programs) {
+ return Maps.uniqueIndex(programs, GET_REGISTRATION_CODE);
+ }
+
+ public static Map<String, Vessel> splitByInternationalRegistrationCode(List<Vessel> programs) {
+ return Maps.uniqueIndex(programs, GET_INTERNAL_REGISTRATION_CODE);
+ }
+
public static final Predicate<Vessel> IS_TEMPORARY = new Predicate<Vessel>() {
@Override
public boolean apply(Vessel input) {
@@ -38,6 +50,13 @@ public class Vessels extends AbstractVessels {
}
};
+ public static final Function<Vessel, String> GET_REGISTRATION_CODE = new Function<Vessel, String>() {
+ @Override
+ public String apply(Vessel input) {
+ return input.getRegistrationCode();
+ }
+ };
+
public static final Function<Vessel, String> GET_INTERNAL_REGISTRATION_CODE = new Function<Vessel, String>() {
@Override
public String apply(Vessel input) {
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
This is an automated email from the git hooks/post-receive script.
New commit to branch develop in repository tutti.
See http://git.codelutin.com/tutti.git
commit 26f5e75dd2521a1e369ed7184add2b66133c4db4
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Fri Feb 6 09:39:07 2015 +0100
suppression de code mort
---
.../tutti/persistence/entities/TuttiEntities.java | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
index 96186e3..1e95bdb 100644
--- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
+++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
@@ -121,27 +121,6 @@ public class TuttiEntities {
}
}
- public static <K, V> void fillEntries(Map<K, V> map,
- Collection<K> keys,
- Function<K, V> function) {
-
- for (K key : keys) {
- V value = function.apply(key);
- map.put(key, value);
- }
- }
-
-// public static <E> List<E> getList(List<E> list) {
-// List<E> result;
-// if (CollectionUtils.isEmpty(list)) {
-// result = Lists.newArrayList();
-// } else {
-// result = Lists.newArrayList(list);
-// }
-//
-// return result;
-// }
-
}
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
06/98: utilisation de methode de service pour creer le modele de progression
by codelutin.com scm 16 Feb '15
by codelutin.com scm 16 Feb '15
16 Feb '15
This is an automated email from the git hooks/post-receive script.
New commit to branch develop in repository tutti.
See http://git.codelutin.com/tutti.git
commit 55bd07d222f1689ac8a4842f4804b64162643971
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Thu Feb 5 12:32:14 2015 +0100
utilisation de methode de service pour creer le modele de progression
---
.../tutti/ui/swing/action/ExportCruiseAction.java | 21 +++++-------------
.../tutti/ui/swing/action/ExportProgramAction.java | 25 +++++-----------------
2 files changed, 10 insertions(+), 36 deletions(-)
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseAction.java
index 532cfe4..08b098f 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseAction.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseAction.java
@@ -91,31 +91,20 @@ public class ExportCruiseAction extends AbstractTuttiAction<SelectCruiseUIModel,
Preconditions.checkNotNull(file);
if (log.isInfoEnabled()) {
- log.info("Will save cruise " + cruise.getId() +
- " to file: " + file);
+ log.info("Will save cruise " + cruise.getId() + " to file: " + file);
}
- ProgressionModel progressionModel = new ProgressionModel();
- setProgressionModel(progressionModel);
- // (check cruise / export cruise / gear caracteristics / operation / parameter / accidental catches / catches / individual observation / species) / zip
- progressionModel.setTotal(10);
+ TuttiExportService service = getContext().getTuttiExportService();
-// TuttiProtocol protocol = null;
-// if (getContext().isProtocolFilled()) {
-// protocol = getDataContext().getProtocol();
-// if (log.isInfoEnabled()) {
-// log.info("Will use protocol " + protocol.getName());
-// }
-// }
+ ProgressionModel progressionModel = service.createExportCruiseProgessionModel();
+ setProgressionModel(progressionModel);
ApplicationBusinessException exportError = null;
- TuttiExportService service = getContext().getTuttiExportService();
try {
service.exportCruise(cruise.getId(), file, progressionModel);
- sendMessage(t("tutti.exportCruise.action.success",
- cruise.getName(), file.getName()));
+ sendMessage(t("tutti.exportCruise.action.success", cruise.getName(), file.getName()));
} catch (ApplicationBusinessException e) {
String errorMessage;
diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProgramAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProgramAction.java
index 09e7670..fd1f231 100644
--- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProgramAction.java
+++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProgramAction.java
@@ -24,7 +24,6 @@ package fr.ifremer.tutti.ui.swing.action;
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.service.export.generic.TuttiExportService;
import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
@@ -35,7 +34,6 @@ import org.apache.commons.logging.LogFactory;
import org.nuiton.jaxx.application.ApplicationBusinessException;
import java.io.File;
-import java.util.List;
import static org.nuiton.i18n.I18n.t;
@@ -91,28 +89,15 @@ public class ExportProgramAction extends AbstractTuttiAction<SelectCruiseUIModel
Preconditions.checkNotNull(file);
if (log.isInfoEnabled()) {
- log.info("Will save program " + program.getId() +
- " to file: " + file);
+ log.info("Will save program " + program.getId() + " to file: " + file);
}
- // nbCruise * (check cruise / export cruise / gear caracteristics / operation / parameter / catches / individual observation / accidental catches / species) + zip
- List<Cruise> allCruise =
- getContext().getPersistenceService().getAllCruise(program.getId());
-
- ProgressionModel progressionModel = new ProgressionModel();
- setProgressionModel(progressionModel);
- progressionModel.setTotal(9 * allCruise.size() + 1);
-
-// TuttiProtocol protocol = null;
-// if (getContext().isProtocolFilled()) {
-// protocol = getDataContext().getProtocol();
-// if (log.isInfoEnabled()) {
-// log.info("Will use protocol " + protocol.getName());
-// }
-// }
+ TuttiExportService service = getContext().getTuttiExportService();
+
+ ProgressionModel progressionModel = service.createExportProgramProgessionModel(program.getId());
+
ApplicationBusinessException exportError = null;
- TuttiExportService service = getContext().getTuttiExportService();
try {
service.exportProgram(program.getId(), file, progressionModel);
} catch (ApplicationBusinessException e) {
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
This is an automated email from the git hooks/post-receive script.
New commit to branch develop in repository tutti.
See http://git.codelutin.com/tutti.git
commit a4943cac04bb47f893e68a589159168b20c074c4
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Thu Feb 5 12:31:39 2015 +0100
use new API
---
.../export/generic/TuttiExportServiceTest.java | 26 +++++++++++-----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java
index cf91057..9019a77 100644
--- a/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java
+++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java
@@ -250,7 +250,7 @@ public class TuttiExportServiceTest {
@Test
public void exportSurvey() throws Exception {
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -266,7 +266,7 @@ public class TuttiExportServiceTest {
@Test
public void exportGearCaracteristics() throws Exception {
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -284,7 +284,7 @@ public class TuttiExportServiceTest {
// loadData(PROGRAM_ID, CRUISE_CGFS_ID);
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -305,7 +305,7 @@ public class TuttiExportServiceTest {
FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100105");
dataContext.operations = Lists.newArrayList(operation);
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -328,7 +328,7 @@ public class TuttiExportServiceTest {
operation.setGear(null);
dataContext.operations = Lists.newArrayList(operation);
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -345,7 +345,7 @@ public class TuttiExportServiceTest {
@Test
public void exportParameters() throws Exception {
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -361,7 +361,7 @@ public class TuttiExportServiceTest {
@Test
public void exportCatches() throws Exception {
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -391,7 +391,7 @@ public class TuttiExportServiceTest {
FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100000");
dataContext.operations = Lists.newArrayList(operation);
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -418,7 +418,7 @@ public class TuttiExportServiceTest {
dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -431,7 +431,7 @@ public class TuttiExportServiceTest {
@Test
public void exportMarineLitters() throws Exception {
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -447,7 +447,7 @@ public class TuttiExportServiceTest {
@Test
public void exportIndividualObservations() throws Exception {
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -463,7 +463,7 @@ public class TuttiExportServiceTest {
@Test
public void exportAccidentalCatch() throws Exception {
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
@@ -479,7 +479,7 @@ public class TuttiExportServiceTest {
@Test
public void exportSpecies() throws Exception {
- TuttiExportService.ExportContext exportContext =
+ GlobalExportContext exportContext =
service.createExportContext(dataDirectory);
try {
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
04/98: ajout traductions pour export des fichiers techniques lors de l'export generique
by codelutin.com scm 16 Feb '15
by codelutin.com scm 16 Feb '15
16 Feb '15
This is an automated email from the git hooks/post-receive script.
New commit to branch develop in repository tutti.
See http://git.codelutin.com/tutti.git
commit 380246f742538220e9ed8e5a68f3485768f4215a
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Thu Feb 5 12:31:01 2015 +0100
ajout traductions pour export des fichiers techniques lors de l'export generique
---
.../src/main/resources/i18n/tutti-service_en_GB.properties | 10 ++++++++++
.../src/main/resources/i18n/tutti-service_fr_FR.properties | 10 ++++++++++
2 files changed, 20 insertions(+)
diff --git a/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties b/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
index 6dcc7c5..befdb31 100644
--- a/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
+++ b/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
@@ -135,6 +135,16 @@ tutti.service.exportSumatraV2.header.species=Species
tutti.service.exportSumatraV2.header.station=Station number
tutti.service.exportSumatraV2.header.totalWeight=TotalWeight
tutti.service.exportSumatraV2.header.year=Year
+tutti.service.genericExport.exportProtocol=
+tutti.service.genericExport.exportTemporaryGear=
+tutti.service.genericExport.exportTemporaryPerson=
+tutti.service.genericExport.exportTemporarySpecies=
+tutti.service.genericExport.exportTemporaryVessel=
+tutti.service.genericExport.skipProtocolExport=
+tutti.service.genericExport.skipTemporaryGearExport=
+tutti.service.genericExport.skipTemporaryPersonExport=
+tutti.service.genericExport.skipTemporarySpeciesExport=
+tutti.service.genericExport.skipTemporaryVesselExport=
tutti.service.multipost.attachment.copy.error=
tutti.service.multipost.attachment.mkdir.error=
tutti.service.multipost.export.attachments.error=
diff --git a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
index abe02d5..98ae40f 100644
--- a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
+++ b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
@@ -112,6 +112,16 @@ tutti.service.exportSumatra.header.surveySpecies=espececampagne
tutti.service.exportSumatra.header.totalWeight=total
tutti.service.exportSumatra.header.weight=total
tutti.service.exportSumatra.header.year=annee
+tutti.service.genericExport.exportProtocol=Export du protocol %s
+tutti.service.genericExport.exportTemporaryGear=Export de %s engins temporaires
+tutti.service.genericExport.exportTemporaryPerson=Export de %s personnes temporaires
+tutti.service.genericExport.exportTemporarySpecies=Export de %s espèces temporaires
+tutti.service.genericExport.exportTemporaryVessel=Export de %s navires temporaires
+tutti.service.genericExport.skipProtocolExport=Pas de protocol à exporter
+tutti.service.genericExport.skipTemporaryGearExport=Pas d'engin temporaire à exporter
+tutti.service.genericExport.skipTemporaryPersonExport=Pas de personne temporaire à exporter
+tutti.service.genericExport.skipTemporarySpeciesExport=Pas d'espèce temporaire à exporter
+tutti.service.genericExport.skipTemporaryVesselExport=Pas de navire temporaire à exporter
tutti.service.multipost.attachment.copy.error=Erreur lors de l'export de la pièce-jointe %s
tutti.service.multipost.attachment.mkdir.error=Impossible de créer le répertoire %s
tutti.service.multipost.export.attachments.error=Erreur lors de l'export des pièces-jointes
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
03/98: Ajout d'une méthode pour obtenir directement la liste des référentiels temporaires (aussi utilisé pour l'export générique)
by codelutin.com scm 16 Feb '15
by codelutin.com scm 16 Feb '15
16 Feb '15
This is an automated email from the git hooks/post-receive script.
New commit to branch develop in repository tutti.
See http://git.codelutin.com/tutti.git
commit 44d8d3213f4314e384a883fb5b206f635ff7e866
Author: Tony CHEMIT <chemit(a)codelutin.com>
Date: Thu Feb 5 12:29:46 2015 +0100
Ajout d'une méthode pour obtenir directement la liste des référentiels temporaires (aussi utilisé pour l'export générique)
---
.../ReferentialTemporaryGearService.java | 64 +++++++++++----------
.../ReferentialTemporaryPersonService.java | 63 ++++++++++++---------
.../ReferentialTemporarySpeciesService.java | 66 ++++++++++++----------
.../ReferentialTemporaryVesselService.java | 65 +++++++++++----------
4 files changed, 141 insertions(+), 117 deletions(-)
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryGearService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryGearService.java
index 97a7420..9985612 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryGearService.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryGearService.java
@@ -121,10 +121,15 @@ public class ReferentialTemporaryGearService extends AbstractTuttiService {
public void exportExistingTemporaryGear(File file) throws IOException {
+ List<Gear> toExport = getTemporaryGears();
+ exportTemporaryGear(file, toExport);
+
+ }
+
+ public List<Gear> getTemporaryGears() {
if (log.isInfoEnabled()) {
log.info("Getting all gears from database");
}
-
List<Gear> targetList = Lists.newArrayList(persistenceService.getAllFishingGear());
targetList.addAll(persistenceService.getAllScientificGear());
if (log.isInfoEnabled()) {
@@ -134,8 +139,7 @@ public class ReferentialTemporaryGearService extends AbstractTuttiService {
if (log.isInfoEnabled()) {
log.info("Got " + toExport.size() + " temporary gears");
}
- exportTemporaryGear(file, toExport);
-
+ return toExport;
}
public void exportTemporaryGearExample(File file) throws IOException {
@@ -172,6 +176,32 @@ public class ReferentialTemporaryGearService extends AbstractTuttiService {
}
+ public void exportTemporaryGear(File file, List<Gear> toExport) throws IOException {
+
+ GearModel csvModel = new GearModel(getCsvSeparator());
+
+ BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
+
+ List<GearRow> toExportRows = Lists.transform(toExport, new Function<Gear, GearRow>() {
+ @Override
+ public GearRow apply(Gear gear) {
+ return new GearRow(gear);
+ }
+ });
+
+ try {
+ Export export = Export.newExport(csvModel, toExportRows);
+ export.write(writer);
+ writer.close();
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApplicationTechnicalException(t("tutti.service.referential.export.gear.error", file), e);
+ } finally {
+ IOUtils.closeQuietly(writer);
+ }
+ }
+
protected ImportRequestResult<Gear, Integer> processImportFile(File file, List<Gear> existingEntities) {
ImportRequestResult<Gear, Integer> requestResult = new ImportRequestResult<>(existingEntities, TuttiEntities.<Gear>newIdAstIntFunction(), Gears.GET_NAME);
@@ -273,33 +303,7 @@ public class ReferentialTemporaryGearService extends AbstractTuttiService {
}
- protected void exportTemporaryGear(File file, List<Gear> toExport) throws IOException {
-
- GearModel csvModel = new GearModel(getCsvSeparator());
-
- BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
-
- List<GearRow> toExportRows = Lists.transform(toExport, new Function<Gear, GearRow>() {
- @Override
- public GearRow apply(Gear gear) {
- return new GearRow(gear);
- }
- });
-
- try {
- Export export = Export.newExport(csvModel, toExportRows);
- export.write(writer);
- writer.close();
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new ApplicationTechnicalException(t("tutti.service.referential.export.gear.error", file), e);
- } finally {
- IOUtils.closeQuietly(writer);
- }
- }
-
protected char getCsvSeparator() {
- return context.getConfig().getCsvSeparator();
+ return ';';
}
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryPersonService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryPersonService.java
index 9a9f6b9..ddea706 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryPersonService.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryPersonService.java
@@ -117,7 +117,7 @@ public class ReferentialTemporaryPersonService extends AbstractTuttiService {
return result;
}
- public void exportExistingTemporaryPerson(File file) throws IOException {
+ public List<Person> getTemporaryPersons() {
if (log.isInfoEnabled()) {
log.info("Getting all persons from database");
@@ -130,6 +130,13 @@ public class ReferentialTemporaryPersonService extends AbstractTuttiService {
if (log.isInfoEnabled()) {
log.info("Got " + toExport.size() + " temporary persons");
}
+ return toExport;
+
+ }
+
+ public void exportExistingTemporaryPerson(File file) throws IOException {
+
+ List<Person> toExport = getTemporaryPersons();
exportTemporaryPerson(file, toExport);
}
@@ -159,6 +166,32 @@ public class ReferentialTemporaryPersonService extends AbstractTuttiService {
}
+ public void exportTemporaryPerson(File file, List<Person> toExport) throws IOException {
+
+ PersonModel csvModel = new PersonModel(getCsvSeparator());
+
+ BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
+
+ List<PersonRow> toExportRows = Lists.transform(toExport, new Function<Person, PersonRow>() {
+ @Override
+ public PersonRow apply(Person person) {
+ return new PersonRow(person);
+ }
+ });
+
+ try {
+ Export export = Export.newExport(csvModel, toExportRows);
+ export.write(writer);
+ writer.close();
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApplicationTechnicalException(t("tutti.service.referential.export.person.error", file), e);
+ } finally {
+ IOUtils.closeQuietly(writer);
+ }
+ }
+
protected ImportRequestResult<Person, Integer> processImportFile(File file, List<Person> existingEntities) {
ImportRequestResult<Person, Integer> requestResult = new ImportRequestResult<>(existingEntities, TuttiEntities.<Person>newIdAstIntFunction(), Persons.GET_FULL_NAME);
@@ -260,33 +293,7 @@ public class ReferentialTemporaryPersonService extends AbstractTuttiService {
}
- protected void exportTemporaryPerson(File file, List<Person> toExport) throws IOException {
-
- PersonModel csvModel = new PersonModel(getCsvSeparator());
-
- BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
-
- List<PersonRow> toExportRows = Lists.transform(toExport, new Function<Person, PersonRow>() {
- @Override
- public PersonRow apply(Person person) {
- return new PersonRow(person);
- }
- });
-
- try {
- Export export = Export.newExport(csvModel, toExportRows);
- export.write(writer);
- writer.close();
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new ApplicationTechnicalException(t("tutti.service.referential.export.person.error", file), e);
- } finally {
- IOUtils.closeQuietly(writer);
- }
- }
-
protected char getCsvSeparator() {
- return context.getConfig().getCsvSeparator();
+ return ';';
}
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporarySpeciesService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporarySpeciesService.java
index 164848d..fdffb63 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporarySpeciesService.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporarySpeciesService.java
@@ -115,7 +115,7 @@ public class ReferentialTemporarySpeciesService extends AbstractTuttiService {
return result;
}
- public void exportExistingTemporarySpecies(File file) throws IOException {
+ public List<Species> getTemporarySpeciess() {
if (log.isInfoEnabled()) {
log.info("Getting all species from database");
@@ -129,6 +129,13 @@ public class ReferentialTemporarySpeciesService extends AbstractTuttiService {
if (log.isInfoEnabled()) {
log.info("Got " + toExport.size() + " temporary species");
}
+ return toExport;
+
+ }
+
+ public void exportExistingTemporarySpecies(File file) throws IOException {
+
+ List<Species> toExport = getTemporarySpeciess();
exportTemporarySpecies(file, toExport);
}
@@ -156,6 +163,33 @@ public class ReferentialTemporarySpeciesService extends AbstractTuttiService {
}
+ public void exportTemporarySpecies(File file, List<Species> toExport) throws IOException {
+
+ SpeciesModel csvModel = new SpeciesModel(getCsvSeparator());
+
+ BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
+
+ List<SpeciesRow> toExportRows = Lists.transform(toExport, new Function<Species, SpeciesRow>() {
+ @Override
+ public SpeciesRow apply(Species species) {
+ return new SpeciesRow(species);
+ }
+ });
+
+ try {
+ Export export = Export.newExport(csvModel, toExportRows);
+ export.write(writer);
+ writer.close();
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApplicationTechnicalException(t("tutti.service.referential.export.species.error", file), e);
+ } finally {
+ IOUtils.closeQuietly(writer);
+ }
+
+ }
+
protected ImportRequestResult<Species, Integer> processImportFile(File file, List<Species> existingEntities) {
ImportRequestResult<Species, Integer> requestResult = new ImportRequestResult<>(existingEntities, TuttiEntities.<Species>newIdAstIntFunction(), Speciess.GET_NAME);
@@ -191,33 +225,6 @@ public class ReferentialTemporarySpeciesService extends AbstractTuttiService {
}
- protected void exportTemporarySpecies(File file, List<Species> toExport) throws IOException {
-
- SpeciesModel csvModel = new SpeciesModel(getCsvSeparator());
-
- BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
-
- List<SpeciesRow> toExportRows = Lists.transform(toExport, new Function<Species, SpeciesRow>() {
- @Override
- public SpeciesRow apply(Species species) {
- return new SpeciesRow(species);
- }
- });
-
- try {
- Export export = Export.newExport(csvModel, toExportRows);
- export.write(writer);
- writer.close();
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new ApplicationTechnicalException(t("tutti.service.referential.export.species.error", file), e);
- } finally {
- IOUtils.closeQuietly(writer);
- }
-
- }
-
protected void importSpecies(SpeciesRow bean, ImportRequestResult<Species, Integer> requestResult) {
Integer id = bean.getIdAsInt();
@@ -287,7 +294,6 @@ public class ReferentialTemporarySpeciesService extends AbstractTuttiService {
}
protected char getCsvSeparator() {
- return context.getConfig().getCsvSeparator();
+ return ';';
}
-
}
diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryVesselService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryVesselService.java
index 2a44997..3bf60de 100644
--- a/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryVesselService.java
+++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/ReferentialTemporaryVesselService.java
@@ -117,7 +117,7 @@ public class ReferentialTemporaryVesselService extends AbstractTuttiService {
return result;
}
- public void exportExistingTemporaryVessel(File file) throws IOException {
+ public List<Vessel> getTemporaryVessels() {
if (log.isInfoEnabled()) {
log.info("Getting all vessels from database");
@@ -132,6 +132,13 @@ public class ReferentialTemporaryVesselService extends AbstractTuttiService {
if (log.isInfoEnabled()) {
log.info("Got " + toExport.size() + " temporary vessels");
}
+ return toExport;
+
+ }
+
+ public void exportExistingTemporaryVessel(File file) throws IOException {
+
+ List<Vessel> toExport = getTemporaryVessels();
exportTemporaryVessel(file, toExport);
}
@@ -176,6 +183,33 @@ public class ReferentialTemporaryVesselService extends AbstractTuttiService {
}
+
+ public void exportTemporaryVessel(File file, List<Vessel> toExport) throws IOException {
+
+ VesselModel csvModel = new VesselModel(getCsvSeparator());
+
+ BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
+
+ List<VesselRow> toExportRows = Lists.transform(toExport, new Function<Vessel, VesselRow>() {
+ @Override
+ public VesselRow apply(Vessel vessel) {
+ return new VesselRow(vessel);
+ }
+ });
+
+ try {
+ Export export = Export.newExport(csvModel, toExportRows);
+ export.write(writer);
+ writer.close();
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApplicationTechnicalException(t("tutti.service.referential.export.vessel.error", file), e);
+ } finally {
+ IOUtils.closeQuietly(writer);
+ }
+ }
+
protected ImportRequestResult<Vessel, String> processImportFile(File file, List<Vessel> existingEntities) {
ImportRequestResult<Vessel, String> requestResult = new ImportRequestResult<>(existingEntities, TuttiEntities.<Vessel>newIdFunction(), Vessels.GET_INTERNAL_REGISTRATION_CODE);
@@ -278,34 +312,7 @@ public class ReferentialTemporaryVesselService extends AbstractTuttiService {
}
- protected void exportTemporaryVessel(File file, List<Vessel> toExport) throws IOException {
-
- VesselModel csvModel = new VesselModel(getCsvSeparator());
-
- BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
-
- List<VesselRow> toExportRows = Lists.transform(toExport, new Function<Vessel, VesselRow>() {
- @Override
- public VesselRow apply(Vessel vessel) {
- return new VesselRow(vessel);
- }
- });
-
- try {
- Export export = Export.newExport(csvModel, toExportRows);
- export.write(writer);
- writer.close();
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new ApplicationTechnicalException(t("tutti.service.referential.export.vessel.error", file), e);
- } finally {
- IOUtils.closeQuietly(writer);
- }
- }
-
-
protected char getCsvSeparator() {
- return context.getConfig().getCsvSeparator();
+ return ';';
}
}
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
0
This is an automated email from the git hooks/post-receive script.
New change to branch develop in repository tutti.
See http://git.codelutin.com/tutti.git
from 2b7bb42 fixes #6672: [RAPPORT] Le rapport birt ne fonctionne plus
new 2cbb96b Specifications version 5.2
The 1 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 2cbb96b0ff4821870e9cc7e030e94d1a6c880e06
Author: Léo Kaufmann <kaufmann(a)codelutin.com>
Date: Mon Feb 16 12:47:14 2015 +0100
Specifications version 5.2
Summary of changes:
.../AllegroCampagne-Specifications.odt | Bin 766872 -> 841456 bytes
.../AllegroCampagne-Specifications.pdf | Bin 1420873 -> 1494390 bytes
2 files changed, 0 insertions(+), 0 deletions(-)
--
To stop receiving notification emails like this one, please contact
codelutin.com SCM administrator <admin+scm(a)codelutin.com>.
1
1