Project

General

Profile

Download (16.2 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.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.in.BerlinModelTaxonImport.PublishMarkerChooser;
23
import eu.etaxonomy.cdm.io.berlinModel.in.validation.BerlinModelGeneralImportValidator;
24
import eu.etaxonomy.cdm.io.common.DbImportConfiguratorBase;
25
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
26
import eu.etaxonomy.cdm.io.common.Source;
27
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
28
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
29
import eu.etaxonomy.cdm.model.taxon.Synonym;
30

    
31
/**
32
 * @author a.mueller
33
 * @created 20.03.2008
34
 */
35
public class BerlinModelImportConfigurator extends DbImportConfiguratorBase<BerlinModelImportState> implements IImportConfigurator{
36
	private static Logger logger = Logger.getLogger(BerlinModelImportConfigurator.class);
37

    
38
	public static BerlinModelImportConfigurator NewInstance(Source berlinModelSource, ICdmDataSource destination){
39
			return new BerlinModelImportConfigurator(berlinModelSource, destination);
40
	}
41

    
42
	private PublishMarkerChooser taxonPublishMarker = PublishMarkerChooser.ALL;
43
	
44
	//TODO
45
	private static IInputTransformer defaultTransformer = null;
46
	
47
	private boolean doNameStatus = true;
48
	private boolean doRelNames = true;
49
	private boolean doCommonNames = true;
50
	private boolean doOccurrence = true;
51
	private boolean doMarker = true;
52
	private boolean doUser = true;
53
	private boolean doFacts = true;
54
	private boolean doNameFacts = true;
55
	private boolean doAuthors = true;
56
	private DO_REFERENCES doReferences = DO_REFERENCES.ALL;
57
	private boolean doTaxonNames = true;
58
	private boolean doTypes = true;
59
	
60
	//taxa
61
	private boolean doTaxa = true;
62
	private boolean doRelTaxa = true;
63

    
64
	private boolean useSingleClassification = false;
65
	private boolean includeFlatClassifications = false;  //concepts with no taxon relationship (even no misapplied name or synonym rel)
66
	private boolean includeAllNonMisappliedRelatedClassifications = false;  //all concepts with any relationship except for misapplied name relationships
67
	
68
	//occurrences
69
	private boolean isSplitTdwgCodes = true;
70
	
71
	private boolean useEmAreaVocabulary = false;
72

    
73
	private boolean includesEmCode = true;  // in Campanula we do not have an EMCOde
74
	private boolean allowInfraSpecTaxonRank = true; 
75

    
76
	private Method namerelationshipTypeMethod;
77
	private Method uuidForDefTermMethod;
78
	private Method nameTypeDesignationStatusMethod;
79
	
80
	private Set<Synonym> proParteSynonyms = new HashSet<Synonym>();
81
	private Set<Synonym> partialSynonyms = new HashSet<Synonym>();
82
	
83
	// NameFact stuff
84
	private URL mediaUrl;
85
	private File mediaPath;
86
	private int maximumNumberOfNameFacts;
87
	private boolean isIgnore0AuthorTeam = false;
88

    
89
	private boolean switchSpeciesGroup = false;
90
	
91
	//Term labels
92
	private String infrGenericRankAbbrev = null;
93
	private String infrSpecificRankAbbrev = null;
94
	
95
	private boolean removeHttpMapsAnchor = false;
96
	
97
	//Data Filter
98

    
99
	private String taxonTable = "PTaxon";
100
	private String classificationQuery = null;
101
	private String relTaxaIdQuery = null;
102
	private String nameIdTable = null;
103
	private String referenceIdTable = null;
104
	private String authorTeamFilter = null;
105
	private String authorFilter = null;
106
	private String factFilter = null;
107
	private String commonNameFilter = null;
108
	private String occurrenceFilter = null;
109
	private String occurrenceSourceFilter = null;
110
	private String webMarkerFilter = null;
111
	
112
	//specific functions
113
	private Method 	makeUrlForTaxon = null;
114

    
115
	protected void makeIoClassList(){
116
		ioClassList = new Class[]{
117
				BerlinModelGeneralImportValidator.class
118
				, BerlinModelUserImport.class
119
				, BerlinModelAuthorImport.class
120
				, BerlinModelAuthorTeamImport.class
121
				, BerlinModelRefDetailImport.class
122
				, BerlinModelReferenceImport.class
123
				, BerlinModelTaxonNameImport.class
124
				, BerlinModelTaxonNameRelationImport.class
125
				, BerlinModelNameStatusImport.class
126
				, BerlinModelNameFactsImport.class
127
				, BerlinModelTypesImport.class
128
				, BerlinModelTaxonImport.class
129
				, BerlinModelTaxonRelationImport.class
130
				, BerlinModelCommonNamesImport.class
131
				, BerlinModelFactsImport.class
132
				, BerlinModelOccurrenceImport.class
133
				, BerlinModelOccurrenceSourceImport.class
134
				, BerlinModelWebMarkerCategoryImport.class
135
				, BerlinModelWebMarkerImport.class
136
		};	
137
	}
138
	
139
	
140
	
141
	/* (non-Javadoc)
142
	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
143
	 */
144
	public BerlinModelImportState getNewState() {
145
		return new BerlinModelImportState(this);
146
	}
147

    
148

    
149

    
150
	/**
151
	 * @param berlinModelSource
152
	 * @param sourceReference
153
	 * @param destination
154
	 */
155
	protected BerlinModelImportConfigurator(Source berlinModelSource, ICdmDataSource destination) {
156
	   super(berlinModelSource, destination, NomenclaturalCode.ICNAFP, defaultTransformer); //default for Berlin Model
157
	}
158
	
159
	
160
	/**
161
	 * Import name relationships yes/no?.
162
	 * @return
163
	 */
164
	public boolean isDoRelNames() {
165
		return doRelNames;
166
	}
167
	public void setDoRelNames(boolean doRelNames) {
168
		this.doRelNames = doRelNames;
169
	}
170
	
171
	
172
	
173
	protected void addProParteSynonym(Synonym proParteSynonym){
174
		this.proParteSynonyms.add(proParteSynonym);
175
	}
176
	
177
	protected boolean isProParteSynonym(Synonym synonym){
178
		return this.proParteSynonyms.contains(synonym);
179
	}
180
	
181
	protected void addPartialSynonym(Synonym partialSynonym){
182
		this.partialSynonyms.add(partialSynonym);
183
	}
184
	
185
	protected boolean isPartialSynonym(Synonym synonym){
186
		return this.partialSynonyms.contains(synonym);
187
	}
188

    
189
	/**
190
	 * @return the mediaUrl
191
	 */
192
	public URL getMediaUrl() {
193
		return mediaUrl;
194
	}
195

    
196
	/**
197
	 * @param mediaUrl the mediaUrl to set
198
	 */
199
	public void setMediaUrl(URL mediaUrl) {
200
		this.mediaUrl = mediaUrl;
201
	}
202

    
203
	/**
204
	 * @return the mediaPath
205
	 */
206
	public File getMediaPath() {
207
		return mediaPath;
208
	}
209

    
210
	/**
211
	 * @param mediaPath the mediaPath to set
212
	 */
213
	public void setMediaPath(File mediaPath) {
214
		this.mediaPath = mediaPath;
215
	}
216
	
217
	public void setMediaPath(String mediaPathString){
218
		this.mediaPath = new File(mediaPathString);
219
	}
220

    
221
	public void setMediaUrl(String mediaUrlString) {
222
		try {
223
			this.mediaUrl = new URL(mediaUrlString);
224
		} catch (MalformedURLException e) {
225
			logger.error("Could not set mediaUrl because it was malformed: " + mediaUrlString);
226
		}
227
	}
228

    
229
	/**
230
	 * @return the maximumNumberOfNameFacts
231
	 */
232
	public int getMaximumNumberOfNameFacts() {
233
		return maximumNumberOfNameFacts;
234
	}
235

    
236
	/**
237
	 * set to 0 for unlimited
238
	 * 
239
	 * @param maximumNumberOfNameFacts the maximumNumberOfNameFacts to set
240
	 */
241
	public void setMaximumNumberOfNameFacts(int maximumNumberOfNameFacts) {
242
		this.maximumNumberOfNameFacts = maximumNumberOfNameFacts;
243
	}
244

    
245
	/**
246
	 * If true, an authorTeam with authorTeamId = 0 is not imported (casus Salvador)
247
	 * @return the isIgnore0AuthorTeam
248
	 */
249
	public boolean isIgnore0AuthorTeam() {
250
		return isIgnore0AuthorTeam;
251
	}
252

    
253
	/**
254
	 * @param isIgnore0AuthorTeam the isIgnore0AuthorTeam to set
255
	 */
256
	public void setIgnore0AuthorTeam(boolean isIgnore0AuthorTeam) {
257
		this.isIgnore0AuthorTeam = isIgnore0AuthorTeam;
258
	}
259

    
260
	/**
261
	 * @return the namerelationshipTypeMethod
262
	 */
263
	public Method getNamerelationshipTypeMethod() {
264
		return namerelationshipTypeMethod;
265
	}
266

    
267
	/**
268
	 * @param namerelationshipTypeMethod the namerelationshipTypeMethod to set
269
	 */
270
	public void setNamerelationshipTypeMethod(Method namerelationshipTypeMethod) {
271
		this.namerelationshipTypeMethod = namerelationshipTypeMethod;
272
	}
273
	
274
	/**
275
	 * @return the taxonPublishMarker
276
	 */
277
	public BerlinModelTaxonImport.PublishMarkerChooser getTaxonPublishMarker() {
278
		return taxonPublishMarker;
279
	}
280

    
281
	/**
282
	 * @param taxonPublishMarker the taxonPublishMarker to set
283
	 */
284
	public void setTaxonPublishMarker(
285
			BerlinModelTaxonImport.PublishMarkerChooser taxonPublishMarker) {
286
		this.taxonPublishMarker = taxonPublishMarker;
287
	}
288

    
289

    
290

    
291
	/**
292
	 * @return the uuidForDefTermMethod
293
	 */
294
	public Method getUuidForDefTermMethod() {
295
		return uuidForDefTermMethod;
296
	}
297

    
298
	/**
299
	 * @param uuidForDefTermMethod the uuidForDefTermMethod to set
300
	 */
301
	public void setUuidForDefTermMethod(Method uuidForDefTermMethod) {
302
		this.uuidForDefTermMethod = uuidForDefTermMethod;
303
	}
304

    
305

    
306

    
307

    
308
	/**
309
	 * @return the nameTypeDesignationStatusMethod
310
	 */
311
	public Method getNameTypeDesignationStatusMethod() {
312
		return nameTypeDesignationStatusMethod;
313
	}
314

    
315

    
316
	/**
317
	 * @param nameTypeDesignationStatusMethod the nameTypeDesignationStatusMethod to set
318
	 */
319
	public void setNameTypeDesignationStatusMethod(
320
			Method nameTypeDesignationStatusMethod) {
321
		this.nameTypeDesignationStatusMethod = nameTypeDesignationStatusMethod;
322
	}
323
	
324
	public boolean isDoNameStatus() {
325
		return doNameStatus;
326
	}
327
	public void setDoNameStatus(boolean doNameStatus) {
328
		this.doNameStatus = doNameStatus;
329
	}
330
	
331
	
332
	public boolean isDoCommonNames() {
333
		return doCommonNames;
334
	}
335

    
336

    
337
	/**
338
	 * @param doCommonNames
339
	 */
340
	public void setDoCommonNames(boolean doCommonNames) {
341
		this.doCommonNames = doCommonNames;
342
		
343
	}
344
	
345
	public boolean isDoFacts() {
346
		return doFacts;
347
	}
348
	public void setDoFacts(boolean doFacts) {
349
		this.doFacts = doFacts;
350
	}
351

    
352
	
353
	public boolean isDoOccurrence() {
354
		return doOccurrence;
355
	}
356
	public void setDoOccurrence(boolean doOccurrence) {
357
		this.doOccurrence = doOccurrence;
358
	}
359

    
360

    
361
	public boolean isDoMarker() {
362
		return doMarker;
363
	}
364

    
365
	public void setDoMarker(boolean doMarker) {
366
		this.doMarker = doMarker;
367
	}
368

    
369
	public boolean isDoUser() {
370
		return doUser;
371
	}
372
	public void setDoUser(boolean doUser) {
373
		this.doUser = doUser;
374
	}
375
	
376
	public boolean isDoNameFacts() {
377
		return doNameFacts;
378
	}
379
	public void setDoNameFacts(boolean doNameFacts) {
380
		this.doNameFacts = doNameFacts;
381
	}
382
	
383
	public boolean isDoAuthors() {
384
		return doAuthors;
385
	}
386
	public void setDoAuthors(boolean doAuthors) {
387
		this.doAuthors = doAuthors;
388
	}
389

    
390
	public DO_REFERENCES getDoReferences() {
391
		return doReferences;
392
	}
393
	public void setDoReferences(DO_REFERENCES doReferences) {
394
		this.doReferences = doReferences;
395
	}
396
	
397
	public boolean isDoTaxonNames() {
398
		return doTaxonNames;
399
	}
400
	public void setDoTaxonNames(boolean doTaxonNames) {
401
		this.doTaxonNames = doTaxonNames;
402
	}
403

    
404
	public boolean isDoTypes() {
405
		return doTypes;
406
	}
407
	public void setDoTypes(boolean doTypes) {
408
		this.doTypes = doTypes;
409
	}
410

    
411
	public boolean isDoTaxa() {
412
		return doTaxa;
413
	}
414
	public void setDoTaxa(boolean doTaxa) {
415
		this.doTaxa = doTaxa;
416
	}
417

    
418
	public boolean isDoRelTaxa() {
419
		return doRelTaxa;
420
	}
421
	public void setDoRelTaxa(boolean doRelTaxa) {
422
		this.doRelTaxa = doRelTaxa;
423
	}
424

    
425

    
426
	public String getTaxonTable() {
427
		return this.taxonTable ;
428
	}
429
	/**
430
	 * @param taxonTable the taxonTable to set
431
	 */
432
	public void setTaxonTable(String taxonTable) {
433
		this.taxonTable = taxonTable;
434
	}
435

    
436

    
437

    
438
	public String getClassificationQuery() {
439
		return this.classificationQuery ;
440
	}
441
	/**
442
	 * @param classificationQuery the classificationQuery to set
443
	 */
444
	public void setClassificationQuery(String classificationQuery) {
445
		this.classificationQuery = classificationQuery;
446
	}
447

    
448
	/**
449
	 * @param relTaxaIdQuery the relTaxaIdQuery to set
450
	 */
451
	public void setRelTaxaIdQuery(String relTaxaIdQuery) {
452
		this.relTaxaIdQuery = relTaxaIdQuery;
453
	}
454
	public String getRelTaxaIdQuery() {
455
		return this.relTaxaIdQuery ;
456
	}
457

    
458

    
459
	/**
460
	 * @return the nameIdTable
461
	 */
462
	public String getNameIdTable() {
463
		return nameIdTable;
464
	}
465
	/**
466
	 * @param nameIdTable the nameIdTable to set
467
	 */
468
	public void setNameIdTable(String nameIdTable) {
469
		this.nameIdTable = nameIdTable;
470
	}
471

    
472

    
473
	public void setReferenceIdTable(String referenceIdTable) {
474
		this.referenceIdTable = referenceIdTable;
475
	}
476
	public String getReferenceIdTable() {
477
		return referenceIdTable;
478
	}
479

    
480
	public void setFactFilter(String factFilter) {
481
		this.factFilter = factFilter;
482
	}
483
	public String getFactFilter() {
484
		return factFilter;
485
	}
486

    
487

    
488

    
489
	public String getOccurrenceFilter() {
490
		return occurrenceFilter;
491
	}
492
	public void setOccurrenceFilter(String occurrenceFilter) {
493
		this.occurrenceFilter = occurrenceFilter;
494
	}
495

    
496

    
497

    
498
	public String getCommonNameFilter() {
499
		return commonNameFilter;
500
	}
501
	public void setCommonNameFilter(String commonNameFilter) {
502
		this.commonNameFilter = commonNameFilter;
503
	}
504

    
505

    
506

    
507
	public String getOccurrenceSourceFilter() {
508
		return occurrenceSourceFilter;
509
	}
510
	public void setOccurrenceSourceFilter(String occurrenceSourceFilter) {
511
		this.occurrenceSourceFilter = occurrenceSourceFilter;
512
	}
513

    
514

    
515

    
516
	public String getWebMarkerFilter() {
517
		return webMarkerFilter;
518
	}
519
	public void setWebMarkerFilter(String webMarkerFilter) {
520
		this.webMarkerFilter = webMarkerFilter;
521
	}
522

    
523

    
524
	public boolean isUseSingleClassification() {
525
		return useSingleClassification;
526
	}
527
	public void setUseSingleClassification(boolean useSingleClassification) {
528
		this.useSingleClassification = useSingleClassification;
529
	}
530

    
531

    
532
	public void setAuthorTeamFilter(String authorTeamFilter) {
533
		this.authorTeamFilter = authorTeamFilter;
534
	}
535
	public String getAuthorTeamFilter() {
536
		return authorTeamFilter;
537
	}
538

    
539

    
540
	public String getAuthorFilter() {
541
		return authorFilter;
542
	}
543
	public void setAuthorFilter(String authorFilter) {
544
		this.authorFilter = authorFilter;
545
	}
546

    
547

    
548

    
549
	public boolean isSwitchSpeciesGroup() {
550
		return switchSpeciesGroup;
551
	}
552
	/**
553
	 * If true, the rankId for speicesGroup is changed from 59 to 57 and
554
	 * 59 is used for coll. species instead
555
	 * @param switchSpeciesGroup
556
	 */
557
	public void setSwitchSpeciesGroup(boolean switchSpeciesGroup) {
558
		this.switchSpeciesGroup = switchSpeciesGroup;
559
	}
560

    
561

    
562
	public boolean isSplitTdwgCodes() {
563
		return isSplitTdwgCodes;
564
	}
565
	public void setSplitTdwgCodes(boolean isSplitTdwgCodes) {
566
		this.isSplitTdwgCodes = isSplitTdwgCodes;
567
	}
568

    
569

    
570
	public Method getMakeUrlForTaxon() {
571
		return makeUrlForTaxon;
572
	}
573
	public void setMakeUrlForTaxon(Method makeUrlForTaxon) {
574
		this.makeUrlForTaxon = makeUrlForTaxon;
575
	}
576

    
577

    
578
	public String getInfrGenericRankAbbrev() {
579
		return infrGenericRankAbbrev;
580
	}
581
	public void setInfrGenericRankAbbrev(String infrGenericRankAbbrev) {
582
		this.infrGenericRankAbbrev = infrGenericRankAbbrev;
583
	}
584

    
585

    
586
	public String getInfrSpecificRankAbbrev() {
587
		return infrSpecificRankAbbrev;
588
	}
589
	public void setInfrSpecificRankAbbrev(String infrSpecificRankAbbrev) {
590
		this.infrSpecificRankAbbrev = infrSpecificRankAbbrev;
591
	}
592

    
593

    
594
	public boolean isRemoveHttpMapsAnchor() {
595
		return removeHttpMapsAnchor;
596
	}
597
	public void setRemoveHttpMapsAnchor(boolean removeHttpMapsAnchor) {
598
		this.removeHttpMapsAnchor = removeHttpMapsAnchor;
599
	}
600

    
601

    
602
	public boolean isIncludeFlatClassifications() {
603
		return includeFlatClassifications;
604
	}
605
	public void setIncludeFlatClassifications(boolean includeFlatClassifications) {
606
		this.includeFlatClassifications = includeFlatClassifications;
607
	}
608

    
609

    
610
	public boolean isIncludesAreaEmCode() {
611
		return includesEmCode;
612
	}
613
	public void setIncludesEmCode(boolean includesEmCode) {
614
		this.includesEmCode = includesEmCode;
615
		
616
	}
617

    
618

    
619
	public boolean isAllowInfraSpecTaxonRank() {
620
		return allowInfraSpecTaxonRank ;
621
	}
622
	public void setAllowInfraSpecTaxonRank(boolean allowInfraSpecTaxonRank) {
623
		this.allowInfraSpecTaxonRank = allowInfraSpecTaxonRank;
624
	}
625

    
626

    
627
	public boolean isIncludeAllNonMisappliedRelatedClassifications() {
628
		return includeAllNonMisappliedRelatedClassifications;
629
	}
630
	public void setIncludeAllNonMisappliedRelatedClassifications(boolean includeAllNonMisappliedRelatedClassifications) {
631
		this.includeAllNonMisappliedRelatedClassifications = includeAllNonMisappliedRelatedClassifications;
632
	}
633

    
634
	
635
	public boolean isUseEmAreaVocabulary() {
636
		return useEmAreaVocabulary;
637
	}
638
	public void setUseEmAreaVocabulary(boolean useEmAreaVocabulary) {
639
		this.useEmAreaVocabulary = useEmAreaVocabulary;
640
	}
641

    
642
}
(6-6/21)