1
|
/**
|
2
|
* Copyright (C) 2007 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.pesi.erms;
|
11
|
|
12
|
import java.lang.reflect.Method;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
|
16
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
17
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
18
|
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
|
19
|
import eu.etaxonomy.cdm.io.common.ImportStateBase;
|
20
|
import eu.etaxonomy.cdm.io.common.Source;
|
21
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES;
|
22
|
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
|
23
|
import eu.etaxonomy.cdm.io.pesi.erms.validation.ErmsGeneralImportValidator;
|
24
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
25
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
26
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
27
|
|
28
|
|
29
|
/**
|
30
|
* @author a.mueller
|
31
|
* @created 20.03.2008
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public class ErmsImportConfigurator extends ImportConfiguratorBase<ErmsImportState, Source> implements IImportConfigurator{
|
35
|
@SuppressWarnings("unused")
|
36
|
private static Logger logger = Logger.getLogger(ErmsImportConfigurator.class);
|
37
|
|
38
|
public static ErmsImportConfigurator NewInstance(Source ermsSource, ICdmDataSource destination){
|
39
|
return new ErmsImportConfigurator(ermsSource, destination);
|
40
|
}
|
41
|
|
42
|
/* Max number of records to be saved with one service call */
|
43
|
private int recordsPerTransaction = 1000; //defaultValue
|
44
|
|
45
|
//TODO needed ??
|
46
|
private Method userTransformationMethod;
|
47
|
|
48
|
private boolean doVernaculars = true;
|
49
|
private boolean doLinks = true;
|
50
|
private boolean doNotes = true;
|
51
|
private boolean doImages = true;
|
52
|
private boolean doOccurrence = true;
|
53
|
private DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
54
|
private boolean doTaxa = true;
|
55
|
private boolean doRelTaxa = true;
|
56
|
|
57
|
|
58
|
private static IInputTransformer defaultTransformer = new ErmsTransformer();
|
59
|
|
60
|
protected void makeIoClassList(){
|
61
|
ioClassList = new Class[]{
|
62
|
ErmsGeneralImportValidator.class
|
63
|
, ErmsImportRankMap.class
|
64
|
, ErmsReferenceImport.class
|
65
|
, ErmsTaxonImport.class
|
66
|
, ErmsTaxonRelationImport.class
|
67
|
, ErmsVernacularImport.class
|
68
|
, ErmsNotesImport.class
|
69
|
, ErmsVernacularSourcesImport.class
|
70
|
, ErmsNotesSourcesImport.class
|
71
|
|
72
|
, ErmsAreaImport.class
|
73
|
, ErmsDrImport.class
|
74
|
, ErmsSourceUsesImport.class
|
75
|
, ErmsLinkImport.class //kann weiter hoch
|
76
|
, ErmsImageImport.class
|
77
|
};
|
78
|
}
|
79
|
|
80
|
|
81
|
/* (non-Javadoc)
|
82
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
|
83
|
*/
|
84
|
public ImportStateBase getNewState() {
|
85
|
return new ErmsImportState(this);
|
86
|
}
|
87
|
|
88
|
|
89
|
|
90
|
/**
|
91
|
* @param berlinModelSource
|
92
|
* @param sourceReference
|
93
|
* @param destination
|
94
|
*/
|
95
|
private ErmsImportConfigurator(Source ermsSource, ICdmDataSource destination) {
|
96
|
super(defaultTransformer);
|
97
|
setNomenclaturalCode(NomenclaturalCode.ICZN); //default for ERMS
|
98
|
setSource(ermsSource);
|
99
|
setDestination(destination);
|
100
|
}
|
101
|
|
102
|
|
103
|
public Source getSource() {
|
104
|
return (Source)super.getSource();
|
105
|
}
|
106
|
public void setSource(Source berlinModelSource) {
|
107
|
super.setSource(berlinModelSource);
|
108
|
}
|
109
|
|
110
|
/* (non-Javadoc)
|
111
|
* @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
|
112
|
*/
|
113
|
public Reference getSourceReference() {
|
114
|
ReferenceFactory refFactory = ReferenceFactory.newInstance();
|
115
|
if (sourceReference == null){
|
116
|
sourceReference = refFactory.newDatabase();
|
117
|
if (getSource() != null){
|
118
|
sourceReference.setTitleCache(getSource().getDatabase(), true);
|
119
|
}
|
120
|
}
|
121
|
return sourceReference;
|
122
|
}
|
123
|
|
124
|
|
125
|
/* (non-Javadoc)
|
126
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
|
127
|
*/
|
128
|
public String getSourceNameString() {
|
129
|
if (this.getSource() == null){
|
130
|
return null;
|
131
|
}else{
|
132
|
return this.getSource().getDatabase();
|
133
|
}
|
134
|
}
|
135
|
|
136
|
/**
|
137
|
* @return the userTransformationMethod
|
138
|
*/
|
139
|
public Method getUserTransformationMethod() {
|
140
|
return userTransformationMethod;
|
141
|
}
|
142
|
|
143
|
/**
|
144
|
* @param userTransformationMethod the userTransformationMethod to set
|
145
|
*/
|
146
|
public void setUserTransformationMethod(Method userTransformationMethod) {
|
147
|
this.userTransformationMethod = userTransformationMethod;
|
148
|
}
|
149
|
|
150
|
|
151
|
/**
|
152
|
* @return the limitSave
|
153
|
*/
|
154
|
public int getRecordsPerTransaction() {
|
155
|
return recordsPerTransaction;
|
156
|
}
|
157
|
|
158
|
/**
|
159
|
* @param limitSave the limitSave to set
|
160
|
*/
|
161
|
public void setRecordsPerTransaction(int recordsPerTransaction) {
|
162
|
this.recordsPerTransaction = recordsPerTransaction;
|
163
|
}
|
164
|
|
165
|
/**
|
166
|
* @param doVernaculars the doVernaculars to set
|
167
|
*/
|
168
|
public void setDoVernaculars(boolean doVernaculars) {
|
169
|
this.doVernaculars = doVernaculars;
|
170
|
}
|
171
|
|
172
|
/**
|
173
|
* @return the doVernaculars
|
174
|
*/
|
175
|
public boolean isDoVernaculars() {
|
176
|
return doVernaculars;
|
177
|
}
|
178
|
|
179
|
|
180
|
|
181
|
/**
|
182
|
* @param doLinks the doLinks to set
|
183
|
*/
|
184
|
public void setDoLinks(boolean doLinks) {
|
185
|
this.doLinks = doLinks;
|
186
|
}
|
187
|
|
188
|
|
189
|
|
190
|
/**
|
191
|
* @return the doLinks
|
192
|
*/
|
193
|
public boolean isDoLinks() {
|
194
|
return doLinks;
|
195
|
}
|
196
|
|
197
|
|
198
|
|
199
|
/**
|
200
|
* @param doNotes the doNotes to set
|
201
|
*/
|
202
|
public void setDoNotes(boolean doNotes) {
|
203
|
this.doNotes = doNotes;
|
204
|
}
|
205
|
|
206
|
|
207
|
|
208
|
/**
|
209
|
* @return the doNotes
|
210
|
*/
|
211
|
public boolean isDoNotes() {
|
212
|
return doNotes;
|
213
|
}
|
214
|
|
215
|
|
216
|
|
217
|
/**
|
218
|
* @param doImages the doImages to set
|
219
|
*/
|
220
|
public void setDoImages(boolean doImages) {
|
221
|
this.doImages = doImages;
|
222
|
}
|
223
|
|
224
|
|
225
|
|
226
|
/**
|
227
|
* @return the doImages
|
228
|
*/
|
229
|
public boolean isDoImages() {
|
230
|
return doImages;
|
231
|
}
|
232
|
|
233
|
|
234
|
public boolean isDoOccurrence() {
|
235
|
return doOccurrence;
|
236
|
}
|
237
|
public void setDoOccurrence(boolean doOccurrence) {
|
238
|
this.doOccurrence = doOccurrence;
|
239
|
}
|
240
|
|
241
|
|
242
|
public DO_REFERENCES getDoReferences() {
|
243
|
return doReferences;
|
244
|
}
|
245
|
public void setDoReferences(DO_REFERENCES doReferences) {
|
246
|
this.doReferences = doReferences;
|
247
|
}
|
248
|
|
249
|
public boolean isDoTaxa() {
|
250
|
return doTaxa;
|
251
|
}
|
252
|
public void setDoTaxa(boolean doTaxa) {
|
253
|
this.doTaxa = doTaxa;
|
254
|
}
|
255
|
|
256
|
public boolean isDoRelTaxa() {
|
257
|
return doRelTaxa;
|
258
|
}
|
259
|
public void setDoRelTaxa(boolean doRelTaxa) {
|
260
|
this.doRelTaxa = doRelTaxa;
|
261
|
}
|
262
|
|
263
|
|
264
|
|
265
|
}
|