1 package fr.ifremer.tutti.service.genericformat.csv;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
26 import fr.ifremer.tutti.persistence.entities.data.Cruise;
27 import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
28 import fr.ifremer.tutti.service.csv.AbstractTuttiImportExportModel;
29 import fr.ifremer.tutti.service.csv.TuttiCsvUtil;
30 import fr.ifremer.tutti.service.genericformat.GenericFormatImportEntityParserFactory;
31
32
33
34
35
36
37
38 public class AccidentalCatchModel extends AbstractTuttiImportExportModel<AccidentalCatchRow> {
39
40 public static AccidentalCatchModel forExport(char separator) {
41
42 AccidentalCatchModel exportModel = new AccidentalCatchModel(separator);
43 exportModel.forExport();
44 return exportModel;
45
46 }
47
48 public static AccidentalCatchModel forImport(char separator, GenericFormatImportEntityParserFactory parserFactory) {
49
50 AccidentalCatchModel importModel = new AccidentalCatchModel(separator);
51 importModel.forImport(parserFactory);
52 return importModel;
53
54 }
55
56 @Override
57 public AccidentalCatchRow newEmptyInstance() {
58
59 return AccidentalCatchRow.newEmptyInstance();
60
61 }
62
63 protected AccidentalCatchModel(char separator) {
64 super(separator);
65 }
66
67 protected void forExport() {
68
69 newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
70 newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, TuttiCsvUtil.PROGRAM_FORMATTER);
71 newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
72
73 newColumnForExport("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
74 newColumnForExport("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
75 newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
76
77 newColumnForExport("Id_Lot", AccidentalCatchRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
78 newColumnForExport("Code_Taxon", AccidentalBatch.PROPERTY_SPECIES, TuttiCsvUtil.SPECIES_TECHNICAL_FORMATTER);
79 newColumnForExport("Nom_Scientifique", AccidentalBatch.PROPERTY_SPECIES, TuttiCsvUtil.SPECIES_FORMATTER);
80 newColumnForExport("Commentaire", AccidentalBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
81 newColumnForExport("Code_PMFM", AccidentalCatchRow.PROPERTY_CARACTERISTIC, TuttiCsvUtil.CARACTERISTIC_TECHNICAL_FORMATTER);
82 newColumnForExport("Libelle_PMFM", AccidentalCatchRow.PROPERTY_CARACTERISTIC, TuttiCsvUtil.CARACTERISTIC_FORMATTER);
83 newColumnForExport("Valeur", AccidentalCatchRow.PROPERTY_CARACTERISTIC_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
84
85 newColumnForExport("Serie_Id", Cruise.PROPERTY_PROGRAM, TuttiCsvUtil.PROGRAM_TECHNICAL_FORMATTER);
86 newColumnForExport("Valeur_Id", AccidentalCatchRow.PROPERTY_CARACTERISTIC_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_TECHNICAL_FORMATTER);
87
88 }
89
90 protected void forImport(GenericFormatImportEntityParserFactory parserFactory) {
91
92 newMandatoryColumn("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
93 newIgnoredColumn("Serie");
94 newMandatoryColumn("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
95
96 newMandatoryColumn("Code_Station", FishingOperation.PROPERTY_STATION_NUMBER);
97 newMandatoryColumn("Id_Operation", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
98 newMandatoryColumn("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
99
100 newMandatoryColumn("Id_Lot", AccidentalCatchRow.PROPERTY_BATCH_ID, TuttiCsvUtil.PRIMITIVE_INTEGER);
101 newMandatoryColumn("Code_Taxon", AccidentalBatch.PROPERTY_SPECIES, parserFactory.getSpeciesParser());
102 newIgnoredColumn("Nom_Scientifique");
103 newMandatoryColumn("Commentaire", AccidentalBatch.PROPERTY_COMMENT, TuttiCsvUtil.COMMENT_PARSER_FORMATTER);
104 newMandatoryColumn("Code_PMFM", AccidentalCatchRow.PROPERTY_CARACTERISTIC, parserFactory.getCaracteristicWithProtectedParser());
105 newIgnoredColumn("Libelle_PMFM");
106 newIgnoredColumn("Valeur");
107
108 newMandatoryColumn("Serie_Id", Cruise.PROPERTY_PROGRAM, parserFactory.getProgramParser());
109 newMandatoryColumn("Valeur_Id", AccidentalCatchRow.PROPERTY_CARACTERISTIC_VALUE);
110
111 }
112
113 }