2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.reference
.endnote
.in
;
12 import java
.io
.InputStream
;
13 import java
.lang
.reflect
.Method
;
14 import java
.net
.MalformedURLException
;
18 import org
.apache
.log4j
.Logger
;
19 import org
.jdom
.Element
;
20 import org
.jdom
.Namespace
;
21 import org
.springframework
.stereotype
.Component
;
23 import eu
.etaxonomy
.cdm
.common
.XmlHelp
;
24 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
25 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
26 import eu
.etaxonomy
.cdm
.io
.common
.ImportConfiguratorBase
;
27 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.IInputTransformer
;
28 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
29 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
32 public class EndnoteImportConfigurator
extends ImportConfiguratorBase
<EndnoteImportState
, URI
> implements IImportConfigurator
{
33 private static final Logger logger
= Logger
.getLogger(EndnoteImportConfigurator
.class);
35 public static EndnoteImportConfigurator
NewInstance(URI uri
, ICdmDataSource destination
){
36 return new EndnoteImportConfigurator(uri
, destination
);
39 private boolean doRecords
= true;
40 // private boolean doSpecimen = true;
42 private Method functionRecordsDetailed
= null;
43 private IEndnotePlaceholderClass placeholderClass
;
46 private static IInputTransformer defaultTransformer
= null;
50 Namespace EndnoteNamespace
;
53 protected void makeIoClassList(){
54 ioClassList
= new Class
[]{
55 EndnoteRecordsImport
.class
59 * @param berlinModelSource
60 * @param sourceReference
63 private EndnoteImportConfigurator() {
64 super(defaultTransformer
);
66 // setDestination(destination);
73 private EndnoteImportConfigurator(URI uri
, ICdmDataSource destination
) {
74 super(defaultTransformer
);
76 setDestination(destination
);
82 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
84 public EndnoteImportState
getNewState() {
85 return new EndnoteImportState(this);
91 public Element
getSourceRoot(){
92 URI source
= getSource();
96 Object o
= url
.getContent();
97 InputStream is
= (InputStream
)o
;
98 Element root
= XmlHelp
.getRoot(is
);
101 } catch (MalformedURLException e
) {
103 }catch (Exception e
) {
104 // TODO Auto-generated catch block
110 private boolean makeNamespaces(Element root
){
111 EndnoteNamespace
= root
.getNamespace();
112 if (EndnoteNamespace
== null){
113 logger
.warn("At least one Namespace is NULL");
119 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
122 public Reference
getSourceReference() {
124 if (this.sourceReference
== null){
125 logger
.warn("getSource Reference not yet fully implemented");
126 ReferenceFactory refFactory
= ReferenceFactory
.newInstance();
127 sourceReference
= refFactory
.newDatabase();
128 sourceReference
.setTitleCache("XXX", true);
130 return sourceReference
;
134 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
136 public String
getSourceNameString() {
137 if (this.getSource() == null){
140 return this.getSource().toString();
144 public Namespace
getEndnoteNamespace() {
145 return EndnoteNamespace
;
148 public void setEndnoteNamespace(Namespace EndnoteNamespace
) {
149 this.EndnoteNamespace
= EndnoteNamespace
;
154 * @return the funMetaDataDetailed
156 public Method
getFunctionRecordsDetailed() {
157 if (functionRecordsDetailed
== null){
159 // functionRecordsDetailed = getDefaultFunction(EndnoteRecordsImport.class, "defaultRecordsDetailedFunction");
161 return functionRecordsDetailed
;
166 * @param funMetaDataDetailed the funMetaDataDetailed to set
168 public void setFunctionRecordsDetailed(Method functionRecordsDetailed
) {
169 this.functionRecordsDetailed
= functionRecordsDetailed
;
173 * @return the doMetaData
175 public boolean isDoRecords() {
180 * @param doMetaData the doMetaData to set
182 public void setDoRecords(boolean doRecords
) {
183 this.doRecords
= doRecords
;
187 * @return the doSpecimen
189 // public boolean isDoSpecimen() {
190 // return doSpecimen;
194 * @param doSpecimen the doSpecimen to set
196 // public void setDoSpecimen(boolean doSpecimen) {
197 // this.doSpecimen = doSpecimen;
201 * @return the placeholderClass
203 public IEndnotePlaceholderClass
getPlaceholderClass() {
204 if (placeholderClass
== null){
205 placeholderClass
= new IEndnotePlaceholderClass();
207 return placeholderClass
;
211 * @param placeholderClass the placeholderClass to set
213 public void setPlaceholderClass(IEndnotePlaceholderClass placeholderClass
) {
214 this.placeholderClass
= placeholderClass
;