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
.common
.IImportConfigurator
;
23 import eu
.etaxonomy
.cdm
.io
.common
.ImportConfiguratorBase
;
24 import eu
.etaxonomy
.cdm
.io
.common
.ImportStateBase
;
25 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
26 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
27 import eu
.etaxonomy
.cdm
.model
.reference
.IDatabase
;
28 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
29 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
31 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelTaxonImport
.PublishMarkerChooser
;
38 public class BerlinModelImportConfigurator
extends ImportConfiguratorBase
<BerlinModelImportState
> implements IImportConfigurator
{
39 private static Logger logger
= Logger
.getLogger(BerlinModelImportConfigurator
.class);
41 public static BerlinModelImportConfigurator
NewInstance(Source berlinModelSource
, ICdmDataSource destination
){
42 return new BerlinModelImportConfigurator(berlinModelSource
, destination
);
45 private PublishMarkerChooser taxonPublishMarker
= PublishMarkerChooser
.ALL
;
47 private Method namerelationshipTypeMethod
;
48 private Method uuidForDefTermMethod
;
49 private Method userTransformationMethod
;
50 private Method nameTypeDesignationStatusMethod
;
52 private Set
<Synonym
> proParteSynonyms
= new HashSet
<Synonym
>();
53 private Set
<Synonym
> partialSynonyms
= new HashSet
<Synonym
>();
57 private File mediaPath
;
58 private int maximumNumberOfNameFacts
;
59 private boolean isIgnore0AuthorTeam
= false;
61 protected void makeIoClassList(){
62 ioClassList
= new Class
[]{
63 BerlinModelGeneralImport
.class,
64 BerlinModelUserImport
.class,
65 BerlinModelAuthorImport
.class,
66 BerlinModelAuthorTeamImport
.class
67 , BerlinModelReferenceImport
.class
68 , BerlinModelTaxonNameImport
.class
69 , BerlinModelTaxonNameRelationImport
.class
70 , BerlinModelNameStatusImport
.class
71 , BerlinModelNameFactsImport
.class
72 , BerlinModelTypesImport
.class
73 , BerlinModelTaxonImport
.class
74 , BerlinModelTaxonRelationImport
.class
75 , BerlinModelFactsImport
.class
76 , BerlinModelOccurrenceImport
.class
77 , BerlinModelWebMarkerCategoryImport
.class
78 , BerlinModelWebMarkerImport
.class
85 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
87 public ImportStateBase
getNewState() {
88 return new BerlinModelImportState(this);
94 * @param berlinModelSource
95 * @param sourceReference
98 private BerlinModelImportConfigurator(Source berlinModelSource
, ICdmDataSource destination
) {
100 setNomenclaturalCode(NomenclaturalCode
.ICBN
); //default for Berlin Model
101 setSource(berlinModelSource
);
102 setDestination(destination
);
106 public Source
getSource() {
107 return (Source
)super.getSource();
109 public void setSource(Source berlinModelSource
) {
110 super.setSource(berlinModelSource
);
114 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
116 public ReferenceBase
getSourceReference() {
117 ReferenceFactory refFactory
= ReferenceFactory
.newInstance();
118 if (sourceReference
== null){
119 sourceReference
= refFactory
.newDatabase();
120 if (getSource() != null){
121 sourceReference
.setTitleCache(getSource().getDatabase());
124 return sourceReference
;
129 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
131 public String
getSourceNameString() {
132 if (this.getSource() == null){
135 return this.getSource().getDatabase();
139 protected void addProParteSynonym(Synonym proParteSynonym
){
140 this.proParteSynonyms
.add(proParteSynonym
);
143 protected boolean isProParteSynonym(Synonym synonym
){
144 return this.proParteSynonyms
.contains(synonym
);
147 protected void addPartialSynonym(Synonym partialSynonym
){
148 this.partialSynonyms
.add(partialSynonym
);
151 protected boolean isPartialSynonym(Synonym synonym
){
152 return this.partialSynonyms
.contains(synonym
);
156 * @return the mediaUrl
158 public URL
getMediaUrl() {
163 * @param mediaUrl the mediaUrl to set
165 public void setMediaUrl(URL mediaUrl
) {
166 this.mediaUrl
= mediaUrl
;
170 * @return the mediaPath
172 public File
getMediaPath() {
177 * @param mediaPath the mediaPath to set
179 public void setMediaPath(File mediaPath
) {
180 this.mediaPath
= mediaPath
;
183 public void setMediaPath(String mediaPathString
){
184 this.mediaPath
= new File(mediaPathString
);
187 public void setMediaUrl(String mediaUrlString
) {
189 this.mediaUrl
= new URL(mediaUrlString
);
190 } catch (MalformedURLException e
) {
191 logger
.error("Could not set mediaUrl because it was malformed: " + mediaUrlString
);
196 * @return the maximumNumberOfNameFacts
198 public int getMaximumNumberOfNameFacts() {
199 return maximumNumberOfNameFacts
;
203 * set to 0 for unlimited
205 * @param maximumNumberOfNameFacts the maximumNumberOfNameFacts to set
207 public void setMaximumNumberOfNameFacts(int maximumNumberOfNameFacts
) {
208 this.maximumNumberOfNameFacts
= maximumNumberOfNameFacts
;
212 * If true, an authorTeam with authorTeamId = 0 is not imported (casus Salvador)
213 * @return the isIgnore0AuthorTeam
215 public boolean isIgnore0AuthorTeam() {
216 return isIgnore0AuthorTeam
;
220 * @param isIgnore0AuthorTeam the isIgnore0AuthorTeam to set
222 public void setIgnore0AuthorTeam(boolean isIgnore0AuthorTeam
) {
223 this.isIgnore0AuthorTeam
= isIgnore0AuthorTeam
;
227 * @return the namerelationshipTypeMethod
229 public Method
getNamerelationshipTypeMethod() {
230 return namerelationshipTypeMethod
;
234 * @param namerelationshipTypeMethod the namerelationshipTypeMethod to set
236 public void setNamerelationshipTypeMethod(Method namerelationshipTypeMethod
) {
237 this.namerelationshipTypeMethod
= namerelationshipTypeMethod
;
241 * @return the taxonPublishMarker
243 public BerlinModelTaxonImport
.PublishMarkerChooser
getTaxonPublishMarker() {
244 return taxonPublishMarker
;
248 * @param taxonPublishMarker the taxonPublishMarker to set
250 public void setTaxonPublishMarker(
251 BerlinModelTaxonImport
.PublishMarkerChooser taxonPublishMarker
) {
252 this.taxonPublishMarker
= taxonPublishMarker
;
258 * @return the uuidForDefTermMethod
260 public Method
getUuidForDefTermMethod() {
261 return uuidForDefTermMethod
;
265 * @param uuidForDefTermMethod the uuidForDefTermMethod to set
267 public void setUuidForDefTermMethod(Method uuidForDefTermMethod
) {
268 this.uuidForDefTermMethod
= uuidForDefTermMethod
;
272 * @return the userTransformationMethod
274 public Method
getUserTransformationMethod() {
275 return userTransformationMethod
;
279 * @param userTransformationMethod the userTransformationMethod to set
281 public void setUserTransformationMethod(Method userTransformationMethod
) {
282 this.userTransformationMethod
= userTransformationMethod
;
288 * @return the nameTypeDesignationStatusMethod
290 public Method
getNameTypeDesignationStatusMethod() {
291 return nameTypeDesignationStatusMethod
;
296 * @param nameTypeDesignationStatusMethod the nameTypeDesignationStatusMethod to set
298 public void setNameTypeDesignationStatusMethod(
299 Method nameTypeDesignationStatusMethod
) {
300 this.nameTypeDesignationStatusMethod
= nameTypeDesignationStatusMethod
;