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
.markup
;
13 import java
.util
.UUID
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.springframework
.stereotype
.Component
;
18 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
19 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
20 import eu
.etaxonomy
.cdm
.io
.common
.XmlImportConfiguratorBase
;
21 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.IInputTransformer
;
22 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
23 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
26 public class MarkupImportConfigurator
extends XmlImportConfiguratorBase
<MarkupImportState
> implements IImportConfigurator
{
27 private static final Logger logger
= Logger
.getLogger(MarkupImportConfigurator
.class);
29 public static MarkupImportConfigurator
NewInstance(URI uri
, ICdmDataSource destination
){
30 return new MarkupImportConfigurator(uri
, destination
);
33 private boolean replaceStandardKeyTitles
= true;
35 private boolean doTaxa
= true;
37 private boolean reuseExistingState
= false;
39 private boolean allowCapitalSpeciesEpithet
= false; //set to true if you want to allow specific epithets with capital letter at the beginning. This was allowed by the code for epithets referring to persons such as Beilschmiedia Zenkeri.
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;
55 private MarkupImportState state
;
58 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#makeIoClassList()
60 protected void makeIoClassList(){
61 ioClassList
= new Class
[]{
62 MarkupDocumentImport
.class
66 protected MarkupImportConfigurator() {
67 super(defaultTransformer
);
74 protected MarkupImportConfigurator(IInputTransformer transformer
) {
83 protected MarkupImportConfigurator(URI uri
, ICdmDataSource destination
) {
84 super(defaultTransformer
);
86 setDestination(destination
);
93 protected MarkupImportConfigurator(URI uri
, ICdmDataSource destination
, IInputTransformer transformer
) {
96 setDestination(destination
);
101 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
103 public MarkupImportState
getNewState() {
104 if (this.isReuseExistingState() == true){
105 if (this.state
== null){
106 this.state
= new MarkupImportState(this);
110 return new MarkupImportState(this);
118 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
121 public Reference
getSourceReference() {
123 if (this.sourceReference
== null){
124 logger
.warn("getSource Reference not yet fully implemented");
125 sourceReference
= ReferenceFactory
.newGeneric();
126 sourceReference
.setTitleCache(sourceReferenceTitle
, true);
128 return sourceReference
;
133 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
135 public String
getSourceNameString() {
136 if (this.getSource() == null){
139 return this.getSource().toString();
144 public UUID
getLastTaxonUuid() {
145 return lastTaxonUuid
;
148 public void setLastTaxonUuid(UUID lastTaxonUuid
) {
149 this.lastTaxonUuid
= lastTaxonUuid
;
152 public void setDoPrintKeys(boolean doPrintKeys
) {
153 this.doPrintKeys
= doPrintKeys
;
156 public boolean isDoPrintKeys() {
160 public UUID
getDefaultLanguageUuid() {
161 return this.defaultLanguageUuid
;
164 public void setDefaultLanguageUuid(UUID defaultLanguageUuid
) {
165 this.defaultLanguageUuid
= defaultLanguageUuid
;
168 public boolean isDoTaxa() {
171 public void setDoTaxa(boolean doTaxa
) {
172 this.doTaxa
= doTaxa
;
175 public void setReplaceStandardKeyTitles(boolean replaceStandardKeyTitles
) {
176 this.replaceStandardKeyTitles
= replaceStandardKeyTitles
;
179 public boolean isReplaceStandardKeyTitles() {
180 return replaceStandardKeyTitles
;
184 * If true, the state is saved in the configurator between 2 imports using this same configurator.
185 * Use with care as you may run into memory issues or also data consistency issues otherwise.
186 * This value must be set before getNewState is called for the <b>first</b> time. The feature is
188 * @return if reuse existing state is set to true.
190 public boolean isReuseExistingState() {
191 return reuseExistingState
;
195 * @see #isReuseExistingState()
196 * @param reuseExistingState
198 public void setReuseExistingState(boolean reuseExistingState
) {
199 this.reuseExistingState
= reuseExistingState
;
203 * If {@link #isReuseExistingState()} is true, this method returns the state.
204 * This is an experimental workaround for Markup import. The functionality
205 * should better be moved to CdmImportBase somewhere.
208 public MarkupImportState
getState() {
212 public boolean isAllowCapitalSpeciesEpithet() {
213 return allowCapitalSpeciesEpithet
;
216 public void setAllowCapitalSpeciesEpithet(boolean allowCapitalSpeciesEpithet
) {
217 this.allowCapitalSpeciesEpithet
= allowCapitalSpeciesEpithet
;