Project

General

Profile

Download (6.08 KB) Statistics
| Branch: | Revision:
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.IImportConfigurator;
19
import eu.etaxonomy.cdm.io.common.ImportStateBase;
20
import eu.etaxonomy.cdm.io.common.Source;
21
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
22
import eu.etaxonomy.cdm.io.pesi.erms.validation.ErmsGeneralImportValidator;
23
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
24
import eu.etaxonomy.cdm.model.reference.Reference;
25
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
26

    
27

    
28
/**
29
 * @author a.mueller
30
 * @created 20.03.2008
31
 * @version 1.0
32
 */
33
public class ErmsImportConfigurator extends DbImportConfiguratorBase<ErmsImportState> implements IImportConfigurator{
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 doOccurrence = true;
52
	private DO_REFERENCES doReferences = DO_REFERENCES.ALL;
53
	private boolean doTaxa = true;
54
	private boolean doRelTaxa = true;
55

    
56
	
57
	private static IInputTransformer defaultTransformer = new ErmsTransformer();
58
	
59
	protected void makeIoClassList(){
60
		ioClassList = new Class[]{
61
				ErmsGeneralImportValidator.class
62
				, ErmsImportRankMap.class
63
				, ErmsReferenceImport.class
64
				, ErmsTaxonImport.class
65
				, ErmsTaxonRelationImport.class
66
				, ErmsVernacularImport.class
67
				, ErmsNotesImport.class
68
				, ErmsVernacularSourcesImport.class
69
				, ErmsNotesSourcesImport.class
70
				
71
				, ErmsAreaImport.class
72
				, ErmsDrImport.class
73
				, ErmsSourceUsesImport.class
74
				, ErmsLinkImport.class  //kann weiter hoch
75
				, ErmsImageImport.class
76
		};	
77
	}
78
	
79

    
80
	/* (non-Javadoc)
81
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
82
	 */
83
	public ImportStateBase getNewState() {
84
		return new ErmsImportState(this);
85
	}
86

    
87

    
88

    
89
	/**
90
	 * @param berlinModelSource
91
	 * @param sourceReference
92
	 * @param destination
93
	 */
94
	private ErmsImportConfigurator(Source ermsSource, ICdmDataSource destination) {
95
	   super(ermsSource, destination, NomenclaturalCode.ICZN, defaultTransformer);//default for ERMS
96
	}
97
	
98
	
99
	public Source getSource() {
100
		return (Source)super.getSource();
101
	}
102
	public void setSource(Source berlinModelSource) {
103
		super.setSource(berlinModelSource);
104
	}
105

    
106
	/* (non-Javadoc)
107
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
108
	 */
109
	public Reference getSourceReference() {
110
		if (sourceReference == null){
111
			sourceReference =  ReferenceFactory.newDatabase();
112
			if (getSource() != null){
113
				sourceReference.setTitleCache(getSource().getDatabase(), true);
114
			}
115
			if (this.getSourceRefUuid() != null){
116
				sourceReference.setUuid(this.getSourceRefUuid());
117
			}
118
		}
119
		return sourceReference;
120
	}
121

    
122

    
123
	/* (non-Javadoc)
124
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
125
	 */
126
	public String getSourceNameString() {
127
		if (this.getSource() == null){
128
			return null;
129
		}else{
130
			return this.getSource().getDatabase();
131
		}
132
	}
133

    
134
	/**
135
	 * @return the userTransformationMethod
136
	 */
137
	public Method getUserTransformationMethod() {
138
		return userTransformationMethod;
139
	}
140

    
141
	/**
142
	 * @param userTransformationMethod the userTransformationMethod to set
143
	 */
144
	public void setUserTransformationMethod(Method userTransformationMethod) {
145
		this.userTransformationMethod = userTransformationMethod;
146
	}
147

    
148
	
149
	/**
150
	 * @return the limitSave
151
	 */
152
	public int getRecordsPerTransaction() {
153
		return recordsPerTransaction;
154
	}
155

    
156
	/**
157
	 * @param limitSave the limitSave to set
158
	 */
159
	public void setRecordsPerTransaction(int recordsPerTransaction) {
160
		this.recordsPerTransaction = recordsPerTransaction;
161
	}
162

    
163
	/**
164
	 * @param doVernaculars the doVernaculars to set
165
	 */
166
	public void setDoVernaculars(boolean doVernaculars) {
167
		this.doVernaculars = doVernaculars;
168
	}
169

    
170
	/**
171
	 * @return the doVernaculars
172
	 */
173
	public boolean isDoVernaculars() {
174
		return doVernaculars;
175
	}
176

    
177

    
178

    
179
	/**
180
	 * @param doLinks the doLinks to set
181
	 */
182
	public void setDoLinks(boolean doLinks) {
183
		this.doLinks = doLinks;
184
	}
185

    
186

    
187

    
188
	/**
189
	 * @return the doLinks
190
	 */
191
	public boolean isDoLinks() {
192
		return doLinks;
193
	}
194

    
195

    
196

    
197
	/**
198
	 * @param doNotes the doNotes to set
199
	 */
200
	public void setDoNotes(boolean doNotes) {
201
		this.doNotes = doNotes;
202
	}
203

    
204

    
205

    
206
	/**
207
	 * @return the doNotes
208
	 */
209
	public boolean isDoNotes() {
210
		return doNotes;
211
	}
212

    
213

    
214

    
215
	/**
216
	 * @param doImages the doImages to set
217
	 */
218
	public void setDoImages(boolean doImages) {
219
		this.doImages = doImages;
220
	}
221

    
222

    
223

    
224
	/**
225
	 * @return the doImages
226
	 */
227
	public boolean isDoImages() {
228
		return doImages;
229
	}
230
	
231
	
232
	public boolean isDoOccurrence() {
233
		return doOccurrence;
234
	}
235
	public void setDoOccurrence(boolean doOccurrence) {
236
		this.doOccurrence = doOccurrence;
237
	}
238
	
239
	
240
	public DO_REFERENCES getDoReferences() {
241
		return doReferences;
242
	}
243
	public void setDoReferences(DO_REFERENCES doReferences) {
244
		this.doReferences = doReferences;
245
	}
246

    
247
	public boolean isDoTaxa() {
248
		return doTaxa;
249
	}
250
	public void setDoTaxa(boolean doTaxa) {
251
		this.doTaxa = doTaxa;
252
	}
253

    
254
	public boolean isDoRelTaxa() {
255
		return doRelTaxa;
256
	}
257
	public void setDoRelTaxa(boolean doRelTaxa) {
258
		this.doRelTaxa = doRelTaxa;
259
	}
260

    
261

    
262

    
263
}
(5-5/17)