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.globis;
|
11
|
|
12
|
import java.util.HashSet;
|
13
|
import java.util.Set;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import org.apache.commons.lang.StringUtils;
|
17
|
import org.apache.log4j.Logger;
|
18
|
|
19
|
import eu.etaxonomy.cdm.io.common.TdwgAreaProvider;
|
20
|
import eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase;
|
21
|
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
|
22
|
import eu.etaxonomy.cdm.model.common.ExtensionType;
|
23
|
import eu.etaxonomy.cdm.model.description.Feature;
|
24
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
25
|
import eu.etaxonomy.cdm.model.location.Country;
|
26
|
|
27
|
/**
|
28
|
* @author a.mueller
|
29
|
* @since 01.03.2010
|
30
|
* @version 1.0
|
31
|
*/
|
32
|
public final class GlobisTransformer extends InputTransformerBase {
|
33
|
private static final Logger logger = Logger.getLogger(GlobisTransformer.class);
|
34
|
|
35
|
|
36
|
//marker types
|
37
|
public static final UUID uuidCheckedMarkerType = UUID.fromString("f2a7926f-def1-49a6-b642-9b81e6b1e35c");
|
38
|
public static final UUID uuidOldRecordMarkerType = UUID.fromString("8616edc5-00d4-40ca-aca4-d48ec32231e9");
|
39
|
public static final UUID uuidNotAvailableMarkerType = UUID.fromString("6931e584-6fc2-44ab-9084-e6452f8cd5d1");
|
40
|
|
41
|
//extension types
|
42
|
public static final UUID uuidExtTypeNotAvailableReason = UUID.fromString("d7dd5632-8c65-4058-b804-d1291560ac4c");
|
43
|
|
44
|
public NamedArea getNamedAreaByKey(String area) {
|
45
|
Set<String> unhandledCountries = new HashSet<String>();
|
46
|
|
47
|
if (StringUtils.isBlank(area)){return null;
|
48
|
}else if (area.equals("Argentina")){return Country.ARGENTINAARGENTINEREPUBLIC();
|
49
|
}else if (area.equals("Bolivia")){return Country.BOLIVIAREPUBLICOF();
|
50
|
}else if (area.equals("Ghana")){return Country.GHANAREPUBLICOF();
|
51
|
}else if (area.equals("Angola")){return Country.ANGOLAREPUBLICOF();
|
52
|
}else if (area.equals("Tanzania")){return Country.TANZANIAUNITEDREPUBLICOF();
|
53
|
}else if (area.equals("China")){return Country.CHINAPEOPLESREPUBLICOF();
|
54
|
}else if (area.equals("Brunei")){return Country.BRUNEIDARUSSALAM();
|
55
|
}else if (area.equals("Australia")){return Country.AUSTRALIACOMMONWEALTHOF();
|
56
|
}else if (area.equals("Indonesia")){return Country.INDONESIAREPUBLICOF();
|
57
|
}else if (area.equals("Philippines")){return Country.PHILIPPINESREPUBLICOFTHE();
|
58
|
}else if (area.equals("Mongolia")){return Country.MONGOLIAMONGOLIANPEOPLESREPUBLIC();
|
59
|
}else if (area.equals("Russia")){return Country.RUSSIANFEDERATION();
|
60
|
}else if (area.equals("France")){return Country.FRANCEFRENCHREPUBLIC();
|
61
|
}else if (area.equals("Poland")){return Country.POLANDPOLISHPEOPLESREPUBLIC();
|
62
|
}else if (area.equals("Brazil")){return Country.BRAZILFEDERATIVEREPUBLICOF();
|
63
|
|
64
|
}else if (area.equals("Cuba")){return Country.BRAZILFEDERATIVEREPUBLICOF();
|
65
|
}else if (area.equals("Guatemala")){return Country.GUATEMALAREPUBLICOF();
|
66
|
}else if (area.equals("Colombia")){return Country.COLOMBIAREPUBLICOF();
|
67
|
}else if (area.equals("India")){return Country.INDIAREPUBLICOF();
|
68
|
|
69
|
}else if (area.equals("Mexico")){return Country.MEXICOUNITEDMEXICANSTATES();
|
70
|
}else if (area.equals("Peru")){return Country.PERUREPUBLICOF();
|
71
|
}else if (area.equals("Ecuador")){return Country.ECUADORREPUBLICOF();
|
72
|
}else if (area.equals("Venezuela")){return Country.VENEZUELABOLIVARIANREPUBLICOF();
|
73
|
}else if (area.equals("Guyana")){return Country.GUYANAREPUBLICOF();
|
74
|
}else if (area.equals("Panama")){return Country.PANAMAREPUBLICOF();
|
75
|
|
76
|
}else if (area.equals("Paraguay")){return Country.PARAGUAYREPUBLICOF();
|
77
|
}else if (area.equals("Suriname")){return Country.SURINAMEREPUBLICOF();
|
78
|
}else if (area.equals("Costa Rica")){return Country.COSTARICAREPUBLICOF();
|
79
|
}else if (area.equals("Ivory Coast")){return Country.COTEDIVOIREIVORYCOASTREPUBLICOFTHE();
|
80
|
|
81
|
}else if (area.equals("Benin")){return Country.BENINPEOPLESREPUBLICOF();
|
82
|
}else if (area.equalsIgnoreCase("Kenya")){return Country.KENYAREPUBLICOF();
|
83
|
}else if (area.equals("Uganda")){return Country.UGANDAREPUBLICOF();
|
84
|
}else if (area.equals("Zambia")){return Country.ZAMBIAREPUBLICOF();
|
85
|
}else if (area.equals("Rwanda")){return Country.RWANDARWANDESEREPUBLIC();
|
86
|
}else if (area.equals("South Africa")){return Country.SOUTHAFRICAREPUBLICOF();
|
87
|
}else if (area.equals("Botswana")){return Country.BOTSWANAREPUBLICOF();
|
88
|
}else if (area.equals("Burundi")){return Country.BURUNDIREPUBLICOF();
|
89
|
}else if (area.equals("Cameroon")){return Country.CAMEROONUNITEDREPUBLICOF();
|
90
|
|
91
|
}else if (area.equals("Congo")){return Country.CONGOPEOPLESREPUBLICOF();
|
92
|
}else if (area.equals("Zaire")){return Country.CONGODEMOCRATICREPUBLICOF();
|
93
|
}else if (area.equals("Equatorial Guinea")){return Country.EQUATORIALGUINEAREPUBLICOF();
|
94
|
}else if (area.equals("Gabon")){return Country.GABONGABONESEREPUBLIC();
|
95
|
}else if (area.equals("Liberia")){return Country.LIBERIAREPUBLICOF();
|
96
|
|
97
|
}else if (area.equals("Togo")){return Country.TOGOTOGOLESEREPUBLIC();
|
98
|
}else if (area.equals("Guinea")){return Country.GUINEAREVOLUTIONARYPEOPLESREPCOF();
|
99
|
}else if (area.equals("Guinea-Bissau")){return Country.GUINEABISSAUREPUBLICOF();
|
100
|
|
101
|
}else if (area.equals("Malawi")){return Country.MALAWIREPUBLICOF();
|
102
|
}else if (area.equals("Mozambique")){return Country.MOZAMBIQUEPEOPLESREPUBLICOF();
|
103
|
}else if (area.equals("Nigeria")){return Country.NIGERIAFEDERALREPUBLICOF();
|
104
|
}else if (area.equals("Senegal")){return Country.SENEGALREPUBLICOF();
|
105
|
}else if (area.equals("Sierra Leone")){return Country.SIERRALEONEREPUBLICOF();
|
106
|
}else if (area.equals("Sudan")){return Country.SUDANDEMOCRATICREPUBLICOFTHE();
|
107
|
}else if (area.equals("Madagascar")){return Country.MADAGASCARREPUBLICOF();
|
108
|
}else if (area.equals("Comoros")){return Country.COMOROSUNIONOFTHE();
|
109
|
|
110
|
}else if (area.equals("Vietnam")){return Country.VIETNAMSOCIALISTREPUBLICOF();
|
111
|
}else if (area.equals("Thailand")){return Country.THAILANDKINGDOMOF();
|
112
|
}else if (area.equals("Bhutan")){return Country.BHUTANKINGDOMOF();
|
113
|
}else if (area.equals("Laos")){return Country.LAOPEOPLESDEMOCRATICREPUBLIC();
|
114
|
}else if (area.equals("Myanmar (Burma)")){return Country.MYANMAR();
|
115
|
}else if (area.equals("Nepal")){return Country.NEPALKINGDOMOF();
|
116
|
}else if (area.equals("Pakistan")){return Country.PAKISTANISLAMICREPUBLICOF();
|
117
|
}else if (area.equals("Singapore")){return Country.SINGAPOREREPUBLICOF();
|
118
|
|
119
|
}else if (area.equals("Honduras")){return Country.HONDURASREPUBLICOF();
|
120
|
}else if (area.equals("Nicaragua")){return Country.NICARAGUAREPUBLICOF();
|
121
|
}else if (area.equals("Trinidad and Tobago")){return Country.TRINIDADANDTOBAGOREPUBLICOF();
|
122
|
}else if (area.equals("United States")){return Country.UNITEDSTATESOFAMERICA();
|
123
|
}else if (area.equals("Uruguay")){return Country.URUGUAYEASTERNREPUBLICOF();
|
124
|
}else if (area.equals("Haiti")){return Country.HAITIREPUBLICOF();
|
125
|
}else if (area.equals("North Korea")){return Country.KOREADEMOCRATICPEOPLESREPUBLICOF();
|
126
|
}else if (area.equals("South Korea")){return Country.KOREAREPUBLICOF();
|
127
|
}else if (area.equals("Taiwan")){return Country.TAIWANPROVINCEOFCHINA();
|
128
|
|
129
|
}else if (area.equals("Somalia")){return Country.SOMALIASOMALIREPUBLIC();
|
130
|
}else if (area.equals("Albania")){return Country.ALBANIAPEOPLESSOCIALISTREPUBLICOF();
|
131
|
}else if (area.equals("Algeria")){return Country.ALGERIAPEOPLESDEMOCRATICREPUBLICOF();
|
132
|
|
133
|
}else if (area.equals("Andorra")){return Country.ANDORRAPRINCIPALITYOF();
|
134
|
}else if (area.equals("Austria")){return Country.AUSTRIAREPUBLICOF();
|
135
|
}else if (area.equals("Azerbaijan")){return Country.AZERBAIJANREPUBLICOF();
|
136
|
}else if (area.equals("Bulgaria")){return Country.BULGARIAPEOPLESREPUBLICOF();
|
137
|
}else if (area.equals("Croatia")){return Country.HRVATSKA();
|
138
|
}else if (area.equals("Greece")){return Country.GREECEHELLENICREPUBLIC();
|
139
|
}else if (area.equals("Hungary")){return Country.HUNGARYHUNGARIANPEOPLESREPUBLIC();
|
140
|
|
141
|
}else if (area.equals("Iran")){return Country.IRANISLAMICREPUBLICOF();
|
142
|
}else if (area.equals("Iraq")){return Country.IRAQREPUBLICOF();
|
143
|
}else if (area.equals("Israel")){return Country.ISRAELSTATEOF();
|
144
|
}else if (area.equals("Italy")){return Country.ITALYITALIANREPUBLIC();
|
145
|
}else if (area.equals("Kazakhstan")){return Country.KAZAKHSTANREPUBLICOF();
|
146
|
}else if (area.equals("Kyrgyzstan")){return Country.KYRGYZREPUBLIC();
|
147
|
}else if (area.equals("Lebanon")){return Country.LEBANONLEBANESEREPUBLIC();
|
148
|
|
149
|
}else if (area.equals("Luxembourg")){return Country.LUXEMBOURGGRANDDUCHYOF();
|
150
|
}else if (area.equals("Macedonia")){return Country.MACEDONIATHEFORMERYUGOSLAVREPUBLICOF();
|
151
|
}else if (area.equals("Moldova")){return Country.MOLDOVAREPUBLICOF();
|
152
|
}else if (area.equals("Morocco")){return Country.MOROCCOKINGDOMOF();
|
153
|
}else if (area.equals("Romania")){return Country.ROMANIASOCIALISTREPUBLICOF();
|
154
|
}else if (area.equals("Serbia")){return Country.SERBIAANDMONTENEGRO();
|
155
|
}else if (area.equals("Slovakia")){return Country.SLOVAKIA();
|
156
|
}else if (area.equals("Spain")){return Country.SPAINSPANISHSTATE();
|
157
|
|
158
|
}else if (area.equals("Switzerland")){return Country.SWITZERLANDSWISSCONFEDERATION();
|
159
|
}else if (area.equals("Syria")){return Country.SYRIANARABREPUBLIC();
|
160
|
}else if (area.equals("Turkey")){return Country.TURKEYREPUBLICOF();
|
161
|
}else if (area.equals("Cambodia")){return Country.CAMBODIAKINGDOMOF();
|
162
|
}else if (area.equals("Bangladesh")){return Country.BANGLADESHPEOPLESREPUBLICOF();
|
163
|
|
164
|
}else if (area.equals("Sri Lanka")){return Country.SRILANKADEMOCRATICSOCIALISTREPUBLICOF();
|
165
|
}else if (area.equals("Bahamas")){return Country.BAHAMASCOMMONWEALTHOFTHE();
|
166
|
}else if (area.equals("Western Samoa")){return Country.SAMOAINDEPENDENTSTATEOF();
|
167
|
}else if (area.equals("Finland")){return Country.FINLANDREPUBLICOF();
|
168
|
}else if (area.equals("Norway")){return Country.NORWAYKINGDOMOF();
|
169
|
}else if (area.equals("El Salvador")){return Country.ELSALVADORREPUBLICOF();
|
170
|
}else if (area.equals("Cyprus")){return Country.CYPRUSREPUBLICOF();
|
171
|
}else if (area.equals("Sweden")){return Country.SWEDENKINGDOMOF();
|
172
|
}else if (area.equals("Denmark")){return Country.DENMARKKINGDOMOF();
|
173
|
}else if (area.equals("Trinidad & Tobago")){return Country.TRINIDADANDTOBAGOREPUBLICOF();
|
174
|
}else if (area.equals("Chile")){return Country.CHILEREPUBLICOF();
|
175
|
}else if (area.equals("Jordan")){return Country.JORDANHASHEMITEKINGDOMOF();
|
176
|
}else if (area.equals("Montenegro")){
|
177
|
logger.warn("Montenegro is currently mapped to 'Serbia & Montenegro'");
|
178
|
return Country.SERBIAANDMONTENEGRO();
|
179
|
}else if (area.equals("Portugal")){return Country.PORTUGALPORTUGUESEREPUBLIC();
|
180
|
}else if (area.equals("Tunisia")){return Country.TUNISIAREPUBLICOF();
|
181
|
}else if (area.equals("Seychelles")){return Country.SEYCHELLESREPUBLICOF();
|
182
|
}else if (area.equals("Fiji")){return Country.FIJIREPUBLICOFTHEFIJIISLANDS();
|
183
|
}else if (area.equals("Belgium")){return Country.BELGIUMKINGDOMOF();
|
184
|
}else if (area.equals("Virgin Islands")){return Country.USVIRGINISLANDS();
|
185
|
}else if (area.equals("Gambia")){return Country.GAMBIAREPUBLICOFTHE();
|
186
|
}else if (area.equals("Dominica")){return Country.DOMINICACOMMONWEALTHOF();
|
187
|
}else if (area.equals("Liechtenstein")){return Country.LIECHTENSTEINPRINCIPALITYOF();
|
188
|
}else if (area.matches("B(y)?elarus")){return Country.BELARUS();
|
189
|
}else if (area.equals("Turkey")){return Country.TURKEYREPUBLICOF();
|
190
|
}else if (area.equals("Turkmenistan")){return Country.TURKMENISTAN();
|
191
|
|
192
|
}else if (area.matches("United States: Alaska")){ return TdwgAreaProvider.getAreaByTdwgAbbreviation("ASK");
|
193
|
|
194
|
|
195
|
}else{
|
196
|
if (unhandledCountries.contains(area)){
|
197
|
logger.warn("Unhandled country '" + area + "' replaced by null" );
|
198
|
return null;
|
199
|
}
|
200
|
return null;
|
201
|
|
202
|
}
|
203
|
|
204
|
}
|
205
|
|
206
|
/* (non-Javadoc)
|
207
|
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getLanguageUuid(java.lang.String)
|
208
|
*/
|
209
|
@Override
|
210
|
public UUID getLanguageUuid(String key)
|
211
|
throws UndefinedTransformerMethodException {
|
212
|
return super.getLanguageUuid(key);
|
213
|
}
|
214
|
|
215
|
|
216
|
|
217
|
|
218
|
|
219
|
|
220
|
/* (non-Javadoc)
|
221
|
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getExtensionTypeByKey(java.lang.String)
|
222
|
*/
|
223
|
@Override
|
224
|
public ExtensionType getExtensionTypeByKey(String key) throws UndefinedTransformerMethodException {
|
225
|
if (key == null){return null;
|
226
|
}
|
227
|
return null;
|
228
|
}
|
229
|
|
230
|
/* (non-Javadoc)
|
231
|
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getExtensionTypeUuid(java.lang.String)
|
232
|
*/
|
233
|
@Override
|
234
|
public UUID getExtensionTypeUuid(String key)
|
235
|
throws UndefinedTransformerMethodException {
|
236
|
if (key == null){return null;
|
237
|
}else if (key.equalsIgnoreCase("not available reason")){return uuidExtTypeNotAvailableReason;
|
238
|
// }else if (key.equalsIgnoreCase("recent + fossil")){return uuidRecentAndFossil;
|
239
|
// }else if (key.equalsIgnoreCase("fossil only")){return uuidFossilOnly;
|
240
|
}
|
241
|
return null;
|
242
|
}
|
243
|
|
244
|
/* (non-Javadoc)
|
245
|
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getExtensionTypeUuid(java.lang.String)
|
246
|
*/
|
247
|
@Override
|
248
|
public UUID getMarkerTypeUuid(String key)
|
249
|
throws UndefinedTransformerMethodException {
|
250
|
if (key == null){return null;
|
251
|
}else if (key.equalsIgnoreCase("old record")){return uuidOldRecordMarkerType;
|
252
|
}else if (key.equalsIgnoreCase("checked")){return uuidCheckedMarkerType;
|
253
|
}else if (key.equalsIgnoreCase("not available")){return uuidNotAvailableMarkerType;
|
254
|
|
255
|
}
|
256
|
return null;
|
257
|
}
|
258
|
|
259
|
|
260
|
|
261
|
/* (non-Javadoc)
|
262
|
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getFeatureByKey(java.lang.String)
|
263
|
*/
|
264
|
@Override
|
265
|
public Feature getFeatureByKey(String key) throws UndefinedTransformerMethodException {
|
266
|
if (StringUtils.isBlank(key)){return null;
|
267
|
}else if (key.equalsIgnoreCase("Distribution")){return Feature.DISTRIBUTION();
|
268
|
}else if (key.equalsIgnoreCase("Ecology")){return Feature.ECOLOGY();
|
269
|
}else if (key.equalsIgnoreCase("Diagnosis")){return Feature.DIAGNOSIS();
|
270
|
}else if (key.equalsIgnoreCase("Biology")){return Feature.BIOLOGY_ECOLOGY();
|
271
|
}else if (key.equalsIgnoreCase("Host")){return Feature.HOSTPLANT();
|
272
|
}else{
|
273
|
return null;
|
274
|
}
|
275
|
}
|
276
|
|
277
|
|
278
|
|
279
|
|
280
|
}
|