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.dwca.out;
|
11
|
|
12
|
import java.io.File;
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.List;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import org.apache.log4j.Logger;
|
18
|
|
19
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
20
|
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
|
21
|
import eu.etaxonomy.cdm.io.common.ExportResultType;
|
22
|
import eu.etaxonomy.cdm.io.common.XmlExportConfiguratorBase;
|
23
|
|
24
|
|
25
|
/**
|
26
|
* @author a.mueller
|
27
|
* @created 18.04.2011
|
28
|
*/
|
29
|
public class DwcaTaxExportConfigurator extends XmlExportConfiguratorBase<DwcaTaxExportState> {
|
30
|
|
31
|
private static final long serialVersionUID = -464609596078614735L;
|
32
|
|
33
|
@SuppressWarnings("unused")
|
34
|
private static final Logger logger = Logger.getLogger(DwcaTaxExportConfigurator.class);
|
35
|
|
36
|
private String encoding = "UTF-8";
|
37
|
private String linesTerminatedBy = "\r\n";
|
38
|
private String fieldsEnclosedBy = "\"";
|
39
|
private boolean hasHeaderLines = true;
|
40
|
private String fieldsTerminatedBy=",";
|
41
|
|
42
|
|
43
|
private boolean doTaxa = true;
|
44
|
private boolean doResourceRelation = true;
|
45
|
private boolean doTypesAndSpecimen = true;
|
46
|
private boolean doVernacularNames = true;
|
47
|
private boolean doReferences = true;
|
48
|
private boolean doDescriptions = true;
|
49
|
private boolean doDistributions = true;
|
50
|
private boolean doImages = true;
|
51
|
private boolean doMetaData = true;
|
52
|
private boolean doEml = true;
|
53
|
|
54
|
private boolean doSynonyms = true;
|
55
|
private boolean doMisappliedNames = true;
|
56
|
|
57
|
private boolean isUseIdWherePossible = false;
|
58
|
|
59
|
private boolean includeBasionymsInResourceRelations;
|
60
|
private boolean includeMisappliedNamesInResourceRelations;
|
61
|
|
62
|
private String defaultBibliographicCitation = null;
|
63
|
|
64
|
private DwcaEmlRecord emlRecord;
|
65
|
|
66
|
private List<UUID> featureExclusions = new ArrayList<>();
|
67
|
|
68
|
private TaxonNodeFilter taxonNodeFilter = new TaxonNodeFilter();
|
69
|
|
70
|
private String defaultTaxonSource;
|
71
|
|
72
|
private boolean withHigherClassification = false;
|
73
|
|
74
|
private String setSeparator = ";";
|
75
|
|
76
|
//TODO
|
77
|
private static DwcaTaxExportTransformer defaultTransformer = null;
|
78
|
|
79
|
|
80
|
public static DwcaTaxExportConfigurator NewInstance(ICdmDataSource source, File destinationFolder, DwcaEmlRecord emlRecord) {
|
81
|
return new DwcaTaxExportConfigurator(source, destinationFolder, emlRecord);
|
82
|
}
|
83
|
|
84
|
|
85
|
@Override
|
86
|
@SuppressWarnings("unchecked")
|
87
|
protected void makeIoClassList() {
|
88
|
ioClassList = new Class[] {
|
89
|
DwcaTaxExport.class
|
90
|
,DwcaMetaDataExport.class
|
91
|
,DwcaEmlExport.class
|
92
|
,DwcaResultWriter.class
|
93
|
};
|
94
|
}
|
95
|
|
96
|
|
97
|
/**
|
98
|
* @param url
|
99
|
* @param destination
|
100
|
*/
|
101
|
private DwcaTaxExportConfigurator(ICdmDataSource source, File destination, DwcaEmlRecord emlRecord) {
|
102
|
super(destination, source, defaultTransformer);
|
103
|
this.resultType = ExportResultType.MAP_BYTE_ARRAY;
|
104
|
this.emlRecord = emlRecord;
|
105
|
this.setDestination(destination);
|
106
|
this.setSource(source);
|
107
|
}
|
108
|
|
109
|
@Override
|
110
|
public File getDestination() {
|
111
|
return super.getDestination();
|
112
|
}
|
113
|
|
114
|
@Override
|
115
|
public void setDestination(File fileName) {
|
116
|
super.setDestination(fileName);
|
117
|
}
|
118
|
|
119
|
@Override
|
120
|
public String getDestinationNameString() {
|
121
|
if (this.getDestination() == null) {
|
122
|
return null;
|
123
|
} else {
|
124
|
return this.getDestination().toString();
|
125
|
}
|
126
|
}
|
127
|
|
128
|
@Override
|
129
|
public DwcaTaxExportState getNewState() {
|
130
|
return new DwcaTaxExportState(this);
|
131
|
}
|
132
|
|
133
|
public boolean isDoTaxa() {
|
134
|
return doTaxa;
|
135
|
}
|
136
|
public void setDoTaxa(boolean doTaxa) {
|
137
|
this.doTaxa = doTaxa;
|
138
|
}
|
139
|
|
140
|
public boolean isDoResourceRelation() {
|
141
|
return doResourceRelation;
|
142
|
}
|
143
|
public void setDoResourceRelations(boolean doResourceRelation) {
|
144
|
this.doResourceRelation = doResourceRelation;
|
145
|
}
|
146
|
|
147
|
public boolean isDoTypesAndSpecimen() {
|
148
|
return doTypesAndSpecimen;
|
149
|
}
|
150
|
public void setDoTypesAndSpecimen(boolean doTypesAndSpecimen) {
|
151
|
this.doTypesAndSpecimen = doTypesAndSpecimen;
|
152
|
}
|
153
|
|
154
|
public boolean isDoVernacularNames() {
|
155
|
return doVernacularNames;
|
156
|
}
|
157
|
public void setDoVernacularNames(boolean doVernacularNames) {
|
158
|
this.doVernacularNames = doVernacularNames;
|
159
|
}
|
160
|
|
161
|
public boolean isDoReferences() {
|
162
|
return doReferences;
|
163
|
}
|
164
|
public void setDoReferences(boolean doReferences) {
|
165
|
this.doReferences = doReferences;
|
166
|
}
|
167
|
|
168
|
public boolean isDoDescriptions() {
|
169
|
return doDescriptions;
|
170
|
}
|
171
|
public void setDoDescriptions(boolean doDescriptions) {
|
172
|
this.doDescriptions = doDescriptions;
|
173
|
}
|
174
|
|
175
|
public boolean isDoDistributions() {
|
176
|
return doDistributions;
|
177
|
}
|
178
|
public void setDoDistributions(boolean doDistributions) {
|
179
|
this.doDistributions = doDistributions;
|
180
|
}
|
181
|
|
182
|
public boolean isDoImages() {
|
183
|
return doImages;
|
184
|
}
|
185
|
public void setDoImages(boolean doImages) {
|
186
|
this.doImages = doImages;
|
187
|
}
|
188
|
|
189
|
public void setFeatureExclusions(List<UUID> featureExclusions) {
|
190
|
this.featureExclusions = featureExclusions;
|
191
|
}
|
192
|
public List<UUID> getFeatureExclusions() {
|
193
|
return featureExclusions;
|
194
|
}
|
195
|
|
196
|
public String getEncoding() {
|
197
|
return encoding;
|
198
|
}
|
199
|
public void setEncoding(String encoding) {
|
200
|
this.encoding = encoding;
|
201
|
}
|
202
|
|
203
|
public String getLinesTerminatedBy() {
|
204
|
return linesTerminatedBy;
|
205
|
}
|
206
|
public void setLinesTerminatedBy(String linesTerminatedBy) {
|
207
|
this.linesTerminatedBy = linesTerminatedBy;
|
208
|
}
|
209
|
|
210
|
public String getFieldsEnclosedBy() {
|
211
|
return fieldsEnclosedBy;
|
212
|
}
|
213
|
public void setFieldsEnclosedBy(String fieldsEnclosedBy) {
|
214
|
this.fieldsEnclosedBy = fieldsEnclosedBy;
|
215
|
}
|
216
|
|
217
|
/**
|
218
|
* Equals darwin core archive ignoreHeaderLines attribute
|
219
|
* @return
|
220
|
*/
|
221
|
public boolean isHasHeaderLines() {
|
222
|
return hasHeaderLines;
|
223
|
}
|
224
|
public void setHasHeaderLines(boolean hasHeaderLines) {
|
225
|
this.hasHeaderLines = hasHeaderLines;
|
226
|
}
|
227
|
|
228
|
public boolean isIncludeBasionymsInResourceRelations() {
|
229
|
return includeBasionymsInResourceRelations;
|
230
|
}
|
231
|
public void setIncludeBasionymsInResourceRelations(boolean includeBasionymsInResourceRelations) {
|
232
|
this.includeBasionymsInResourceRelations = includeBasionymsInResourceRelations;
|
233
|
}
|
234
|
|
235
|
public boolean isIncludeMisappliedNamesInResourceRelations() {
|
236
|
return includeMisappliedNamesInResourceRelations;
|
237
|
}
|
238
|
public void setIncludeMisappliedNamesInResourceRelations(boolean includeMisappliedNamesInResourceRelations) {
|
239
|
this.includeMisappliedNamesInResourceRelations = includeMisappliedNamesInResourceRelations;
|
240
|
}
|
241
|
|
242
|
public void setDoMetaData(boolean doMetaData) {
|
243
|
this.doMetaData = doMetaData;
|
244
|
}
|
245
|
public boolean isDoMetaData() {
|
246
|
return doMetaData;
|
247
|
}
|
248
|
|
249
|
public boolean isUseIdWherePossible() {
|
250
|
return this.isUseIdWherePossible;
|
251
|
}
|
252
|
public void setUseIdWherePossible(boolean isUseIdWherePossible) {
|
253
|
this.isUseIdWherePossible = isUseIdWherePossible;
|
254
|
}
|
255
|
|
256
|
public void setEmlRecord(DwcaEmlRecord emlRecord) {
|
257
|
this.emlRecord = emlRecord;
|
258
|
}
|
259
|
public DwcaEmlRecord getEmlRecord() {
|
260
|
return emlRecord;
|
261
|
}
|
262
|
|
263
|
public void setDoEml(boolean doEml) {
|
264
|
this.doEml = doEml;
|
265
|
}
|
266
|
public boolean isDoEml() {
|
267
|
return doEml;
|
268
|
}
|
269
|
|
270
|
|
271
|
public void setDefaultBibliographicCitation(String defaultBibliographicCitation) {
|
272
|
this.defaultBibliographicCitation = defaultBibliographicCitation;
|
273
|
}
|
274
|
public String getDefaultBibliographicCitation() {
|
275
|
return defaultBibliographicCitation;
|
276
|
}
|
277
|
|
278
|
|
279
|
/**
|
280
|
* The default value for the taxon.source column. This may be a column linking to a url that provides
|
281
|
* data about the given taxon. The id is replaced by a placeholder,
|
282
|
* e.g. http://wp6-cichorieae.e-taxonomy.eu/portal/?q=cdm_dataportal/taxon/{id}.
|
283
|
* NOTE: This may be replaced in future versions by concrete CDM server implementations.
|
284
|
*
|
285
|
* @return the taxonSourceDefault
|
286
|
*/
|
287
|
public String getDefaultTaxonSource() {
|
288
|
return defaultTaxonSource;
|
289
|
}
|
290
|
public void setDefaultTaxonSource(String taxonSourceDefault) {
|
291
|
this.defaultTaxonSource = taxonSourceDefault;
|
292
|
}
|
293
|
|
294
|
|
295
|
public boolean isWithHigherClassification() {
|
296
|
return withHigherClassification;
|
297
|
}
|
298
|
public void setWithHigherClassification(boolean withHigherClassification) {
|
299
|
this.withHigherClassification = withHigherClassification;
|
300
|
}
|
301
|
|
302
|
public String getSetSeparator() {
|
303
|
return setSeparator;
|
304
|
}
|
305
|
public void setSetSeparator(String setSeparator) {
|
306
|
this.setSeparator = setSeparator;
|
307
|
}
|
308
|
|
309
|
public void setFieldsTerminatedBy(String fieldsTerminatedBy) {
|
310
|
this.fieldsTerminatedBy = fieldsTerminatedBy;
|
311
|
}
|
312
|
public String getFieldsTerminatedBy() {
|
313
|
return fieldsTerminatedBy;
|
314
|
}
|
315
|
|
316
|
public TaxonNodeFilter getTaxonNodeFilter() {
|
317
|
return taxonNodeFilter;
|
318
|
}
|
319
|
public void setTaxonNodeFilter(TaxonNodeFilter taxonNodeFilter) {
|
320
|
this.taxonNodeFilter = taxonNodeFilter;
|
321
|
}
|
322
|
|
323
|
|
324
|
public boolean isDoSynonyms() {
|
325
|
return doSynonyms;
|
326
|
}
|
327
|
public void setDoSynonyms(boolean doSynonyms) {
|
328
|
this.doSynonyms = doSynonyms;
|
329
|
}
|
330
|
|
331
|
public boolean isDoMisappliedNames() {
|
332
|
return doMisappliedNames;
|
333
|
}
|
334
|
public void setDoMisappliedNames(boolean doMisappliedNames) {
|
335
|
this.doMisappliedNames = doMisappliedNames;
|
336
|
}
|
337
|
|
338
|
|
339
|
}
|