newest developments for specimen import (e.g. area levels)
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / specimen / excel / in / SpecimenRow.java
1 /**
2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.cdm.io.specimen.excel.in;
11
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.TreeMap;
16 import java.util.UUID;
17
18 import org.apache.log4j.Logger;
19
20 import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenRow.LeveledArea;
21 import eu.etaxonomy.cdm.model.common.IdentifiableSource;
22 import eu.etaxonomy.cdm.model.location.NamedArea;
23 import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
24 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
25 import eu.etaxonomy.cdm.model.name.NonViralName;
26 import eu.etaxonomy.cdm.model.name.Rank;
27 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
28 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
29 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
30 import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
31 import eu.etaxonomy.cdm.model.reference.Reference;
32
33 /**
34 * @author a.mueller
35 * @created 08.04.2011
36 * @version 1.0
37 */
38 public class SpecimenRow {
39 @SuppressWarnings("unused")
40 private static final Logger logger = Logger.getLogger(SpecimenRow.class);
41
42 private UUID uuid = null;
43 private String basisOfRecord;
44 private String country;
45 private String isoCountry;
46 private String locality;
47 private String latitude;
48 private String longitude;
49 private String fieldNotes;
50 private String fieldNumber;
51 private String accessionNumber;
52 private String barcode;
53 // private String author;
54 private String absoluteElevation;
55 // private String family;
56 // private String genus;
57 // private String specificEpithet;
58 private String sex;
59 private String ecology;
60 private String plantDescription;
61 private String collectionCode;
62 private String collection;
63 private String collectingDate;
64 private String collectingDateEnd;
65 private String collectorsNumber;
66 private String referenceSystem;
67 private String errorRadius;
68
69
70 private TreeMap<Integer, IdentifiableSource> sources = new TreeMap<Integer, IdentifiableSource>();
71 private TreeMap<Integer, String> collectors = new TreeMap<Integer, String>();
72 private TreeMap<Integer, SpecimenTypeDesignation> types = new TreeMap<Integer, SpecimenTypeDesignation>();
73 private TreeMap<Integer, DeterminationLight> determinations = new TreeMap<Integer, DeterminationLight>();
74 private List<LeveledArea> levels = new ArrayList<LeveledArea>();
75
76
77
78 public SpecimenRow() {
79 }
80
81 protected class LeveledArea{
82 String area;
83 String areaLevel;
84 }
85
86
87
88 // may be public if necessary
89 protected class DeterminationLight{
90 String family;
91 String genus;
92 String rank;
93 String fullName;
94 String speciesEpi;
95 String infraSpeciesEpi;
96 String author;
97 String modifier;
98 String determinedBy;
99 String determinedWhen;
100 String notes;
101 }
102
103
104 // **************************** GETTER / SETTER *********************************/
105
106
107 public void setUuid(UUID uuid) {
108 this.uuid = uuid;
109 }
110
111
112 public UUID getUuid() {
113 return uuid;
114 }
115
116
117 public void setBasisOfRecord(String basisOfRecord) {
118 this.basisOfRecord = basisOfRecord;
119 }
120
121
122 public String getBasisOfRecord() {
123 return basisOfRecord;
124 }
125
126
127 public void setCountry(String country) {
128 this.country = country;
129 }
130
131
132 public String getCountry() {
133 return country;
134 }
135
136
137 public void setIsoCountry(String isoCountry) {
138 this.isoCountry = isoCountry;
139 }
140
141
142 public String getIsoCountry() {
143 return isoCountry;
144 }
145
146
147 public void setLocality(String locality) {
148 this.locality = locality;
149 }
150
151
152 public String getLocality() {
153 return locality;
154 }
155
156
157 public void setFieldNotes(String fieldNotes) {
158 this.fieldNotes = fieldNotes;
159 }
160
161
162 public String getFieldNotes() {
163 return fieldNotes;
164 }
165
166
167 public void setAccessionNumber(String accessionNumber) {
168 this.accessionNumber = accessionNumber;
169 }
170
171
172 public String getAccessionNumber() {
173 return accessionNumber;
174 }
175
176
177 public void setFieldNumber(String fieldNumber) {
178 this.fieldNumber = fieldNumber;
179 }
180
181
182 public String getFieldNumber() {
183 return fieldNumber;
184 }
185
186
187 public void setBarcode(String barcode) {
188 this.barcode = barcode;
189 }
190 //
191 // /**
192 // * @return the author
193 // */
194 // public String getAuthor() {
195 // return author;
196 // }
197 //
198 //
199 // /**
200 // * @param author the author to set
201 // */
202 // public void setAuthor(String author) {
203 // this.author = author;
204 // }
205
206
207 /**
208 * @return the absoluteElevation
209 */
210 public String getAbsoluteElevation() {
211 return absoluteElevation;
212 }
213
214
215 /**
216 * @param absoluteElevation the absoluteElevation to set
217 */
218 public void setAbsoluteElevation(String absoluteElevation) {
219 this.absoluteElevation = absoluteElevation;
220 }
221
222
223
224 /**
225 * @return the ecology
226 */
227 public String getEcology() {
228 return ecology;
229 }
230
231
232 /**
233 * @param ecology the ecology to set
234 */
235 public void setEcology(String ecology) {
236 this.ecology = ecology;
237 }
238
239
240 /**
241 * @return the plantDescription
242 */
243 public String getPlantDescription() {
244 return plantDescription;
245 }
246
247
248 /**
249 * @param plantDescription the plantDescription to set
250 */
251 public void setPlantDescription(String plantDescription) {
252 this.plantDescription = plantDescription;
253 }
254
255
256 /**
257 * @return the collectionCode
258 */
259 public String getCollectionCode() {
260 return collectionCode;
261 }
262
263
264 /**
265 * @param collectionCode the collectionCode to set
266 */
267 public void setCollectionCode(String collectionCode) {
268 this.collectionCode = collectionCode;
269 }
270
271
272 /**
273 * @return the collectingDate
274 */
275 public String getCollectingDate() {
276 return collectingDate;
277 }
278
279
280 /**
281 * @param collectingDate the collectingDate to set
282 */
283 public void setCollectingDate(String collectingDate) {
284 this.collectingDate = collectingDate;
285 }
286
287
288 /**
289 * @return the collectorsNumber
290 */
291 public String getCollectorsNumber() {
292 return collectorsNumber;
293 }
294
295
296 /**
297 * @param collectorsNumber the collectorsNumber to set
298 */
299 public void setCollectorsNumber(String collectorsNumber) {
300 this.collectorsNumber = collectorsNumber;
301 }
302
303
304 /**
305 * @return the barcode
306 */
307 public String getBarcode() {
308 return barcode;
309 }
310
311
312 /**
313 * @return the collectingDateEnd
314 */
315 public String getCollectingDateEnd() {
316 return collectingDateEnd;
317 }
318
319
320 /**
321 * @param collectingDateEnd the collectingDateEnd to set
322 */
323 public void setCollectingDateEnd(String collectingDateEnd) {
324 this.collectingDateEnd = collectingDateEnd;
325 }
326
327
328 /**
329 * @return the latitude
330 */
331 public String getLatitude() {
332 return latitude;
333 }
334
335
336 /**
337 * @param latitude the latitude to set
338 */
339 public void setLatitude(String latitude) {
340 this.latitude = latitude;
341 }
342
343
344 /**
345 * @return the longitude
346 */
347 public String getLongitude() {
348 return longitude;
349 }
350
351
352 /**
353 * @param longitude the longitude to set
354 */
355 public void setLongitude(String longitude) {
356 this.longitude = longitude;
357 }
358
359
360 public void putIdInSource(int key, String id){
361 IdentifiableSource source = getOrMakeSource(key);
362 source.setIdInSource(id);
363 }
364 public void putSourceReference(int key, Reference<?> reference){
365 IdentifiableSource source = getOrMakeSource(key);
366 source.setCitation(reference);
367 }
368
369 public List<IdentifiableSource> getSources() {
370 return getOrdered(sources);
371 }
372
373 public void putCollector(int key, String collector){
374 this.collectors.put(key, collector);
375 }
376
377 public List<String> getCollectors() {
378 return getOrdered(collectors);
379 }
380
381
382
383 /**
384 * @param key
385 * @return
386 */
387 private IdentifiableSource getOrMakeSource(int key) {
388 IdentifiableSource source = sources.get(key);
389 if (source == null){
390 source = IdentifiableSource.NewInstance();
391 sources.put(key, source);
392 }
393 return source;
394 }
395
396
397 public void putTypeCategory(int key, SpecimenTypeDesignationStatus status){
398 SpecimenTypeDesignation designation = getOrMakeTypeDesignation(key);
399 designation.setTypeStatus(status);
400 }
401 public void putTypifiedName(int key, TaxonNameBase<?,?> name){
402 if (name != null){
403 SpecimenTypeDesignation designation = getOrMakeTypeDesignation(key);
404 name.addTypeDesignation(designation, false);
405 }
406 }
407
408 public List<SpecimenTypeDesignation> getTypeDesignations() {
409 return getOrdered(types);
410 }
411
412
413 private SpecimenTypeDesignation getOrMakeTypeDesignation(int key) {
414 SpecimenTypeDesignation designation = types.get(key);
415 if (designation == null){
416 designation = SpecimenTypeDesignation.NewInstance();
417 types.put(key, designation);
418 }
419 return designation;
420 }
421
422 public void putDeterminationFamily(int key, String family){
423 DeterminationLight determinationEvent = getOrMakeDetermination(key);
424 determinationEvent.family = family;
425 }
426
427 public void putDeterminationFullName(int key, String fullName){
428 DeterminationLight determinationEvent = getOrMakeDetermination(key);
429 determinationEvent.fullName = fullName;
430 }
431
432 public void putDeterminationRank(int key, String rank){
433 DeterminationLight determinationEvent = getOrMakeDetermination(key);
434 determinationEvent.rank = rank;
435 }
436
437 public void putDeterminationGenus(int key, String genus){
438 DeterminationLight determinationEvent = getOrMakeDetermination(key);
439 determinationEvent.genus = genus;
440 }
441
442 public void putDeterminationSpeciesEpi(int key, String speciesEpi){
443 DeterminationLight determinationEvent = getOrMakeDetermination(key);
444 determinationEvent.speciesEpi = speciesEpi;
445 }
446
447 public void putDeterminationInfraSpeciesEpi(int key, String infraSpeciesEpi){
448 DeterminationLight determinationEvent = getOrMakeDetermination(key);
449 determinationEvent.infraSpeciesEpi = infraSpeciesEpi;
450 }
451
452 public void putDeterminationAuthor(int key, String author){
453 DeterminationLight determinationEvent = getOrMakeDetermination(key);
454 determinationEvent.author = author;
455 }
456
457 public void putDeterminationDeterminedBy(int key, String determinedBy){
458 DeterminationLight determinationEvent = getOrMakeDetermination(key);
459 determinationEvent.determinedBy = determinedBy;
460 }
461
462 public void putDeterminationDeterminedWhen(int key, String determinedWhen){
463 DeterminationLight determinationEvent = getOrMakeDetermination(key);
464 determinationEvent.determinedWhen = determinedWhen;
465 }
466
467 public void putDeterminationDeterminationNotes(int key, String notes){
468 DeterminationLight determinationEvent = getOrMakeDetermination(key);
469 determinationEvent.notes = notes;
470 }
471
472 public void putDeterminationDeterminationModifier(int key, String modifier){
473 DeterminationLight determinationEvent = getOrMakeDetermination(key);
474 determinationEvent.modifier = modifier;
475 }
476
477 public List<DeterminationLight> getDetermination() {
478 return getOrdered(determinations);
479 }
480
481
482
483 private DeterminationLight getOrMakeDetermination(int key) {
484 DeterminationLight determination = this.determinations.get(key);
485 if (determination == null){
486 determination = new DeterminationLight();
487 this.determinations.put(key, determination);
488 }
489 return determination;
490 }
491
492
493 private<T extends Object> List<T> getOrdered(TreeMap<?, T> tree) {
494 List<T> result = new ArrayList<T>();
495 for (T value : tree.values()){
496 result.add(value);
497 }
498 return result;
499 }
500
501 public void setSex(String sex) {
502 this.sex = sex;
503 }
504
505
506 public String getSex() {
507 return sex;
508 }
509
510
511 /**
512 * @return the referenceSystem
513 */
514 public String getReferenceSystem() {
515 return referenceSystem;
516 }
517
518
519 /**
520 * @param referenceSystem the referenceSystem to set
521 */
522 public void setReferenceSystem(String referenceSystem) {
523 this.referenceSystem = referenceSystem;
524 }
525
526
527 /**
528 * @return the errorRadius
529 */
530 public String getErrorRadius() {
531 return errorRadius;
532 }
533
534
535 /**
536 * @param errorRadius the errorRadius to set
537 */
538 public void setErrorRadius(String errorRadius) {
539 this.errorRadius = errorRadius;
540 }
541
542
543 public void setCollection(String collection) {
544 this.collection = collection;
545 }
546
547
548 public String getCollection() {
549 return collection;
550 }
551
552
553 public void addLeveledArea(String levelPostfix, String value) {
554 LeveledArea area = new LeveledArea();
555 this.levels.add(area);
556 // getOrMakeLeveledArea(level);
557 }
558
559 public List<LeveledArea> getLeveledAreas(){
560 return levels;
561 }
562
563 // private NamedAreaLevel getOrMakeLeveledArea(String key) {
564 // NamedAreaLevel level = this.levels.get(key);
565 // if (level == null){
566 // level = new NamedAreaLevel();
567 // this.levels.put(key, level);
568 // }
569 // return level;
570 // }
571
572
573 }