Project

General

Profile

Download (8.91 KB) Statistics
| Branch: | Tag: | 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.berlinModel.in;
11

    
12
import java.io.File;
13
import java.lang.reflect.Method;
14
import java.net.MalformedURLException;
15
import java.net.URL;
16
import java.util.HashSet;
17
import java.util.Set;
18

    
19
import org.apache.log4j.Logger;
20

    
21
import eu.etaxonomy.cdm.database.ICdmDataSource;
22
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer;
23
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelTaxonImport.PublishMarkerChooser;
24
import eu.etaxonomy.cdm.io.berlinModel.in.validation.BerlinModelGeneralImportValidator;
25
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
26
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
27
import eu.etaxonomy.cdm.io.common.ImportStateBase;
28
import eu.etaxonomy.cdm.io.common.Source;
29
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
30
import eu.etaxonomy.cdm.io.erms.ErmsTransformer;
31
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
32
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
33
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
34
import eu.etaxonomy.cdm.model.taxon.Synonym;
35

    
36
/**
37
 * @author a.mueller
38
 * @created 20.03.2008
39
 * @version 1.0
40
 */
41
public class BerlinModelImportConfigurator extends ImportConfiguratorBase<BerlinModelImportState> implements IImportConfigurator{
42
	private static Logger logger = Logger.getLogger(BerlinModelImportConfigurator.class);
43

    
44
	public static BerlinModelImportConfigurator NewInstance(Source berlinModelSource, ICdmDataSource destination){
45
			return new BerlinModelImportConfigurator(berlinModelSource, destination);
46
	}
47

    
48
	private PublishMarkerChooser taxonPublishMarker = PublishMarkerChooser.ALL;
49
	
50
	//TODO
51
	private static IInputTransformer defaultTransformer = null;
52
	
53
	
54
	/* Max number of records to be saved with one service call */
55
	private int recordsPerTransaction = 1000;
56

    
57
	private Method namerelationshipTypeMethod;
58
	private Method uuidForDefTermMethod;
59
	private Method userTransformationMethod;
60
	private Method nameTypeDesignationStatusMethod;
61
	
62
	private Set<Synonym> proParteSynonyms = new HashSet<Synonym>();
63
	private Set<Synonym> partialSynonyms = new HashSet<Synonym>();
64
	
65
	// NameFact stuff
66
	private URL mediaUrl;
67
	private File mediaPath;
68
	private int maximumNumberOfNameFacts;
69
	private boolean isIgnore0AuthorTeam = false;
70
	
71
	protected void makeIoClassList(){
72
		ioClassList = new Class[]{
73
				BerlinModelGeneralImportValidator.class
74
				, BerlinModelUserImport.class
75
				, BerlinModelAuthorImport.class
76
				, BerlinModelAuthorTeamImport.class
77
				, BerlinModelRefDetailImport.class
78
				, BerlinModelReferenceImport.class
79
				, BerlinModelTaxonNameImport.class
80
				, BerlinModelTaxonNameRelationImport.class
81
				, BerlinModelNameStatusImport.class
82
				, BerlinModelNameFactsImport.class
83
				, BerlinModelTypesImport.class
84
				, BerlinModelTaxonImport.class
85
				, BerlinModelTaxonRelationImport.class
86
				, BerlinModelFactsImport.class
87
				, BerlinModelOccurrenceImport.class
88
				, BerlinModelWebMarkerCategoryImport.class
89
				, BerlinModelWebMarkerImport.class
90
		};	
91
	}
92
	
93
	
94
	
95
	/* (non-Javadoc)
96
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
97
	 */
98
	public ImportStateBase getNewState() {
99
		return new BerlinModelImportState(this);
100
	}
101

    
102

    
103

    
104
	/**
105
	 * @param berlinModelSource
106
	 * @param sourceReference
107
	 * @param destination
108
	 */
109
	private BerlinModelImportConfigurator(Source berlinModelSource, ICdmDataSource destination) {
110
	   super(defaultTransformer);
111
	   setNomenclaturalCode(NomenclaturalCode.ICBN); //default for Berlin Model
112
	   setSource(berlinModelSource);
113
	   setDestination(destination);
114
	}
115
	
116
	
117
	public Source getSource() {
118
		return (Source)super.getSource();
119
	}
120
	public void setSource(Source berlinModelSource) {
121
		super.setSource(berlinModelSource);
122
	}
123

    
124
	/* (non-Javadoc)
125
	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
126
	 */
127
	public ReferenceBase getSourceReference() {
128
		ReferenceFactory refFactory = ReferenceFactory.newInstance();
129
		if (sourceReference == null){
130
			sourceReference =  refFactory.newDatabase();
131
			if (getSource() != null){
132
				sourceReference.setTitleCache(getSource().getDatabase());
133
			}
134
		}
135
		return sourceReference;
136
	}
137

    
138

    
139
	/* (non-Javadoc)
140
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
141
	 */
142
	public String getSourceNameString() {
143
		if (this.getSource() == null){
144
			return null;
145
		}else{
146
			return this.getSource().getDatabase();
147
		}
148
	}
149
	
150
	protected void addProParteSynonym(Synonym proParteSynonym){
151
		this.proParteSynonyms.add(proParteSynonym);
152
	}
153
	
154
	protected boolean isProParteSynonym(Synonym synonym){
155
		return this.proParteSynonyms.contains(synonym);
156
	}
157
	
158
	protected void addPartialSynonym(Synonym partialSynonym){
159
		this.partialSynonyms.add(partialSynonym);
160
	}
161
	
162
	protected boolean isPartialSynonym(Synonym synonym){
163
		return this.partialSynonyms.contains(synonym);
164
	}
165

    
166
	/**
167
	 * @return the mediaUrl
168
	 */
169
	public URL getMediaUrl() {
170
		return mediaUrl;
171
	}
172

    
173
	/**
174
	 * @param mediaUrl the mediaUrl to set
175
	 */
176
	public void setMediaUrl(URL mediaUrl) {
177
		this.mediaUrl = mediaUrl;
178
	}
179

    
180
	/**
181
	 * @return the mediaPath
182
	 */
183
	public File getMediaPath() {
184
		return mediaPath;
185
	}
186

    
187
	/**
188
	 * @param mediaPath the mediaPath to set
189
	 */
190
	public void setMediaPath(File mediaPath) {
191
		this.mediaPath = mediaPath;
192
	}
193
	
194
	public void setMediaPath(String mediaPathString){
195
		this.mediaPath = new File(mediaPathString);
196
	}
197

    
198
	public void setMediaUrl(String mediaUrlString) {
199
		try {
200
			this.mediaUrl = new URL(mediaUrlString);
201
		} catch (MalformedURLException e) {
202
			logger.error("Could not set mediaUrl because it was malformed: " + mediaUrlString);
203
		}
204
	}
205

    
206
	/**
207
	 * @return the maximumNumberOfNameFacts
208
	 */
209
	public int getMaximumNumberOfNameFacts() {
210
		return maximumNumberOfNameFacts;
211
	}
212

    
213
	/**
214
	 * set to 0 for unlimited
215
	 * 
216
	 * @param maximumNumberOfNameFacts the maximumNumberOfNameFacts to set
217
	 */
218
	public void setMaximumNumberOfNameFacts(int maximumNumberOfNameFacts) {
219
		this.maximumNumberOfNameFacts = maximumNumberOfNameFacts;
220
	}
221

    
222
	/**
223
	 * If true, an authorTeam with authorTeamId = 0 is not imported (casus Salvador)
224
	 * @return the isIgnore0AuthorTeam
225
	 */
226
	public boolean isIgnore0AuthorTeam() {
227
		return isIgnore0AuthorTeam;
228
	}
229

    
230
	/**
231
	 * @param isIgnore0AuthorTeam the isIgnore0AuthorTeam to set
232
	 */
233
	public void setIgnore0AuthorTeam(boolean isIgnore0AuthorTeam) {
234
		this.isIgnore0AuthorTeam = isIgnore0AuthorTeam;
235
	}
236

    
237
	/**
238
	 * @return the namerelationshipTypeMethod
239
	 */
240
	public Method getNamerelationshipTypeMethod() {
241
		return namerelationshipTypeMethod;
242
	}
243

    
244
	/**
245
	 * @param namerelationshipTypeMethod the namerelationshipTypeMethod to set
246
	 */
247
	public void setNamerelationshipTypeMethod(Method namerelationshipTypeMethod) {
248
		this.namerelationshipTypeMethod = namerelationshipTypeMethod;
249
	}
250
	
251
	/**
252
	 * @return the taxonPublishMarker
253
	 */
254
	public BerlinModelTaxonImport.PublishMarkerChooser getTaxonPublishMarker() {
255
		return taxonPublishMarker;
256
	}
257

    
258
	/**
259
	 * @param taxonPublishMarker the taxonPublishMarker to set
260
	 */
261
	public void setTaxonPublishMarker(
262
			BerlinModelTaxonImport.PublishMarkerChooser taxonPublishMarker) {
263
		this.taxonPublishMarker = taxonPublishMarker;
264
	}
265

    
266

    
267

    
268
	/**
269
	 * @return the uuidForDefTermMethod
270
	 */
271
	public Method getUuidForDefTermMethod() {
272
		return uuidForDefTermMethod;
273
	}
274

    
275
	/**
276
	 * @param uuidForDefTermMethod the uuidForDefTermMethod to set
277
	 */
278
	public void setUuidForDefTermMethod(Method uuidForDefTermMethod) {
279
		this.uuidForDefTermMethod = uuidForDefTermMethod;
280
	}
281

    
282
	/**
283
	 * @return the userTransformationMethod
284
	 */
285
	public Method getUserTransformationMethod() {
286
		return userTransformationMethod;
287
	}
288

    
289
	/**
290
	 * @param userTransformationMethod the userTransformationMethod to set
291
	 */
292
	public void setUserTransformationMethod(Method userTransformationMethod) {
293
		this.userTransformationMethod = userTransformationMethod;
294
	}
295

    
296

    
297

    
298
	/**
299
	 * @return the nameTypeDesignationStatusMethod
300
	 */
301
	public Method getNameTypeDesignationStatusMethod() {
302
		return nameTypeDesignationStatusMethod;
303
	}
304

    
305

    
306
	/**
307
	 * @param nameTypeDesignationStatusMethod the nameTypeDesignationStatusMethod to set
308
	 */
309
	public void setNameTypeDesignationStatusMethod(
310
			Method nameTypeDesignationStatusMethod) {
311
		this.nameTypeDesignationStatusMethod = nameTypeDesignationStatusMethod;
312
	}
313
	
314
	/**
315
	 * @return the limitSave
316
	 */
317
	public int getRecordsPerTransaction() {
318
		return recordsPerTransaction;
319
	}
320

    
321
	/**
322
	 * @param limitSave the limitSave to set
323
	 */
324
	public void setRecordsPerTransaction(int recordsPerTransaction) {
325
		this.recordsPerTransaction = recordsPerTransaction;
326
	}
327

    
328
}
(6-6/20)