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
.eflora
;
12 import java
.io
.InputStream
;
13 import java
.net
.MalformedURLException
;
16 import java
.util
.UUID
;
18 import org
.apache
.log4j
.Logger
;
19 import org
.jdom
.Element
;
20 import org
.springframework
.stereotype
.Component
;
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
.mapping
.IInputTransformer
;
27 import eu
.etaxonomy
.cdm
.io
.eflora
.EfloraImportState
;
28 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
29 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
32 public class EfloraImportConfigurator
extends ImportConfiguratorBase
<EfloraImportState
, URI
> implements IImportConfigurator
{
33 private static final Logger logger
= Logger
.getLogger(EfloraImportConfigurator
.class);
35 public static EfloraImportConfigurator
NewInstance(URI uri
, ICdmDataSource destination
){
36 return new EfloraImportConfigurator(uri
, destination
);
39 private boolean doTaxa
= true;
43 private static IInputTransformer defaultTransformer
= null;
44 private String classificationTitle
= "E-Flora Import";
45 private String sourceReferenceTitle
= "E-Flora";
46 private UUID defaultLanguageUuid
;
48 //TODO move to state, but a state gets lost after each import.invoke, so I can't move this information
49 //from the one import to another import in case I run 2 imports in line
50 private UUID lastTaxonUuid
;
52 //if true, the keys will be printed after they have been created
53 private boolean doPrintKeys
= false;
57 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#makeIoClassList()
59 protected void makeIoClassList(){
60 ioClassList
= new Class
[]{
61 EfloraTaxonImport
.class
65 protected EfloraImportConfigurator() {
66 super(defaultTransformer
);
73 protected EfloraImportConfigurator(IInputTransformer transformer
) {
82 protected EfloraImportConfigurator(URI uri
, ICdmDataSource destination
) {
83 super(defaultTransformer
);
85 setDestination(destination
);
92 protected EfloraImportConfigurator(URI uri
, ICdmDataSource destination
, IInputTransformer transformer
) {
95 setDestination(destination
);
100 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
102 public EfloraImportState
getNewState() {
103 return new EfloraImportState(this);
109 public Element
getSourceRoot(){
111 URL url
= getSource().toURL();
112 Object o
= url
.getContent();
113 InputStream is
= (InputStream
)o
;
114 Element root
= XmlHelp
.getRoot(is
);
115 // makeNamespaces(root);
117 } catch (MalformedURLException e
) {
119 }catch (Exception e
) {
120 // TODO Auto-generated catch block
128 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
131 public Reference
getSourceReference() {
133 if (this.sourceReference
== null){
134 logger
.warn("getSource Reference not yet fully implemented");
135 sourceReference
= ReferenceFactory
.newGeneric();
136 sourceReference
.setTitleCache(sourceReferenceTitle
, true);
138 return sourceReference
;
143 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
145 public String
getSourceNameString() {
146 if (this.getSource() == null){
149 return this.getSource().toString();
153 public void setClassificationTitle(String classificationTitle
) {
154 this.classificationTitle
= classificationTitle
;
157 public String
getClassificationTitle() {
158 return classificationTitle
;
163 public UUID
getLastTaxonUuid() {
164 return lastTaxonUuid
;
167 public void setLastTaxonUuid(UUID lastTaxonUuid
) {
168 this.lastTaxonUuid
= lastTaxonUuid
;
171 public void setDoPrintKeys(boolean doPrintKeys
) {
172 this.doPrintKeys
= doPrintKeys
;
175 public boolean isDoPrintKeys() {
179 public UUID
getDefaultLanguageUuid() {
180 return this.defaultLanguageUuid
;
183 public void setDefaultLanguageUuid(UUID defaultLanguageUuid
) {
184 this.defaultLanguageUuid
= defaultLanguageUuid
;
187 public boolean isDoTaxa() {
190 public void setDoTaxa(boolean doTaxa
) {
191 this.doTaxa
= doTaxa
;