2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.berlinModel
.in
;
13 import java
.lang
.reflect
.Method
;
14 import java
.net
.MalformedURLException
;
16 import java
.util
.HashSet
;
19 import org
.apache
.log4j
.Logger
;
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
;
39 public class BerlinModelImportConfigurator
extends ImportConfiguratorBase
<BerlinModelImportState
, Source
> implements IImportConfigurator
{
40 private static Logger logger
= Logger
.getLogger(BerlinModelImportConfigurator
.class);
42 public static BerlinModelImportConfigurator
NewInstance(Source berlinModelSource
, ICdmDataSource destination
){
43 return new BerlinModelImportConfigurator(berlinModelSource
, destination
);
46 private PublishMarkerChooser taxonPublishMarker
= PublishMarkerChooser
.ALL
;
49 private static IInputTransformer defaultTransformer
= null;
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;
65 private boolean doTaxa
= true;
66 private boolean doRelTaxa
= true;
68 private boolean useSingleClassification
= false;
71 private boolean isSplitTdwgCodes
= true;
73 /* Max number of records to be saved with one service call */
74 private int recordsPerTransaction
= 1000;
76 private Method namerelationshipTypeMethod
;
77 private Method uuidForDefTermMethod
;
78 private Method userTransformationMethod
;
79 private Method nameTypeDesignationStatusMethod
;
81 private Set
<Synonym
> proParteSynonyms
= new HashSet
<Synonym
>();
82 private Set
<Synonym
> partialSynonyms
= new HashSet
<Synonym
>();
86 private File mediaPath
;
87 private int maximumNumberOfNameFacts
;
88 private boolean isIgnore0AuthorTeam
= false;
90 private boolean switchSpeciesGroup
= false;
93 private String infrGenericRankAbbrev
= null;
94 private String infrSpecificRankAbbrev
= null;
96 private boolean removeHttpMapsAnchor
= false;
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;
114 private Method makeUrlForTaxon
= null;
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
143 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
145 public ImportStateBase
getNewState() {
146 return new BerlinModelImportState(this);
152 * @param berlinModelSource
153 * @param sourceReference
156 private BerlinModelImportConfigurator(Source berlinModelSource
, ICdmDataSource destination
) {
157 super(defaultTransformer
);
158 setNomenclaturalCode(NomenclaturalCode
.ICBN
); //default for Berlin Model
159 setSource(berlinModelSource
);
160 setDestination(destination
);
164 public Source
getSource() {
165 return (Source
)super.getSource();
167 public void setSource(Source berlinModelSource
) {
168 super.setSource(berlinModelSource
);
172 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
174 public Reference
getSourceReference() {
175 if (sourceReference
== null){
176 sourceReference
= ReferenceFactory
.newDatabase();
177 if (getSource() != null){
178 sourceReference
.setTitleCache(getSource().getDatabase(), true);
180 if (getSourceRefUuid() != null){
181 sourceReference
.setUuid(getSourceRefUuid());
184 return sourceReference
;
189 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
191 public String
getSourceNameString() {
192 if (this.getSource() == null){
195 return this.getSource().getDatabase();
200 * Import name relationships yes/no?.
203 public boolean isDoRelNames() {
206 public void setDoRelNames(boolean doRelNames
) {
207 this.doRelNames
= doRelNames
;
212 protected void addProParteSynonym(Synonym proParteSynonym
){
213 this.proParteSynonyms
.add(proParteSynonym
);
216 protected boolean isProParteSynonym(Synonym synonym
){
217 return this.proParteSynonyms
.contains(synonym
);
220 protected void addPartialSynonym(Synonym partialSynonym
){
221 this.partialSynonyms
.add(partialSynonym
);
224 protected boolean isPartialSynonym(Synonym synonym
){
225 return this.partialSynonyms
.contains(synonym
);
229 * @return the mediaUrl
231 public URL
getMediaUrl() {
236 * @param mediaUrl the mediaUrl to set
238 public void setMediaUrl(URL mediaUrl
) {
239 this.mediaUrl
= mediaUrl
;
243 * @return the mediaPath
245 public File
getMediaPath() {
250 * @param mediaPath the mediaPath to set
252 public void setMediaPath(File mediaPath
) {
253 this.mediaPath
= mediaPath
;
256 public void setMediaPath(String mediaPathString
){
257 this.mediaPath
= new File(mediaPathString
);
260 public void setMediaUrl(String mediaUrlString
) {
262 this.mediaUrl
= new URL(mediaUrlString
);
263 } catch (MalformedURLException e
) {
264 logger
.error("Could not set mediaUrl because it was malformed: " + mediaUrlString
);
269 * @return the maximumNumberOfNameFacts
271 public int getMaximumNumberOfNameFacts() {
272 return maximumNumberOfNameFacts
;
276 * set to 0 for unlimited
278 * @param maximumNumberOfNameFacts the maximumNumberOfNameFacts to set
280 public void setMaximumNumberOfNameFacts(int maximumNumberOfNameFacts
) {
281 this.maximumNumberOfNameFacts
= maximumNumberOfNameFacts
;
285 * If true, an authorTeam with authorTeamId = 0 is not imported (casus Salvador)
286 * @return the isIgnore0AuthorTeam
288 public boolean isIgnore0AuthorTeam() {
289 return isIgnore0AuthorTeam
;
293 * @param isIgnore0AuthorTeam the isIgnore0AuthorTeam to set
295 public void setIgnore0AuthorTeam(boolean isIgnore0AuthorTeam
) {
296 this.isIgnore0AuthorTeam
= isIgnore0AuthorTeam
;
300 * @return the namerelationshipTypeMethod
302 public Method
getNamerelationshipTypeMethod() {
303 return namerelationshipTypeMethod
;
307 * @param namerelationshipTypeMethod the namerelationshipTypeMethod to set
309 public void setNamerelationshipTypeMethod(Method namerelationshipTypeMethod
) {
310 this.namerelationshipTypeMethod
= namerelationshipTypeMethod
;
314 * @return the taxonPublishMarker
316 public BerlinModelTaxonImport
.PublishMarkerChooser
getTaxonPublishMarker() {
317 return taxonPublishMarker
;
321 * @param taxonPublishMarker the taxonPublishMarker to set
323 public void setTaxonPublishMarker(
324 BerlinModelTaxonImport
.PublishMarkerChooser taxonPublishMarker
) {
325 this.taxonPublishMarker
= taxonPublishMarker
;
331 * @return the uuidForDefTermMethod
333 public Method
getUuidForDefTermMethod() {
334 return uuidForDefTermMethod
;
338 * @param uuidForDefTermMethod the uuidForDefTermMethod to set
340 public void setUuidForDefTermMethod(Method uuidForDefTermMethod
) {
341 this.uuidForDefTermMethod
= uuidForDefTermMethod
;
345 * @return the userTransformationMethod
347 public Method
getUserTransformationMethod() {
348 return userTransformationMethod
;
352 * @param userTransformationMethod the userTransformationMethod to set
354 public void setUserTransformationMethod(Method userTransformationMethod
) {
355 this.userTransformationMethod
= userTransformationMethod
;
361 * @return the nameTypeDesignationStatusMethod
363 public Method
getNameTypeDesignationStatusMethod() {
364 return nameTypeDesignationStatusMethod
;
369 * @param nameTypeDesignationStatusMethod the nameTypeDesignationStatusMethod to set
371 public void setNameTypeDesignationStatusMethod(
372 Method nameTypeDesignationStatusMethod
) {
373 this.nameTypeDesignationStatusMethod
= nameTypeDesignationStatusMethod
;
377 * @return the limitSave
379 public int getRecordsPerTransaction() {
380 return recordsPerTransaction
;
384 * @param limitSave the limitSave to set
386 public void setRecordsPerTransaction(int recordsPerTransaction
) {
387 this.recordsPerTransaction
= recordsPerTransaction
;
392 public boolean isDoNameStatus() {
395 public void setDoNameStatus(boolean doNameStatus
) {
396 this.doNameStatus
= doNameStatus
;
400 public boolean isDoCommonNames() {
401 return doCommonNames
;
406 * @param doCommonNames
408 public void setDoCommonNames(boolean doCommonNames
) {
409 this.doCommonNames
= doCommonNames
;
413 public boolean isDoFacts() {
416 public void setDoFacts(boolean doFacts
) {
417 this.doFacts
= doFacts
;
421 public boolean isDoOccurrence() {
424 public void setDoOccurrence(boolean doOccurrence
) {
425 this.doOccurrence
= doOccurrence
;
429 public boolean isDoMarker() {
433 public void setDoMarker(boolean doMarker
) {
434 this.doMarker
= doMarker
;
437 public boolean isDoUser() {
441 public void setDoUser(boolean doUser
) {
442 this.doUser
= doUser
;
445 public boolean isDoNameFacts() {
448 public void setDoNameFacts(boolean doNameFacts
) {
449 this.doNameFacts
= doNameFacts
;
452 public boolean isDoAuthors() {
455 public void setDoAuthors(boolean doAuthors
) {
456 this.doAuthors
= doAuthors
;
459 public DO_REFERENCES
getDoReferences() {
462 public void setDoReferences(DO_REFERENCES doReferences
) {
463 this.doReferences
= doReferences
;
466 public boolean isDoTaxonNames() {
469 public void setDoTaxonNames(boolean doTaxonNames
) {
470 this.doTaxonNames
= doTaxonNames
;
473 public boolean isDoTypes() {
476 public void setDoTypes(boolean doTypes
) {
477 this.doTypes
= doTypes
;
480 public boolean isDoTaxa() {
483 public void setDoTaxa(boolean doTaxa
) {
484 this.doTaxa
= doTaxa
;
487 public boolean isDoRelTaxa() {
490 public void setDoRelTaxa(boolean doRelTaxa
) {
491 this.doRelTaxa
= doRelTaxa
;
496 public String
getTaxonTable() {
497 return this.taxonTable
;
501 * @param taxonTable the taxonTable to set
503 public void setTaxonTable(String taxonTable
) {
504 this.taxonTable
= taxonTable
;
509 public String
getClassificationQuery() {
510 return this.classificationQuery
;
514 * @param classificationQuery the classificationQuery to set
516 public void setClassificationQuery(String classificationQuery
) {
517 this.classificationQuery
= classificationQuery
;
521 * @param relTaxaIdQuery the relTaxaIdQuery to set
523 public void setRelTaxaIdQuery(String relTaxaIdQuery
) {
524 this.relTaxaIdQuery
= relTaxaIdQuery
;
527 public String
getRelTaxaIdQuery() {
528 return this.relTaxaIdQuery
;
534 * @return the nameIdTable
536 public String
getNameIdTable() {
543 * @param nameIdTable the nameIdTable to set
545 public void setNameIdTable(String nameIdTable
) {
546 this.nameIdTable
= nameIdTable
;
551 public void setReferenceIdTable(String referenceIdTable
) {
552 this.referenceIdTable
= referenceIdTable
;
555 public String
getReferenceIdTable() {
556 return referenceIdTable
;
561 public void setFactFilter(String factFilter
) {
562 this.factFilter
= factFilter
;
567 public String
getFactFilter() {
573 public String
getOccurrenceFilter() {
574 return occurrenceFilter
;
579 public void setOccurrenceFilter(String occurrenceFilter
) {
580 this.occurrenceFilter
= occurrenceFilter
;
585 public String
getCommonNameFilter() {
586 return commonNameFilter
;
591 public void setCommonNameFilter(String commonNameFilter
) {
592 this.commonNameFilter
= commonNameFilter
;
597 public String
getOccurrenceSourceFilter() {
598 return occurrenceSourceFilter
;
603 public void setOccurrenceSourceFilter(String occurrenceSourceFilter
) {
604 this.occurrenceSourceFilter
= occurrenceSourceFilter
;
609 public String
getWebMarkerFilter() {
610 return webMarkerFilter
;
615 public void setWebMarkerFilter(String webMarkerFilter
) {
616 this.webMarkerFilter
= webMarkerFilter
;
621 public boolean isUseSingleClassification() {
622 return useSingleClassification
;
627 public void setUseSingleClassification(boolean useSingleClassification
) {
628 this.useSingleClassification
= useSingleClassification
;
632 public void setAuthorTeamFilter(String authorTeamFilter
) {
633 this.authorTeamFilter
= authorTeamFilter
;
636 public String
getAuthorTeamFilter() {
637 return authorTeamFilter
;
642 public String
getAuthorFilter() {
648 public void setAuthorFilter(String authorFilter
) {
649 this.authorFilter
= authorFilter
;
654 public boolean isSwitchSpeciesGroup() {
655 return switchSpeciesGroup
;
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
665 public void setSwitchSpeciesGroup(boolean switchSpeciesGroup
) {
666 this.switchSpeciesGroup
= switchSpeciesGroup
;
671 public boolean isSplitTdwgCodes() {
672 return isSplitTdwgCodes
;
676 public void setSplitTdwgCodes(boolean isSplitTdwgCodes
) {
677 this.isSplitTdwgCodes
= isSplitTdwgCodes
;
681 public Method
getMakeUrlForTaxon() {
682 return makeUrlForTaxon
;
685 public void setMakeUrlForTaxon(Method makeUrlForTaxon
) {
686 this.makeUrlForTaxon
= makeUrlForTaxon
;
691 public String
getInfrGenericRankAbbrev() {
692 return infrGenericRankAbbrev
;
697 public void setInfrGenericRankAbbrev(String infrGenericRankAbbrev
) {
698 this.infrGenericRankAbbrev
= infrGenericRankAbbrev
;
703 public String
getInfrSpecificRankAbbrev() {
704 return infrSpecificRankAbbrev
;
709 public void setInfrSpecificRankAbbrev(String infrSpecificRankAbbrev
) {
710 this.infrSpecificRankAbbrev
= infrSpecificRankAbbrev
;
715 public boolean isRemoveHttpMapsAnchor() {
716 return removeHttpMapsAnchor
;
721 public void setRemoveHttpMapsAnchor(boolean removeHttpMapsAnchor
) {
722 this.removeHttpMapsAnchor
= removeHttpMapsAnchor
;