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
|
|
10
|
package eu.etaxonomy.cdm.io.markup;
|
11
|
|
12
|
import java.net.URI;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.springframework.stereotype.Component;
|
17
|
|
18
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
19
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
20
|
import eu.etaxonomy.cdm.io.common.XmlImportConfiguratorBase;
|
21
|
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
|
22
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
23
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
24
|
|
25
|
@Component
|
26
|
public class MarkupImportConfigurator extends XmlImportConfiguratorBase<MarkupImportState> implements IImportConfigurator {
|
27
|
private static final Logger logger = Logger.getLogger(MarkupImportConfigurator.class);
|
28
|
|
29
|
public static MarkupImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
|
30
|
return new MarkupImportConfigurator(uri, destination);
|
31
|
}
|
32
|
|
33
|
private boolean replaceStandardKeyTitles = true;
|
34
|
|
35
|
private boolean doTaxa = true;
|
36
|
|
37
|
private boolean reuseExistingState = false;
|
38
|
|
39
|
private boolean allowCapitalSpeciesEpithet = false; //set to true if you want to allow specific epithets with capital letter at the beginning. This was allowed by the code for epithets referring to persons such as Beilschmiedia Zenkeri.
|
40
|
|
41
|
|
42
|
//TODO
|
43
|
private static IInputTransformer defaultTransformer = null;
|
44
|
private String classificationTitle = "E-Flora Import";
|
45
|
private String sourceReferenceTitle = "E-Flora";
|
46
|
private UUID defaultLanguageUuid;
|
47
|
|
48
|
//TODO move to state, but a state gets lost after each import.invoke, so I can't move this information
|
49
|
//from the one import to another import in case I run 2 imports in line
|
50
|
private UUID lastTaxonUuid;
|
51
|
|
52
|
//if true, the keys will be printed after they have been created
|
53
|
private boolean doPrintKeys = false;
|
54
|
|
55
|
private MarkupImportState state;
|
56
|
|
57
|
/* (non-Javadoc)
|
58
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#makeIoClassList()
|
59
|
*/
|
60
|
protected void makeIoClassList(){
|
61
|
ioClassList = new Class[]{
|
62
|
MarkupDocumentImport.class
|
63
|
};
|
64
|
};
|
65
|
|
66
|
protected MarkupImportConfigurator() {
|
67
|
super(defaultTransformer);
|
68
|
}
|
69
|
|
70
|
|
71
|
/**
|
72
|
*
|
73
|
*/
|
74
|
protected MarkupImportConfigurator(IInputTransformer transformer) {
|
75
|
super(transformer);
|
76
|
}
|
77
|
|
78
|
|
79
|
/**
|
80
|
* @param url
|
81
|
* @param destination
|
82
|
*/
|
83
|
protected MarkupImportConfigurator(URI uri, ICdmDataSource destination) {
|
84
|
super(defaultTransformer);
|
85
|
setSource(uri);
|
86
|
setDestination(destination);
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* @param url
|
91
|
* @param destination
|
92
|
*/
|
93
|
protected MarkupImportConfigurator(URI uri, ICdmDataSource destination, IInputTransformer transformer) {
|
94
|
super(transformer);
|
95
|
setSource(uri);
|
96
|
setDestination(destination);
|
97
|
}
|
98
|
|
99
|
|
100
|
/* (non-Javadoc)
|
101
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
|
102
|
*/
|
103
|
public MarkupImportState getNewState() {
|
104
|
if (this.isReuseExistingState() == true){
|
105
|
if (this.state == null){
|
106
|
this.state = new MarkupImportState(this);
|
107
|
}
|
108
|
return this.state;
|
109
|
}else{
|
110
|
return new MarkupImportState(this);
|
111
|
}
|
112
|
|
113
|
|
114
|
}
|
115
|
|
116
|
|
117
|
/* (non-Javadoc)
|
118
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
|
119
|
*/
|
120
|
@Override
|
121
|
public Reference getSourceReference() {
|
122
|
//TODO
|
123
|
if (this.sourceReference == null){
|
124
|
logger.warn("getSource Reference not yet fully implemented");
|
125
|
sourceReference = ReferenceFactory.newGeneric();
|
126
|
sourceReference.setTitleCache(sourceReferenceTitle, true);
|
127
|
}
|
128
|
return sourceReference;
|
129
|
}
|
130
|
|
131
|
|
132
|
/* (non-Javadoc)
|
133
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
|
134
|
*/
|
135
|
public String getSourceNameString() {
|
136
|
if (this.getSource() == null){
|
137
|
return null;
|
138
|
}else{
|
139
|
return this.getSource().toString();
|
140
|
}
|
141
|
}
|
142
|
|
143
|
|
144
|
public UUID getLastTaxonUuid() {
|
145
|
return lastTaxonUuid;
|
146
|
}
|
147
|
|
148
|
public void setLastTaxonUuid(UUID lastTaxonUuid) {
|
149
|
this.lastTaxonUuid = lastTaxonUuid;
|
150
|
}
|
151
|
|
152
|
public void setDoPrintKeys(boolean doPrintKeys) {
|
153
|
this.doPrintKeys = doPrintKeys;
|
154
|
}
|
155
|
|
156
|
public boolean isDoPrintKeys() {
|
157
|
return doPrintKeys;
|
158
|
}
|
159
|
|
160
|
public UUID getDefaultLanguageUuid() {
|
161
|
return this.defaultLanguageUuid;
|
162
|
}
|
163
|
|
164
|
public void setDefaultLanguageUuid(UUID defaultLanguageUuid) {
|
165
|
this.defaultLanguageUuid = defaultLanguageUuid;
|
166
|
}
|
167
|
|
168
|
public boolean isDoTaxa() {
|
169
|
return doTaxa;
|
170
|
}
|
171
|
public void setDoTaxa(boolean doTaxa) {
|
172
|
this.doTaxa = doTaxa;
|
173
|
}
|
174
|
|
175
|
public void setReplaceStandardKeyTitles(boolean replaceStandardKeyTitles) {
|
176
|
this.replaceStandardKeyTitles = replaceStandardKeyTitles;
|
177
|
}
|
178
|
|
179
|
public boolean isReplaceStandardKeyTitles() {
|
180
|
return replaceStandardKeyTitles;
|
181
|
}
|
182
|
|
183
|
/**
|
184
|
* If true, the state is saved in the configurator between 2 imports using this same configurator.
|
185
|
* Use with care as you may run into memory issues or also data consistency issues otherwise.
|
186
|
* This value must be set before getNewState is called for the <b>first</b> time. The feature is
|
187
|
* experimental.
|
188
|
* @return if reuse existing state is set to true.
|
189
|
*/
|
190
|
public boolean isReuseExistingState() {
|
191
|
return reuseExistingState;
|
192
|
}
|
193
|
|
194
|
/**
|
195
|
* @see #isReuseExistingState()
|
196
|
* @param reuseExistingState
|
197
|
*/
|
198
|
public void setReuseExistingState(boolean reuseExistingState) {
|
199
|
this.reuseExistingState = reuseExistingState;
|
200
|
}
|
201
|
|
202
|
/**
|
203
|
* If {@link #isReuseExistingState()} is true, this method returns the state.
|
204
|
* This is an experimental workaround for Markup import. The functionality
|
205
|
* should better be moved to CdmImportBase somewhere.
|
206
|
* @return
|
207
|
*/
|
208
|
public MarkupImportState getState() {
|
209
|
return state;
|
210
|
}
|
211
|
|
212
|
public boolean isAllowCapitalSpeciesEpithet() {
|
213
|
return allowCapitalSpeciesEpithet;
|
214
|
}
|
215
|
|
216
|
public void setAllowCapitalSpeciesEpithet(boolean allowCapitalSpeciesEpithet) {
|
217
|
this.allowCapitalSpeciesEpithet = allowCapitalSpeciesEpithet;
|
218
|
}
|
219
|
|
220
|
|
221
|
}
|