Project

General

Profile

Download (8.96 KB) Statistics
| Branch: | Tag: | Revision:
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 eu.etaxonomy.cdm.common.URI;
13
import java.util.HashMap;
14
import java.util.Map;
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.io.common.ImportConfiguratorBase;
21
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
22
import eu.etaxonomy.cdm.model.agent.Person;
23
import eu.etaxonomy.cdm.model.name.Rank;
24
import eu.etaxonomy.cdm.model.reference.Reference;
25
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
26

    
27

    
28
/**
29
 * @author p.kelber
30
 * @since 2012
31
 */
32
public class TaxonXImportConfigurator
33
    extends ImportConfiguratorBase<TaxonXImportState, URI>{
34

    
35
    private static final long serialVersionUID = -7607808010688414010L;
36
    @SuppressWarnings("unused")
37
    private static final Logger logger = Logger.getLogger(TaxonXImportConfigurator.class);
38

    
39
    private String defaultImportClassification = null;
40
    //if true the information in the mods part (taxonxHeader)
41
    private boolean doMods = true;
42
    private boolean doFacts = true;
43
    private boolean doTypes = true;
44
    private boolean alwaysUseDefaultClassification = false;
45

    
46

    
47
    //TODO
48
    private static IInputTransformer defaultTransformer = null;
49

    
50
    //the original TaxonXImport extracted Synonyms by creating acc Taxa with partial names
51
    //I (AM) do not understand this but don't want to destroy code which maybe works in some cases) there
52
    //I created this switch for old
53
    //for Spiders the new version is preferred
54
    private boolean isUseOldUnparsedSynonymExtraction = true;
55

    
56
    //if false references in this rdf file are not published in the bibliography list
57
    private boolean isPublishReferences = true;
58

    
59
    private String originalSourceTaxonNamespace = "TaxonConcept";
60
    private String originalSourceId;
61

    
62
    private Map<String, Person> titleCachePerson;
63
    private Map<String,UUID> namedAreaDecisions = new HashMap<String,UUID>();
64

    
65

    
66

    
67
    private static Reference sourceRef = null;
68

    
69
    private Reference secundum;
70
    private boolean keepOriginalSecundum;
71
    private Rank maxRank;
72
    private boolean askedForHRank =false;
73
    private Reference sourceURL;
74
    private boolean lastImport=false;
75

    
76

    
77
    @SuppressWarnings("unchecked")
78
    @Override
79
    protected void makeIoClassList(){
80
        ioClassList = new Class[]{
81
                TaxonXImport.class,
82
        };
83
    }
84

    
85
    /**
86
     * @param uri
87
     * @param destination
88
     * @return
89
     */
90
    public static TaxonXImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
91
        return new TaxonXImportConfigurator(uri, destination);
92
    }
93

    
94

    
95
    /**
96
     * @param url
97
     * @param destination
98
     */
99
    private TaxonXImportConfigurator(URI uri, ICdmDataSource destination) {
100
        super(defaultTransformer);
101
        setSource(uri);
102
        setDestination(destination);
103
    }
104

    
105
    /**
106
     * @param url
107
     * @param destination
108
     */
109
    private TaxonXImportConfigurator(ICdmDataSource destination) {
110
        super(defaultTransformer);
111
        setDestination(destination);
112
    }
113

    
114
    @SuppressWarnings("unchecked")
115
    @Override
116
    public TaxonXImportState getNewState() {
117
        return new TaxonXImportState(this);
118
    }
119

    
120
    @Override
121
    public Reference getSourceReference() {
122
        if (sourceReference == null){
123
            sourceReference =  ReferenceFactory.newGeneric();
124

    
125
            if (getSourceRefUuid() != null){
126
                sourceReference.setUuid(getSourceRefUuid());
127
            }
128
            if (sourceRef != null){
129
                sourceReference.setTitleCache(sourceRef.getTitleCache(), true);
130
            }
131
        }
132
        return sourceReference;
133
    }
134

    
135
    @Override
136
    public String getSourceNameString() {
137
        if (this.getSource() == null){
138
            return null;
139
        }else{
140
            return this.getSource().toString();
141
        }
142
    }
143

    
144
    public String getOriginalSourceTaxonNamespace() {
145
        return originalSourceTaxonNamespace;
146
    }
147

    
148
    public void setOriginalSourceTaxonNamespace(String originalSourceTaxonNamespace) {
149
        this.originalSourceTaxonNamespace = originalSourceTaxonNamespace;
150
    }
151

    
152
    public String getOriginalSourceId() {
153
        return originalSourceId;
154
    }
155

    
156
    public void setOriginalSourceId(String originalSourceId) {
157
        this.originalSourceId = originalSourceId;
158
    }
159

    
160

    
161
    /**
162
     * @return the doMods
163
     */
164
    public boolean isDoMods() {
165
        return doMods;
166
    }
167

    
168
    /**
169
     * @param doMods the doMods to set
170
     */
171
    public void setDoMods(boolean doMods) {
172
        this.doMods = doMods;
173
    }
