Project

General

Profile

Download (16.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.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 refDetailFilter = null;
108
	private String commonNameFilter = null;
109
	private String occurrenceFilter = null;
110
	private String occurrenceSourceFilter = null;
111
	private String webMarkerFilter = null;
112
	
113
	//specific functions
114
	private Method 	makeUrlForTaxon = null;
115

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

    
149

    
150

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

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

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

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

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

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

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

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

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

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

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

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

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

    
290

    
291

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

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

    
306

    
307

    
308

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

    
316

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

    
337

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

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

    
361

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

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

    
370
	public boolean isDoUser() {
371
		return doUser;
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
	public String getTaxonTable() {
428
		return this.taxonTable ;
429
	}
430
	/**
431
	 * @param taxonTable the taxonTable to set
432
	 */
433
	public void setTaxonTable(String taxonTable) {
434
		this.taxonTable = taxonTable;
435
	}
436

    
437

    
438

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

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

    
459

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

    
473

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

    
481
	public void setFactFilter(String factFilter) {
482
		this.factFilter = factFilter;
483
	}
484
	public String getFactFilter() {
485
		return factFilter;
486
	}
487
	
488
	public void setRefDetailFilter(String refDetailFilter) {
489
		this.refDetailFilter = refDetailFilter;
490
	}
491
	public String getRefDetailFilter() {
492
		return refDetailFilter;
493
	}
494

    
495

    
496

    
497
	public String getOccurrenceFilter() {
498
		return occurrenceFilter;
499
	}
500
	public void setOccurrenceFilter(String occurrenceFilter) {
501
		this.occurrenceFilter = occurrenceFilter;
502
	}
503

    
504

    
505

    
506
	public String getCommonNameFilter() {
507
		return commonNameFilter;
508
	}
509
	public void setCommonNameFilter(String commonNameFilter) {
510
		this.commonNameFilter = commonNameFilter;
511
	}
512

    
513

    
514

    
515
	public String getOccurrenceSourceFilter() {
516
		return occurrenceSourceFilter;
517
	}
518
	public void setOccurrenceSourceFilter(String occurrenceSourceFilter) {
519
		this.occurrenceSourceFilter = occurrenceSourceFilter;
520
	}
521

    
522

    
523

    
524
	public String getWebMarkerFilter() {
525
		return webMarkerFilter;
526
	}
527
	public void setWebMarkerFilter(String webMarkerFilter) {
528
		this.webMarkerFilter = webMarkerFilter;
529
	}
530

    
531

    
532
	public boolean isUseSingleClassification() {
533
		return useSingleClassification;
534
	}
535
	public void setUseSingleClassification(boolean useSingleClassification) {
536
		this.useSingleClassification = useSingleClassification;
537
	}
538

    
539

    
540
	public void setAuthorTeamFilter(String authorTeamFilter) {
541
		this.authorTeamFilter = authorTeamFilter;
542
	}
543
	public String getAuthorTeamFilter() {
544
		return authorTeamFilter;
545
	}
546

    
547

    
548
	public String getAuthorFilter() {
549
		return authorFilter;
550
	}
551
	public void setAuthorFilter(String authorFilter) {
552
		this.authorFilter = authorFilter;
553
	}
554

    
555

    
556

    
557
	public boolean isSwitchSpeciesGroup() {
558
		return switchSpeciesGroup;
559
	}
560
	/**
561
	 * If true, the rankId for speicesGroup is changed from 59 to 57 and
562
	 * 59 is used for coll. species instead
563
	 * @param switchSpeciesGroup
564
	 */
565
	public void setSwitchSpeciesGroup(boolean switchSpeciesGroup) {
566
		this.switchSpeciesGroup = switchSpeciesGroup;
567
	}
568

    
569

    
570
	public boolean isSplitTdwgCodes() {
571
		return isSplitTdwgCodes;
572
	}
573
	public void setSplitTdwgCodes(boolean isSplitTdwgCodes) {
574
		this.isSplitTdwgCodes = isSplitTdwgCodes;
575
	}
576

    
577

    
578
	public Method getMakeUrlForTaxon() {
579
		return makeUrlForTaxon;
580
	}
581
	public void setMakeUrlForTaxon(Method makeUrlForTaxon) {
582
		this.makeUrlForTaxon = makeUrlForTaxon;
583
	}
584

    
585

    
586
	public String getInfrGenericRankAbbrev() {
587
		return infrGenericRankAbbrev;
588
	}
589
	public void setInfrGenericRankAbbrev(String infrGenericRankAbbrev) {
590
		this.infrGenericRankAbbrev = infrGenericRankAbbrev;
591
	}
592

    
593

    
594
	public String getInfrSpecificRankAbbrev() {
595
		return infrSpecificRankAbbrev;
596
	}
597
	public void setInfrSpecificRankAbbrev(String infrSpecificRankAbbrev) {
598
		this.infrSpecificRankAbbrev = infrSpecificRankAbbrev;
599
	}
600

    
601

    
602
	public boolean isRemoveHttpMapsAnchor() {
603
		return removeHttpMapsAnchor;
604
	}
605
	public void setRemoveHttpMapsAnchor(boolean removeHttpMapsAnchor) {
606
		this.removeHttpMapsAnchor = removeHttpMapsAnchor;
607
	}
608

    
609

    
610
	public boolean isIncludeFlatClassifications() {
611
		return includeFlatClassifications;
612
	}
613
	public void setIncludeFlatClassifications(boolean includeFlatClassifications) {
614
		this.includeFlatClassifications = includeFlatClassifications;
615
	}
616

    
617

    
618
	public boolean isIncludesAreaEmCode() {
619
		return includesEmCode;
620
	}
621
	public void setIncludesEmCode(boolean includesEmCode) {
622
		this.includesEmCode = includesEmCode;
623
		
624
	}
625

    
626

    
627
	public boolean isAllowInfraSpecTaxonRank() {
628
		return allowInfraSpecTaxonRank ;
629
	}
630
	public void setAllowInfraSpecTaxonRank(boolean allowInfraSpecTaxonRank) {
631
		this.allowInfraSpecTaxonRank = allowInfraSpecTaxonRank;
632
	}
633

    
634

    
635
	public boolean isIncludeAllNonMisappliedRelatedClassifications() {
636
		return includeAllNonMisappliedRelatedClassifications;
637
	}
638
	public void setIncludeAllNonMisappliedRelatedClassifications(boolean includeAllNonMisappliedRelatedClassifications) {
639
		this.includeAllNonMisappliedRelatedClassifications = includeAllNonMisappliedRelatedClassifications;
640
	}
641

    
642
	
643
	public boolean isUseEmAreaVocabulary() {
644
		return useEmAreaVocabulary;
645
	}
646
	public void setUseEmAreaVocabulary(boolean useEmAreaVocabulary) {
647
		this.useEmAreaVocabulary = useEmAreaVocabulary;
648
	}
649

    
650
}
(6-6/21)