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
|
package eu.etaxonomy.cdm.io.excel.common;
|
10
|
|
11
|
import java.net.URI;
|
12
|
import java.util.HashMap;
|
13
|
import java.util.Map;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
18
|
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
|
19
|
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
|
20
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
21
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
22
|
|
23
|
public abstract class ExcelImportConfiguratorBase
|
24
|
extends ImportConfiguratorBase<ExcelImportState, URI>{
|
25
|
|
26
|
private static final long serialVersionUID = 9031559773350645304L;
|
27
|
private static final Logger logger = Logger.getLogger(ExcelImportConfiguratorBase.class);
|
28
|
|
29
|
//TODO
|
30
|
private static IInputTransformer defaultTransformer = null;
|
31
|
private byte[] stream;
|
32
|
private boolean deduplicateReferences = false;
|
33
|
private boolean deduplicateAuthors = false;
|
34
|
|
35
|
private String worksheetName = null;
|
36
|
|
37
|
private Map<String,String> labelReplacements = new HashMap<>();
|
38
|
|
39
|
protected ExcelImportConfiguratorBase(URI uri, ICdmDataSource destination) {
|
40
|
this(uri, destination, defaultTransformer);
|
41
|
}
|
42
|
|
43
|
protected ExcelImportConfiguratorBase(URI uri, ICdmDataSource destination, IInputTransformer transformer) {
|
44
|
super(transformer);
|
45
|
setSource(uri);
|
46
|
setDestination(destination);
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
public Reference getSourceReference() {
|
51
|
//TODO
|
52
|
if (this.sourceReference == null){
|
53
|
logger.warn("getSource Reference not yet fully implemented");
|
54
|
sourceReference = ReferenceFactory.newDatabase();
|
55
|
sourceReference.setTitleCache("Excel import " + getDateString(), true);
|
56
|
}
|
57
|
return sourceReference;
|
58
|
}
|
59
|
|
60
|
public boolean isReuseExistingTaxaWhenPossible() {
|
61
|
return false;
|
62
|
}
|
63
|
public byte[] getStream(){
|
64
|
return stream;
|
65
|
}
|
66
|
public void setStream(byte[] stream) {
|
67
|
this.stream = stream;
|
68
|
}
|
69
|
|
70
|
public boolean isDeduplicateReferences() {
|
71
|
return deduplicateReferences;
|
72
|
}
|
73
|
public void setDeduplicateReferences(boolean deduplicateReferences) {
|
74
|
this.deduplicateReferences = deduplicateReferences;
|
75
|
}
|
76
|
|
77
|
public boolean isDeduplicateAuthors() {
|
78
|
return deduplicateAuthors;
|
79
|
}
|
80
|
public void setDeduplicateAuthors(boolean deduplicateAuthors) {
|
81
|
this.deduplicateAuthors = deduplicateAuthors;
|
82
|
}
|
83
|
|
84
|
public String getWorksheetName() {
|
85
|
return worksheetName;
|
86
|
}
|
87
|
public void setWorksheetName(String worksheetName) {
|
88
|
this.worksheetName = worksheetName;
|
89
|
}
|
90
|
|
91
|
public String replaceColumnLabel(String label) {
|
92
|
String result = labelReplacements.get(label);
|
93
|
if (result == null){
|
94
|
return label;
|
95
|
}else{
|
96
|
return result;
|
97
|
}
|
98
|
}
|
99
|
|
100
|
protected void putLabelReplacement(String defaultLabel, String newLabel) {
|
101
|
labelReplacements.put(defaultLabel, newLabel);
|
102
|
}
|
103
|
}
|