bugfix for wrong http anchor replacement
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / berlinModel / in / BerlinModelImportConfigurator.java
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.IImportConfigurator;
25 import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
26 import eu.etaxonomy.cdm.io.common.ImportStateBase;
27 import eu.etaxonomy.cdm.io.common.Source;
28 import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
29 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
30 import eu.etaxonomy.cdm.model.reference.Reference;
31 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
32 import eu.etaxonomy.cdm.model.taxon.Synonym;
33
34 /**
35 * @author a.mueller
36 * @created 20.03.2008
37 * @version 1.0
38 */
39 public class BerlinModelImportConfigurator extends ImportConfiguratorBase<BerlinModelImportState, Source> implements IImportConfigurator{
40 private static Logger logger = Logger.getLogger(BerlinModelImportConfigurator.class);
41
42 public static BerlinModelImportConfigurator NewInstance(Source berlinModelSource, ICdmDataSource destination){
43 return new BerlinModelImportConfigurator(berlinModelSource, destination);
44 }
45
46 private PublishMarkerChooser taxonPublishMarker = PublishMarkerChooser.ALL;
47
48 //TODO
49 private static IInputTransformer defaultTransformer = null;
50
51 private boolean doNameStatus = true;
52 private boolean doRelNames = true;
53 private boolean doCommonNames = true;
54 private boolean doOccurrence = true;
55 private boolean doMarker = true;
56 private boolean doUser = true;
57 private boolean doFacts = true;
58 private boolean doNameFacts = true;
59 private boolean doAuthors = true;
60 private DO_REFERENCES doReferences = DO_REFERENCES.ALL;
61 private boolean doTaxonNames = true;
62 private boolean doTypes = true;
63
64 //taxa
65 private boolean doTaxa = true;
66 private boolean doRelTaxa = true;
67
68 private boolean useSingleClassification = false;
69
70 //occurrences
71 private boolean isSplitTdwgCodes = true;
72
73 /* Max number of records to be saved with one service call */
74 private int recordsPerTransaction = 1000;
75
76 private Method namerelationshipTypeMethod;
77 private Method uuidForDefTermMethod;
78 private Method userTransformationMethod;
79 private Method nameTypeDesignationStatusMethod;
80
81 private Set<Synonym> proParteSynonyms = new HashSet<Synonym>();
82 private Set<Synonym> partialSynonyms = new HashSet<Synonym>();
83
84 // NameFact stuff
85 private URL mediaUrl;
86 private File mediaPath;
87 private int maximumNumberOfNameFacts;
88 private boolean isIgnore0AuthorTeam = false;
89
90 private boolean switchSpeciesGroup = false;
91
92 //Term labels
93 private String infrGenericRankAbbrev = null;
94 private String infrSpecificRankAbbrev = null;
95
96 private boolean removeHttpMapsAnchor = false;
97
98 //Data Filter
99
100 private String taxonTable = "PTaxon";
101 private String classificationQuery = null;
102 private String relTaxaIdQuery = null;
103 private String nameIdTable = null;
104 private String referenceIdTable = null;
105 private String authorTeamFilter = null;
106 private String authorFilter = null;
107 private String factFilter = 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 ImportStateBase getNewState() {
146 return new BerlinModelImportState(this);
147 }
148
149
150
151 /**
152 * @param berlinModelSource
153 * @param sourceReference
154 * @param destination
155 */
156 private BerlinModelImportConfigurator(Source berlinModelSource, ICdmDataSource destination) {
157 super(defaultTransformer);
158 setNomenclaturalCode(NomenclaturalCode.ICBN); //default for Berlin Model
159 setSource(berlinModelSource);
160 setDestination(destination);
161 }
162
163
164 public Source getSource() {
165 return (Source)super.getSource();
166 }
167 public void setSource(Source berlinModelSource) {
168 super.setSource(berlinModelSource);
169 }
170
171 /* (non-Javadoc)
172 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
173 */
174 public Reference getSourceReference() {
175 if (sourceReference == null){
176 sourceReference = ReferenceFactory.newDatabase();
177 if (getSource() != null){
178 sourceReference.setTitleCache(getSource().getDatabase(), true);
179 }
180 if (getSourceRefUuid() != null){
181 sourceReference.setUuid(getSourceRefUuid());
182 }
183 }
184 return sourceReference;
185 }
186
187
188 /* (non-Javadoc)
189 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
190 */
191 public String getSourceNameString() {
192 if (this.getSource() == null){
193 return null;
194 }else{
195 return this.getSource().getDatabase();
196 }
197 }
198
199 /**
200 * Import name relationships yes/no?.
201 * @return
202 */
203 public boolean isDoRelNames() {
204 return doRelNames;
205 }
206 public void setDoRelNames(boolean doRelNames) {
207 this.doRelNames = doRelNames;
208 }
209
210
211
212 protected void addProParteSynonym(Synonym proParteSynonym){
213 this.proParteSynonyms.add(proParteSynonym);
214 }
215
216 protected boolean isProParteSynonym(Synonym synonym){
217 return this.proParteSynonyms.contains(synonym);
218 }
219
220 protected void addPartialSynonym(Synonym partialSynonym){
221 this.partialSynonyms.add(partialSynonym);
222 }
223
224 protected boolean isPartialSynonym(Synonym synonym){
225 return this.partialSynonyms.contains(synonym);
226 }
227
228 /**
229 * @return the mediaUrl
230 */
231 public URL getMediaUrl() {
232 return mediaUrl;
233 }
234
235 /**
236 * @param mediaUrl the mediaUrl to set
237 */
238 public void setMediaUrl(URL mediaUrl) {
239 this.mediaUrl = mediaUrl;
240 }
241
242 /**
243 * @return the mediaPath
244 */
245 public File getMediaPath() {
246 return mediaPath;
247 }
248
249 /**
250 * @param mediaPath the mediaPath to set
251 */
252 public void setMediaPath(File mediaPath) {
253 this.mediaPath = mediaPath;
254 }
255
256 public void setMediaPath(String mediaPathString){
257 this.mediaPath = new File(mediaPathString);
258 }
259
260 public void setMediaUrl(String mediaUrlString) {
261 try {
262 this.mediaUrl = new URL(mediaUrlString);
263 } catch (MalformedURLException e) {
264 logger.error("Could not set mediaUrl because it was malformed: " + mediaUrlString);
265 }
266 }
267
268 /**
269 * @return the maximumNumberOfNameFacts
270 */
271 public int getMaximumNumberOfNameFacts() {
272 return maximumNumberOfNameFacts;
273 }
274
275 /**
276 * set to 0 for unlimited
277 *
278 * @param maximumNumberOfNameFacts the maximumNumberOfNameFacts to set
279 */
280 public void setMaximumNumberOfNameFacts(int maximumNumberOfNameFacts) {
281 this.maximumNumberOfNameFacts = maximumNumberOfNameFacts;
282 }
283
284 /**
285 * If true, an authorTeam with authorTeamId = 0 is not imported (casus Salvador)
286 * @return the isIgnore0AuthorTeam
287 */
288 public boolean isIgnore0AuthorTeam() {
289 return isIgnore0AuthorTeam;
290 }
291
292 /**
293 * @param isIgnore0AuthorTeam the isIgnore0AuthorTeam to set
294 */
295 public void setIgnore0AuthorTeam(boolean isIgnore0AuthorTeam) {
296 this.isIgnore0AuthorTeam = isIgnore0AuthorTeam;
297 }
298
299 /**
300 * @return the namerelationshipTypeMethod
301 */
302 public Method getNamerelationshipTypeMethod() {
303 return namerelationshipTypeMethod;
304 }
305
306 /**
307 * @param namerelationshipTypeMethod the namerelationshipTypeMethod to set
308 */
309 public void setNamerelationshipTypeMethod(Method namerelationshipTypeMethod) {
310 this.namerelationshipTypeMethod = namerelationshipTypeMethod;
311 }
312
313 /**
314 * @return the taxonPublishMarker
315 */
316 public BerlinModelTaxonImport.PublishMarkerChooser getTaxonPublishMarker() {
317 return taxonPublishMarker;
318 }
319
320 /**
321 * @param taxonPublishMarker the taxonPublishMarker to set
322 */
323 public void setTaxonPublishMarker(
324 BerlinModelTaxonImport.PublishMarkerChooser taxonPublishMarker) {
325 this.taxonPublishMarker = taxonPublishMarker;
326 }
327
328
329
330 /**
331 * @return the uuidForDefTermMethod
332 */
333 public Method getUuidForDefTermMethod() {
334 return uuidForDefTermMethod;
335 }
336
337 /**
338 * @param uuidForDefTermMethod the uuidForDefTermMethod to set
339 */
340 public void setUuidForDefTermMethod(Method uuidForDefTermMethod) {
341 this.uuidForDefTermMethod = uuidForDefTermMethod;
342 }
343
344 /**
345 * @return the userTransformationMethod
346 */
347 public Method getUserTransformationMethod() {
348 return userTransformationMethod;
349 }
350
351 /**
352 * @param userTransformationMethod the userTransformationMethod to set
353 */
354 public void setUserTransformationMethod(Method userTransformationMethod) {
355 this.userTransformationMethod = userTransformationMethod;
356 }
357
358
359
360 /**
361 * @return the nameTypeDesignationStatusMethod
362 */
363 public Method getNameTypeDesignationStatusMethod() {
364 return nameTypeDesignationStatusMethod;
365 }
366
367
368 /**
369 * @param nameTypeDesignationStatusMethod the nameTypeDesignationStatusMethod to set
370 */
371 public void setNameTypeDesignationStatusMethod(
372 Method nameTypeDesignationStatusMethod) {
373 this.nameTypeDesignationStatusMethod = nameTypeDesignationStatusMethod;
374 }
375
376 /**
377 * @return the limitSave
378 */
379 public int getRecordsPerTransaction() {
380 return recordsPerTransaction;
381 }
382
383 /**
384 * @param limitSave the limitSave to set
385 */
386 public void setRecordsPerTransaction(int recordsPerTransaction) {
387 this.recordsPerTransaction = recordsPerTransaction;
388 }
389
390
391
392 public boolean isDoNameStatus() {
393 return doNameStatus;
394 }
395 public void setDoNameStatus(boolean doNameStatus) {
396 this.doNameStatus = doNameStatus;
397 }
398
399
400 public boolean isDoCommonNames() {
401 return doCommonNames;
402 }
403
404
405 /**
406 * @param doCommonNames
407 */
408 public void setDoCommonNames(boolean doCommonNames) {
409 this.doCommonNames = doCommonNames;
410
411 }
412
413 public boolean isDoFacts() {
414 return doFacts;
415 }
416 public void setDoFacts(boolean doFacts) {
417 this.doFacts = doFacts;
418 }
419
420
421 public boolean isDoOccurrence() {
422 return doOccurrence;
423 }
424 public void setDoOccurrence(boolean doOccurrence) {
425 this.doOccurrence = doOccurrence;
426 }
427
428
429 public boolean isDoMarker() {
430 return doMarker;
431 }
432
433 public void setDoMarker(boolean doMarker) {
434 this.doMarker = doMarker;
435 }
436
437 public boolean isDoUser() {
438 return doUser;
439 }
440
441 public void setDoUser(boolean doUser) {
442 this.doUser = doUser;
443 }
444
445 public boolean isDoNameFacts() {
446 return doNameFacts;
447 }
448 public void setDoNameFacts(boolean doNameFacts) {
449 this.doNameFacts = doNameFacts;
450 }
451
452 public boolean isDoAuthors() {
453 return doAuthors;
454 }
455 public void setDoAuthors(boolean doAuthors) {
456 this.doAuthors = doAuthors;
457 }
458
459 public DO_REFERENCES getDoReferences() {
460 return doReferences;
461 }
462 public void setDoReferences(DO_REFERENCES doReferences) {
463 this.doReferences = doReferences;
464 }
465
466 public boolean isDoTaxonNames() {
467 return doTaxonNames;
468 }
469 public void setDoTaxonNames(boolean doTaxonNames) {
470 this.doTaxonNames = doTaxonNames;
471 }
472
473 public boolean isDoTypes() {
474 return doTypes;
475 }
476 public void setDoTypes(boolean doTypes) {
477 this.doTypes = doTypes;
478 }
479
480 public boolean isDoTaxa() {
481 return doTaxa;
482 }
483 public void setDoTaxa(boolean doTaxa) {
484 this.doTaxa = doTaxa;
485 }
486
487 public boolean isDoRelTaxa() {
488 return doRelTaxa;
489 }
490 public void setDoRelTaxa(boolean doRelTaxa) {
491 this.doRelTaxa = doRelTaxa;
492 }
493
494
495
496 public String getTaxonTable() {
497 return this.taxonTable ;
498 }
499
500 /**
501 * @param taxonTable the taxonTable to set
502 */
503 public void setTaxonTable(String taxonTable) {
504 this.taxonTable = taxonTable;
505 }
506
507
508
509 public String getClassificationQuery() {
510 return this.classificationQuery ;
511 }
512
513 /**
514 * @param classificationQuery the classificationQuery to set
515 */
516 public void setClassificationQuery(String classificationQuery) {
517 this.classificationQuery = classificationQuery;
518 }
519
520 /**
521 * @param relTaxaIdQuery the relTaxaIdQuery to set
522 */
523 public void setRelTaxaIdQuery(String relTaxaIdQuery) {
524 this.relTaxaIdQuery = relTaxaIdQuery;
525 }
526
527 public String getRelTaxaIdQuery() {
528 return this.relTaxaIdQuery ;
529 }
530
531
532
533 /**
534 * @return the nameIdTable
535 */
536 public String getNameIdTable() {
537 return nameIdTable;
538 }
539
540
541
542 /**
543 * @param nameIdTable the nameIdTable to set
544 */
545 public void setNameIdTable(String nameIdTable) {
546 this.nameIdTable = nameIdTable;
547 }
548
549
550
551 public void setReferenceIdTable(String referenceIdTable) {
552 this.referenceIdTable = referenceIdTable;
553 }
554
555 public String getReferenceIdTable() {
556 return referenceIdTable;
557 }
558
559
560
561 public void setFactFilter(String factFilter) {
562 this.factFilter = factFilter;
563 }
564
565
566
567 public String getFactFilter() {
568 return factFilter;
569 }
570
571
572
573 public String getOccurrenceFilter() {
574 return occurrenceFilter;
575 }
576
577
578
579 public void setOccurrenceFilter(String occurrenceFilter) {
580 this.occurrenceFilter = occurrenceFilter;
581 }
582
583
584
585 public String getCommonNameFilter() {
586 return commonNameFilter;
587 }
588
589
590
591 public void setCommonNameFilter(String commonNameFilter) {
592 this.commonNameFilter = commonNameFilter;
593 }
594
595
596
597 public String getOccurrenceSourceFilter() {
598 return occurrenceSourceFilter;
599 }
600
601
602
603 public void setOccurrenceSourceFilter(String occurrenceSourceFilter) {
604 this.occurrenceSourceFilter = occurrenceSourceFilter;
605 }
606
607
608
609 public String getWebMarkerFilter() {
610 return webMarkerFilter;
611 }
612
613
614
615 public void setWebMarkerFilter(String webMarkerFilter) {
616 this.webMarkerFilter = webMarkerFilter;
617 }
618
619
620
621 public boolean isUseSingleClassification() {
622 return useSingleClassification;
623 }
624
625
626
627 public void setUseSingleClassification(boolean useSingleClassification) {
628 this.useSingleClassification = useSingleClassification;
629 }
630
631
632 public void setAuthorTeamFilter(String authorTeamFilter) {
633 this.authorTeamFilter = authorTeamFilter;
634 }
635
636 public String getAuthorTeamFilter() {
637 return authorTeamFilter;
638 }
639
640
641
642 public String getAuthorFilter() {
643 return authorFilter;
644 }
645
646
647
648 public void setAuthorFilter(String authorFilter) {
649 this.authorFilter = authorFilter;
650 }
651
652
653
654 public boolean isSwitchSpeciesGroup() {
655 return switchSpeciesGroup;
656 }
657
658
659
660 /**
661 * If true, the rankId for speicesGroup is changed from 59 to 57 and
662 * 59 is used for coll. species instead
663 * @param switchSpeciesGroup
664 */
665 public void setSwitchSpeciesGroup(boolean switchSpeciesGroup) {
666 this.switchSpeciesGroup = switchSpeciesGroup;
667 }
668
669
670
671 public boolean isSplitTdwgCodes() {
672 return isSplitTdwgCodes;
673 }
674
675
676 public void setSplitTdwgCodes(boolean isSplitTdwgCodes) {
677 this.isSplitTdwgCodes = isSplitTdwgCodes;
678 }
679
680
681 public Method getMakeUrlForTaxon() {
682 return makeUrlForTaxon;
683 }
684
685 public void setMakeUrlForTaxon(Method makeUrlForTaxon) {
686 this.makeUrlForTaxon = makeUrlForTaxon;
687 }
688
689
690
691 public String getInfrGenericRankAbbrev() {
692 return infrGenericRankAbbrev;
693 }
694
695
696
697 public void setInfrGenericRankAbbrev(String infrGenericRankAbbrev) {
698 this.infrGenericRankAbbrev = infrGenericRankAbbrev;
699 }
700
701
702
703 public String getInfrSpecificRankAbbrev() {
704 return infrSpecificRankAbbrev;
705 }
706
707
708
709 public void setInfrSpecificRankAbbrev(String infrSpecificRankAbbrev) {
710 this.infrSpecificRankAbbrev = infrSpecificRankAbbrev;
711 }
712
713
714
715 public boolean isRemoveHttpMapsAnchor() {
716 return removeHttpMapsAnchor;
717 }
718
719
720
721 public void setRemoveHttpMapsAnchor(boolean removeHttpMapsAnchor) {
722 this.removeHttpMapsAnchor = removeHttpMapsAnchor;
723 }
724
725
726
727
728
729
730 }