2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.specimen
.excel
.in
;
12 import java
.util
.ArrayList
;
13 import java
.util
.List
;
14 import java
.util
.TreeMap
;
16 import org
.apache
.commons
.lang
.StringUtils
;
17 import org
.apache
.log4j
.Logger
;
19 import eu
.etaxonomy
.cdm
.io
.excel
.common
.ExcelRowBase
;
20 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
21 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
22 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
23 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
24 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
31 public class SpecimenRow
extends ExcelRowBase
{
32 @SuppressWarnings("unused")
33 private static final Logger logger
= Logger
.getLogger(SpecimenRow
.class);
35 private String basisOfRecord
;
37 private String country
;
38 private String isoCountry
;
39 private String locality
;
40 private String latitude
;
41 private String longitude
;
42 private String referenceSystem
;
43 private String errorRadius
;
44 private String altitude
;
45 private String altitudeMax
;
46 private String fieldNotes
;
47 private String collectingDate
;
48 private String collectingDateEnd
;
49 private String collectorsNumber
;
50 private String primaryCollector
;
54 private String accessionNumber
;
55 private String barcode
;
57 // private String author;
59 // private String family;
60 // private String genus;
61 // private String specificEpithet;
62 private String collectionCode
;
63 private String collection
;
66 private TreeMap
<Integer
, IdentifiableSource
> sources
= new TreeMap
<Integer
, IdentifiableSource
>();
67 private TreeMap
<Integer
, String
> collectors
= new TreeMap
<Integer
, String
>();
68 private TreeMap
<Integer
, String
> unitNotes
= new TreeMap
<Integer
, String
>();
69 private TreeMap
<Integer
, SpecimenTypeDesignation
> types
= new TreeMap
<Integer
, SpecimenTypeDesignation
>();
70 private TreeMap
<Integer
, DeterminationLight
> determinations
= new TreeMap
<Integer
, DeterminationLight
>();
71 private List
<PostfixTerm
> levels
= new ArrayList
<PostfixTerm
>();
75 public SpecimenRow() {
80 // may be public if necessary
81 protected class DeterminationLight
{
88 String infraSpeciesEpi
;
92 String determinedWhen
;
95 public boolean hasTaxonInformation() {
96 boolean result
= StringUtils
.isNotBlank(taxonUuid
)
97 || StringUtils
.isNotBlank(family
)
98 || StringUtils
.isNotBlank(genus
)
99 || StringUtils
.isNotBlank(rank
)
100 || StringUtils
.isNotBlank(fullName
)
101 || StringUtils
.isNotBlank(speciesEpi
)
102 || StringUtils
.isNotBlank(author
)
103 || StringUtils
.isNotBlank(infraSpeciesEpi
);
110 // **************************** GETTER / SETTER *********************************/
112 public void setBasisOfRecord(String basisOfRecord
) {
113 this.basisOfRecord
= basisOfRecord
;
117 public String
getBasisOfRecord() {
118 return basisOfRecord
;
122 public void setCountry(String country
) {
123 this.country
= country
;
127 public String
getCountry() {
132 public void setIsoCountry(String isoCountry
) {
133 this.isoCountry
= isoCountry
;
137 public String
getIsoCountry() {
142 public void setLocality(String locality
) {
143 this.locality
= locality
;
147 public String
getLocality() {
152 public void setFieldNotes(String fieldNotes
) {
153 this.fieldNotes
= fieldNotes
;
157 public String
getFieldNotes() {
162 public void setAccessionNumber(String accessionNumber
) {
163 this.accessionNumber
= accessionNumber
;
167 public String
getAccessionNumber() {
168 return accessionNumber
;
172 public void setBarcode(String barcode
) {
173 this.barcode
= barcode
;
177 // * @return the author
179 // public String getAuthor() {
185 // * @param author the author to set
187 // public void setAuthor(String author) {
188 // this.author = author;
193 * @return the absoluteElevation
195 public String
getAltitude() {
201 * @param absoluteElevation the absoluteElevation to set
203 public void setAltitude(String altitude
) {
204 this.altitude
= altitude
;
209 * @return the collectionCode
211 public String
getCollectionCode() {
212 return collectionCode
;
217 * @param collectionCode the collectionCode to set
219 public void setCollectionCode(String collectionCode
) {
220 this.collectionCode
= collectionCode
;
225 * @return the collectingDate
227 public String
getCollectingDate() {
228 return collectingDate
;
233 * @param collectingDate the collectingDate to set
235 public void setCollectingDate(String collectingDate
) {
236 this.collectingDate
= collectingDate
;
241 * @return the collectorsNumber
243 public String
getCollectorsNumber() {
244 return collectorsNumber
;
249 * @param collectorsNumber the collectorsNumber to set
251 public void setCollectorsNumber(String collectorsNumber
) {
252 this.collectorsNumber
= collectorsNumber
;
257 * @return the barcode
259 public String
getBarcode() {
265 * @return the collectingDateEnd
267 public String
getCollectingDateEnd() {
268 return collectingDateEnd
;
273 * @param collectingDateEnd the collectingDateEnd to set
275 public void setCollectingDateEnd(String collectingDateEnd
) {
276 this.collectingDateEnd
= collectingDateEnd
;
281 * @return the latitude
283 public String
getLatitude() {
289 * @param latitude the latitude to set
291 public void setLatitude(String latitude
) {
292 this.latitude
= latitude
;
297 * @return the longitude
299 public String
getLongitude() {
305 * @param longitude the longitude to set
307 public void setLongitude(String longitude
) {
308 this.longitude
= longitude
;
312 public void putIdInSource(int key
, String id
){
313 IdentifiableSource source
= getOrMakeSource(key
);
314 source
.setIdInSource(id
);
316 public void putSourceReference(int key
, Reference
<?
> reference
){
317 IdentifiableSource source
= getOrMakeSource(key
);
318 source
.setCitation(reference
);
321 public List
<IdentifiableSource
> getSources() {
322 return getOrdered(sources
);
326 public void setCollectors(String value
) {
327 //TODO better parse somewhere else? Quick and dirty implementation
328 List
<String
> authors
= new ArrayList
<String
>();
329 String
[] splits
= value
.split("&");
330 for (String split
: splits
){
331 split
= split
.trim();
335 for (int i
= 0; i
< authors
.size() ; i
++){
336 String author
= authors
.get(i
);
337 if (i
< authors
.size()-1){
338 String
[] internalSplits
= author
.split(",");
339 for (String internal
: internalSplits
){
340 internal
= internal
.trim();
341 this.collectors
.put(index
++, internal
);
344 this.collectors
.put(index
++, author
);
349 public void putCollector(int key
, String collector
){
350 this.collectors
.put(key
, collector
);
353 public List
<String
> getCollectors() {
354 return getOrdered(collectors
);
357 public void putUnitNote(int key
, String unitNote
){
358 this.unitNotes
.put(key
, unitNote
);
361 public List
<String
> getUnitNotes() {
362 return getOrdered(unitNotes
);
371 private IdentifiableSource
getOrMakeSource(int key
) {
372 IdentifiableSource source
= sources
.get(key
);
374 source
= IdentifiableSource
.NewInstance();
375 sources
.put(key
, source
);
381 public void putTypeCategory(int key
, SpecimenTypeDesignationStatus status
){
382 SpecimenTypeDesignation designation
= getOrMakeTypeDesignation(key
);
383 designation
.setTypeStatus(status
);
385 public void putTypifiedName(int key
, TaxonNameBase
<?
,?
> name
){
387 SpecimenTypeDesignation designation
= getOrMakeTypeDesignation(key
);
388 name
.addTypeDesignation(designation
, false);
392 public List
<SpecimenTypeDesignation
> getTypeDesignations() {
393 return getOrdered(types
);
397 private SpecimenTypeDesignation
getOrMakeTypeDesignation(int key
) {
398 SpecimenTypeDesignation designation
= types
.get(key
);
399 if (designation
== null){
400 designation
= SpecimenTypeDesignation
.NewInstance();
401 types
.put(key
, designation
);
406 public void putDeterminationFamily(int key
, String family
){
407 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
408 determinationEvent
.family
= family
;
411 public void putDeterminationFullName(int key
, String fullName
){
412 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
413 determinationEvent
.fullName
= fullName
;
416 public void putDeterminationTaxonUuid(int key
, String taxonUuid
){
417 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
418 determinationEvent
.taxonUuid
= taxonUuid
;
421 public void putDeterminationRank(int key
, String rank
){
422 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
423 determinationEvent
.rank
= rank
;
426 public void putDeterminationGenus(int key
, String genus
){
427 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
428 determinationEvent
.genus
= genus
;
431 public void putDeterminationSpeciesEpi(int key
, String speciesEpi
){
432 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
433 determinationEvent
.speciesEpi
= speciesEpi
;
436 public void putDeterminationInfraSpeciesEpi(int key
, String infraSpeciesEpi
){
437 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
438 determinationEvent
.infraSpeciesEpi
= infraSpeciesEpi
;
441 public void putDeterminationAuthor(int key
, String author
){
442 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
443 determinationEvent
.author
= author
;
446 public void putDeterminationDeterminedBy(int key
, String determinedBy
){
447 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
448 determinationEvent
.determinedBy
= determinedBy
;
451 public void putDeterminationDeterminedWhen(int key
, String determinedWhen
){
452 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
453 determinationEvent
.determinedWhen
= determinedWhen
;
456 public void putDeterminationDeterminationNotes(int key
, String notes
){
457 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
458 determinationEvent
.notes
= notes
;
461 public void putDeterminationDeterminationModifier(int key
, String modifier
){
462 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
463 determinationEvent
.modifier
= modifier
;
467 public List
<DeterminationLight
> getDetermination() {
468 List
<DeterminationLight
> result
= getOrdered(determinations
);
469 if (determinations
.size() > 1 && getCommonDetermination()!= null ){
470 result
.remove(getCommonDetermination());
476 * Returns the determination with key "0".
479 public DeterminationLight
getCommonDetermination() {
480 if (determinations
.get(0) != null){
481 return determinations
.get(0);
488 private DeterminationLight
getOrMakeDetermination(int key
) {
489 DeterminationLight determination
= this.determinations
.get(key
);
490 if (determination
== null){
491 determination
= new DeterminationLight();
492 this.determinations
.put(key
, determination
);
494 return determination
;
498 private<T
extends Object
> List
<T
> getOrdered(TreeMap
<?
, T
> tree
) {
499 List
<T
> result
= new ArrayList
<T
>();
500 for (T value
: tree
.values()){
506 public void setSex(String sex
) {
511 public String
getSex() {
517 * @return the referenceSystem
519 public String
getReferenceSystem() {
520 return referenceSystem
;
525 * @param referenceSystem the referenceSystem to set
527 public void setReferenceSystem(String referenceSystem
) {
528 this.referenceSystem
= referenceSystem
;
533 * @return the errorRadius
535 public String
getErrorRadius() {
541 * @param errorRadius the errorRadius to set
543 public void setErrorRadius(String errorRadius
) {
544 this.errorRadius
= errorRadius
;
548 public void setCollection(String collection
) {
549 this.collection
= collection
;
553 public String
getCollection() {
558 public void addLeveledArea(String levelPostfix
, String value
) {
559 PostfixTerm area
= new PostfixTerm();
561 area
.postfix
= levelPostfix
;
562 this.levels
.add(area
);
565 public List
<PostfixTerm
> getLeveledAreas(){
569 public void setAltitudeMax(String altitudeMax
) {
570 this.altitudeMax
= altitudeMax
;
574 public String
getAltitudeMax() {
580 * @param primaryCollector the primaryCollector to set
582 public void setPrimaryCollector(String primaryCollector
) {
583 this.primaryCollector
= primaryCollector
;
588 * @return the primaryCollector
590 public String
getPrimaryCollector() {
591 return primaryCollector
;