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.
9 package eu
.etaxonomy
.cdm
.io
.eflora
;
11 import java
.io
.InputStream
;
12 import java
.net
.MalformedURLException
;
14 import java
.util
.UUID
;
16 import org
.apache
.logging
.log4j
.LogManager
;
17 import org
.apache
.logging
.log4j
.Logger
;
18 import org
.jdom
.Element
;
19 import org
.springframework
.stereotype
.Component
;
21 import eu
.etaxonomy
.cdm
.common
.URI
;
22 import eu
.etaxonomy
.cdm
.common
.XmlHelp
;
23 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
24 import eu
.etaxonomy
.cdm
.io
.common
.ImportConfiguratorBase
;
25 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.IInputTransformer
;
26 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
27 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
30 public class EfloraImportConfigurator
extends ImportConfiguratorBase
<EfloraImportState
, URI
> {
32 private static final long serialVersionUID
= -2922682361995025203L;
33 private static Logger logger
= LogManager
.getLogger();
35 public static EfloraImportConfigurator
NewInstance(URI uri
, ICdmDataSource destination
){
36 return new EfloraImportConfigurator(uri
, destination
);
39 private boolean doTaxa
= true;
42 private static IInputTransformer defaultTransformer
= null;
43 private String classificationTitle
= "E-Flora Import";
44 private String sourceReferenceTitle
= "E-Flora";
45 private UUID defaultLanguageUuid
;
47 //TODO move to state, but a state gets lost after each import.invoke, so I can't move this information
48 //from the one import to another import in case I run 2 imports in line
49 private UUID lastTaxonUuid
;
51 //if true, the keys will be printed after they have been created
52 private boolean doPrintKeys
= false;
54 @SuppressWarnings("unchecked")
56 protected void makeIoClassList(){
57 ioClassList
= new Class
[]{
58 EfloraTaxonImport
.class
62 protected EfloraImportConfigurator() {
63 super(defaultTransformer
);
66 protected EfloraImportConfigurator(IInputTransformer transformer
) {
70 protected EfloraImportConfigurator(URI uri
, ICdmDataSource destination
) {
71 super(defaultTransformer
);
73 setDestination(destination
);
76 protected EfloraImportConfigurator(URI uri
, ICdmDataSource destination
, IInputTransformer transformer
) {
79 setDestination(destination
);
83 public EfloraImportState
getNewState() {
84 return new EfloraImportState(this);
87 public Element
getSourceRoot(){
89 URL url
= getSource().toURL();
90 Object o
= url
.getContent();
91 InputStream is
= (InputStream
)o
;
92 Element root
= XmlHelp
.getRoot(is
);
93 // makeNamespaces(root);
95 } catch (MalformedURLException e
) {
97 }catch (Exception e
) {
98 // TODO Auto-generated catch block
105 public Reference
getSourceReference() {
107 if (this.sourceReference
== null){
108 logger
.warn("getSource Reference not yet fully implemented");
109 sourceReference
= ReferenceFactory
.newGeneric();
110 sourceReference
.setTitleCache(sourceReferenceTitle
, true);
112 return sourceReference
;
116 public String
getSourceNameString() {
117 if (this.getSource() == null){
120 return this.getSource().toString();
124 public void setClassificationTitle(String classificationTitle
) {
125 this.classificationTitle
= classificationTitle
;
127 public String
getClassificationTitle() {
128 return classificationTitle
;
131 public UUID
getLastTaxonUuid() {
132 return lastTaxonUuid
;
134 public void setLastTaxonUuid(UUID lastTaxonUuid
) {
135 this.lastTaxonUuid
= lastTaxonUuid
;
138 public void setDoPrintKeys(boolean doPrintKeys
) {
139 this.doPrintKeys
= doPrintKeys
;
141 public boolean isDoPrintKeys() {
145 public UUID
getDefaultLanguageUuid() {
146 return this.defaultLanguageUuid
;
148 public void setDefaultLanguageUuid(UUID defaultLanguageUuid
) {
149 this.defaultLanguageUuid
= defaultLanguageUuid
;
152 public boolean isDoTaxa() {
155 public void setDoTaxa(boolean doTaxa
) {
156 this.doTaxa
= doTaxa
;