1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.cdm.io.csv.redlist.out;
|
11
|
|
12
|
import java.io.ByteArrayOutputStream;
|
13
|
import java.io.File;
|
14
|
import java.util.ArrayList;
|
15
|
import java.util.HashSet;
|
16
|
import java.util.List;
|
17
|
import java.util.Set;
|
18
|
import java.util.UUID;
|
19
|
|
20
|
import org.apache.log4j.Logger;
|
21
|
|
22
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
23
|
import eu.etaxonomy.cdm.io.common.XmlExportConfiguratorBase;
|
24
|
import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer;
|
25
|
import eu.etaxonomy.cdm.model.description.Feature;
|
26
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
27
|
|
28
|
|
29
|
/**
|
30
|
* @author a.oppermann
|
31
|
* @since 17.10.2012
|
32
|
*/
|
33
|
public class CsvTaxExportConfiguratorRedlist extends XmlExportConfiguratorBase<CsvTaxExportStateRedlist> {
|
34
|
|
35
|
private static final long serialVersionUID = 423795815976481982L;
|
36
|
|
37
|
@SuppressWarnings("unused")
|
38
|
private static final Logger logger = Logger.getLogger(CsvTaxExportConfiguratorRedlist.class);
|
39
|
|
40
|
private String encoding = "UTF-8";
|
41
|
private String linesTerminatedBy = "\r\n";
|
42
|
private String fieldsEnclosedBy = "\"";
|
43
|
private boolean hasHeaderLines = true;
|
44
|
private String fieldsTerminatedBy=",";
|
45
|
private boolean doTaxa = true;
|
46
|
private boolean doDistributions = false;
|
47
|
private ByteArrayOutputStream baos;
|
48
|
private boolean isUseIdWherePossible = false;
|
49
|
private boolean includeBasionymsInResourceRelations;
|
50
|
private boolean includeMisappliedNamesInResourceRelations;
|
51
|
private String defaultBibliographicCitation = null;
|
52
|
private List<UUID> featureExclusions = new ArrayList<UUID>();
|
53
|
//filter on the classifications to be exported
|
54
|
private Set<UUID> taxonNodeUuids = new HashSet<UUID>();
|
55
|
private boolean withHigherClassification = false;
|
56
|
private String setSeparator = ";";
|
57
|
|
58
|
private List<Feature> features;
|
59
|
|
60
|
private String classificationTitleCache;
|
61
|
|
62
|
private List<NamedArea> areas;
|
63
|
|
64
|
//TODO
|
65
|
private static IExportTransformer defaultTransformer = null;
|
66
|
|
67
|
public static CsvTaxExportConfiguratorRedlist NewInstance(ICdmDataSource source, File destinationFolder) {
|
68
|
return new CsvTaxExportConfiguratorRedlist(source, destinationFolder);
|
69
|
}
|
70
|
|
71
|
@Override
|
72
|
@SuppressWarnings("unchecked")
|
73
|
protected void makeIoClassList() {
|
74
|
ioClassList = new Class[] {
|
75
|
CsvTaxExportRedlist.class
|
76
|
};
|
77
|
}
|
78
|
|
79
|
/**
|
80
|
* @param url
|
81
|
* @param destination
|
82
|
*/
|
83
|
private CsvTaxExportConfiguratorRedlist(ICdmDataSource source, File destination) {
|
84
|
super(destination, source, defaultTransformer);
|
85
|
}
|
86
|
|
87
|
@Override
|
88
|
public File getDestination() {
|
89
|
return super.getDestination();
|
90
|
}
|
91
|
|
92
|
/**
|
93
|
* @param file
|
94
|
*/
|
95
|
@Override
|
96
|
public void setDestination(File fileName) {
|
97
|
super.setDestination(fileName);
|
98
|
}
|
99
|
|
100
|
@Override
|
101
|
public String getDestinationNameString() {
|
102
|
if (this.getDestination() == null) {
|
103
|
return null;
|
104
|
} else {
|
105
|
return this.getDestination().toString();
|
106
|
}
|
107
|
}
|
108
|
|
109
|
@Override
|
110
|
public CsvTaxExportStateRedlist getNewState() {
|
111
|
return new CsvTaxExportStateRedlist(this);
|
112
|
}
|
113
|
|
114
|
public boolean isDoTaxa() {
|
115
|
return doTaxa;
|
116
|
}
|
117
|
|
118
|
public void setDoTaxa(boolean doTaxa) {
|
119
|
this.doTaxa = doTaxa;
|
120
|
}
|
121
|
|
122
|
|
123
|
public boolean isDoDistributions() {
|
124
|
return doDistributions;
|
125
|
}
|
126
|
|
127
|
public void setDoDistributions(boolean doDistributions) {
|
128
|
this.doDistributions = doDistributions;
|
129
|
}
|
130
|
|
131
|
public void setFeatureExclusions(List<UUID> featureExclusions) {
|
132
|
this.featureExclusions = featureExclusions;
|
133
|
}
|
134
|
|
135
|
public List<UUID> getFeatureExclusions() {
|
136
|
return featureExclusions;
|
137
|
}
|
138
|
|
139
|
public String getEncoding() {
|
140
|
return encoding;
|
141
|
}
|
142
|
|
143
|
public void setEncoding(String encoding) {
|
144
|
this.encoding = encoding;
|
145
|
}
|
146
|
|
147
|
public String getLinesTerminatedBy() {
|
148
|
return linesTerminatedBy;
|
149
|
}
|
150
|
|
151
|
public void setLinesTerminatedBy(String linesTerminatedBy) {
|
152
|
this.linesTerminatedBy = linesTerminatedBy;
|
153
|
}
|
154
|
|
155
|
public String getFieldsEnclosedBy() {
|
156
|
return fieldsEnclosedBy;
|
157
|
}
|
158
|
|
159
|
public void setFieldsEnclosedBy(String fieldsEnclosedBy) {
|
160
|
this.fieldsEnclosedBy = fieldsEnclosedBy;
|
161
|
}
|
162
|
|
163
|
/**
|
164
|
* Equals darwin core archive ignoreHeaderLines attribute
|
165
|
* @return
|
166
|
*/
|
167
|
public boolean isHasHeaderLines() {
|
168
|
return hasHeaderLines;
|
169
|
}
|
170
|
|
171
|
public void setHasHeaderLines(boolean hasHeaderLines) {
|
172
|
this.hasHeaderLines = hasHeaderLines;
|
173
|
}
|
174
|
|
175
|
public boolean isIncludeBasionymsInResourceRelations() {
|
176
|
return includeBasionymsInResourceRelations;
|
177
|
}
|
178
|
|
179
|
public void setIncludeBasionymsInResourceRelations(boolean includeBasionymsInResourceRelations) {
|
180
|
this.includeBasionymsInResourceRelations = includeBasionymsInResourceRelations;
|
181
|
}
|
182
|
|
183
|
public boolean isIncludeMisappliedNamesInResourceRelations() {
|
184
|
return includeMisappliedNamesInResourceRelations;
|
185
|
}
|
186
|
|
187
|
public void setIncludeMisappliedNamesInResourceRelations(boolean includeMisappliedNamesInResourceRelations) {
|
188
|
this.includeMisappliedNamesInResourceRelations = includeMisappliedNamesInResourceRelations;
|
189
|
}
|
190
|
|
191
|
public boolean isUseIdWherePossible() {
|
192
|
return this.isUseIdWherePossible;
|
193
|
}
|
194
|
|
195
|
public void setUseIdWherePossible(boolean isUseIdWherePossible) {
|
196
|
this.isUseIdWherePossible = isUseIdWherePossible;
|
197
|
}
|
198
|
|
199
|
public void setDefaultBibliographicCitation(String defaultBibliographicCitation) {
|
200
|
this.defaultBibliographicCitation = defaultBibliographicCitation;
|
201
|
}
|
202
|
|
203
|
|
204
|
public String getDefaultBibliographicCitation() {
|
205
|
return defaultBibliographicCitation;
|
206
|
}
|
207
|
|
208
|
/**
|
209
|
* The default value for the taxon.source column. This may be a column linking to a url that provides
|
210
|
* data about the given taxon. The id is replaced by a placeholder,
|
211
|
* e.g. http://wp6-cichorieae.e-taxonomy.eu/portal/?q=cdm_dataportal/taxon/{id}.
|
212
|
* NOTE: This may be replaced in future versions by concrete CDM server implementations.
|
213
|
*
|
214
|
* @return the taxonSourceDefault
|
215
|
*/
|
216
|
|
217
|
public boolean isWithHigherClassification() {
|
218
|
return withHigherClassification;
|
219
|
}
|
220
|
|
221
|
public void setWithHigherClassification(boolean withHigherClassification) {
|
222
|
this.withHigherClassification = withHigherClassification;
|
223
|
}
|
224
|
|
225
|
/**
|
226
|
* @return the setSeparator
|
227
|
*/
|
228
|
public String getSetSeparator() {
|
229
|
return setSeparator;
|
230
|
}
|
231
|
|
232
|
/**
|
233
|
* @param setSeparator the setSeparator to set
|
234
|
*/
|
235
|
public void setSetSeparator(String setSeparator) {
|
236
|
this.setSeparator = setSeparator;
|
237
|
}
|
238
|
|
239
|
public void setFieldsTerminatedBy(String fieldsTerminatedBy) {
|
240
|
this.fieldsTerminatedBy = fieldsTerminatedBy;
|
241
|
}
|
242
|
|
243
|
public String getFieldsTerminatedBy() {
|
244
|
return fieldsTerminatedBy;
|
245
|
}
|
246
|
|
247
|
public Set<UUID> getTaxonNodeUuids() {
|
248
|
return taxonNodeUuids;
|
249
|
}
|
250
|
|
251
|
public void setTaxonNodeUuids(Set<UUID> taxonNodeUuids) {
|
252
|
this.taxonNodeUuids = taxonNodeUuids;
|
253
|
}
|
254
|
|
255
|
public ByteArrayOutputStream getByteArrayOutputStream() {
|
256
|
return baos;
|
257
|
}
|
258
|
|
259
|
public void setByteArrayOutputStream(ByteArrayOutputStream baos) {
|
260
|
this.baos = baos;
|
261
|
}
|
262
|
|
263
|
public void setFeatures(List<Feature> features) {
|
264
|
this.features = features;
|
265
|
|
266
|
}
|
267
|
|
268
|
public List<Feature> getFeatures() {
|
269
|
return features;
|
270
|
|
271
|
}
|
272
|
|
273
|
public void setClassificationTitleCache(String classificationTitleCache) {
|
274
|
this.classificationTitleCache = classificationTitleCache;
|
275
|
}
|
276
|
|
277
|
public String getClassificationTitleCache() {
|
278
|
return classificationTitleCache;
|
279
|
}
|
280
|
|
281
|
/**
|
282
|
* @param areas
|
283
|
*/
|
284
|
public void setNamedAreas(List<NamedArea> areas) {
|
285
|
// TODO Auto-generated method stub
|
286
|
this.areas = areas;
|
287
|
|
288
|
}
|
289
|
public List<NamedArea> getNamedAreas(){
|
290
|
return areas;
|
291
|
}
|
292
|
|
293
|
}
|