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
.common
.OriginalSourceType
;
22 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
23 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
24 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
25 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
32 public class SpecimenRow
extends ExcelRowBase
{
33 @SuppressWarnings("unused")
34 private static final Logger logger
= Logger
.getLogger(SpecimenRow
.class);
36 private String basisOfRecord
;
38 private String country
;
39 private String isoCountry
;
40 private String locality
;
41 private String latitude
;
42 private String longitude
;
43 private String referenceSystem
;
44 private String errorRadius
;
45 private String altitude
;
46 private String altitudeMax
;
47 private String fieldNotes
;
48 private String collectingDate
;
49 private String collectingDateEnd
;
50 private String collectorsNumber
;
51 private String primaryCollector
;
52 private String language
;
56 private String accessionNumber
;
57 private String barcode
;
59 // private String author;
61 // private String family;
62 // private String genus;
63 // private String specificEpithet;
64 private String collectionCode
;
65 private String collection
;
68 private TreeMap
<Integer
, IdentifiableSource
> sources
= new TreeMap
<Integer
, IdentifiableSource
>();
69 private TreeMap
<Integer
, String
> collectors
= new TreeMap
<Integer
, String
>();
70 private TreeMap
<Integer
, String
> unitNotes
= new TreeMap
<Integer
, String
>();
71 private TreeMap
<Integer
, SpecimenTypeDesignation
> types
= new TreeMap
<Integer
, SpecimenTypeDesignation
>();
72 private TreeMap
<Integer
, DeterminationLight
> determinations
= new TreeMap
<Integer
, DeterminationLight
>();
73 private List
<PostfixTerm
> levels
= new ArrayList
<PostfixTerm
>();
77 public SpecimenRow() {
82 // may be public if necessary
83 protected class DeterminationLight
{
90 String infraSpeciesEpi
;
94 String determinedWhen
;
97 public boolean hasTaxonInformation() {
98 boolean result
= StringUtils
.isNotBlank(taxonUuid
)
99 || StringUtils
.isNotBlank(family
)
100 || StringUtils
.isNotBlank(genus
)
101 || StringUtils
.isNotBlank(rank
)
102 || StringUtils
.isNotBlank(fullName
)
103 || StringUtils
.isNotBlank(speciesEpi
)
104 || StringUtils
.isNotBlank(author
)
105 || StringUtils
.isNotBlank(infraSpeciesEpi
);
112 // **************************** GETTER / SETTER *********************************/
114 public void setBasisOfRecord(String basisOfRecord
) {
115 this.basisOfRecord
= basisOfRecord
;
119 public String
getBasisOfRecord() {
120 return basisOfRecord
;
124 public void setCountry(String country
) {
125 this.country
= country
;
129 public String
getCountry() {
134 public void setIsoCountry(String isoCountry
) {
135 this.isoCountry
= isoCountry
;
139 public String
getIsoCountry() {
144 public void setLocality(String locality
) {
145 this.locality
= locality
;
149 public String
getLocality() {
154 public void setFieldNotes(String fieldNotes
) {
155 this.fieldNotes
= fieldNotes
;
159 public String
getFieldNotes() {
164 public void setAccessionNumber(String accessionNumber
) {
165 this.accessionNumber
= accessionNumber
;
169 public String
getAccessionNumber() {
170 return accessionNumber
;
174 public void setBarcode(String barcode
) {
175 this.barcode
= barcode
;
179 // * @return the author
181 // public String getAuthor() {
187 // * @param author the author to set
189 // public void setAuthor(String author) {
190 // this.author = author;
195 * @return the absoluteElevation
197 public String
getAltitude() {
203 * @param absoluteElevation the absoluteElevation to set
205 public void setAltitude(String altitude
) {
206 this.altitude
= altitude
;
211 * @return the collectionCode
213 public String
getCollectionCode() {
214 return collectionCode
;
219 * @param collectionCode the collectionCode to set
221 public void setCollectionCode(String collectionCode
) {
222 this.collectionCode
= collectionCode
;
227 * @return the collectingDate
229 public String
getCollectingDate() {
230 return collectingDate
;
235 * @param collectingDate the collectingDate to set
237 public void setCollectingDate(String collectingDate
) {
238 this.collectingDate
= collectingDate
;
243 * @return the collectorsNumber
245 public String
getCollectorsNumber() {
246 return collectorsNumber
;
251 * @param collectorsNumber the collectorsNumber to set
253 public void setCollectorsNumber(String collectorsNumber
) {
254 this.collectorsNumber
= collectorsNumber
;
259 * @return the barcode
261 public String
getBarcode() {
267 * @return the collectingDateEnd
269 public String
getCollectingDateEnd() {
270 return collectingDateEnd
;
275 * @param collectingDateEnd the collectingDateEnd to set
277 public void setCollectingDateEnd(String collectingDateEnd
) {
278 this.collectingDateEnd
= collectingDateEnd
;
283 * @return the latitude
285 public String
getLatitude() {
291 * @param latitude the latitude to set
293 public void setLatitude(String latitude
) {
294 this.latitude
= latitude
;
299 * @return the longitude
301 public String
getLongitude() {
307 * @param longitude the longitude to set
309 public void setLongitude(String longitude
) {
310 this.longitude
= longitude
;
314 public void putIdInSource(int key
, String id
){
315 IdentifiableSource source
= getOrMakeSource(key
, OriginalSourceType
.Import
);
316 source
.setIdInSource(id
);
318 public void putSourceReference(int key
, Reference
<?
> reference
){
319 IdentifiableSource source
= getOrMakeSource(key
, OriginalSourceType
.Unknown
);
320 source
.setCitation(reference
);
323 public List
<IdentifiableSource
> getSources() {
324 return getOrdered(sources
);
328 public void setCollectors(String value
) {
329 //TODO better parse somewhere else? Quick and dirty implementation
330 List
<String
> authors
= new ArrayList
<String
>();
331 String
[] splits
= value
.split("&");
332 for (String split
: splits
){
333 split
= split
.trim();
337 for (int i
= 0; i
< authors
.size() ; i
++){
338 String author
= authors
.get(i
);
339 if (i
< authors
.size()-1){
340 String
[] internalSplits
= author
.split(",");
341 for (String internal
: internalSplits
){
342 internal
= internal
.trim();
343 this.collectors
.put(index
++, internal
);
346 this.collectors
.put(index
++, author
);
351 public void putCollector(int key
, String collector
){
352 this.collectors
.put(key
, collector
);
355 public List
<String
> getCollectors() {
356 return getOrdered(collectors
);
359 public void putUnitNote(int key
, String unitNote
){
360 this.unitNotes
.put(key
, unitNote
);
363 public List
<String
> getUnitNotes() {
364 return getOrdered(unitNotes
);
373 private IdentifiableSource
getOrMakeSource(int key
, OriginalSourceType type
) {
374 IdentifiableSource source
= sources
.get(key
);
376 source
= IdentifiableSource
.NewInstance(type
);
377 sources
.put(key
, source
);
383 public void putTypeCategory(int key
, SpecimenTypeDesignationStatus status
){
384 SpecimenTypeDesignation designation
= getOrMakeTypeDesignation(key
);
385 designation
.setTypeStatus(status
);
387 public void putTypifiedName(int key
, TaxonNameBase
<?
,?
> name
){
389 SpecimenTypeDesignation designation
= getOrMakeTypeDesignation(key
);
390 name
.addTypeDesignation(designation
, false);
394 public List
<SpecimenTypeDesignation
> getTypeDesignations() {
395 return getOrdered(types
);
399 private SpecimenTypeDesignation
getOrMakeTypeDesignation(int key
) {
400 SpecimenTypeDesignation designation
= types
.get(key
);
401 if (designation
== null){
402 designation
= SpecimenTypeDesignation
.NewInstance();
403 types
.put(key
, designation
);
408 public void putDeterminationFamily(int key
, String family
){
409 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
410 determinationEvent
.family
= family
;
413 public void putDeterminationFullName(int key
, String fullName
){
414 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
415 determinationEvent
.fullName
= fullName
;
418 public void putDeterminationTaxonUuid(int key
, String taxonUuid
){
419 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
420 determinationEvent
.taxonUuid
= taxonUuid
;
423 public void putDeterminationRank(int key
, String rank
){
424 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
425 determinationEvent
.rank
= rank
;
428 public void putDeterminationGenus(int key
, String genus
){
429 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
430 determinationEvent
.genus
= genus
;
433 public void putDeterminationSpeciesEpi(int key
, String speciesEpi
){
434 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
435 determinationEvent
.speciesEpi
= speciesEpi
;
438 public void putDeterminationInfraSpeciesEpi(int key
, String infraSpeciesEpi
){
439 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
440 determinationEvent
.infraSpeciesEpi
= infraSpeciesEpi
;
443 public void putDeterminationAuthor(int key
, String author
){
444 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
445 determinationEvent
.author
= author
;
448 public void putDeterminationDeterminedBy(int key
, String determinedBy
){
449 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
450 determinationEvent
.determinedBy
= determinedBy
;
453 public void putDeterminationDeterminedWhen(int key
, String determinedWhen
){
454 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
455 determinationEvent
.determinedWhen
= determinedWhen
;
458 public void putDeterminationDeterminationNotes(int key
, String notes
){
459 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
460 determinationEvent
.notes
= notes
;
463 public void putDeterminationDeterminationModifier(int key
, String modifier
){
464 DeterminationLight determinationEvent
= getOrMakeDetermination(key
);
465 determinationEvent
.modifier
= modifier
;
469 public List
<DeterminationLight
> getDetermination() {
470 List
<DeterminationLight
> result
= getOrdered(determinations
);
471 if (determinations
.size() > 1 && getCommonDetermination()!= null ){
472 result
.remove(getCommonDetermination());
478 * Returns the determination with key "0".
481 public DeterminationLight
getCommonDetermination() {
482 if (determinations
.get(0) != null){
483 return determinations
.get(0);
490 private DeterminationLight
getOrMakeDetermination(int key
) {
491 DeterminationLight determination
= this.determinations
.get(key
);
492 if (determination
== null){
493 determination
= new DeterminationLight();
494 this.determinations
.put(key
, determination
);
496 return determination
;
500 private<T
extends Object
> List
<T
> getOrdered(TreeMap
<?
, T
> tree
) {
501 List
<T
> result
= new ArrayList
<T
>();
502 for (T value
: tree
.values()){
508 public void setSex(String sex
) {
513 public String
getSex() {
519 * @return the referenceSystem
521 public String
getReferenceSystem() {
522 return referenceSystem
;
527 * @param referenceSystem the referenceSystem to set
529 public void setReferenceSystem(String referenceSystem
) {
530 this.referenceSystem
= referenceSystem
;
535 * @return the errorRadius
537 public String
getErrorRadius() {
543 * @param errorRadius the errorRadius to set
545 public void setErrorRadius(String errorRadius
) {
546 this.errorRadius
= errorRadius
;
550 public void setCollection(String collection
) {
551 this.collection
= collection
;
555 public String
getCollection() {
560 public void addLeveledArea(String levelPostfix
, String value
) {
561 PostfixTerm area
= new PostfixTerm();
563 area
.postfix
= levelPostfix
;
564 this.levels
.add(area
);
567 public List
<PostfixTerm
> getLeveledAreas(){
571 public void setAltitudeMax(String altitudeMax
) {
572 this.altitudeMax
= altitudeMax
;
576 public String
getAltitudeMax() {
582 * @param primaryCollector the primaryCollector to set
584 public void setPrimaryCollector(String primaryCollector
) {
585 this.primaryCollector
= primaryCollector
;
590 * @return the primaryCollector
592 public String
getPrimaryCollector() {
593 return primaryCollector
;
597 public String
getLanguage() {
602 public void setLanguage(String language
) {
603 this.language
= language
;