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
|
package eu.etaxonomy.cdm.io.csv.redlist.demo;
|
10
|
|
11
|
import java.io.PrintWriter;
|
12
|
import java.net.URISyntaxException;
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.List;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
|
18
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
19
|
|
20
|
import eu.etaxonomy.cdm.io.dwca.TermUri;
|
21
|
import eu.etaxonomy.cdm.model.description.Feature;
|
22
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
23
|
|
24
|
/**
|
25
|
* @author a.oppermann
|
26
|
* @date 18.10.2012
|
27
|
*
|
28
|
*/
|
29
|
public class CsvDemoRecord extends CsvDemoRecordBase{
|
30
|
|
31
|
@SuppressWarnings("unused")
|
32
|
private static final Logger logger = Logger.getLogger(CsvDemoRecord.class);
|
33
|
|
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;
|
49
|
private String rank;
|
50
|
private String parentUuid;
|
51
|
private String lastUpdated;
|
52
|
private String externalID;
|
53
|
|
54
|
/**
|
55
|
*
|
56
|
* @param metaDataRecord
|
57
|
* @param config
|
58
|
*/
|
59
|
public CsvDemoRecord(CsvDemoMetaDataRecord metaDataRecord, CsvDemoExportConfigurator config){
|
60
|
super(metaDataRecord, config);
|
61
|
this.config = config;
|
62
|
datasetId = new CsvDemoId(config);
|
63
|
}
|
64
|
|
65
|
/* (non-Javadoc)
|
66
|
* @see eu.etaxonomy.cdm.io.dwca.out.DwcaRecordBase#registerKnownFields()
|
67
|
*/
|
68
|
@Override
|
69
|
protected void registerKnownFields(){
|
70
|
try {
|
71
|
addKnownField(TermUri.DWC_SCIENTIFIC_NAME);
|
72
|
addKnownField(TermUri.DWC_TAXONOMIC_STATUS);
|
73
|
addKnownField(TermUri.DWC_DATASET_NAME);
|
74
|
addKnownField("countryCode", "http://rs.tdwg.org/dwc/terms/countryCode");
|
75
|
} catch (URISyntaxException e) {
|
76
|
throw new RuntimeException(e);
|
77
|
}
|
78
|
}
|
79
|
|
80
|
@Override
|
81
|
public void write(PrintWriter writer) {
|
82
|
if(isHeadLinePrinted() != null && isHeadLinePrinted() == true){
|
83
|
printHeadline(writer, setHeadlines(), TermUri.DWC_DATASET_NAME);
|
84
|
isHeadLinePrinted=false;
|
85
|
}
|
86
|
if(config.isClassification()){
|
87
|
print(datasetName, writer, IS_FIRST, TermUri.DWC_DATASET_NAME);
|
88
|
}
|
89
|
if(config.isDoTaxonConceptExport()){
|
90
|
if(config.isTaxonName()){
|
91
|
print(scientificName, writer, IS_FIRST, TermUri.DWC_SCIENTIFIC_NAME);
|
92
|
}
|
93
|
}else{
|
94
|
if(config.isTaxonName()){
|
95
|
print(scientificName, writer, IS_NOT_FIRST, TermUri.DWC_SCIENTIFIC_NAME);
|
96
|
}
|
97
|
}
|
98
|
if(config.isTaxonNameID()){
|
99
|
print(scientificNameId, writer, IS_NOT_FIRST, TermUri.DWC_DATASET_ID);
|
100
|
}
|
101
|
if(config.isAuthor()){
|
102
|
print(authorshipCache, writer, IS_NOT_FIRST, TermUri.DC_CREATOR);
|
103
|
}
|
104
|
if(config.isRank()){
|
105
|
print(rank, writer, IS_NOT_FIRST, TermUri.DWC_TAXON_RANK);
|
106
|
}
|
107
|
if(config.isTaxonConceptID()){
|
108
|
print(taxonConceptID, writer, IS_NOT_FIRST, TermUri.DWC_TAXON_CONCEPT_ID);
|
109
|
}
|
110
|
if(config.isTaxonStatus()){
|
111
|
print(taxonomicStatus, writer, IS_NOT_FIRST, TermUri.DWC_TAXONOMIC_STATUS);
|
112
|
}
|
113
|
if(config.isAcceptedName()){
|
114
|
//TODO print accepted Name
|
115
|
}
|
116
|
if(config.isParentID()){
|
117
|
print(parentUuid, writer, IS_NOT_FIRST, TermUri.DWC_PARENT_NAME_USAGE_ID);
|
118
|
}
|
119
|
if(config.isSynonyms()){
|
120
|
print(synonyms, TermUri.DWC_SCIENTIFIC_NAME, writer);
|
121
|
}
|
122
|
if(config.isDistributions()){
|
123
|
print(countryCodes, TermUri.DWC_COUNTRY_CODE, writer);
|
124
|
}
|
125
|
if(config.isRedlistFeatures()){
|
126
|
if(features != null ||featuresCells != null || !featuresCells.isEmpty()){
|
127
|
for(List<String> featureList : featuresCells) {
|
128
|
print((ArrayList<String>)featureList, TermUri.DWC_LIFESTAGE, writer);
|
129
|
}
|
130
|
}
|
131
|
}
|
132
|
if(config.isExternalID()){
|
133
|
print(externalID, writer, IS_NOT_FIRST,TermUri.DWC_ORIGINAL_NAME_USAGE_ID);
|
134
|
}
|
135
|
if(config.isLastChange()){
|
136
|
print(lastUpdated, writer, IS_NOT_FIRST,TermUri.DC_MODIFIED);
|
137
|
}
|
138
|
writer.println();
|
139
|
}
|
140
|
|
141
|
|
142
|
//--------------Getter-Setter-Methods------------------//
|
143
|
|
144
|
/* public String getDatasetName() {
|
145
|
return datasetName;
|
146
|
}*/
|
147
|
public void setDatasetName(String datasetName) {
|
148
|
this.datasetName = datasetName;
|
149
|
}
|
150
|
public String getScientificName() {
|
151
|
return scientificName;
|
152
|
}
|
153
|
public void setScientificName(String scientificName) {
|
154
|
this.scientificName = scientificName;
|
155
|
}
|
156
|
/* public String getTaxonomicStatus() {
|
157
|
return taxonomicStatus;
|
158
|
}*/
|
159
|
public void setTaxonomicStatus(String taxonomicStatus) {
|
160
|
this.taxonomicStatus = taxonomicStatus;
|
161
|
}
|
162
|
/* public String getDatasetId() {
|
163
|
return datasetId.getId();
|
164
|
}*/
|
165
|
public void setDatasetId(Classification classification) {
|
166
|
this.datasetId.setId(classification);
|
167
|
}
|
168
|
public void setSynonyms(ArrayList<String> synonyms){
|
169
|
this.synonyms = synonyms;
|
170
|
}
|
171
|
/* public ArrayList<String> getSynonyms(){
|
172
|
return synonyms;
|
173
|
}*/
|
174
|
/* public String getThreadStatus() {
|
175
|
return threadStatus;
|
176
|
}*/
|
177
|
public void setThreadStatus(String threadStatus) {
|
178
|
this.threadStatus = threadStatus;
|
179
|
}
|
180
|
|
181
|
public void setCountryCode(ArrayList<String> countryCodes) {
|
182
|
this.countryCodes = countryCodes;
|
183
|
}
|
184
|
|
185
|
//FIXME: hard coded header lines
|
186
|
private ArrayList<String> setHeadlines(){
|
187
|
// if(config.isDoDemoExport()){
|
188
|
headlines = new ArrayList<String>();
|
189
|
|
190
|
if(config.isClassification()){
|
191
|
headlines.add("Classification");
|
192
|
}
|
193
|
if(config.isTaxonName()){
|
194
|
headlines.add("Wissenschaftlicher Name");
|
195
|
}
|
196
|
if(config.isTaxonNameID()){
|
197
|
headlines.add("Taxon ID");
|
198
|
}
|
199
|
if(config.isAuthor()){
|
200
|
headlines.add("Autor");
|
201
|
}
|
202
|
if(config.isRank()){
|
203
|
headlines.add("Rang");
|
204
|
}
|
205
|
if(config.isTaxonStatus()){
|
206
|
headlines.add("Taxon Status");
|
207
|
}
|
208
|
if(config.isAcceptedName()){
|
209
|
headlines.add("Akzeptierter Name");
|
210
|
}
|
211
|
if(config.isTaxonConceptID()){
|
212
|
headlines.add("Taxon Konzept ID");
|
213
|
}
|
214
|
if(config.isParentID()){
|
215
|
headlines.add("Parent ID");
|
216
|
}
|
217
|
if(config.isSynonyms()){
|
218
|
headlines.add("Synonym");
|
219
|
}
|
220
|
if(config.isDistributions()){
|
221
|
headlines.add("Distribution");
|
222
|
}
|
223
|
if(features != null){
|
224
|
if(!features.isEmpty()){
|
225
|
for(Feature f : features) {
|
226
|
headlines.add(f.getLabel());
|
227
|
}
|
228
|
}
|
229
|
}
|
230
|
if(config.isExternalID()){
|
231
|
headlines.add("External ID");
|
232
|
}
|
233
|
if(config.isLastChange()){
|
234
|
headlines.add("Letztes Update");
|
235
|
}
|
236
|
// }else if(config.isDoTaxonConceptExport()){
|
237
|
// headlines = new ArrayList<String>();
|
238
|
// Collections.addAll(headlines, "Taxon Name UUID","Taxon Name","Author","Rank","Taxon Status","Accepted Name", "Taxon Concept ID", "Parent ID", "Last Change");
|
239
|
// }
|
240
|
return headlines;
|
241
|
}
|
242
|
@JsonIgnore
|
243
|
public Boolean isHeadLinePrinted() {
|
244
|
return isHeadLinePrinted;
|
245
|
}
|
246
|
|
247
|
public void setHeadLinePrinted(Boolean isHeadLinePrinted) {
|
248
|
this.isHeadLinePrinted = isHeadLinePrinted;
|
249
|
}
|
250
|
|
251
|
public void setScientificNameId(String scientificNameId) {
|
252
|
this.scientificNameId = scientificNameId;
|
253
|
}
|
254
|
|
255
|
public void setPrintFeatures(List<Feature> features) {
|
256
|
this.features = features;
|
257
|
|
258
|
}
|
259
|
|
260
|
public void setFeatures(List<List<String>> featureCells) {
|
261
|
this.featuresCells = featureCells;
|
262
|
|
263
|
}
|
264
|
|
265
|
public void setAuthorName(String authorshipCache) {
|
266
|
this.authorshipCache = authorshipCache;
|
267
|
}
|
268
|
|
269
|
public void setRank(String rank) {
|
270
|
this.rank = rank;
|
271
|
}
|
272
|
|
273
|
public void setParentUUID(String parentUuid) {
|
274
|
this.parentUuid = parentUuid;
|
275
|
|
276
|
}
|
277
|
|
278
|
public void setLastChange(String lastUpdated) {
|
279
|
this.lastUpdated = lastUpdated;
|
280
|
}
|
281
|
|
282
|
public void setTaxonConceptID(String taxonConceptID) {
|
283
|
this.taxonConceptID = taxonConceptID;
|
284
|
}
|
285
|
|
286
|
public void setExternalID(String externalID) {
|
287
|
this.externalID = externalID;
|
288
|
}
|
289
|
/**
|
290
|
* @return the scientificNameId
|
291
|
*/
|
292
|
/* public String getScientificNameId() {
|
293
|
return scientificNameId;
|
294
|
}*/
|
295
|
|
296
|
/**
|
297
|
* @return the taxonConceptID
|
298
|
*/
|
299
|
public String getTaxonConceptID() {
|
300
|
return taxonConceptID;
|
301
|
}
|
302
|
/*
|
303
|
public ArrayList<String> getCountryCodes() {
|
304
|
return countryCodes;
|
305
|
}
|
306
|
*/
|
307
|
/**
|
308
|
* @return the authorshipCache
|
309
|
*/
|
310
|
public String getAuthor() {
|
311
|
return authorshipCache;
|
312
|
}
|
313
|
|
314
|
/**
|
315
|
* @return the rank
|
316
|
*/
|
317
|
public String getRank() {
|
318
|
return rank;
|
319
|
}
|
320
|
|
321
|
/**
|
322
|
* @return the parentUuid
|
323
|
*/
|
324
|
public String getParentUuid() {
|
325
|
return parentUuid;
|
326
|
}
|
327
|
|
328
|
/**
|
329
|
* @return the lastUpdated
|
330
|
*/
|
331
|
public String getLastUpdated() {
|
332
|
return lastUpdated;
|
333
|
}
|
334
|
|
335
|
/**
|
336
|
* @return the externalID
|
337
|
*/
|
338
|
public String getExternalID() {
|
339
|
return externalID;
|
340
|
}
|
341
|
|
342
|
}
|