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