174

    
175

    
176
    public boolean isDoFacts() {
177
        return doFacts;
178
    }
179
    public void setDoFacts(boolean doFacts) {
180
        this.doFacts = doFacts;
181
    }
182

    
183

    
184

    
185
    public boolean isDoTypes() {
186
        return doTypes;
187
    }
188
    public void setDoTypes(boolean doTypes) {
189
        this.doTypes = doTypes;
190
    }
191

    
192

    
193
    /**
194
     * @return the isPublishReferences
195
     */
196
    public boolean isPublishReferences() {
197
        return isPublishReferences;
198
    }
199

    
200
    /**
201
     * @param isPublishReferences the isPublishReferences to set
202
     */
203
    public void setPublishReferences(boolean isPublishReferences) {
204
        this.isPublishReferences = isPublishReferences;
205
    }
206

    
207
    /**
208
     * @param b
209
     */
210
    public void setDoAutomaticParsing(boolean b) {
211

    
212
    }
213

    
214
    /**
215
     * @param destination
216
     * @return
217
     */
218
    public static TaxonXImportConfigurator NewInstance(ICdmDataSource destination) {
219
        return new TaxonXImportConfigurator(destination);
220
    }
221

    
222
    /**
223
     * @param reference
224
     */
225
    public static void setSourceRef(Reference reference) {
226
        sourceRef = reference;
227

    
228
    }
229

    
230
    public Map<String, Person> getPersons() {
231
        return titleCachePerson;
232
    }
233

    
234
    public void setPersons(Map<String, Person> titleCachePerson) {
235
        this.titleCachePerson=titleCachePerson;
236
        //System.out.println(titleCachePerson);
237

    
238
    }
239
    public Map<String,UUID> getNamedAreaDecisions() {
240
        return namedAreaDecisions;
241
    }
242
    public void setNamedAreaDecisions(Map<String,UUID> namedAreaDecisions) {
243
        this.namedAreaDecisions = namedAreaDecisions;
244
    }
245
    public void putNamedAreaDecision(String areaStr,UUID uuid){
246
        this.namedAreaDecisions.put(areaStr,uuid);
247
    }
248
    public UUID getNamedAreaDecision(String areaStr){
249
        return namedAreaDecisions.get(areaStr);
250
    }
251

    
252
    /**
253
     * @return
254
     */
255
    public boolean doKeepOriginalSecundum() {
256
        return keepOriginalSecundum;
257
    }
258

    
259
    public void setKeepOriginalSecundum(boolean reuseSecundum) {
260
        this.keepOriginalSecundum = reuseSecundum;
261
    }
262

    
263
    /**
264
     * @return
265
     */
266
    public Reference getSecundum() {
267
        if(secundum == null){
268
            secundum = ReferenceFactory.newGeneric();
269
            secundum.setTitle("default secundum");
270
        }
271

    
272
        return secundum;
273
    }
274

    
275

    
276
    public void setSecundum(Reference reference){
277
        this.secundum=reference;
278
    }
279

    
280
    public Rank getMaxRank() {
281
        return maxRank;
282
    }
283

    
284
    public void setMaxRank(Rank maxRank) {
285
        this.maxRank = maxRank;
286
    }
287

    
288

    
289
    public boolean hasAskedForHigherRank(){
290
        return askedForHRank;
291
    }
292

    
293
    public void setHasAskedForHigherRank(boolean asked){
294
        askedForHRank=asked;
295
    }
296

    
297
    /**
298
     * @return
299
     */
300
    public String getImportClassificationName() {
301
       return defaultImportClassification;
302
    }
303

    
304
    public void setImportClassificationName(String className){
305
        defaultImportClassification=className;
306
    }
307

    
308
    /**
309
     * @param referenceUrl
310
     */
311
    public void addOriginalSource(Reference referenceUrl) {
312
       this.sourceURL = referenceUrl;
313

    
314
    }
315

    
316
    /**
317
     * @return the sourceURL
318
     */
319
    public Reference getOriginalSourceURL() {
320
        return sourceURL;
321
    }
322

    
323
    /**
324
     * @param b
325
     */
326
    public void setLastImport(boolean b) {
327
        lastImport=b;
328
    }
329

    
330
    public boolean getLastImport(){
331
        return  lastImport;
332
    }
333

    
334
	public boolean isAlwaysUseDefaultClassification() {
335
		return alwaysUseDefaultClassification;
336
	}
337

    
338
	public void setAlwaysUseDefaultClassification(
339
			boolean alwaysUseDefaultClassification) {
340
		this.alwaysUseDefaultClassification = alwaysUseDefaultClassification;
341
	}
342

    
343

    
344
	public boolean isUseOldUnparsedSynonymExtraction() {
345
		return isUseOldUnparsedSynonymExtraction;
346
	}
347

    
348
	public void setUseOldUnparsedSynonymExtraction(boolean isUseOldUnparsedSynonymExtraction) {
349
		this.isUseOldUnparsedSynonymExtraction = isUseOldUnparsedSynonymExtraction;
350
	}
351

    
352

    
353

    
354
}
(5-5/9)