1 package fr.ifremer.tutti.service.referential.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.adagio.core.dao.technical.hibernate.TemporaryDataHelper;
26 import fr.ifremer.tutti.persistence.entities.referential.Vessel;
27 import fr.ifremer.tutti.persistence.entities.referential.Vessels;
28 import fr.ifremer.tutti.service.csv.AbstractTuttiImportExportModel;
29 import fr.ifremer.tutti.service.csv.TuttiCsvUtil;
30 import org.nuiton.csv.Common;
31
32 import static org.nuiton.i18n.I18n.t;
33
34
35
36
37
38
39
40 public class VesselModel extends AbstractTuttiImportExportModel<VesselRow> {
41
42 public static VesselModel forExport(char separator) {
43
44 VesselModel exportModel = new VesselModel(separator);
45 exportModel.forExport();
46 return exportModel;
47
48 }
49
50 public static VesselModel forImport(char separator) {
51
52 VesselModel importModel = new VesselModel(separator);
53 importModel.forImport();
54 return importModel;
55
56 }
57
58 @Override
59 public VesselRow newEmptyInstance() {
60 return new VesselRow();
61 }
62
63 protected VesselModel(char separator) {
64 super(separator);
65 }
66
67 protected void forImport() {
68
69 newMandatoryColumn(GearRow.PROPERTY_ID, new TemporaryReferentialEntityIdParser(
70 t("tutti.service.referential.import.vessel.codePrefixMissing.error", TemporaryDataHelper.TEMPORARY_NAME_PREFIX)){
71
72 @Override
73 protected boolean isTemporaryId(String parse) {
74 return Vessels.isTemporaryId(parse);
75 }
76 });
77 newMandatoryColumn(VesselRow.PROPERTY_NAME);
78 newMandatoryColumn(VesselRow.PROPERTY_INTERNATIONAL_REGISTRATION_CODE);
79 newMandatoryColumn(VesselRow.PROPERTY_SCIENTIFIC_VESSEL, Common.PRIMITIVE_BOOLEAN);
80 newMandatoryColumn(VesselRow.PROPERTY_TO_DELETE, TuttiCsvUtil.BOOLEAN);
81
82 }
83
84 protected void forExport() {
85
86 newColumnForExport(VesselRow.PROPERTY_ID);
87 newColumnForExport(VesselRow.PROPERTY_NAME);
88 newColumnForExport(VesselRow.PROPERTY_INTERNATIONAL_REGISTRATION_CODE);
89 newColumnForExport(VesselRow.PROPERTY_SCIENTIFIC_VESSEL, Common.PRIMITIVE_BOOLEAN);
90 newColumnForExport(VesselRow.PROPERTY_TO_DELETE);
91
92 }
93
94 }