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.
9 package eu
.etaxonomy
.cdm
.io
.csv
.redlist
.demo
;
11 import java
.io
.PrintWriter
;
12 import java
.net
.URISyntaxException
;
13 import java
.util
.ArrayList
;
14 import java
.util
.List
;
16 import org
.apache
.log4j
.Logger
;
18 import com
.fasterxml
.jackson
.annotation
.JsonIgnore
;
20 import eu
.etaxonomy
.cdm
.io
.stream
.terms
.TermUri
;
21 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
29 public class CsvDemoRecord
extends CsvDemoRecordBase
{
31 @SuppressWarnings("unused")
32 private static final Logger logger
= Logger
.getLogger(CsvDemoRecord
.class);
34 private String scientificNameId
;
35 private String scientificName
;
36 private String taxonomicStatus
;
37 private final CsvDemoId datasetId
;
38 private String taxonConceptID
;
39 private String datasetName
;
40 private ArrayList
<String
> synonyms
;
41 private String threadStatus
;
42 private ArrayList
<String
> countryCodes
;
43 private ArrayList
<String
> headlines
;
44 private Boolean isHeadLinePrinted
;
45 private List
<Feature
> features
;
46 private List
<List
<String
>> featuresCells
;
47 private final CsvDemoExportConfigurator config
;
48 private String authorshipCache
;
50 private String parentUuid
;
51 private String lastUpdated
;
52 private String externalID
;
56 * @param metaDataRecord
59 public CsvDemoRecord(CsvDemoMetaDataRecord metaDataRecord
, CsvDemoExportConfigurator config
){
60 super(metaDataRecord
, config
);
62 datasetId
= new CsvDemoId(config
);
66 protected void registerKnownFields(){
68 addKnownField(TermUri
.DWC_SCIENTIFIC_NAME
);
69 addKnownField(TermUri
.DWC_TAXONOMIC_STATUS
);
70 addKnownField(TermUri
.DWC_DATASET_NAME
);
71 addKnownField("countryCode", "http://rs.tdwg.org/dwc/terms/countryCode");
72 } catch (URISyntaxException e
) {
73 throw new RuntimeException(e
);
78 public void write(PrintWriter writer
) {
79 if(isHeadLinePrinted() != null && isHeadLinePrinted() == true){
80 printHeadline(writer
, setHeadlines(), TermUri
.DWC_DATASET_NAME
);
81 isHeadLinePrinted
=false;
83 if(config
.isClassification()){
84 print(datasetName
, writer
, IS_FIRST
, TermUri
.DWC_DATASET_NAME
);
86 if(config
.isDoTaxonConceptExport()){
87 if(config
.isTaxonName()){
88 print(scientificName
, writer
, IS_FIRST
, TermUri
.DWC_SCIENTIFIC_NAME
);
91 if(config
.isTaxonName()){
92 print(scientificName
, writer
, IS_NOT_FIRST
, TermUri
.DWC_SCIENTIFIC_NAME
);
95 if(config
.isTaxonNameID()){
96 print(scientificNameId
, writer
, IS_NOT_FIRST
, TermUri
.DWC_DATASET_ID
);
98 if(config
.isAuthor()){
99 print(authorshipCache
, writer
, IS_NOT_FIRST
, TermUri
.DC_CREATOR
);
102 print(rank
, writer
, IS_NOT_FIRST
, TermUri
.DWC_TAXON_RANK
);
104 if(config
.isTaxonConceptID()){
105 print(taxonConceptID
, writer
, IS_NOT_FIRST
, TermUri
.DWC_TAXON_CONCEPT_ID
);
107 if(config
.isTaxonStatus()){
108 print(taxonomicStatus
, writer
, IS_NOT_FIRST
, TermUri
.DWC_TAXONOMIC_STATUS
);
110 if(config
.isAcceptedName()){
111 //TODO print accepted Name
113 if(config
.isParentID()){
114 print(parentUuid
, writer
, IS_NOT_FIRST
, TermUri
.DWC_PARENT_NAME_USAGE_ID
);
116 if(config
.isSynonyms()){
117 print(synonyms
, TermUri
.DWC_SCIENTIFIC_NAME
, writer
);
119 if(config
.isDistributions()){
120 print(countryCodes
, TermUri
.DWC_COUNTRY_CODE
, writer
);
122 if(config
.isRedlistFeatures()){
123 if(features
!= null ||featuresCells
!= null || !featuresCells
.isEmpty()){
124 for(List
<String
> featureList
: featuresCells
) {
125 print((ArrayList
<String
>)featureList
, TermUri
.DWC_LIFESTAGE
, writer
);
129 if(config
.isExternalID()){
130 print(externalID
, writer
, IS_NOT_FIRST
,TermUri
.DWC_ORIGINAL_NAME_USAGE_ID
);
132 if(config
.isLastChange()){
133 print(lastUpdated
, writer
, IS_NOT_FIRST
,TermUri
.DC_MODIFIED
);
139 //--------------Getter-Setter-Methods------------------//
141 /* public String getDatasetName() {
144 public void setDatasetName(String datasetName
) {
145 this.datasetName
= datasetName
;
147 public String
getScientificName() {
148 return scientificName
;
150 public void setScientificName(String scientificName
) {
151 this.scientificName
= scientificName
;
153 /* public String getTaxonomicStatus() {
154 return taxonomicStatus;
156 public void setTaxonomicStatus(String taxonomicStatus
) {
157 this.taxonomicStatus
= taxonomicStatus
;
159 /* public String getDatasetId() {
160 return datasetId.getId();
162 public void setDatasetId(Classification classification
) {
163 this.datasetId
.setId(classification
);
165 public void setSynonyms(ArrayList
<String
> synonyms
){
166 this.synonyms
= synonyms
;
168 /* public ArrayList<String> getSynonyms(){
171 /* public String getThreadStatus() {
174 public void setThreadStatus(String threadStatus
) {
175 this.threadStatus
= threadStatus
;
178 public void setCountryCode(ArrayList
<String
> countryCodes
) {
179 this.countryCodes
= countryCodes
;
182 //FIXME: hard coded header lines
183 private ArrayList
<String
> setHeadlines(){
184 // if(config.isDoDemoExport()){
185 headlines
= new ArrayList
<>();
187 if(config
.isClassification()){
188 headlines
.add("Classification");
190 if(config
.isTaxonName()){
191 headlines
.add("Wissenschaftlicher Name");
193 if(config
.isTaxonNameID()){
194 headlines
.add("Taxon ID");
196 if(config
.isAuthor()){
197 headlines
.add("Autor");
200 headlines
.add("Rang");
202 if(config
.isTaxonStatus()){
203 headlines
.add("Taxon Status");
205 if(config
.isAcceptedName()){
206 headlines
.add("Akzeptierter Name");
208 if(config
.isTaxonConceptID()){
209 headlines
.add("Taxon Konzept ID");
211 if(config
.isParentID()){
212 headlines
.add("Parent ID");
214 if(config
.isSynonyms()){
215 headlines
.add("Synonym");
217 if(config
.isDistributions()){
218 headlines
.add("Distribution");
220 if(features
!= null){
221 if(!features
.isEmpty()){
222 for(Feature f
: features
) {
223 headlines
.add(f
.getLabel());
227 if(config
.isExternalID()){
228 headlines
.add("External ID");
230 if(config
.isLastChange()){
231 headlines
.add("Letztes Update");
233 // }else if(config.isDoTaxonConceptExport()){
234 // headlines = new ArrayList<String>();
235 // Collections.addAll(headlines, "Taxon Name UUID","Taxon Name","Author","Rank","Taxon Status","Accepted Name", "Taxon Concept ID", "Parent ID", "Last Change");
240 public Boolean
isHeadLinePrinted() {
241 return isHeadLinePrinted
;
244 public void setHeadLinePrinted(Boolean isHeadLinePrinted
) {
245 this.isHeadLinePrinted
= isHeadLinePrinted
;
248 public void setScientificNameId(String scientificNameId
) {
249 this.scientificNameId
= scientificNameId
;
252 public void setPrintFeatures(List
<Feature
> features
) {
253 this.features
= features
;
257 public void setFeatures(List
<List
<String
>> featureCells
) {
258 this.featuresCells
= featureCells
;
262 public void setAuthorName(String authorshipCache
) {
263 this.authorshipCache
= authorshipCache
;
266 public void setRank(String rank
) {
270 public void setParentUUID(String parentUuid
) {
271 this.parentUuid
= parentUuid
;
275 public void setLastChange(String lastUpdated
) {
276 this.lastUpdated
= lastUpdated
;
279 public void setTaxonConceptID(String taxonConceptID
) {
280 this.taxonConceptID
= taxonConceptID
;
283 public void setExternalID(String externalID
) {
284 this.externalID
= externalID
;
287 * @return the scientificNameId
289 /* public String getScientificNameId() {
290 return scientificNameId;
294 * @return the taxonConceptID
296 public String
getTaxonConceptID() {
297 return taxonConceptID
;
300 public ArrayList<String> getCountryCodes() {
305 * @return the authorshipCache
307 public String
getAuthor() {
308 return authorshipCache
;
314 public String
getRank() {
319 * @return the parentUuid
321 public String
getParentUuid() {
326 * @return the lastUpdated
328 public String
getLastUpdated() {
333 * @return the externalID
335 public String
getExternalID() {