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
|
|
38
|
//TODO
|
39
|
private static IInputTransformer defaultTransformer = null;
|
40
|
private String classificationTitle = "E-Flora Import";
|
41
|
private String sourceReferenceTitle = "E-Flora";
|
42
|
private UUID defaultLanguageUuid;
|
43
|
|
44
|
//TODO move to state, but a state gets lost after each import.invoke, so I can't move this information
|
45
|
//from the one import to another import in case I run 2 imports in line
|
46
|
private UUID lastTaxonUuid;
|
47
|
|
48
|
//if true, the keys will be printed after they have been created
|
49
|
private boolean doPrintKeys = false;
|
50
|
|
51
|
|
52
|
/* (non-Javadoc)
|
53
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#makeIoClassList()
|
54
|
*/
|
55
|
protected void makeIoClassList(){
|
56
|
ioClassList = new Class[]{
|
57
|
MarkupDocumentImport.class
|
58
|
};
|
59
|
};
|
60
|
|
61
|
protected MarkupImportConfigurator() {
|
62
|
super(defaultTransformer);
|
63
|
}
|
64
|
|
65
|
|
66
|
/**
|
67
|
*
|
68
|
*/
|
69
|
protected MarkupImportConfigurator(IInputTransformer transformer) {
|
70
|
super(transformer);
|
71
|
}
|
72
|
|
73
|
|
74
|
/**
|
75
|
* @param url
|
76
|
* @param destination
|
77
|
*/
|
78
|
protected MarkupImportConfigurator(URI uri, ICdmDataSource destination) {
|
79
|
super(defaultTransformer);
|
80
|
setSource(uri);
|
81
|
setDestination(destination);
|
82
|
}
|
83
|
|
84
|
/**
|
85
|
* @param url
|
86
|
* @param destination
|
87
|
*/
|
88
|
protected MarkupImportConfigurator(URI uri, ICdmDataSource destination, IInputTransformer transformer) {
|
89
|
super(transformer);
|
90
|
setSource(uri);
|
91
|
setDestination(destination);
|
92
|
}
|
93
|
|
94
|
|
95
|
/* (non-Javadoc)
|
96
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
|
97
|
*/
|
98
|
public MarkupImportState getNewState() {
|
99
|
return new MarkupImportState(this);
|
100
|
}
|
101
|
|
102
|
|
103
|
/* (non-Javadoc)
|
104
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
|
105
|
*/
|
106
|
@Override
|
107
|
public Reference getSourceReference() {
|
108
|
//TODO
|
109
|
if (this.sourceReference == null){
|
110
|
logger.warn("getSource Reference not yet fully implemented");
|
111
|
sourceReference = ReferenceFactory.newGeneric();
|
112
|
sourceReference.setTitleCache(sourceReferenceTitle, true);
|
113
|
}
|
114
|
return sourceReference;
|
115
|
}
|
116
|
|
117
|
|
118
|
/* (non-Javadoc)
|
119
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
|
120
|
*/
|
121
|
public String getSourceNameString() {
|
122
|
if (this.getSource() == null){
|
123
|
return null;
|
124
|
}else{
|
125
|
return this.getSource().toString();
|
126
|
}
|
127
|
}
|
128
|
|
129
|
public void setClassificationTitle(String classificationTitle) {
|
130
|
this.classificationTitle = classificationTitle;
|
131
|
}
|
132
|
|
133
|
public String getClassificationTitle() {
|
134
|
return classificationTitle;
|
135
|
}
|
136
|
|
137
|
|
138
|
|
139
|
public UUID getLastTaxonUuid() {
|
140
|
return lastTaxonUuid;
|
141
|
}
|
142
|
|
143
|
public void setLastTaxonUuid(UUID lastTaxonUuid) {
|
144
|
this.lastTaxonUuid = lastTaxonUuid;
|
145
|
}
|
146
|
|
147
|
public void setDoPrintKeys(boolean doPrintKeys) {
|
148
|
this.doPrintKeys = doPrintKeys;
|
149
|
}
|
150
|
|
151
|
public boolean isDoPrintKeys() {
|
152
|
return doPrintKeys;
|
153
|
}
|
154
|
|
155
|
public UUID getDefaultLanguageUuid() {
|
156
|
return this.defaultLanguageUuid;
|
157
|
}
|
158
|
|
159
|
public void setDefaultLanguageUuid(UUID defaultLanguageUuid) {
|
160
|
this.defaultLanguageUuid = defaultLanguageUuid;
|
161
|
}
|
162
|
|
163
|
public boolean isDoTaxa() {
|
164
|
return doTaxa;
|
165
|
}
|
166
|
public void setDoTaxa(boolean doTaxa) {
|
167
|
this.doTaxa = doTaxa;
|
168
|
}
|
169
|
|
170
|
public void setReplaceStandardKeyTitles(boolean replaceStandardKeyTitles) {
|
171
|
this.replaceStandardKeyTitles = replaceStandardKeyTitles;
|
172
|
}
|
173
|
|
174
|
public boolean isReplaceStandardKeyTitles() {
|
175
|
return replaceStandardKeyTitles;
|
176
|
}
|
177
|
|
178
|
|
179
|
}
|