Project

General

Profile

Download (5.4 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.globis;
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.mapping.IInputTransformer;
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
/**
28
 * @author a.mueller
29
 * @created 20.03.2008
30
 * @version 1.0
31
 */
32
public class GlobisImportConfigurator extends ImportConfiguratorBase<GlobisImportState, Source> implements IImportConfigurator{
33
	@SuppressWarnings("unused")
34
	private static Logger logger = Logger.getLogger(GlobisImportConfigurator.class);
35

    
36
	public static GlobisImportConfigurator NewInstance(Source ermsSource, ICdmDataSource destination){
37
			return new GlobisImportConfigurator(ermsSource, destination);
38
	}
39

    
40
	/* Max number of records to be saved with one service call */
41
	private int recordsPerTransaction = 2000;  //defaultValue
42

    
43
	//TODO needed ??
44
	private Method userTransformationMethod;
45
	
46
	private boolean doImages = true;
47
	private boolean doCurrentTaxa = true;
48
	private boolean doSpecTaxa = true;
49
	private boolean doCommonNames = true;
50
	
51
	private boolean doReadMediaData = true;
52
	
53
	private DO_REFERENCES doReferences = DO_REFERENCES.ALL;
54

    
55
	private String imageBaseUrl = "http://globis-images.insects-online.de/images/";
56
	
57
	private static IInputTransformer defaultTransformer = new GlobisTransformer();
58
	
59
	protected void makeIoClassList(){
60
		ioClassList = new Class[]{
61
				//ErmsGeneralImportValidator.class
62
				 GlobisReferenceImport.class
63
	//			, ErmsReferenceImport.class
64
				, GlobisCurrentSpeciesImport.class
65
				, GlobisSpecTaxImport.class
66
				, GlobisImageImport.class
67
		};	
68
	}
69
	
70

    
71
	/* (non-Javadoc)
72
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
73
	 */
74
	public ImportStateBase getNewState() {
75
		return new GlobisImportState(this);
76
	}
77

    
78

    
79

    
80
	private GlobisImportConfigurator(Source source, ICdmDataSource destination) {
81
	   super(defaultTransformer);
82
	   setNomenclaturalCode(NomenclaturalCode.ICZN); //default for ERMS
83
	   setSource(source);
84
	   setDestination(destination);
85
	}
86
	
87
	
88
	public Source getSource() {
89
		return (Source)super.getSource();
90
	}
91
	public void setSource(Source berlinModelSource) {
92
		super.setSource(berlinModelSource);
93
	}
94

    
95
	/* (non-Javadoc)
96
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
97
	 */
98
	public Reference getSourceReference() {
99
		ReferenceFactory refFactory = ReferenceFactory.newInstance();
100
		if (sourceReference == null){
101
			sourceReference =  refFactory.newDatabase();
102
			if (getSource() != null){
103
				sourceReference.setTitleCache(getSource().getDatabase(), true);
104
			}
105
		}
106
		return sourceReference;
107
	}
108

    
109

    
110
	/* (non-Javadoc)
111
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
112
	 */
113
	public String getSourceNameString() {
114
		if (this.getSource() == null){
115
			return null;
116
		}else{
117
			return this.getSource().getDatabase();
118
		}
119
	}
120

    
121
	/**
122
	 * @return the userTransformationMethod
123
	 */
124
	public Method getUserTransformationMethod() {
125
		return userTransformationMethod;
126
	}
127

    
128
	/**
129
	 * @param userTransformationMethod the userTransformationMethod to set
130
	 */
131
	public void setUserTransformationMethod(Method userTransformationMethod) {
132
		this.userTransformationMethod = userTransformationMethod;
133
	}
134

    
135
	
136
	/**
137
	 * @return the limitSave
138
	 */
139
	public int getRecordsPerTransaction() {
140
		return recordsPerTransaction;
141
	}
142
	/**
143
	 * @param limitSave the limitSave to set
144
	 */
145
	public void setRecordsPerTransaction(int recordsPerTransaction) {
146
		this.recordsPerTransaction = recordsPerTransaction;
147
	}
148

    
149

    
150
	/**
151
	 * @param doImages the doImages to set
152
	 */
153
	public void setDoImages(boolean doImages) {
154
		this.doImages = doImages;
155
	}
156
	/**
157
	 * @return the doImages
158
	 */
159
	public boolean isDoImages() {
160
		return doImages;
161
	}
162
	
163
	public DO_REFERENCES getDoReferences() {
164
		return doReferences;
165
	}
166
	public void setDoReferences(DO_REFERENCES doReferences) {
167
		this.doReferences = doReferences;
168
	}
169

    
170

    
171
	public void setDoCurrentTaxa(boolean doCurrentTaxa) {
172
		this.doCurrentTaxa = doCurrentTaxa;
173
	}
174

    
175

    
176
	public boolean isDoCurrentTaxa() {
177
		return doCurrentTaxa;
178
	}
179

    
180

    
181
	public void setDoSpecTaxa(boolean doSpecTaxa) {
182
		this.doSpecTaxa = doSpecTaxa;
183
	}
184

    
185

    
186
	public boolean isDoSpecTaxa() {
187
		return doSpecTaxa;
188
	}
189

    
190

    
191
	public void setDoCommonNames(boolean doCommonNames) {
192
		this.doCommonNames = doCommonNames;
193
	}
194

    
195

    
196
	public boolean isDoCommonNames() {
197
		return doCommonNames;
198
	}
199

    
200

    
201
	public void setImageBaseUrl(String imageBaseUrl) {
202
		this.imageBaseUrl = imageBaseUrl;
203
	}
204

    
205

    
206
	public String getImageBaseUrl() {
207
		return imageBaseUrl;
208
	}
209

    
210

    
211
	public void setDoReadMediaData(boolean doReadMediaData) {
212
		this.doReadMediaData = doReadMediaData;
213
	}
214

    
215

    
216
	public boolean isDoReadMediaData() {
217
		return doReadMediaData;
218
	}
219

    
220

    
221
	
222

    
223
}
(4-4/9)