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.demo;
|
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
|
* @created 17.10.2012
|
32
|
*/
|
33
|
public class CsvDemoExportConfigurator extends XmlExportConfiguratorBase<CsvDemoExportState> {
|
34
|
@SuppressWarnings("unused")
|
35
|
private static final Logger logger = Logger.getLogger(CsvDemoExportConfigurator.class);
|
36
|
|
37
|
private String encoding = "UTF-8";
|
38
|
private String linesTerminatedBy = "\r\n";
|
39
|
private String fieldsEnclosedBy = "\"";
|
40
|
private boolean hasHeaderLines = true;
|
41
|
private String fieldsTerminatedBy=",";
|
42
|
private boolean doTaxa = true;
|
43
|
private boolean doDistributions = false;
|
44
|
private ByteArrayOutputStream baos;
|
45
|
private boolean isUseIdWherePossible = false;
|
46
|
private boolean includeBasionymsInResourceRelations;
|
47
|
private boolean includeMisappliedNamesInResourceRelations;
|
48
|
private String defaultBibliographicCitation = null;
|
49
|
private List<UUID> featureExclusions = new ArrayList<UUID>();
|
50
|
//filter on the classifications to be exported
|
51
|
private Set<UUID> classificationUuids = new HashSet<UUID>();
|
52
|
private boolean withHigherClassification = false;
|
53
|
private String setSeparator = ";";
|
54
|
|
55
|
private boolean doGeographicalFilter = true;
|
56
|
private boolean doDemoExport = false;
|
57
|
private boolean doTaxonConceptExport = false;
|
58
|
|
59
|
//attributes for export
|
60
|
private boolean classification;
|
61
|
private boolean taxonName;
|
62
|
private boolean taxonNameID;
|
63
|
private boolean author;
|
64
|
private boolean rank;
|
65
|
private boolean taxonStatus;
|
66
|
private boolean taxonConceptID;
|
67
|
private boolean synonyms;
|
68
|
private boolean distributions;
|
69
|
private boolean redlistFeatures;
|
70
|
private boolean acceptedName;
|
71
|
private boolean parentID;
|
72
|
private boolean externalID;
|
73
|
private boolean lastChange;
|
74
|
|
75
|
private List<CsvDemoRecord> recordList;
|
76
|
|
77
|
|
78
|
|
79
|
|
80
|
private List<Feature> features;
|
81
|
private String classificationTitleCache;
|
82
|
private List<NamedArea> areas;
|
83
|
|
84
|
|
85
|
private Integer pageSize;
|
86
|
|
87
|
private Integer pageNumber;
|
88
|
|
89
|
private int taxonNodeListSize;
|
90
|
|
91
|
|
92
|
//TODO
|
93
|
private static IExportTransformer defaultTransformer = null;
|
94
|
|
95
|
public static CsvDemoExportConfigurator NewInstance(ICdmDataSource source, File destinationFolder) {
|
96
|
return new CsvDemoExportConfigurator(source, destinationFolder);
|
97
|
|
98
|
}
|
99
|
|
100
|
@Override
|
101
|
@SuppressWarnings("unchecked")
|
102
|
protected void makeIoClassList() {
|
103
|
ioClassList = new Class[] {
|
104
|
CsvDemoExport.class
|
105
|
};
|
106
|
}
|
107
|
|
108
|
|
109
|
/**
|
110
|
* This is function is only to have a shortcut for
|
111
|
* a preselection for available fields. One can still
|
112
|
* select fields manually.
|
113
|
* <p><p>
|
114
|
* Only one of the parameter should be true, otherwise
|
115
|
* all fields are set to true and will be exported.
|
116
|
* <p><p>
|
117
|
* In future this function might be removed.
|
118
|
*
|
119
|
*
|
120
|
* @param doDemoExport
|
121
|
* @param doTaxonConceptExport
|
122
|
*/
|
123
|
public void createPreSelectedExport(boolean doDemoExport, boolean doTaxonConceptExport){
|
124
|
if(doDemoExport){
|
125
|
setDoDemoExport(true);
|
126
|
setClassification(true);
|
127
|
setTaxonName(true);
|
128
|
setTaxonNameID(true);
|
129
|
setTaxonStatus(true);
|
130
|
setSynonyms(true);
|
131
|
setDistributions(true);
|
132
|
setRedlistFeatures(true);
|
133
|
}else if(doTaxonConceptExport){
|
134
|
setDoTaxonConceptExport(true);
|
135
|
setTaxonName(true);
|
136
|
setAuthor(true);
|
137
|
setRank(true);
|
138
|
setTaxonConceptID(true);
|
139
|
setParentID(true);
|
140
|
setExternalID(true);
|
141
|
setLastChange(true);
|
142
|
}
|
143
|
}
|
144
|
|
145
|
|
146
|
|
147
|
/**
|
148
|
* @param url
|
149
|
* @param destination
|
150
|
*/
|
151
|
private CsvDemoExportConfigurator(ICdmDataSource source, File destination) {
|
152
|
super(destination, source, defaultTransformer);
|
153
|
}
|
154
|
|
155
|
/* (non-Javadoc)
|
156
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource()
|
157
|
*/
|
158
|
@Override
|
159
|
public File getDestination() {
|
160
|
return super.getDestination();
|
161
|
}
|
162
|
|
163
|
/**
|
164
|
* @param file
|
165
|
*/
|
166
|
@Override
|
167
|
public void setDestination(File fileName) {
|
168
|
super.setDestination(fileName);
|
169
|
}
|
170
|
|
171
|
/* (non-Javadoc)
|
172
|
* @see eu.etaxonomy.cdm.io.common.IExportConfigurator#getDestinationNameString()
|
173
|
*/
|
174
|
@Override
|
175
|
public String getDestinationNameString() {
|
176
|
if (this.getDestination() == null) {
|
177
|
return null;
|
178
|
} else {
|
179
|
return this.getDestination().toString();
|
180
|
}
|
181
|
}
|
182
|
|
183
|
/* (non-Javadoc)
|
184
|
* @see eu.etaxonomy.cdm.io.common.IExportConfigurator#getNewState()
|
185
|
*/
|
186
|
@Override
|
187
|
public CsvDemoExportState getNewState() {
|
188
|
return new CsvDemoExportState(this);
|
189
|
}
|
190
|
|
191
|
public boolean isDoTaxa() {
|
192
|
return doTaxa;
|
193
|
}
|
194
|
|
195
|
public void setDoTaxa(boolean doTaxa) {
|
196
|
this.doTaxa = doTaxa;
|
197
|
}
|
198
|
|
199
|
|
200
|
public boolean isDoDistributions() {
|
201
|
return doDistributions;
|
202
|
}
|
203
|
|
204
|
public void setDoDistributions(boolean doDistributions) {
|
205
|
this.doDistributions = doDistributions;
|
206
|
}
|
207
|
|
208
|
public void setFeatureExclusions(List<UUID> featureExclusions) {
|
209
|
this.featureExclusions = featureExclusions;
|
210
|
}
|
211
|
|
212
|
public List<UUID> getFeatureExclusions() {
|
213
|
return featureExclusions;
|
214
|
}
|
215
|
|
216
|
public String getEncoding() {
|
217
|
return encoding;
|
218
|
}
|
219
|
|
220
|
public void setEncoding(String encoding) {
|
221
|
this.encoding = encoding;
|
222
|
}
|
223
|
|
224
|
public String getLinesTerminatedBy() {
|
225
|
return linesTerminatedBy;
|
226
|
}
|
227
|
|
228
|
public void setLinesTerminatedBy(String linesTerminatedBy) {
|
229
|
this.linesTerminatedBy = linesTerminatedBy;
|
230
|
}
|
231
|
|
232
|
public String getFieldsEnclosedBy() {
|
233
|
return fieldsEnclosedBy;
|
234
|
}
|
235
|
|
236
|
public void setFieldsEnclosedBy(String fieldsEnclosedBy) {
|
237
|
this.fieldsEnclosedBy = fieldsEnclosedBy;
|
238
|
}
|
239
|
|
240
|
/**
|
241
|
* Equals darwin core archive ignoreHeaderLines attribute
|
242
|
* @return
|
243
|
*/
|
244
|
public boolean isHasHeaderLines() {
|
245
|
return hasHeaderLines;
|
246
|
}
|
247
|
|
248
|
public void setHasHeaderLines(boolean hasHeaderLines) {
|
249
|
this.hasHeaderLines = hasHeaderLines;
|
250
|
}
|
251
|
|
252
|
public boolean isIncludeBasionymsInResourceRelations() {
|
253
|
return includeBasionymsInResourceRelations;
|
254
|
}
|
255
|
|
256
|
public void setIncludeBasionymsInResourceRelations(boolean includeBasionymsInResourceRelations) {
|
257
|
this.includeBasionymsInResourceRelations = includeBasionymsInResourceRelations;
|
258
|
}
|
259
|
|
260
|
public boolean isIncludeMisappliedNamesInResourceRelations() {
|
261
|
return includeMisappliedNamesInResourceRelations;
|
262
|
}
|
263
|
|
264
|
public void setIncludeMisappliedNamesInResourceRelations(boolean includeMisappliedNamesInResourceRelations) {
|
265
|
this.includeMisappliedNamesInResourceRelations = includeMisappliedNamesInResourceRelations;
|
266
|
}
|
267
|
|
268
|
public boolean isUseIdWherePossible() {
|
269
|
return this.isUseIdWherePossible;
|
270
|
}
|
271
|
|
272
|
public void setUseIdWherePossible(boolean isUseIdWherePossible) {
|
273
|
this.isUseIdWherePossible = isUseIdWherePossible;
|
274
|
}
|
275
|
|
276
|
public void setDefaultBibliographicCitation(String defaultBibliographicCitation) {
|
277
|
this.defaultBibliographicCitation = defaultBibliographicCitation;
|
278
|
}
|
279
|
|
280
|
|
281
|
public String getDefaultBibliographicCitation() {
|
282
|
return defaultBibliographicCitation;
|
283
|
}
|
284
|
|
285
|
/**
|
286
|
* The default value for the taxon.source column. This may be a column linking to a url that provides
|
287
|
* data about the given taxon. The id is replaced by a placeholder,
|
288
|
* e.g. http://wp6-cichorieae.e-taxonomy.eu/portal/?q=cdm_dataportal/taxon/{id}.
|
289
|
* NOTE: This may be replaced in future versions by concrete CDM server implementations.
|
290
|
*
|
291
|
* @return the taxonSourceDefault
|
292
|
*/
|
293
|
|
294
|
public boolean isWithHigherClassification() {
|
295
|
return withHigherClassification;
|
296
|
}
|
297
|
|
298
|
public void setWithHigherClassification(boolean withHigherClassification) {
|
299
|
this.withHigherClassification = withHigherClassification;
|
300
|
}
|
301
|
|
302
|
/**
|
303
|
* @return the setSeparator
|
304
|
*/
|
305
|
public String getSetSeparator() {
|
306
|
return setSeparator;
|
307
|
}
|
308
|
|
309
|
/**
|
310
|
* @param setSeparator the setSeparator to set
|
311
|
*/
|
312
|
public void setSetSeparator(String setSeparator) {
|
313
|
this.setSeparator = setSeparator;
|
314
|
}
|
315
|
|
316
|
public void setFieldsTerminatedBy(String fieldsTerminatedBy) {
|
317
|
this.fieldsTerminatedBy = fieldsTerminatedBy;
|
318
|
}
|
319
|
|
320
|
public String getFieldsTerminatedBy() {
|
321
|
return fieldsTerminatedBy;
|
322
|
}
|
323
|
|
324
|
public Set<UUID> getClassificationUuids() {
|
325
|
return classificationUuids;
|
326
|
}
|
327
|
|
328
|
public void setClassificationUuids(Set<UUID> classificationUuids) {
|
329
|
this.classificationUuids = classificationUuids;
|
330
|
}
|
331
|
|
332
|
public ByteArrayOutputStream getByteArrayOutputStream() {
|
333
|
return baos;
|
334
|
}
|
335
|
|
336
|
public void setByteArrayOutputStream(ByteArrayOutputStream baos) {
|
337
|
this.baos = baos;
|
338
|
}
|
339
|
|
340
|
public void setFeatures(List<Feature> features) {
|
341
|
this.features = features;
|
342
|
|
343
|
}
|
344
|
|
345
|
public List<Feature> getFeatures() {
|
346
|
return features;
|
347
|
|
348
|
}
|
349
|
|
350
|
public void setClassificationTitleCache(String classificationTitleCache) {
|
351
|
this.classificationTitleCache = classificationTitleCache;
|
352
|
}
|
353
|
|
354
|
public String getClassificationTitleCache() {
|
355
|
return classificationTitleCache;
|
356
|
}
|
357
|
|
358
|
/**
|
359
|
* @param areas
|
360
|
*/
|
361
|
public void setNamedAreas(List<NamedArea> areas) {
|
362
|
// TODO Auto-generated method stub
|
363
|
this.areas = areas;
|
364
|
|
365
|
}
|
366
|
public List<NamedArea> getNamedAreas(){
|
367
|
return areas;
|
368
|
}
|
369
|
|
370
|
public boolean isDoGeographicalFilter() {
|
371
|
return doGeographicalFilter;
|
372
|
}
|
373
|
|
374
|
public void setDoGeographicalFilter(boolean doGeographicalFilter) {
|
375
|
this.doGeographicalFilter = doGeographicalFilter;
|
376
|
}
|
377
|
|
378
|
public boolean isDoDemoExport() {
|
379
|
return doDemoExport;
|
380
|
}
|
381
|
|
382
|
public void setDoDemoExport(boolean doDemoHeadlines) {
|
383
|
this.doDemoExport = doDemoHeadlines;
|
384
|
}
|
385
|
|
386
|
|
387
|
public boolean isDoTaxonConceptExport() {
|
388
|
return doTaxonConceptExport;
|
389
|
}
|
390
|
|
391
|
public void setDoTaxonConceptExport(boolean doTaxonConceptExport) {
|
392
|
this.doTaxonConceptExport = doTaxonConceptExport;
|
393
|
}
|
394
|
|
395
|
public boolean isAuthor() {
|
396
|
return author;
|
397
|
}
|
398
|
|
399
|
public void setAuthor(boolean author) {
|
400
|
this.author = author;
|
401
|
}
|
402
|
|
403
|
public boolean isRank() {
|
404
|
return rank;
|
405
|
}
|
406
|
|
407
|
public void setRank(boolean rank) {
|
408
|
this.rank = rank;
|
409
|
}
|
410
|
|
411
|
public boolean isTaxonConceptID() {
|
412
|
return taxonConceptID;
|
413
|
}
|
414
|
|
415
|
public void setTaxonConceptID(boolean taxonConceptID) {
|
416
|
this.taxonConceptID = taxonConceptID;
|
417
|
}
|
418
|
|
419
|
public boolean isAcceptedName() {
|
420
|
return acceptedName;
|
421
|
}
|
422
|
|
423
|
public void setAcceptedName(boolean acceptedName) {
|
424
|
this.acceptedName = acceptedName;
|
425
|
}
|
426
|
public boolean isClassification() {
|
427
|
return classification;
|
428
|
}
|
429
|
|
430
|
public void setClassification(boolean classification) {
|
431
|
this.classification = classification;
|
432
|
}
|
433
|
|
434
|
public boolean isTaxonName() {
|
435
|
return taxonName;
|
436
|
}
|
437
|
|
438
|
public void setTaxonName(boolean taxonName) {
|
439
|
this.taxonName = taxonName;
|
440
|
}
|
441
|
|
442
|
public boolean isTaxonNameID() {
|
443
|
return taxonNameID;
|
444
|
}
|
445
|
|
446
|
public void setTaxonNameID(boolean taxonNameID) {
|
447
|
this.taxonNameID = taxonNameID;
|
448
|
}
|
449
|
|
450
|
public boolean isTaxonStatus() {
|
451
|
return taxonStatus;
|
452
|
}
|
453
|
|
454
|
public void setTaxonStatus(boolean taxonStatus) {
|
455
|
this.taxonStatus = taxonStatus;
|
456
|
}
|
457
|
|
458
|
public boolean isSynonyms() {
|
459
|
return synonyms;
|
460
|
}
|
461
|
|
462
|
public void setSynonyms(boolean synonyms) {
|
463
|
this.synonyms = synonyms;
|
464
|
}
|
465
|
|
466
|
public boolean isDistributions() {
|
467
|
return distributions;
|
468
|
}
|
469
|
|
470
|
public void setDistributions(boolean distributions) {
|
471
|
this.distributions = distributions;
|
472
|
}
|
473
|
|
474
|
public boolean isRedlistFeatures() {
|
475
|
return redlistFeatures;
|
476
|
}
|
477
|
|
478
|
public void setRedlistFeatures(boolean redlistFeatures) {
|
479
|
this.redlistFeatures = redlistFeatures;
|
480
|
}
|
481
|
|
482
|
public boolean isParentID() {
|
483
|
return parentID;
|
484
|
}
|
485
|
|
486
|
public void setParentID(boolean parentID) {
|
487
|
this.parentID = parentID;
|
488
|
}
|
489
|
|
490
|
public boolean isLastChange() {
|
491
|
return lastChange;
|
492
|
}
|
493
|
|
494
|
public void setLastChange(boolean lastChange) {
|
495
|
this.lastChange = lastChange;
|
496
|
}
|
497
|
|
498
|
public boolean isExternalID() {
|
499
|
return externalID;
|
500
|
}
|
501
|
|
502
|
public void setExternalID(boolean externalID) {
|
503
|
this.externalID = externalID;
|
504
|
}
|
505
|
public List<CsvDemoRecord> getRecordList() {
|
506
|
return recordList;
|
507
|
}
|
508
|
public void setRecordList(List<CsvDemoRecord> recordList) {
|
509
|
this.recordList = recordList;
|
510
|
}
|
511
|
|
512
|
public Integer getPageSize() {
|
513
|
return pageSize;
|
514
|
}
|
515
|
public void setPageSize(Integer pageSize) {
|
516
|
this.pageSize = pageSize;
|
517
|
}
|
518
|
|
519
|
public Integer getPageNumber() {
|
520
|
return pageNumber;
|
521
|
}
|
522
|
|
523
|
public void setPageNumber(Integer pageNumber) {
|
524
|
this.pageNumber = pageNumber;
|
525
|
}
|
526
|
|
527
|
|
528
|
public int getTaxonNodeListSize() {
|
529
|
return taxonNodeListSize;
|
530
|
}
|
531
|
|
532
|
public void setTaxonNodeListSize(int size) {
|
533
|
this.taxonNodeListSize = size;
|
534
|
|
535
|
}
|
536
|
|
537
|
}
|