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.reference.endnote.in;
|
11
|
|
12
|
import java.io.InputStream;
|
13
|
import java.lang.reflect.Method;
|
14
|
import java.net.MalformedURLException;
|
15
|
import java.net.URL;
|
16
|
|
17
|
import org.apache.log4j.Logger;
|
18
|
import org.jdom.Element;
|
19
|
import org.jdom.Namespace;
|
20
|
import org.springframework.stereotype.Component;
|
21
|
|
22
|
import eu.etaxonomy.cdm.common.XmlHelp;
|
23
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
24
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
25
|
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
|
26
|
import eu.etaxonomy.cdm.io.common.ImportStateBase;
|
27
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
28
|
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
|
29
|
import eu.etaxonomy.cdm.io.jaxb.JaxbExport;
|
30
|
import eu.etaxonomy.cdm.model.reference.IDatabase;
|
31
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
32
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
33
|
|
34
|
@Component
|
35
|
public class EndnoteImportConfigurator extends ImportConfiguratorBase<EndnoteImportState> implements IImportConfigurator {
|
36
|
private static final Logger logger = Logger.getLogger(EndnoteImportConfigurator.class);
|
37
|
|
38
|
public static EndnoteImportConfigurator NewInstance(String url,
|
39
|
ICdmDataSource destination){
|
40
|
return new EndnoteImportConfigurator(url, destination);
|
41
|
}
|
42
|
|
43
|
private boolean doRecords = true;
|
44
|
// private boolean doSpecimen = true;
|
45
|
|
46
|
private Method functionRecordsDetailed = null;
|
47
|
private IEndnotePlaceholderClass placeholderClass;
|
48
|
|
49
|
//TODO
|
50
|
private static IInputTransformer defaultTransformer = null;
|
51
|
|
52
|
|
53
|
// rdfNamespace
|
54
|
Namespace EndnoteNamespace;
|
55
|
/*TODO: wieder zur?ck!!!
|
56
|
protected void makeIoClassList(){
|
57
|
ioClassList = new Class[]{
|
58
|
EndnoteRecordsImport.class
|
59
|
};
|
60
|
};
|
61
|
*/
|
62
|
/**
|
63
|
* @param berlinModelSource
|
64
|
* @param sourceReference
|
65
|
* @param destination
|
66
|
*/
|
67
|
private EndnoteImportConfigurator() {
|
68
|
super(defaultTransformer);
|
69
|
// setSource(url);
|
70
|
// setDestination(destination);
|
71
|
}
|
72
|
|
73
|
/**
|
74
|
* @param url
|
75
|
* @param destination
|
76
|
*/
|
77
|
private EndnoteImportConfigurator(String url, ICdmDataSource destination) {
|
78
|
super(defaultTransformer);
|
79
|
setSource(url);
|
80
|
setDestination(destination);
|
81
|
}
|
82
|
|
83
|
|
84
|
|
85
|
/* (non-Javadoc)
|
86
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
|
87
|
*/
|
88
|
public EndnoteImportState getNewState() {
|
89
|
return new EndnoteImportState(this);
|
90
|
}
|
91
|
|
92
|
/* (non-Javadoc)
|
93
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource()
|
94
|
*/
|
95
|
public String getSource() {
|
96
|
return (String)super.getSource();
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* @param file
|
101
|
*/
|
102
|
public void setSource(String file) {
|
103
|
super.setSource(file);
|
104
|
}
|
105
|
|
106
|
/**
|
107
|
* @return
|
108
|
*/
|
109
|
public Element getSourceRoot(){
|
110
|
String source = getSource();
|
111
|
try {
|
112
|
URL url;
|
113
|
url = new URL(source);
|
114
|
Object o = url.getContent();
|
115
|
InputStream is = (InputStream)o;
|
116
|
Element root = XmlHelp.getRoot(is);
|
117
|
makeNamespaces(root);
|
118
|
return root;
|
119
|
} catch (MalformedURLException e) {
|
120
|
e.printStackTrace();
|
121
|
}catch (Exception e) {
|
122
|
// TODO Auto-generated catch block
|
123
|
e.printStackTrace();
|
124
|
}
|
125
|
return null;
|
126
|
}
|
127
|
|
128
|
private boolean makeNamespaces(Element root){
|
129
|
EndnoteNamespace = root.getNamespace();
|
130
|
if (EndnoteNamespace == null){
|
131
|
logger.warn("At least one Namespace is NULL");
|
132
|
}
|
133
|
return true;
|
134
|
}
|
135
|
|
136
|
/* (non-Javadoc)
|
137
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
|
138
|
*/
|
139
|
@Override
|
140
|
public ReferenceBase getSourceReference() {
|
141
|
//TODO
|
142
|
if (this.sourceReference == null){
|
143
|
logger.warn("getSource Reference not yet fully implemented");
|
144
|
ReferenceFactory refFactory = ReferenceFactory.newInstance();
|
145
|
sourceReference = refFactory.newDatabase();
|
146
|
sourceReference.setTitleCache("XXX", true);
|
147
|
}
|
148
|
return sourceReference;
|
149
|
}
|
150
|
|
151
|
/* (non-Javadoc)
|
152
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
|
153
|
*/
|
154
|
public String getSourceNameString() {
|
155
|
if (this.getSource() == null){
|
156
|
return null;
|
157
|
}else{
|
158
|
return this.getSource();
|
159
|
}
|
160
|
}
|
161
|
|
162
|
public Namespace getEndnoteNamespace() {
|
163
|
return EndnoteNamespace;
|
164
|
}
|
165
|
|
166
|
public void setEndnoteNamespace(Namespace EndnoteNamespace) {
|
167
|
this.EndnoteNamespace = EndnoteNamespace;
|
168
|
}
|
169
|
|
170
|
|
171
|
/**
|
172
|
* @return the funMetaDataDetailed
|
173
|
*/
|
174
|
public Method getFunctionRecordsDetailed() {
|
175
|
if (functionRecordsDetailed == null){
|
176
|
//TODO!!!
|
177
|
// functionRecordsDetailed = getDefaultFunction(EndnoteRecordsImport.class, "defaultRecordsDetailedFunction");
|
178
|
}
|
179
|
return functionRecordsDetailed;
|
180
|
|
181
|
}
|
182
|
|
183
|
/**
|
184
|
* @param funMetaDataDetailed the funMetaDataDetailed to set
|
185
|
*/
|
186
|
public void setFunctionRecordsDetailed(Method functionRecordsDetailed) {
|
187
|
this.functionRecordsDetailed = functionRecordsDetailed;
|
188
|
}
|
189
|
|
190
|
/**
|
191
|
* @return the doMetaData
|
192
|
*/
|
193
|
public boolean isDoRecords() {
|
194
|
return doRecords;
|
195
|
}
|
196
|
|
197
|
/**
|
198
|
* @param doMetaData the doMetaData to set
|
199
|
*/
|
200
|
public void setDoRecords(boolean doRecords) {
|
201
|
this.doRecords = doRecords;
|
202
|
}
|
203
|
|
204
|
/**
|
205
|
* @return the doSpecimen
|
206
|
*/
|
207
|
// public boolean isDoSpecimen() {
|
208
|
// return doSpecimen;
|
209
|
// }
|
210
|
|
211
|
/**
|
212
|
* @param doSpecimen the doSpecimen to set
|
213
|
*/
|
214
|
// public void setDoSpecimen(boolean doSpecimen) {
|
215
|
// this.doSpecimen = doSpecimen;
|
216
|
// }
|
217
|
|
218
|
/**
|
219
|
* @return the placeholderClass
|
220
|
*/
|
221
|
public IEndnotePlaceholderClass getPlaceholderClass() {
|
222
|
if (placeholderClass == null){
|
223
|
placeholderClass = new IEndnotePlaceholderClass();
|
224
|
}
|
225
|
return placeholderClass;
|
226
|
}
|
227
|
|
228
|
/**
|
229
|
* @param placeholderClass the placeholderClass to set
|
230
|
*/
|
231
|
public void setPlaceholderClass(IEndnotePlaceholderClass placeholderClass) {
|
232
|
this.placeholderClass = placeholderClass;
|
233
|
}
|
234
|
|
235
|
@Override
|
236
|
protected void makeIoClassList() {
|
237
|
// TODO Auto-generated method stub
|
238
|
|
239
|
}
|
240
|
|
241
|
|
242
|
}
|