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.
41 private boolean handlePagesAsDetailWhereNeeded
= true; //often details in publications and citations are tagged as pages, not as details. If value is true, pages are handled as details where possible
43 private boolean useEditorAsInAuthorWhereNeeded
= true; //often the inAuthor is stored as "Editor" in citations, atleast in FM.
46 private static IInputTransformer defaultTransformer
= null;
47 private String classificationTitle
= "E-Flora Import";
48 private String sourceReferenceTitle
= "E-Flora";
49 private UUID defaultLanguageUuid
;
51 //TODO move to state, but a state gets lost after each import.invoke, so I can't move this information
52 //from the one import to another import in case I run 2 imports in line
53 private UUID lastTaxonUuid
;
55 //if true, the keys will be printed after they have been created
56 private boolean doPrintKeys
= false;
58 private MarkupImportState state
;
61 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#makeIoClassList()
63 protected void makeIoClassList(){
64 ioClassList
= new Class
[]{
65 MarkupDocumentImport
.class
69 protected MarkupImportConfigurator() {
70 super(defaultTransformer
);
77 protected MarkupImportConfigurator(IInputTransformer transformer
) {
86 protected MarkupImportConfigurator(URI uri
, ICdmDataSource destination
) {
87 super(defaultTransformer
);
89 setDestination(destination
);
96 protected MarkupImportConfigurator(URI uri
, ICdmDataSource destination
, IInputTransformer transformer
) {
99 setDestination(destination
);
104 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
106 public MarkupImportState
getNewState() {
107 if (this.isReuseExistingState() == true){
108 if (this.state
== null){
109 this.state
= new MarkupImportState(this);
115 return new MarkupImportState(this);
123 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
126 public Reference
getSourceReference() {
128 if (this.sourceReference
== null){
129 logger
.warn("getSource Reference not yet fully implemented");
130 sourceReference
= ReferenceFactory
.newGeneric();
131 sourceReference
.setTitleCache(sourceReferenceTitle
, true);
133 return sourceReference
;
138 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
140 public String
getSourceNameString() {
141 if (this.getSource() == null){
144 return this.getSource().toString();
149 public UUID
getLastTaxonUuid() {
150 return lastTaxonUuid
;
153 public void setLastTaxonUuid(UUID lastTaxonUuid
) {
154 this.lastTaxonUuid
= lastTaxonUuid
;
157 public void setDoPrintKeys(boolean doPrintKeys
) {
158 this.doPrintKeys
= doPrintKeys
;
161 public boolean isDoPrintKeys() {
165 public UUID
getDefaultLanguageUuid() {
166 return this.defaultLanguageUuid
;
169 public void setDefaultLanguageUuid(UUID defaultLanguageUuid
) {
170 this.defaultLanguageUuid
= defaultLanguageUuid
;
173 public boolean isDoTaxa() {
176 public void setDoTaxa(boolean doTaxa
) {
177 this.doTaxa
= doTaxa
;
180 public void setReplaceStandardKeyTitles(boolean replaceStandardKeyTitles
) {
181 this.replaceStandardKeyTitles
= replaceStandardKeyTitles
;
184 public boolean isReplaceStandardKeyTitles() {
185 return replaceStandardKeyTitles
;
189 * If true, the state is saved in the configurator between 2 imports using this same configurator.
190 * Use with care as you may run into memory issues or also data consistency issues otherwise.
191 * This value must be set before getNewState is called for the <b>first</b> time. The feature is
193 * @return if reuse existing state is set to true.
195 public boolean isReuseExistingState() {
196 return reuseExistingState
;
200 * @see #isReuseExistingState()
201 * @param reuseExistingState
203 public void setReuseExistingState(boolean reuseExistingState
) {
204 this.reuseExistingState
= reuseExistingState
;
208 * If {@link #isReuseExistingState()} is true, this method returns the state.
209 * This is an experimental workaround for Markup import. The functionality
210 * should better be moved to CdmImportBase somewhere.
213 public MarkupImportState
getState() {
217 public boolean isAllowCapitalSpeciesEpithet() {
218 return allowCapitalSpeciesEpithet
;
221 public void setAllowCapitalSpeciesEpithet(boolean allowCapitalSpeciesEpithet
) {
222 this.allowCapitalSpeciesEpithet
= allowCapitalSpeciesEpithet
;
225 public boolean isHandlePagesAsDetailWhereNeeded() {
226 return this.handlePagesAsDetailWhereNeeded
;
229 public void setHandlePagesAsDetailWhereNeeded(boolean handlePagesAsDetailWhereNeeded
) {
230 this.handlePagesAsDetailWhereNeeded
= handlePagesAsDetailWhereNeeded
;
233 public boolean isUseEditorAsInAuthorWhereNeeded() {
234 return useEditorAsInAuthorWhereNeeded
;
237 public void setUseEditorAsInAuthorWhereNeeded(boolean useEditorAsInAuthorWhereNeeded
) {
238 this.useEditorAsInAuthorWhereNeeded
= useEditorAsInAuthorWhereNeeded
;