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