1
2
3
4
5
6 package fr.ifremer.quadrige2.core.dao.referential;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 import fr.ifremer.quadrige2.core.dao.referential.monitoringLocation.ProjectionSystem;
30 import fr.ifremer.quadrige2.core.dao.referential.pmfm.Pmfm;
31 import java.io.Serializable;
32 import java.sql.Timestamp;
33 import java.util.Collection;
34 import java.util.Date;
35 import java.util.HashSet;
36
37
38
39
40
41 public abstract class Unit
42 implements Serializable, Comparable<Unit>
43 {
44
45
46
47 private static final long serialVersionUID = -4718773931997930290L;
48
49
50 private Integer unitId;
51
52
53
54
55
56 public Integer getUnitId()
57 {
58 return this.unitId;
59 }
60
61
62
63
64
65 public void setUnitId(Integer unitIdIn)
66 {
67 this.unitId = unitIdIn;
68 }
69
70 private String unitNm;
71
72
73
74
75
76 public String getUnitNm()
77 {
78 return this.unitNm;
79 }
80
81
82
83
84
85 public void setUnitNm(String unitNmIn)
86 {
87 this.unitNm = unitNmIn;
88 }
89
90 private String unitSymbol;
91
92
93
94
95
96 public String getUnitSymbol()
97 {
98 return this.unitSymbol;
99 }
100
101
102
103
104
105 public void setUnitSymbol(String unitSymbolIn)
106 {
107 this.unitSymbol = unitSymbolIn;
108 }
109
110 private Date unitCreationDt;
111
112
113
114
115
116 public Date getUnitCreationDt()
117 {
118 return this.unitCreationDt;
119 }
120
121
122
123
124
125 public void setUnitCreationDt(Date unitCreationDtIn)
126 {
127 this.unitCreationDt = unitCreationDtIn;
128 }
129
130 private Timestamp updateDt;
131
132
133
134
135
136 public Timestamp getUpdateDt()
137 {
138 return this.updateDt;
139 }
140
141
142
143
144
145 public void setUpdateDt(Timestamp updateDtIn)
146 {
147 this.updateDt = updateDtIn;
148 }
149
150
151 private Collection<Pmfm> pmfms = new HashSet<Pmfm>();
152
153
154
155
156
157 public Collection<Pmfm> getPmfms()
158 {
159 return this.pmfms;
160 }
161
162
163
164
165
166 public void setPmfms(Collection<Pmfm> pmfmsIn)
167 {
168 this.pmfms = pmfmsIn;
169 }
170
171
172
173
174
175
176
177 public boolean addPmfms(Pmfm elementToAdd)
178 {
179 return this.pmfms.add(elementToAdd);
180 }
181
182
183
184
185
186
187
188 public boolean removePmfms(Pmfm elementToRemove)
189 {
190 return this.pmfms.remove(elementToRemove);
191 }
192
193 private Status status;
194
195
196
197
198
199 public Status getStatus()
200 {
201 return this.status;
202 }
203
204
205
206
207
208 public void setStatus(Status statusIn)
209 {
210 this.status = statusIn;
211 }
212
213 private Collection<SamplingEquipment> samplingEquipmentIds = new HashSet<SamplingEquipment>();
214
215
216
217
218
219 public Collection<SamplingEquipment> getSamplingEquipmentIds()
220 {
221 return this.samplingEquipmentIds;
222 }
223
224
225
226
227
228 public void setSamplingEquipmentIds(Collection<SamplingEquipment> samplingEquipmentIdsIn)
229 {
230 this.samplingEquipmentIds = samplingEquipmentIdsIn;
231 }
232
233
234
235
236
237
238
239 public boolean addSamplingEquipmentIds(SamplingEquipment elementToAdd)
240 {
241 return this.samplingEquipmentIds.add(elementToAdd);
242 }
243
244
245
246
247
248
249
250 public boolean removeSamplingEquipmentIds(SamplingEquipment elementToRemove)
251 {
252 return this.samplingEquipmentIds.remove(elementToRemove);
253 }
254
255 private Collection<ProjectionSystem> projSystemCds = new HashSet<ProjectionSystem>();
256
257
258
259
260
261 public Collection<ProjectionSystem> getProjSystemCds()
262 {
263 return this.projSystemCds;
264 }
265
266
267
268
269
270 public void setProjSystemCds(Collection<ProjectionSystem> projSystemCdsIn)
271 {
272 this.projSystemCds = projSystemCdsIn;
273 }
274
275
276
277
278
279
280
281 public boolean addProjSystemCds(ProjectionSystem elementToAdd)
282 {
283 return this.projSystemCds.add(elementToAdd);
284 }
285
286
287
288
289
290
291
292 public boolean removeProjSystemCds(ProjectionSystem elementToRemove)
293 {
294 return this.projSystemCds.remove(elementToRemove);
295 }
296
297
298
299
300
301 @Override
302 public boolean equals(Object object)
303 {
304 if (this == object)
305 {
306 return true;
307 }
308 if (!(object instanceof Unit))
309 {
310 return false;
311 }
312 final Unit that = (Unit)object;
313 if (this.unitId == null || that.getUnitId() == null || !this.unitId.equals(that.getUnitId()))
314 {
315 return false;
316 }
317 return true;
318 }
319
320
321
322
323 @Override
324 public int hashCode()
325 {
326 int hashCode = 0;
327 hashCode = 29 * hashCode + (this.unitId == null ? 0 : this.unitId.hashCode());
328
329 return hashCode;
330 }
331
332
333
334
335 public static final class Factory
336 {
337
338
339
340
341 public static Unit newInstance()
342 {
343 return new UnitImpl();
344 }
345
346
347
348
349
350
351
352
353
354 public static Unit newInstance(String unitNm, Timestamp updateDt, Status status)
355 {
356 final Unit entity = new UnitImpl();
357 entity.setUnitNm(unitNm);
358 entity.setUpdateDt(updateDt);
359 entity.setStatus(status);
360 return entity;
361 }
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376 public static Unit newInstance(String unitNm, String unitSymbol, Date unitCreationDt, Timestamp updateDt, Collection<Pmfm> pmfms, Status status, Collection<SamplingEquipment> samplingEquipmentIds, Collection<ProjectionSystem> projSystemCds)
377 {
378 final Unit entity = new UnitImpl();
379 entity.setUnitNm(unitNm);
380 entity.setUnitSymbol(unitSymbol);
381 entity.setUnitCreationDt(unitCreationDt);
382 entity.setUpdateDt(updateDt);
383 entity.setPmfms(pmfms);
384 entity.setStatus(status);
385 entity.setSamplingEquipmentIds(samplingEquipmentIds);
386 entity.setProjSystemCds(projSystemCds);
387 return entity;
388 }
389 }
390
391
392
393
394 public int compareTo(Unit o)
395 {
396 int cmp = 0;
397 if (this.getUnitId() != null)
398 {
399 cmp = this.getUnitId().compareTo(o.getUnitId());
400 }
401 else
402 {
403 if (this.getUnitNm() != null)
404 {
405 cmp = (cmp != 0 ? cmp : this.getUnitNm().compareTo(o.getUnitNm()));
406 }
407 if (this.getUnitSymbol() != null)
408 {
409 cmp = (cmp != 0 ? cmp : this.getUnitSymbol().compareTo(o.getUnitSymbol()));
410 }
411 if (this.getUnitCreationDt() != null)
412 {
413 cmp = (cmp != 0 ? cmp : this.getUnitCreationDt().compareTo(o.getUnitCreationDt()));
414 }
415 if (this.getUpdateDt() != null)
416 {
417 cmp = (cmp != 0 ? cmp : this.getUpdateDt().compareTo(o.getUpdateDt()));
418 }
419 }
420 return cmp;
421 }
422
423
424 }