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.Person;
29 import fr.ifremer.tutti.persistence.entities.referential.Persons;
30
31
32
33
34
35 public class PersonRow {
36
37 public static final String PROPERTY_ID = "id";
38
39 public static final String PROPERTY_FIRST_NAME = "firstName";
40
41 public static final String PROPERTY_LAST_NAME = "lastName";
42
43 public static final String PROPERTY_TO_DELETE = "toDelete";
44
45 protected String id;
46
47 protected String firstName;
48
49 protected String lastName;
50
51 protected Boolean toDelete;
52
53 public PersonRow() {
54 super();
55 }
56
57 public PersonRow(Person person) {
58 super();
59 Preconditions.checkNotNull(person);
60 setId(person.getId());
61 setFirstName(person.getFirstName());
62 setLastName(person.getLastName());
63 }
64
65 public String getId() {
66 return id;
67 }
68
69 public void setId(String id) {
70 this.id = id;
71 }
72
73 public String getFirstName() {
74 return firstName;
75 }
76
77 public void setFirstName(String firstName) {
78 this.firstName = firstName;
79 }
80
81 public String getLastName() {
82 return lastName;
83 }
84
85 public void setLastName(String lastName) {
86 this.lastName = lastName;
87 }
88
89 public String getFullName() {
90
91 Person person = this.toEntity();
92 return Persons.GET_FULL_NAME.apply(person);
93
94 }
95
96 public Boolean getToDelete() {
97 return toDelete;
98 }
99
100 public void setToDelete(Boolean toDelete) {
101 this.toDelete = toDelete;
102 }
103
104 public Person toEntity() {
105
106 Person person = Persons.newPerson();
107 person.setId(getId());
108 person.setFirstName(getFirstName());
109 person.setLastName(getLastName());
110 return person;
111
112 }
113
114 public Integer getIdAsInt() {
115 Integer idAsInt = null;
116 if (id != null) {
117 idAsInt = Integer.valueOf(id);
118 }
119 return idAsInt;
120 }
121 }