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.taxonx2013;
|
11
|
|
12
|
import java.net.URI;
|
13
|
import java.util.HashMap;
|
14
|
import java.util.Map;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
18
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
19
|
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
|
20
|
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
|
21
|
import eu.etaxonomy.cdm.model.agent.Person;
|
22
|
import eu.etaxonomy.cdm.model.name.Rank;
|
23
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
24
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
25
|
|
26
|
|
27
|
/**
|
28
|
* @author a.mueller
|
29
|
* @created 29.07.2008
|
30
|
* @version 1.0
|
31
|
*/
|
32
|
public class TaxonXImportConfigurator extends ImportConfiguratorBase<TaxonXImportState, URI> implements IImportConfigurator {
|
33
|
// private static final Logger logger = Logger.getLogger(TaxonXImportConfigurator.class);
|
34
|
|
35
|
private String defaultImportClassification = null;
|
36
|
//if true the information in the mods part (taxonxHeader)
|
37
|
private boolean doMods = true;
|
38
|
private boolean doFacts = true;
|
39
|
private boolean doTypes = true;
|
40
|
private boolean alwaysUseDefaultClassification = false;
|
41
|
|
42
|
|
43
|
//TODO
|
44
|
private static IInputTransformer defaultTransformer = null;
|
45
|
|
46
|
//the original TaxonXImport extracted Synonyms by creating acc Taxa with partial names
|
47
|
//I (AM) do not understand this but don't want to destroy code which maybe works in some cases) there
|
48
|
//I created this switch for old
|
49
|
//for Spiders the new version is preferred
|
50
|
private boolean isUseOldUnparsedSynonymExtraction = true;
|
51
|
|
52
|
//if false references in this rdf file are not published in the bibliography list
|
53
|
private boolean isPublishReferences = true;
|
54
|
|
55
|
private String originalSourceTaxonNamespace = "TaxonConcept";
|
56
|
private String originalSourceId;
|
57
|
|
58
|
private Map<String, Person> titleCachePerson;
|
59
|
private Map<String,UUID> namedAreaDecisions = new HashMap<String,UUID>();
|
60
|
|
61
|
|
62
|
|
63
|
private static Reference sourceRef = null;
|
64
|
|
65
|
private Reference secundum;
|
66
|
private boolean keepOriginalSecundum;
|
67
|
private Rank maxRank;
|
68
|
private boolean askedForHRank =false;
|
69
|
private Reference sourceURL;
|
70
|
private boolean lastImport=false;
|
71
|
|
72
|
|
73
|
@SuppressWarnings("unchecked")
|
74
|
@Override
|
75
|
protected void makeIoClassList(){
|
76
|
ioClassList = new Class[]{
|
77
|
TaxonXImport.class,
|
78
|
};
|
79
|
}
|
80
|
|
81
|
/**
|
82
|
* @param uri
|
83
|
* @param destination
|
84
|
* @return
|
85
|
*/
|
86
|
public static TaxonXImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
|
87
|
return new TaxonXImportConfigurator(uri, destination);
|
88
|
}
|
89
|
|
90
|
|
91
|
/**
|
92
|
* @param url
|
93
|
* @param destination
|
94
|
*/
|
95
|
private TaxonXImportConfigurator(URI uri, ICdmDataSource destination) {
|
96
|
super(defaultTransformer);
|
97
|
setSource(uri);
|
98
|
setDestination(destination);
|
99
|
}
|
100
|
|
101
|
/**
|
102
|
* @param url
|
103
|
* @param destination
|
104
|
*/
|
105
|
private TaxonXImportConfigurator(ICdmDataSource destination) {
|
106
|
super(defaultTransformer);
|
107
|
setDestination(destination);
|
108
|
}
|
109
|
|
110
|
@SuppressWarnings("unchecked")
|
111
|
@Override
|
112
|
public TaxonXImportState getNewState() {
|
113
|
return new TaxonXImportState(this);
|
114
|
}
|
115
|
|
116
|
@SuppressWarnings("rawtypes")
|
117
|
@Override
|
118
|
public Reference getSourceReference() {
|
119
|
if (sourceReference == null){
|
120
|
sourceReference = ReferenceFactory.newGeneric();
|
121
|
|
122
|
if (getSourceRefUuid() != null){
|
123
|
sourceReference.setUuid(getSourceRefUuid());
|
124
|
}
|
125
|
if (sourceRef != null){
|
126
|
sourceReference.setTitleCache(sourceRef.getTitleCache(), true);
|
127
|
}
|
128
|
}
|
129
|
return sourceReference;
|
130
|
}
|
131
|
|
132
|
@Override
|
133
|
public String getSourceNameString() {
|
134
|
if (this.getSource() == null){
|
135
|
return null;
|
136
|
}else{
|
137
|
return this.getSource().toString();
|
138
|
}
|
139
|
}
|
140
|
|
141
|
public String getOriginalSourceTaxonNamespace() {
|
142
|
return originalSourceTaxonNamespace;
|
143
|
}
|
144
|
|
145
|
public void setOriginalSourceTaxonNamespace(String originalSourceTaxonNamespace) {
|
146
|
this.originalSourceTaxonNamespace = originalSourceTaxonNamespace;
|
147
|
}
|
148
|
|
149
|
public String getOriginalSourceId() {
|
150
|
return originalSourceId;
|
151
|
}
|
152
|
|
153
|
public void setOriginalSourceId(String originalSourceId) {
|
154
|
this.originalSourceId = originalSourceId;
|
155
|
}
|
156
|
|
157
|
|
158
|
/**
|
159
|
* @return the doMods
|
160
|
*/
|
161
|
public boolean isDoMods() {
|
162
|
return doMods;
|
163
|
}
|
164
|
|
165
|
/**
|
166
|
* @param doMods the doMods to set
|
167
|
*/
|
168
|
public void setDoMods(boolean doMods) {
|
169
|
this.doMods = doMods;
|
170
|
}
|
171
|
|
172
|
|
173
|
public boolean isDoFacts() {
|
174
|
return doFacts;
|
175
|
}
|
176
|
public void setDoFacts(boolean doFacts) {
|
177
|
this.doFacts = doFacts;
|
178
|
}
|
179
|
|
180
|
|
181
|
|
182
|
public boolean isDoTypes() {
|
183
|
return doTypes;
|
184
|
}
|
185
|
public void setDoTypes(boolean doTypes) {
|
186
|
this.doTypes = doTypes;
|
187
|
}
|
188
|
|
189
|
|
190
|
/**
|
191
|
* @return the isPublishReferences
|
192
|
*/
|
193
|
public boolean isPublishReferences() {
|
194
|
return isPublishReferences;
|
195
|
}
|
196
|
|
197
|
/**
|
198
|
* @param isPublishReferences the isPublishReferences to set
|
199
|
*/
|
200
|
public void setPublishReferences(boolean isPublishReferences) {
|
201
|
this.isPublishReferences = isPublishReferences;
|
202
|
}
|
203
|
|
204
|
/**
|
205
|
* @param b
|
206
|
*/
|
207
|
public void setDoAutomaticParsing(boolean b) {
|
208
|
|
209
|
}
|
210
|
|
211
|
/**
|
212
|
* @param destination
|
213
|
* @return
|
214
|
*/
|
215
|
public static TaxonXImportConfigurator NewInstance(ICdmDataSource destination) {
|
216
|
return new TaxonXImportConfigurator(destination);
|
217
|
}
|
218
|
|
219
|
/**
|
220
|
* @param reference
|
221
|
*/
|
222
|
public static void setSourceRef(Reference reference) {
|
223
|
sourceRef = reference;
|
224
|
|
225
|
}
|
226
|
|
227
|
/**
|
228
|
* @return
|
229
|
*/
|
230
|
public Map<String, Person> getPersons() {
|
231
|
return titleCachePerson;
|
232
|
}
|
233
|
|
234
|
/**
|
235
|
* @param titleCachePerson
|
236
|
*/
|
237
|
public void setPersons(Map<String, Person> titleCachePerson) {
|
238
|
this.titleCachePerson=titleCachePerson;
|
239
|
//System.out.println(titleCachePerson);
|
240
|
|
241
|
}
|
242
|
public Map<String,UUID> getNamedAreaDecisions() {
|
243
|
return namedAreaDecisions;
|
244
|
}
|
245
|
|
246
|
public void setNamedAreaDecisions(Map<String,UUID> namedAreaDecisions) {
|
247
|
this.namedAreaDecisions = namedAreaDecisions;
|
248
|
}
|
249
|
|
250
|
public void putNamedAreaDecision(String areaStr,UUID uuid){
|
251
|
this.namedAreaDecisions.put(areaStr,uuid);
|
252
|
}
|
253
|
|
254
|
public UUID getNamedAreaDecision(String areaStr){
|
255
|
return namedAreaDecisions.get(areaStr);
|
256
|
}
|
257
|
|
258
|
/**
|
259
|
* @return
|
260
|
*/
|
261
|
public boolean doKeepOriginalSecundum() {
|
262
|
return keepOriginalSecundum;
|
263
|
}
|
264
|
|
265
|
public void setKeepOriginalSecundum(boolean reuseSecundum) {
|
266
|
this.keepOriginalSecundum = reuseSecundum;
|
267
|
}
|
268
|
|
269
|
/**
|
270
|
* @return
|
271
|
*/
|
272
|
public Reference getSecundum() {
|
273
|
if(secundum == null){
|
274
|
secundum = ReferenceFactory.newGeneric();
|
275
|
secundum.setTitle("default secundum");
|
276
|
}
|
277
|
|
278
|
return secundum;
|
279
|
}
|
280
|
|
281
|
|
282
|
public void setSecundum(Reference reference){
|
283
|
this.secundum=reference;
|
284
|
}
|
285
|
|
286
|
public Rank getMaxRank() {
|
287
|
return maxRank;
|
288
|
}
|
289
|
|
290
|
public void setMaxRank(Rank maxRank) {
|
291
|
this.maxRank = maxRank;
|
292
|
}
|
293
|
|
294
|
|
295
|
public boolean hasAskedForHigherRank(){
|
296
|
return askedForHRank;
|
297
|
}
|
298
|
|
299
|
public void setHasAskedForHigherRank(boolean asked){
|
300
|
askedForHRank=asked;
|
301
|
}
|
302
|
|
303
|
/**
|
304
|
* @return
|
305
|
*/
|
306
|
public String getImportClassificationName() {
|
307
|
return defaultImportClassification;
|
308
|
}
|
309
|
|
310
|
public void setImportClassificationName(String className){
|
311
|
defaultImportClassification=className;
|
312
|
}
|
313
|
|
314
|
/**
|
315
|
* @param referenceUrl
|
316
|
*/
|
317
|
public void addOriginalSource(Reference referenceUrl) {
|
318
|
this.sourceURL = referenceUrl;
|
319
|
|
320
|
}
|
321
|
|
322
|
/**
|
323
|
* @return the sourceURL
|
324
|
*/
|
325
|
public Reference getOriginalSourceURL() {
|
326
|
return sourceURL;
|
327
|
}
|
328
|
|
329
|
/**
|
330
|
* @param b
|
331
|
*/
|
332
|
public void setLastImport(boolean b) {
|
333
|
lastImport=b;
|
334
|
}
|
335
|
|
336
|
public boolean getLastImport(){
|
337
|
return lastImport;
|
338
|
}
|
339
|
|
340
|
public boolean isAlwaysUseDefaultClassification() {
|
341
|
return alwaysUseDefaultClassification;
|
342
|
}
|
343
|
|
344
|
public void setAlwaysUseDefaultClassification(
|
345
|
boolean alwaysUseDefaultClassification) {
|
346
|
this.alwaysUseDefaultClassification = alwaysUseDefaultClassification;
|
347
|
}
|
348
|
|
349
|
|
350
|
public boolean isUseOldUnparsedSynonymExtraction() {
|
351
|
return isUseOldUnparsedSynonymExtraction;
|
352
|
}
|
353
|
|
354
|
public void setUseOldUnparsedSynonymExtraction(boolean isUseOldUnparsedSynonymExtraction) {
|
355
|
this.isUseOldUnparsedSynonymExtraction = isUseOldUnparsedSynonymExtraction;
|
356
|
}
|
357
|
|
358
|
|
359
|
|
360
|
}
|