3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.io
.csv
.redlist
.demo
;
12 import java
.io
.PrintWriter
;
13 import java
.net
.URISyntaxException
;
14 import java
.util
.ArrayList
;
15 import java
.util
.List
;
17 import org
.apache
.log4j
.Logger
;
19 import eu
.etaxonomy
.cdm
.io
.dwca
.TermUri
;
20 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
28 public class CsvDemoRecord
extends CsvDemoRecordBase
{
30 @SuppressWarnings("unused")
31 private static final Logger logger
= Logger
.getLogger(CsvDemoRecord
.class);
33 private String scientificNameId
;
34 private String scientificName
;
35 private String taxonomicStatus
;
36 private CsvDemoId datasetId
;
37 private String taxonConceptID
;
38 private String datasetName
;
39 private ArrayList
<String
> synonyms
;
40 private String threadStatus
;
41 private ArrayList
<String
> countryCodes
;
42 private ArrayList
<String
> headlines
;
43 private boolean isHeadLinePrinted
;
44 private List
<Feature
> features
;
45 private List
<List
<String
>> featuresCells
;
46 private CsvDemoExportConfigurator config
;
48 private String authorshipCache
;
52 private String parentUuid
;
54 private String lastUpdated
;
56 private String externalID
;
60 * @param metaDataRecord
63 public CsvDemoRecord(CsvDemoMetaDataRecord metaDataRecord
, CsvDemoExportConfigurator config
){
64 super(metaDataRecord
, config
);
66 datasetId
= new CsvDemoId(config
);
70 * @see eu.etaxonomy.cdm.io.dwca.out.DwcaRecordBase#registerKnownFields()
72 protected void registerKnownFields(){
74 addKnownField(TermUri
.DWC_SCIENTIFIC_NAME
);
75 addKnownField(TermUri
.DWC_TAXONOMIC_STATUS
);
76 addKnownField(TermUri
.DWC_DATASET_NAME
);
77 addKnownField("countryCode", "http://rs.tdwg.org/dwc/terms/countryCode");
78 } catch (URISyntaxException e
) {
79 throw new RuntimeException(e
);
83 public void write(PrintWriter writer
) {
84 if(isHeadLinePrinted()){
85 printHeadline(writer
, setHeadlines(), TermUri
.DWC_DATASET_NAME
);
86 isHeadLinePrinted
=false;
88 if(config
.isClassification()){
89 print(datasetName
, writer
, IS_FIRST
, TermUri
.DWC_DATASET_NAME
);
91 if(config
.isDoTaxonConceptExport()){
92 if(config
.isTaxonName()){
93 print(scientificName
, writer
, IS_FIRST
, TermUri
.DWC_SCIENTIFIC_NAME
);
96 if(config
.isTaxonName()){
97 print(scientificName
, writer
, IS_NOT_FIRST
, TermUri
.DWC_SCIENTIFIC_NAME
);
100 if(config
.isTaxonNameID()){
101 print(scientificNameId
, writer
, IS_NOT_FIRST
, TermUri
.DWC_DATASET_ID
);
103 if(config
.isAuthor()){
104 print(authorshipCache
, writer
, IS_NOT_FIRST
, TermUri
.DC_CREATOR
);
107 print(rank
, writer
, IS_NOT_FIRST
, TermUri
.DWC_TAXON_RANK
);
109 if(config
.isTaxonConceptID()){
110 print(taxonConceptID
, writer
, IS_NOT_FIRST
, TermUri
.DWC_TAXON_CONCEPT_ID
);
112 if(config
.isTaxonStatus()){
113 print(taxonomicStatus
, writer
, IS_NOT_FIRST
, TermUri
.DWC_TAXONOMIC_STATUS
);
115 if(config
.isAcceptedName()){
116 //TODO print accepted Name
118 if(config
.isParentID()){
119 print(parentUuid
, writer
, IS_NOT_FIRST
, TermUri
.DWC_PARENT_NAME_USAGE_ID
);
121 if(config
.isSynonyms()){
122 print(synonyms
, TermUri
.DWC_SCIENTIFIC_NAME
, writer
);
124 if(config
.isDistributions()){
125 print(countryCodes
, TermUri
.DWC_COUNTRY_CODE
, writer
);
127 if(config
.isRedlistFeatures()){
128 if(features
!= null ||featuresCells
!= null || !featuresCells
.isEmpty()){
129 for(List
<String
> featureList
: featuresCells
) {
130 print((ArrayList
<String
>)featureList
, TermUri
.DWC_LIFESTAGE
, writer
);
134 if(config
.isExternalID()){
135 print(externalID
, writer
, IS_NOT_FIRST
,TermUri
.DWC_ORIGINAL_NAME_USAGE_ID
);
137 if(config
.isLastChange()){
138 print(lastUpdated
, writer
, IS_NOT_FIRST
,TermUri
.DC_MODIFIED
);
144 //--------------Getter-Setter-Methods------------------//
146 public String
getDatasetName() {
149 public void setDatasetName(String datasetName
) {
150 this.datasetName
= datasetName
;
152 public String
getScientificName() {
153 return scientificName
;
155 public void setScientificName(String scientificName
) {
156 this.scientificName
= scientificName
;
158 public String
getTaxonomicStatus() {
159 return taxonomicStatus
;
161 public void setTaxonomicStatus(String taxonomicStatus
) {
162 this.taxonomicStatus
= taxonomicStatus
;
164 public String
getDatasetId() {
165 return datasetId
.getId();
167 public void setDatasetId(Classification classification
) {
168 this.datasetId
.setId(classification
);
170 public void setSynonyms(ArrayList
<String
> synonyms
){
171 this.synonyms
= synonyms
;
173 public ArrayList
<String
> getSynonyms(){
176 public String
getThreadStatus() {
179 public void setThreadStatus(String threadStatus
) {
180 this.threadStatus
= threadStatus
;
183 public void setCountryCode(ArrayList
<String
> countryCodes
) {
184 this.countryCodes
= countryCodes
;
187 //FIXME: hard coded header lines
188 private ArrayList
<String
> setHeadlines(){
189 // if(config.isDoDemoExport()){
190 headlines
= new ArrayList
<String
>();
192 if(config
.isClassification()){
193 headlines
.add("Classification");
195 if(config
.isTaxonName()){
196 headlines
.add("Wissenschaftlicher Name");
198 if(config
.isTaxonNameID()){
199 headlines
.add("Taxon ID");
201 if(config
.isAuthor()){
202 headlines
.add("Autor");
205 headlines
.add("Rang");
207 if(config
.isTaxonStatus()){
208 headlines
.add("Taxon Status");
210 if(config
.isAcceptedName()){
211 headlines
.add("Akzeptierter Name");
213 if(config
.isTaxonConceptID()){
214 headlines
.add("Taxon Konzept ID");
216 if(config
.isParentID()){
217 headlines
.add("Parent ID");
219 if(config
.isSynonyms()){
220 headlines
.add("Synonym");
222 if(config
.isDistributions()){
223 headlines
.add("Distribution");
225 if(features
!= null){
226 if(!features
.isEmpty()){
227 for(Feature f
: features
) {
228 headlines
.add(f
.getLabel());
232 if(config
.isExternalID()){
233 headlines
.add("External ID");
235 if(config
.isLastChange()){
236 headlines
.add("Letztes Update");
238 // }else if(config.isDoTaxonConceptExport()){
239 // headlines = new ArrayList<String>();
240 // Collections.addAll(headlines, "Taxon Name UUID","Taxon Name","Author","Rank","Taxon Status","Accepted Name", "Taxon Concept ID", "Parent ID", "Last Change");
245 public boolean isHeadLinePrinted() {
246 return isHeadLinePrinted
;
249 public void setHeadLinePrinted(boolean isHeadLinePrinted
) {
250 this.isHeadLinePrinted
= isHeadLinePrinted
;
253 public void setScientificNameId(String scientificNameId
) {
254 this.scientificNameId
= scientificNameId
;
257 public void setPrintFeatures(List
<Feature
> features
) {
258 this.features
= features
;
262 public void setFeatures(List
<List
<String
>> featureCells
) {
263 this.featuresCells
= featureCells
;
267 public void setAuthorName(String authorshipCache
) {
268 this.authorshipCache
= authorshipCache
;
272 public void setRank(String rank
) {
276 public void setParentUUID(String parentUuid
) {
277 this.parentUuid
= parentUuid
;
281 public void setLastChange(String lastUpdated
) {
282 this.lastUpdated
= lastUpdated
;
285 public void setTaxonConceptID(String taxonConceptID
) {
286 this.taxonConceptID
= taxonConceptID
;
289 public void setExternalID(String externalID
) {
290 this.externalID
= externalID
;