1 package fr.ifremer.tutti.persistence.entities.data;
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 com.google.common.base.Preconditions;
26 import com.google.common.primitives.Ints;
27 import fr.ifremer.tutti.persistence.TuttiPersistence;
28 import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
29
30 import java.io.Serializable;
31
32
33
34
35
36
37
38
39
40 public class SampleCategoryModelEntry implements Comparable<SampleCategoryModelEntry>, Serializable {
41
42 private static final long serialVersionUID = 1L;
43
44 protected String code;
45
46 protected String label;
47
48 protected Integer categoryId;
49
50 protected int order;
51
52 protected transient Caracteristic caracteristic;
53
54 public void load(TuttiPersistence service) {
55 Preconditions.checkNotNull(code, "Can't have a null code");
56 Preconditions.checkNotNull(categoryId, "Can't have a null category id");
57 caracteristic = service.getCaracteristic(categoryId);
58 Preconditions.checkNotNull(caracteristic, "Could not find category if id: " + categoryId);
59 }
60
61 public String getCode() {
62 return code;
63 }
64
65 public void setCode(String code) {
66 this.code = code;
67 }
68
69 public String getLabel() {
70 return label;
71 }
72
73 public void setLabel(String label) {
74 this.label = label;
75 }
76
77 public Caracteristic getCaracteristic() {
78 return caracteristic;
79 }
80
81 public void setCaracteristic(Caracteristic caracteristic) {
82 this.caracteristic = caracteristic;
83 }
84
85 public Integer getCategoryId() {
86 return categoryId;
87 }
88
89 public void setCategoryId(Integer categoryId) {
90 this.categoryId = categoryId;
91 }
92
93 public int getOrder() {
94 return order;
95 }
96
97 public void setOrder(int order) {
98 this.order = order;
99 }
100
101 @Override
102 public int compareTo(SampleCategoryModelEntry o) {
103 return Ints.compare(order, o.getOrder());
104 }
105
106 @Override
107 public String toString() {
108 return categoryId + "," + label + "," + code;
109 }
110 }