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