Revision f9a87300
Added by Andreas Müller almost 14 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/reference/endnote/in/EndnoteImportConfigurator.java | ||
---|---|---|
12 | 12 |
import java.io.InputStream; |
13 | 13 |
import java.lang.reflect.Method; |
14 | 14 |
import java.net.MalformedURLException; |
15 |
import java.net.URI; |
|
15 | 16 |
import java.net.URL; |
16 | 17 |
|
17 | 18 |
import org.apache.log4j.Logger; |
... | ... | |
23 | 24 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
24 | 25 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator; |
25 | 26 |
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 | 27 |
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 | 28 |
import eu.etaxonomy.cdm.model.reference.ReferenceBase; |
32 | 29 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
33 | 30 |
|
34 | 31 |
@Component |
35 |
public class EndnoteImportConfigurator extends ImportConfiguratorBase<EndnoteImportState> implements IImportConfigurator { |
|
32 |
public class EndnoteImportConfigurator extends ImportConfiguratorBase<EndnoteImportState, URI> implements IImportConfigurator {
|
|
36 | 33 |
private static final Logger logger = Logger.getLogger(EndnoteImportConfigurator.class); |
37 | 34 |
|
38 |
public static EndnoteImportConfigurator NewInstance(String url, |
|
39 |
ICdmDataSource destination){ |
|
40 |
return new EndnoteImportConfigurator(url, destination); |
|
35 |
public static EndnoteImportConfigurator NewInstance(URI uri, ICdmDataSource destination){ |
|
36 |
return new EndnoteImportConfigurator(uri, destination); |
|
41 | 37 |
} |
42 | 38 |
|
43 | 39 |
private boolean doRecords = true; |
... | ... | |
74 | 70 |
* @param url |
75 | 71 |
* @param destination |
76 | 72 |
*/ |
77 |
private EndnoteImportConfigurator(String url, ICdmDataSource destination) {
|
|
73 |
private EndnoteImportConfigurator(URI uri, ICdmDataSource destination) {
|
|
78 | 74 |
super(defaultTransformer); |
79 |
setSource(url);
|
|
75 |
setSource(uri);
|
|
80 | 76 |
setDestination(destination); |
81 | 77 |
} |
82 | 78 |
|
... | ... | |
89 | 85 |
return new EndnoteImportState(this); |
90 | 86 |
} |
91 | 87 |
|
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 | 88 |
/** |
107 | 89 |
* @return |
108 | 90 |
*/ |
109 | 91 |
public Element getSourceRoot(){ |
110 |
String source = getSource();
|
|
92 |
URI source = getSource();
|
|
111 | 93 |
try { |
112 | 94 |
URL url; |
113 |
url = new URL(source);
|
|
95 |
url = source.toURL();
|
|
114 | 96 |
Object o = url.getContent(); |
115 | 97 |
InputStream is = (InputStream)o; |
116 | 98 |
Element root = XmlHelp.getRoot(is); |
... | ... | |
155 | 137 |
if (this.getSource() == null){ |
156 | 138 |
return null; |
157 | 139 |
}else{ |
158 |
return this.getSource(); |
|
140 |
return this.getSource().toString();
|
|
159 | 141 |
} |
160 | 142 |
} |
161 | 143 |
|
Also available in: Unified diff
added source type generic to import configurator base class