Project

General

Profile

Download (16.3 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

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

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

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

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

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

    
426

    
427

    
428
	public String getTaxonTable() {
429
		return this.taxonTable ;
430
	}
431

    
432
	/**
433
	 * @param taxonTable the taxonTable to set
434
	 */
435
	public void setTaxonTable(String taxonTable) {
436
		this.taxonTable = taxonTable;
437
	}
438

    
439

    
440

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

    
452
	/**
453
	 * @param relTaxaIdQuery the relTaxaIdQuery to set
454
	 */
455
	public void setRelTaxaIdQuery(String relTaxaIdQuery) {
456
		this.relTaxaIdQuery = relTaxaIdQuery;
457
	}
458

    
459
	public String getRelTaxaIdQuery() {
460
		return this.relTaxaIdQuery ;
461
	}
462

    
463

    
464

    
465
	/**
466
	 * @return the nameIdTable
467
	 */
468
	public String getNameIdTable() {
469
		return nameIdTable;
470
	}
471

    
472

    
473

    
474
	/**
475
	 * @param nameIdTable the nameIdTable to set
476
	 */
477
	public void setNameIdTable(String nameIdTable) {
478
		this.nameIdTable = nameIdTable;
479
	}
480

    
481

    
482

    
483
	public void setReferenceIdTable(String referenceIdTable) {
484
		this.referenceIdTable = referenceIdTable;
485
	}
486

    
487
	public String getReferenceIdTable() {
488
		return referenceIdTable;
489
	}
490

    
491

    
492

    
493
	public void setFactFilter(String factFilter) {
494
		this.factFilter = factFilter;
495
	}
496

    
497

    
498

    
499
	public String getFactFilter() {
500
		return factFilter;
501
	}
502

    
503

    
504

    
505
	public String getOccurrenceFilter() {
506
		return occurrenceFilter;
507
	}
508

    
509

    
510

    
511
	public void setOccurrenceFilter(String occurrenceFilter) {
512
		this.occurrenceFilter = occurrenceFilter;
513
	}
514

    
515

    
516

    
517
	public String getCommonNameFilter() {
518
		return commonNameFilter;
519
	}
520

    
521

    
522

    
523
	public void setCommonNameFilter(String commonNameFilter) {
524
		this.commonNameFilter = commonNameFilter;
525
	}
526

    
527

    
528

    
529
	public String getOccurrenceSourceFilter() {
530
		return occurrenceSourceFilter;
531
	}
532

    
533

    
534

    
535
	public void setOccurrenceSourceFilter(String occurrenceSourceFilter) {
536
		this.occurrenceSourceFilter = occurrenceSourceFilter;
537
	}
538

    
539

    
540

    
541
	public String getWebMarkerFilter() {
542
		return webMarkerFilter;
543
	}
544

    
545

    
546

    
547
	public void setWebMarkerFilter(String webMarkerFilter) {
548
		this.webMarkerFilter = webMarkerFilter;
549
	}
550

    
551

    
552

    
553
	public boolean isUseSingleClassification() {
554
		return useSingleClassification;
555
	}
556

    
557

    
558

    
559
	public void setUseSingleClassification(boolean useSingleClassification) {
560
		this.useSingleClassification = useSingleClassification;
561
	}
562

    
563

    
564
	public void setAuthorTeamFilter(String authorTeamFilter) {
565
		this.authorTeamFilter = authorTeamFilter;
566
	}
567

    
568
	public String getAuthorTeamFilter() {
569
		return authorTeamFilter;
570
	}
571

    
572

    
573

    
574
	public String getAuthorFilter() {
575
		return authorFilter;
576
	}
577

    
578

    
579

    
580
	public void setAuthorFilter(String authorFilter) {
581
		this.authorFilter = authorFilter;
582
	}
583

    
584

    
585

    
586
	public boolean isSwitchSpeciesGroup() {
587
		return switchSpeciesGroup;
588
	}
589

    
590

    
591

    
592
	/**
593
	 * If true, the rankId for speicesGroup is changed from 59 to 57 and
594
	 * 59 is used for coll. species instead
595
	 * @param switchSpeciesGroup
596
	 */
597
	public void setSwitchSpeciesGroup(boolean switchSpeciesGroup) {
598
		this.switchSpeciesGroup = switchSpeciesGroup;
599
	}
600

    
601

    
602

    
603
	public boolean isSplitTdwgCodes() {
604
		return isSplitTdwgCodes;
605
	}
606
	
607
	
608
	public void setSplitTdwgCodes(boolean isSplitTdwgCodes) {
609
		this.isSplitTdwgCodes = isSplitTdwgCodes;
610
	}
611

    
612

    
613
	public Method getMakeUrlForTaxon() {
614
		return makeUrlForTaxon;
615
	}
616

    
617
	public void setMakeUrlForTaxon(Method makeUrlForTaxon) {
618
		this.makeUrlForTaxon = makeUrlForTaxon;
619
	}
620

    
621

    
622

    
623
	public String getInfrGenericRankAbbrev() {
624
		return infrGenericRankAbbrev;
625
	}
626

    
627

    
628

    
629
	public void setInfrGenericRankAbbrev(String infrGenericRankAbbrev) {
630
		this.infrGenericRankAbbrev = infrGenericRankAbbrev;
631
	}
632

    
633

    
634

    
635
	public String getInfrSpecificRankAbbrev() {
636
		return infrSpecificRankAbbrev;
637
	}
638

    
639

    
640

    
641
	public void setInfrSpecificRankAbbrev(String infrSpecificRankAbbrev) {
642
		this.infrSpecificRankAbbrev = infrSpecificRankAbbrev;
643
	}
644

    
645

    
646

    
647
	public boolean isRemoveHttpMapsAnchor() {
648
		return removeHttpMapsAnchor;
649
	}
650

    
651

    
652

    
653
	public void setRemoveHttpMapsAnchor(boolean removeHttpMapsAnchor) {
654
		this.removeHttpMapsAnchor = removeHttpMapsAnchor;
655
	}
656

    
657

    
658

    
659
	public boolean isIncludeFlatClassifications() {
660
		return includeFlatClassifications;
661
	}
662

    
663

    
664

    
665
	public void setIncludeFlatClassifications(boolean includeFlatClassifications) {
666
		this.includeFlatClassifications = includeFlatClassifications;
667
	}
668

    
669

    
670

    
671
	public boolean isIncludesAreaEmCode() {
672
		return includesEmCode;
673
	}
674

    
675

    
676

    
677
	public void setIncludesEmCode(boolean includesEmCode) {
678
		this.includesEmCode = includesEmCode;
679
		
680
	}
681

    
682

    
683

    
684
	public boolean isAllowInfraSpecTaxonRank() {
685
		return allowInfraSpecTaxonRank ;
686
	}
687

    
688
	public void setAllowInfraSpecTaxonRank(boolean allowInfraSpecTaxonRank) {
689
		this.allowInfraSpecTaxonRank = allowInfraSpecTaxonRank;
690
	}
691

    
692

    
693

    
694
	public boolean isIncludeAllNonMisappliedRelatedClassifications() {
695
		return includeAllNonMisappliedRelatedClassifications;
696
	}
697

    
698

    
699

    
700
	public void setIncludeAllNonMisappliedRelatedClassifications(
701
			boolean includeAllNonMisappliedRelatedClassifications) {
702
		this.includeAllNonMisappliedRelatedClassifications = includeAllNonMisappliedRelatedClassifications;
703
	}
704

    
705

    
706

    
707
	public boolean isUseEmAreaVocabulary() {
708
		return useEmAreaVocabulary;
709
	}
710

    
711

    
712

    
713
	public void setUseEmAreaVocabulary(boolean useEmAreaVocabulary) {
714
		this.useEmAreaVocabulary = useEmAreaVocabulary;
715
	}
716

    
717
}
(6-6/21)