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;
|
11
|
|
12
|
import java.io.File;
|
13
|
import java.net.MalformedURLException;
|
14
|
import java.net.URL;
|
15
|
import java.util.HashSet;
|
16
|
import java.util.Set;
|
17
|
|
18
|
import org.apache.log4j.Logger;
|
19
|
|
20
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
21
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
22
|
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
|
23
|
import eu.etaxonomy.cdm.io.common.Source;
|
24
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
25
|
import eu.etaxonomy.cdm.model.reference.Database;
|
26
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
27
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
28
|
|
29
|
/**
|
30
|
* @author a.mueller
|
31
|
* @created 20.03.2008
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public class BerlinModelImportConfigurator extends ImportConfiguratorBase implements IImportConfigurator{
|
35
|
private static Logger logger = Logger.getLogger(BerlinModelImportConfigurator.class);
|
36
|
|
37
|
public static BerlinModelImportConfigurator NewInstance(Source berlinModelSource, ICdmDataSource destination){
|
38
|
return new BerlinModelImportConfigurator(berlinModelSource, destination);
|
39
|
}
|
40
|
|
41
|
private Set<Synonym> proParteSynonyms = new HashSet<Synonym>();
|
42
|
private Set<Synonym> partialSynonyms = new HashSet<Synonym>();
|
43
|
|
44
|
// NameFact stuff
|
45
|
private URL mediaUrl;
|
46
|
private File mediaPath;
|
47
|
private int maximumNumberOfNameFacts;
|
48
|
|
49
|
protected void makeIoClassList(){
|
50
|
ioClassList = new Class[]{
|
51
|
BerlinModelAuthorImport.class
|
52
|
, BerlinModelReferenceImport.class
|
53
|
, BerlinModelTaxonNameImport.class
|
54
|
, BerlinModelTaxonNameRelationImport.class
|
55
|
, BerlinModelNameStatusImport.class
|
56
|
, BerlinModelNameFactsImport.class
|
57
|
, BerlinModelTypesImport.class
|
58
|
, BerlinModelTaxonImport.class
|
59
|
, BerlinModelTaxonRelationImport.class
|
60
|
, BerlinModelFactsImport.class
|
61
|
, BerlinModelOccurrenceImport.class
|
62
|
};
|
63
|
|
64
|
}
|
65
|
|
66
|
/**
|
67
|
* @param berlinModelSource
|
68
|
* @param sourceReference
|
69
|
* @param destination
|
70
|
*/
|
71
|
private BerlinModelImportConfigurator(Source berlinModelSource, ICdmDataSource destination) {
|
72
|
super();
|
73
|
setNomenclaturalCode(NomenclaturalCode.ICBN); //default for Berlin Model
|
74
|
setSource(berlinModelSource);
|
75
|
setDestination(destination);
|
76
|
}
|
77
|
|
78
|
|
79
|
public Source getSource() {
|
80
|
return (Source)super.getSource();
|
81
|
}
|
82
|
public void setSource(Source berlinModelSource) {
|
83
|
super.setSource(berlinModelSource);
|
84
|
}
|
85
|
|
86
|
/* (non-Javadoc)
|
87
|
* @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
|
88
|
*/
|
89
|
public ReferenceBase getSourceReference() {
|
90
|
if (sourceReference == null){
|
91
|
sourceReference = Database.NewInstance();
|
92
|
if (getSource() != null){
|
93
|
sourceReference.setTitleCache(getSource().getDatabase());
|
94
|
}
|
95
|
}
|
96
|
return sourceReference;
|
97
|
}
|
98
|
|
99
|
|
100
|
/* (non-Javadoc)
|
101
|
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
|
102
|
*/
|
103
|
public String getSourceNameString() {
|
104
|
if (this.getSource() == null){
|
105
|
return null;
|
106
|
}else{
|
107
|
return this.getSource().getDatabase();
|
108
|
}
|
109
|
}
|
110
|
|
111
|
protected void addProParteSynonym(Synonym proParteSynonym){
|
112
|
this.proParteSynonyms.add(proParteSynonym);
|
113
|
}
|
114
|
|
115
|
protected boolean isProParteSynonym(Synonym synonym){
|
116
|
return this.proParteSynonyms.contains(synonym);
|
117
|
}
|
118
|
|
119
|
protected void addPartialSynonym(Synonym partialSynonym){
|
120
|
this.partialSynonyms.add(partialSynonym);
|
121
|
}
|
122
|
|
123
|
protected boolean isPartialSynonym(Synonym synonym){
|
124
|
return this.partialSynonyms.contains(synonym);
|
125
|
}
|
126
|
|
127
|
/**
|
128
|
* @return the mediaUrl
|
129
|
*/
|
130
|
public URL getMediaUrl() {
|
131
|
return mediaUrl;
|
132
|
}
|
133
|
|
134
|
/**
|
135
|
* @param mediaUrl the mediaUrl to set
|
136
|
*/
|
137
|
public void setMediaUrl(URL mediaUrl) {
|
138
|
this.mediaUrl = mediaUrl;
|
139
|
}
|
140
|
|
141
|
/**
|
142
|
* @return the mediaPath
|
143
|
*/
|
144
|
public File getMediaPath() {
|
145
|
return mediaPath;
|
146
|
}
|
147
|
|
148
|
/**
|
149
|
* @param mediaPath the mediaPath to set
|
150
|
*/
|
151
|
public void setMediaPath(File mediaPath) {
|
152
|
this.mediaPath = mediaPath;
|
153
|
}
|
154
|
|
155
|
public void setMediaPath(String mediaPathString){
|
156
|
this.mediaPath = new File(mediaPathString);
|
157
|
}
|
158
|
|
159
|
public void setMediaUrl(String mediaUrlString) {
|
160
|
try {
|
161
|
this.mediaUrl = new URL(mediaUrlString);
|
162
|
} catch (MalformedURLException e) {
|
163
|
logger.error("Could not set mediaUrl because it was malformed: " + mediaUrlString);
|
164
|
}
|
165
|
}
|
166
|
|
167
|
/**
|
168
|
* @return the maximumNumberOfNameFacts
|
169
|
*/
|
170
|
public int getMaximumNumberOfNameFacts() {
|
171
|
return maximumNumberOfNameFacts;
|
172
|
}
|
173
|
|
174
|
/**
|
175
|
* set to 0 for unlimited
|
176
|
*
|
177
|
* @param maximumNumberOfNameFacts the maximumNumberOfNameFacts to set
|
178
|
*/
|
179
|
public void setMaximumNumberOfNameFacts(int maximumNumberOfNameFacts) {
|
180
|
this.maximumNumberOfNameFacts = maximumNumberOfNameFacts;
|
181
|
}
|
182
|
|
183
|
}
|