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.model.name.NomenclaturalCode;
|
22
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
23
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
24
|
|
25
|
/**
|
26
|
* @author a.mueller
|
27
|
* @since 20.03.2008
|
28
|
*/
|
29
|
public class ErmsImportConfigurator
|
30
|
extends DbImportConfiguratorBase<ErmsImportState>{
|
31
|
|
32
|
private static final long serialVersionUID = 5434106058744720246L;
|
33
|
|
34
|
@SuppressWarnings("unused")
|
35
|
private static Logger logger = Logger.getLogger(ErmsImportConfigurator.class);
|
36
|
|
37
|
public static ErmsImportConfigurator NewInstance(Source ermsSource, ICdmDataSource destination){
|
38
|
return new ErmsImportConfigurator(ermsSource, destination);
|
39
|
}
|
40
|
|
41
|
/* Max number of records to be saved with one service call */
|
42
|
private int recordsPerTransaction = 1000; //defaultValue
|
43
|
|
44
|
//TODO needed ??
|
45
|
private Method userTransformationMethod;
|
46
|
|
47
|
private boolean doVernaculars = true;
|
48
|
private boolean doLinks = true;
|
49
|
private boolean doNotes = true;
|
50
|
private boolean doImages = true;
|
51
|
private boolean doDistributions = true;
|
52
|
private DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
53
|
private boolean doTaxa = true;
|
54
|
private boolean doRelTaxa = true;
|
55
|
private boolean doSourceUse = 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
|
, ErmsSourceUsesImport.class
|
70
|
, ErmsVernacularImport.class
|
71
|
, ErmsVernacularSourcesImport.class
|
72
|
, ErmsNotesImport.class
|
73
|
, ErmsNotesSourcesImport.class
|
74
|
, ErmsAreaImport.class
|
75
|
, ErmsDistributionImport.class
|
76
|
, ErmsLinkImport.class //kann weiter hoch
|
77
|
, ErmsImageImport.class
|
78
|
};
|
79
|
}
|
80
|
|
81
|
@Override
|
82
|
public ImportStateBase getNewState() {
|
83
|
return new ErmsImportState(this);
|
84
|
}
|
85
|
|
86
|
private ErmsImportConfigurator(Source ermsSource, ICdmDataSource destination) {
|
87
|
super(ermsSource, destination, NomenclaturalCode.ICZN, defaultTransformer);//default for ERMS
|
88
|
}
|
89
|
|
90
|
@Override
|
91
|
public Source getSource() {
|
92
|
return super.getSource();
|
93
|
}
|
94
|
@Override
|
95
|
public void setSource(Source berlinModelSource) {
|
96
|
super.setSource(berlinModelSource);
|
97
|
}
|
98
|
|
99
|
@Override
|
100
|
public Reference getSourceReference() {
|
101
|
if (sourceReference == null){
|
102
|
sourceReference = ReferenceFactory.newDatabase();
|
103
|
if (getSource() != null){
|
104
|
sourceReference.setTitleCache(getSource().getDatabase(), true);
|
105
|
}
|
106
|
if (this.getSourceRefUuid() != null){
|
107
|
sourceReference.setUuid(this.getSourceRefUuid());
|
108
|
}
|
109
|
}
|
110
|
return sourceReference;
|
111
|
}
|
112
|
|
113
|
@Override
|
114
|
public String getSourceNameString() {
|
115
|
if (this.getSource() == null){
|
116
|
return null;
|
117
|
}else{
|
118
|
return this.getSource().getDatabase();
|
119
|
}
|
120
|
}
|
121
|
|
122
|
@Override
|
123
|
public Method getUserTransformationMethod() {
|
124
|
return userTransformationMethod;
|
125
|
}
|
126
|
@Override
|
127
|
public void setUserTransformationMethod(Method userTransformationMethod) {
|
128
|
this.userTransformationMethod = userTransformationMethod;
|
129
|
}
|
130
|
|
131
|
@Override
|
132
|
public int getRecordsPerTransaction() {
|
133
|
return recordsPerTransaction;
|
134
|
}
|
135
|
@Override
|
136
|
public void setRecordsPerTransaction(int recordsPerTransaction) {
|
137
|
this.recordsPerTransaction = recordsPerTransaction;
|
138
|
}
|
139
|
|
140
|
public void setDoVernaculars(boolean doVernaculars) {
|
141
|
this.doVernaculars = doVernaculars;
|
142
|
}
|
143
|
public boolean isDoVernaculars() {
|
144
|
return doVernaculars;
|
145
|
}
|
146
|
|
147
|
public void setDoLinks(boolean doLinks) {
|
148
|
this.doLinks = doLinks;
|
149
|
}
|
150
|
public boolean isDoLinks() {
|
151
|
return doLinks;
|
152
|
}
|
153
|
|
154
|
public void setDoNotes(boolean doNotes) {
|
155
|
this.doNotes = doNotes;
|
156
|
}
|
157
|
public boolean isDoNotes() {
|
158
|
return doNotes;
|
159
|
}
|
160
|
|
161
|
public void setDoImages(boolean doImages) {
|
162
|
this.doImages = doImages;
|
163
|
}
|
164
|
public boolean isDoImages() {
|
165
|
return doImages;
|
166
|
}
|
167
|
|
168
|
public boolean isDoDistributions() {
|
169
|
return doDistributions;
|
170
|
}
|
171
|
public void setDoDistributions(boolean doDistributions) {
|
172
|
this.doDistributions = doDistributions;
|
173
|
}
|
174
|
|
175
|
public DO_REFERENCES getDoReferences() {
|
176
|
return doReferences;
|
177
|
}
|
178
|
public void setDoReferences(DO_REFERENCES doReferences) {
|
179
|
this.doReferences = doReferences;
|
180
|
}
|
181
|
|
182
|
public boolean isDoTaxa() {
|
183
|
return doTaxa;
|
184
|
}
|
185
|
public void setDoTaxa(boolean doTaxa) {
|
186
|
this.doTaxa = doTaxa;
|
187
|
}
|
188
|
|
189
|
public boolean isDoRelTaxa() {
|
190
|
return doRelTaxa;
|
191
|
}
|
192
|
public void setDoRelTaxa(boolean doRelTaxa) {
|
193
|
this.doRelTaxa = doRelTaxa;
|
194
|
}
|
195
|
|
196
|
public boolean isDoSourceUse() {
|
197
|
return doSourceUse;
|
198
|
}
|
199
|
public void setDoSourceUse(boolean doSourceUse) {
|
200
|
this.doSourceUse = doSourceUse;
|
201
|
}
|
202
|
}
|