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
.ReferenceBase
;
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
);
40 private static IInputTransformer defaultTransformer
= null;
41 private String classificationTitle
= "E-Flora Import";
42 private String sourceReferenceTitle
= "E-Flora";
43 private UUID defaultLanguageUuid
;
45 //TODO move to state, but a state gets lost after each import.invoke, so I can't move this information
46 //from the one import to another import in case I run 2 imports in line
47 private UUID lastTaxonUuid
;
49 //if true, the keys will be printed after they have been created
50 private boolean doPrintKeys
= false;
54 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#makeIoClassList()
56 protected void makeIoClassList(){
57 ioClassList
= new Class
[]{
58 EfloraTaxonImport
.class
62 protected EfloraImportConfigurator() {
63 super(defaultTransformer
);
70 protected EfloraImportConfigurator(IInputTransformer transformer
) {
79 protected EfloraImportConfigurator(URI uri
, ICdmDataSource destination
) {
80 super(defaultTransformer
);
82 setDestination(destination
);
89 protected EfloraImportConfigurator(URI uri
, ICdmDataSource destination
, IInputTransformer transformer
) {
92 setDestination(destination
);
97 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
99 public EfloraImportState
getNewState() {
100 return new EfloraImportState(this);
106 public Element
getSourceRoot(){
108 URL url
= getSource().toURL();
109 Object o
= url
.getContent();
110 InputStream is
= (InputStream
)o
;
111 Element root
= XmlHelp
.getRoot(is
);
112 // makeNamespaces(root);
114 } catch (MalformedURLException e
) {
116 }catch (Exception e
) {
117 // TODO Auto-generated catch block
125 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
128 public ReferenceBase
getSourceReference() {
130 if (this.sourceReference
== null){
131 logger
.warn("getSource Reference not yet fully implemented");
132 sourceReference
= ReferenceFactory
.newGeneric();
133 sourceReference
.setTitleCache(sourceReferenceTitle
, true);
135 return sourceReference
;
140 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
142 public String
getSourceNameString() {
143 if (this.getSource() == null){
146 return this.getSource().toString();
150 public void setClassificationTitle(String classificationTitle
) {
151 this.classificationTitle
= classificationTitle
;
154 public String
getClassificationTitle() {
155 return classificationTitle
;
160 public UUID
getLastTaxonUuid() {
161 return lastTaxonUuid
;
164 public void setLastTaxonUuid(UUID lastTaxonUuid
) {
165 this.lastTaxonUuid
= lastTaxonUuid
;
168 public void setDoPrintKeys(boolean doPrintKeys
) {
169 this.doPrintKeys
= doPrintKeys
;
172 public boolean isDoPrintKeys() {
176 public UUID
getDefaultLanguageUuid() {
177 return this.defaultLanguageUuid
;
180 public void setDefaultLanguageUuid(UUID defaultLanguageUuid
) {
181 this.defaultLanguageUuid
= defaultLanguageUuid
;