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
26
27 import com.google.common.base.Preconditions;
28 import fr.ifremer.tutti.persistence.entities.referential.Vessel;
29 import fr.ifremer.tutti.persistence.entities.referential.Vessels;
30
31
32
33
34
35 public class VesselRow {
36
37 public static final String PROPERTY_ID = "id";
38
39 public static final String PROPERTY_NAME = "name";
40
41 public static final String PROPERTY_SCIENTIFIC_VESSEL = "scientificVessel";
42
43 public static final String PROPERTY_INTERNATIONAL_REGISTRATION_CODE = "internationalRegistrationCode";
44
45 public static final String PROPERTY_TO_DELETE = "toDelete";
46
47 protected String id;
48
49 protected String name;
50
51 protected boolean scientificVessel;
52
53 protected String internationalRegistrationCode;
54
55 protected Boolean toDelete;
56
57 public VesselRow() {
58 super();
59 }
60
61 public VesselRow(Vessel vessel) {
62 super();
63 Preconditions.checkNotNull(vessel);
64 setId(vessel.getId());
65
66 setName(vessel.getName());
67 setInternationalRegistrationCode(vessel.getInternationalRegistrationCode());
68 setScientificVessel(vessel.isScientificVessel());
69 }
70
71 public String getId() {
72 return id;
73 }
74
75 public void setId(String id) {
76 this.id = id;
77 }
78
79 public String getName() {
80 return name;
81 }
82
83 public void setName(String name) {
84 this.name = name;
85 }
86
87 public boolean isScientificVessel() {
88 return scientificVessel;
89 }
90
91 public void setScientificVessel(boolean scientificVessel) {
92 this.scientificVessel = scientificVessel;
93 }
94
95 public String getInternationalRegistrationCode() {
96 return internationalRegistrationCode;
97 }
98
99 public void setInternationalRegistrationCode(String internationalRegistrationCode) {
100 this.internationalRegistrationCode = internationalRegistrationCode;
101 }
102
103 public Boolean getToDelete() {
104 return toDelete;
105 }
106
107 public void setToDelete(Boolean toDelete) {
108 this.toDelete = toDelete;
109 }
110
111 public Vessel toEntity() {
112
113 Vessel vessel = Vessels.newVessel();
114 vessel.setId(getId());
115 vessel.setName(getName());
116 vessel.setScientificVessel(isScientificVessel());
117 vessel.setInternationalRegistrationCode(getInternationalRegistrationCode());
118 return vessel;
119
120 }
121
122 public Integer getIdAsInt() {
123 Integer idAsInt = null;
124 if (id != null) {
125 idAsInt = Integer.valueOf(id);
126 }
127 return idAsInt;
128 }
129 }