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