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.DbImportConfiguratorBase;
|
18
|
import eu.etaxonomy.cdm.io.common.ImportStateBase;
|
19
|
import eu.etaxonomy.cdm.io.common.Source;
|
20
|
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
|
21
|
import eu.etaxonomy.cdm.io.pesi.erms.validation.ErmsGeneralImportValidator;
|
22
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
23
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
24
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
25
|
|
26
|
/**
|
27
|
* @author a.mueller
|
28
|
* @since 20.03.2008
|
29
|
*/
|
30
|
public class ErmsImportConfigurator
|
31
|
extends DbImportConfiguratorBase<ErmsImportState>{
|
32
|
|
33
|
private static final long serialVersionUID = 5434106058744720246L;
|
34
|
|
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
|
@SuppressWarnings("unchecked")
|
61
|
@Override
|
62
|
protected void makeIoClassList(){
|
63
|
ioClassList = new Class[]{
|
64
|
ErmsGeneralImportValidator.class
|
65
|
, ErmsImportRankMap.class
|
66
|
, ErmsReferenceImport.class
|
67
|
, ErmsTaxonImport.class
|
68
|
, ErmsTaxonRelationImport.class
|
69
|
, ErmsVernacularImport.class
|
70
|
, ErmsNotesImport.class
|
71
|
, ErmsVernacularSourcesImport.class
|
72
|
, ErmsNotesSourcesImport.class
|
73
|
|
74
|
, ErmsAreaImport.class
|
75
|
, ErmsDrImport.class
|
76
|
, ErmsSourceUsesImport.class
|
77
|
, ErmsLinkImport.class //kann weiter hoch
|
78
|
, ErmsImageImport.class
|
79
|
};
|
80
|
}
|
81
|
|
82
|
@Override
|
83
|
public ImportStateBase getNewState() {
|
84
|
return new ErmsImportState(this);
|
85
|
}
|
86
|
|
87
|
/**
|
88
|
* @param berlinModelSource
|
89
|
* @param sourceReference
|
90
|
* @param destination
|
91
|
*/
|
92
|
private ErmsImportConfigurator(Source ermsSource, ICdmDataSource destination) {
|
93
|
super(ermsSource, destination, NomenclaturalCode.ICZN, defaultTransformer);//default for ERMS
|
94
|
}
|
95
|
|
96
|
@Override
|
97
|
public Source getSource() {
|
98
|
return super.getSource();
|
99
|
}
|
100
|
@Override
|
101
|
public void setSource(Source berlinModelSource) {
|
102
|
super.setSource(berlinModelSource);
|
103
|
}
|
104
|
|
105
|
@Override
|
106
|
public Reference getSourceReference() {
|
107
|
if (sourceReference == null){
|
108
|
sourceReference = ReferenceFactory.newDatabase();
|
109
|
if (getSource() != null){
|
110
|
sourceReference.setTitleCache(getSource().getDatabase(), true);
|
111
|
}
|
112
|
if (this.getSourceRefUuid() != null){
|
113
|
sourceReference.setUuid(this.getSourceRefUuid());
|
114
|
}
|
115
|
}
|
116
|
return sourceReference;
|
117
|
}
|
118
|
|
119
|
@Override
|
120
|
public String getSourceNameString() {
|
121
|
if (this.getSource() == null){
|
122
|
return null;
|
123
|
}else{
|
124
|
return this.getSource().getDatabase();
|
125
|
}
|
126
|
}
|
127
|
|
128
|
@Override
|
129
|
public Method getUserTransformationMethod() {
|
130
|
return userTransformationMethod;
|
131
|
}
|
132
|
@Override
|
133
|
public void setUserTransformationMethod(Method userTransformationMethod) {
|
134
|
this.userTransformationMethod = userTransformationMethod;
|
135
|
}
|
136
|
|
137
|
@Override
|
138
|
public int getRecordsPerTransaction() {
|
139
|
return recordsPerTransaction;
|
140
|
}
|
141
|
@Override
|
142
|
public void setRecordsPerTransaction(int recordsPerTransaction) {
|
143
|
this.recordsPerTransaction = recordsPerTransaction;
|
144
|
}
|
145
|
|
146
|
public void setDoVernaculars(boolean doVernaculars) {
|
147
|
this.doVernaculars = doVernaculars;
|
148
|
}
|
149
|
public boolean isDoVernaculars() {
|
150
|
return doVernaculars;
|
151
|
}
|
152
|
|
153
|
public void setDoLinks(boolean doLinks) {
|
154
|
this.doLinks = doLinks;
|
155
|
}
|
156
|
public boolean isDoLinks() {
|
157
|
return doLinks;
|
158
|
}
|
159
|
|
160
|
public void setDoNotes(boolean doNotes) {
|
161
|
this.doNotes = doNotes;
|
162
|
}
|
163
|
public boolean isDoNotes() {
|
164
|
return doNotes;
|
165
|
}
|
166
|
|
167
|
public void setDoImages(boolean doImages) {
|
168
|
this.doImages = doImages;
|
169
|
}
|
170
|
public boolean isDoImages() {
|
171
|
return doImages;
|
172
|
}
|
173
|
|
174
|
public boolean isDoOccurrence() {
|
175
|
return doOccurrence;
|
176
|
}
|
177
|
public void setDoOccurrence(boolean doOccurrence) {
|
178
|
this.doOccurrence = doOccurrence;
|
179
|
}
|
180
|
|
181
|
public DO_REFERENCES getDoReferences() {
|
182
|
return doReferences;
|
183
|
}
|
184
|
public void setDoReferences(DO_REFERENCES doReferences) {
|
185
|
this.doReferences = doReferences;
|
186
|
}
|
187
|
|
188
|
public boolean isDoTaxa() {
|
189
|
return doTaxa;
|
190
|
}
|
191
|
public void setDoTaxa(boolean doTaxa) {
|
192
|
this.doTaxa = doTaxa;
|
193
|
}
|
194
|
|
195
|
public boolean isDoRelTaxa() {
|
196
|
return doRelTaxa;
|
197
|
}
|
198
|
public void setDoRelTaxa(boolean doRelTaxa) {
|
199
|
this.doRelTaxa = doRelTaxa;
|
200
|
}
|
201
|
|
202
|
}
|