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.taxonx;
|
11
|
|
12
|
import java.io.InputStream;
|
13
|
import java.net.URI;
|
14
|
import java.net.URL;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
import org.jdom.Element;
|
18
|
|
19
|
import eu.etaxonomy.cdm.common.XmlHelp;
|
20
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
21
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
22
|
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
|
23
|
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
|
24
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
25
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
26
|
|
27
|
|
28
|
/**
|
29
|
* @author a.mueller
|
30
|
* @created 29.07.2008
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class TaxonXImportConfigurator extends ImportConfiguratorBase<TaxonXImportState, URI> implements IImportConfigurator {
|
34
|
private static final Logger logger = Logger.getLogger(TaxonXImportConfigurator.class);
|
35
|
|
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
|
|
41
|
|
42
|
//TODO
|
43
|
private static IInputTransformer defaultTransformer = null;
|
44
|
|
45
|
|
46
|
//if false references in this rdf file are not published in the bibliography list
|
47
|
private boolean isPublishReferences = true;
|
48
|
|
49
|
|
50
|
private String originalSourceTaxonNamespace = "TaxonConcept";
|
51
|
private String originalSourceId;
|
52
|
|
53
|
@Override
|
54
|
protected void makeIoClassList(){
|
55
|
ioClassList = new Class[]{
|
56
|
TaxonXModsImport.class,
|
57
|
TaxonXDescriptionImport.class
|
58
|
, TaxonXNomenclatureImport.class
|
59
|
// , new TaxonXDescriptionImport(config.isDoFacts())
|
60
|
|
61
|
};
|
62
|
}
|
63
|
|
64
|
/**
|
65
|
* @param uri
|
66
|
* @param destination
|
67
|
* @return
|
68
|
*/
|
69
|
public static TaxonXImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
|
70
|
return new TaxonXImportConfigurator(uri, destination);
|
71
|
}
|
72
|
|
73
|
|
74
|
/**
|
75
|
* @param url
|
76
|
* @param destination
|
77
|
*/
|
78
|
private TaxonXImportConfigurator(URI uri, ICdmDataSource destination) {
|
79
|
super(defaultTransformer);
|
80
|
setSource(uri);
|
81
|
setDestination(destination);
|
82
|
}
|
83
|
|
84
|
|
85
|
|
86
|
/* (non-Javadoc)
|
87
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
|
88
|
*/
|
89
|
@Override
|
90
|
public TaxonXImportState getNewState() {
|
91
|
return new TaxonXImportState(this);
|
92
|
}
|
93
|
|
94
|
public Element getSourceRoot(){
|
95
|
URI source = getSource();
|
96
|
try {
|
97
|
URL url;
|
98
|
url = source.toURL();
|
99
|
Object o = url.getContent();
|
100
|
InputStream is = (InputStream)o;
|
101
|
Element root = XmlHelp.getRoot(is);
|
102
|
return root;
|
103
|
} catch (Exception e) {
|
104
|
logger.error("The source '" + source + "' has errors.", e);
|
105
|
}
|
106
|
return null;
|
107
|
}
|
108
|
|
109
|
|
110
|
/* (non-Javadoc)
|
111
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
|
112
|
*/
|
113
|
@Override
|
114
|
public Reference getSourceReference() {
|
115
|
//TODO
|
116
|
logger.warn("getSource Reference not yet implemented");
|
117
|
Reference result = ReferenceFactory.newDatabase();
|
118
|
result.setTitleCache("XXX", true);
|
119
|
return result;
|
120
|
}
|
121
|
|
122
|
|
123
|
/* (non-Javadoc)
|
124
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
|
125
|
*/
|
126
|
@Override
|
127
|
public String getSourceNameString() {
|
128
|
if (this.getSource() == null){
|
129
|
return null;
|
130
|
}else{
|
131
|
return this.getSource().toString();
|
132
|
}
|
133
|
}
|
134
|
|
135
|
public String getOriginalSourceTaxonNamespace() {
|
136
|
return originalSourceTaxonNamespace;
|
137
|
}
|
138
|
|
139
|
public void setOriginalSourceTaxonNamespace(String originalSourceTaxonNamespace) {
|
140
|
this.originalSourceTaxonNamespace = originalSourceTaxonNamespace;
|
141
|
}
|
142
|
|
143
|
public String getOriginalSourceId() {
|
144
|
return originalSourceId;
|
145
|
}
|
146
|
|
147
|
public void setOriginalSourceId(String originalSourceId) {
|
148
|
this.originalSourceId = originalSourceId;
|
149
|
}
|
150
|
|
151
|
|
152
|
/**
|
153
|
* @return the doMods
|
154
|
*/
|
155
|
public boolean isDoMods() {
|
156
|
return doMods;
|
157
|
}
|
158
|
|
159
|
/**
|
160
|
* @param doMods the doMods to set
|
161
|
*/
|
162
|
public void setDoMods(boolean doMods) {
|
163
|
this.doMods = doMods;
|
164
|
}
|
165
|
|
166
|
|
167
|
public boolean isDoFacts() {
|
168
|
return doFacts;
|
169
|
}
|
170
|
public void setDoFacts(boolean doFacts) {
|
171
|
this.doFacts = doFacts;
|
172
|
}
|
173
|
|
174
|
|
175
|
|
176
|
public boolean isDoTypes() {
|
177
|
return doTypes;
|
178
|
}
|
179
|
public void setDoTypes(boolean doTypes) {
|
180
|
this.doTypes = doTypes;
|
181
|
}
|
182
|
|
183
|
|
184
|
/**
|
185
|
* @return the isPublishReferences
|
186
|
*/
|
187
|
public boolean isPublishReferences() {
|
188
|
return isPublishReferences;
|
189
|
}
|
190
|
|
191
|
/**
|
192
|
* @param isPublishReferences the isPublishReferences to set
|
193
|
*/
|
194
|
public void setPublishReferences(boolean isPublishReferences) {
|
195
|
this.isPublishReferences = isPublishReferences;
|
196
|
}
|
197
|
|
198
|
|
199
|
|
200
|
}
|