1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.io.markup;
|
11
|
|
12
|
import java.net.URI;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.springframework.stereotype.Component;
|
17
|
|
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;
|
24
|
|
25
|
@Component
|
26
|
public class MarkupImportConfigurator extends XmlImportConfiguratorBase<MarkupImportState> implements IImportConfigurator {
|
27
|
private static final Logger logger = Logger.getLogger(MarkupImportConfigurator.class);
|
28
|
|
29
|
public static MarkupImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
|
30
|
return new MarkupImportConfigurator(uri, destination);
|
31
|
}
|
32
|
|
33
|
private boolean replaceStandardKeyTitles = true;
|
34
|
|
35
|
private boolean doTaxa = true;
|
36
|
|
37
|
private boolean reuseExistingState = false;
|
38
|
|
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.
|
40
|
|
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
|
42
|
|
43
|
private boolean useEditorAsInAuthorWhereNeeded = true; //often the inAuthor is stored as "Editor" in citations, atleast in FM.
|
44
|
|
45
|
//TODO
|
46
|
private static IInputTransformer defaultTransformer = null;
|
47
|
private String classificationTitle = "E-Flora Import";
|
48
|
private String sourceReferenceTitle = "E-Flora";
|
49
|
private UUID defaultLanguageUuid;
|
50
|
|
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;
|
54
|
|
55
|
//if true, the keys will be printed after they have been created
|
56
|
private boolean doPrintKeys = false;
|
57
|
|
58
|
private MarkupImportState state;
|
59
|
|
60
|
/* (non-Javadoc)
|
61
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#makeIoClassList()
|
62
|
*/
|
63
|
protected void makeIoClassList(){
|
64
|
ioClassList = new Class[]{
|
65
|
MarkupDocumentImport.class
|
66
|
};
|
67
|
};
|
68
|
|
69
|
protected MarkupImportConfigurator() {
|
70
|
super(defaultTransformer);
|
71
|
}
|
72
|
|
73
|
|
74
|
/**
|
75
|
*
|
76
|
*/
|
77
|
protected MarkupImportConfigurator(IInputTransformer transformer) {
|
78
|
super(transformer);
|
79
|
}
|
80
|
|
81
|
|
82
|
/**
|
83
|
* @param url
|
84
|
* @param destination
|
85
|
*/
|
86
|
protected MarkupImportConfigurator(URI uri, ICdmDataSource destination) {
|
87
|
super(defaultTransformer);
|
88
|
setSource(uri);
|
89
|
setDestination(destination);
|
90
|
}
|
91
|
|
92
|
/**
|
93
|
* @param url
|
94
|
* @param destination
|
95
|
*/
|
96
|
protected MarkupImportConfigurator(URI uri, ICdmDataSource destination, IInputTransformer transformer) {
|
97
|
super(transformer);
|
98
|
setSource(uri);
|
99
|
setDestination(destination);
|
100
|
}
|
101
|
|
102
|
|
103
|
/* (non-Javadoc)
|
104
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
|
105
|
*/
|
106
|
public MarkupImportState getNewState() {
|
107
|
if (this.isReuseExistingState() == true){
|
108
|
if (this.state == null){
|
109
|
this.state = new MarkupImportState(this);
|
110
|
}
|
111
|
return this.state;
|
112
|
}else{
|
113
|
return new MarkupImportState(this);
|
114
|
}
|
115
|
|
116
|
|
117
|
}
|
118
|
|
119
|
|
120
|
/* (non-Javadoc)
|
121
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
|
122
|
*/
|
123
|
@Override
|
124
|
public Reference getSourceReference() {
|
125
|
//TODO
|
126
|
if (this.sourceReference == null){
|
127
|
logger.warn("getSource Reference not yet fully implemented");
|
128
|
sourceReference = ReferenceFactory.newGeneric();
|
129
|
sourceReference.setTitleCache(sourceReferenceTitle, true);
|
130
|
}
|
131
|
return sourceReference;
|
132
|
}
|
133
|
|
134
|
|
135
|
/* (non-Javadoc)
|
136
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
|
137
|
*/
|
138
|
public String getSourceNameString() {
|
139
|
if (this.getSource() == null){
|
140
|
return null;
|
141
|
}else{
|
142
|
return this.getSource().toString();
|
143
|
}
|
144
|
}
|
145
|
|
146
|
|
147
|
public UUID getLastTaxonUuid() {
|
148
|
return lastTaxonUuid;
|
149
|
}
|
150
|
|
151
|
public void setLastTaxonUuid(UUID lastTaxonUuid) {
|
152
|
this.lastTaxonUuid = lastTaxonUuid;
|
153
|
}
|
154
|
|
155
|
public void setDoPrintKeys(boolean doPrintKeys) {
|
156
|
this.doPrintKeys = doPrintKeys;
|
157
|
}
|
158
|
|
159
|
public boolean isDoPrintKeys() {
|
160
|
return doPrintKeys;
|
161
|
}
|
162
|
|
163
|
public UUID getDefaultLanguageUuid() {
|
164
|
return this.defaultLanguageUuid;
|
165
|
}
|
166
|
|
167
|
public void setDefaultLanguageUuid(UUID defaultLanguageUuid) {
|
168
|
this.defaultLanguageUuid = defaultLanguageUuid;
|
169
|
}
|
170
|
|
171
|
public boolean isDoTaxa() {
|
172
|
return doTaxa;
|
173
|
}
|
174
|
public void setDoTaxa(boolean doTaxa) {
|
175
|
this.doTaxa = doTaxa;
|
176
|
}
|
177
|
|
178
|
public void setReplaceStandardKeyTitles(boolean replaceStandardKeyTitles) {
|
179
|
this.replaceStandardKeyTitles = replaceStandardKeyTitles;
|
180
|
}
|
181
|
|
182
|
public boolean isReplaceStandardKeyTitles() {
|
183
|
return replaceStandardKeyTitles;
|
184
|
}
|
185
|
|
186
|
/**
|
187
|
* If true, the state is saved in the configurator between 2 imports using this same configurator.
|
188
|
* Use with care as you may run into memory issues or also data consistency issues otherwise.
|
189
|
* This value must be set before getNewState is called for the <b>first</b> time. The feature is
|
190
|
* experimental.
|
191
|
* @return if reuse existing state is set to true.
|
192
|
*/
|
193
|
public boolean isReuseExistingState() {
|
194
|
return reuseExistingState;
|
195
|
}
|
196
|
|
197
|
/**
|
198
|
* @see #isReuseExistingState()
|
199
|
* @param reuseExistingState
|
200
|
*/
|
201
|
public void setReuseExistingState(boolean reuseExistingState) {
|
202
|
this.reuseExistingState = reuseExistingState;
|
203
|
}
|
204
|
|
205
|
/**
|
206
|
* If {@link #isReuseExistingState()} is true, this method returns the state.
|
207
|
* This is an experimental workaround for Markup import. The functionality
|
208
|
* should better be moved to CdmImportBase somewhere.
|
209
|
* @return
|
210
|
*/
|
211
|
public MarkupImportState getState() {
|
212
|
return state;
|
213
|
}
|
214
|
|
215
|
public boolean isAllowCapitalSpeciesEpithet() {
|
216
|
return allowCapitalSpeciesEpithet;
|
217
|
}
|
218
|
|
219
|
public void setAllowCapitalSpeciesEpithet(boolean allowCapitalSpeciesEpithet) {
|
220
|
this.allowCapitalSpeciesEpithet = allowCapitalSpeciesEpithet;
|
221
|
}
|
222
|
|
223
|
public boolean isHandlePagesAsDetailWhereNeeded() {
|
224
|
return this.handlePagesAsDetailWhereNeeded;
|
225
|
}
|
226
|
|
227
|
public void setHandlePagesAsDetailWhereNeeded(boolean handlePagesAsDetailWhereNeeded) {
|
228
|
this.handlePagesAsDetailWhereNeeded = handlePagesAsDetailWhereNeeded;
|
229
|
}
|
230
|
|
231
|
public boolean isUseEditorAsInAuthorWhereNeeded() {
|
232
|
return useEditorAsInAuthorWhereNeeded;
|
233
|
}
|
234
|
|
235
|
public void setUseEditorAsInAuthorWhereNeeded(boolean useEditorAsInAuthorWhereNeeded) {
|
236
|
this.useEditorAsInAuthorWhereNeeded = useEditorAsInAuthorWhereNeeded;
|
237
|
}
|
238
|
|
239
|
|
240
|
}
|