Revision bff8d9fe
Added by Andreas Müller over 5 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTransformer.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
16 | 16 |
import org.apache.commons.lang.StringUtils; |
17 | 17 |
import org.apache.log4j.Logger; |
18 | 18 |
|
19 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
20 | 19 |
import eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase; |
21 | 20 |
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException; |
22 | 21 |
import eu.etaxonomy.cdm.model.common.ExtensionType; |
... | ... | |
30 | 29 |
* @since 01.03.2010 |
31 | 30 |
*/ |
32 | 31 |
public final class ErmsTransformer extends InputTransformerBase { |
33 |
private static final Logger logger = Logger.getLogger(ErmsTransformer.class); |
|
34 |
|
|
32 |
private static final long serialVersionUID = 1777919792691129468L; |
|
33 |
|
|
34 |
private static final Logger logger = Logger.getLogger(ErmsTransformer.class); |
|
35 |
|
|
35 | 36 |
public static final int SOURCE_USE_ORIGINAL_DESCRIPTION = 1; |
36 | 37 |
public static final int SOURCE_USE_BASIS_OF_RECORD = 2; |
37 | 38 |
public static final int SOURCE_USE_ADDITIONAL_SOURCE = 3; |
... | ... | |
40 | 41 |
public static final int SOURCE_USE_NEW_COMBINATION_REFERENCE = 6; |
41 | 42 |
public static final int SOURCE_USE_STATUS_SOURCE = 7; |
42 | 43 |
public static final int SOURCE_USE_EMENDATION = 8; |
43 |
|
|
44 |
|
|
44 | 45 |
//taxon relationship type uuids |
45 | 46 |
public static final UUID uuidTaxRelTypeIsTaxonSynonymOf = UUID.fromString("cc648276-0823-47b1-9deb-fa7c046e4afd"); |
46 |
|
|
47 |
|
|
47 |
|
|
48 | 48 |
//rank uuids |
49 | 49 |
public static final UUID uuidRankSuperdomain = UUID.fromString("66d4d773-4946-4e02-b758-8903563eaa26"); |
50 |
|
|
50 |
|
|
51 | 51 |
//language uuids |
52 | 52 |
public static final UUID uuidEuropeanMarineWaters = UUID.fromString("47389e42-3b3c-4873-bded-ac030db86462"); |
53 | 53 |
public static final UUID uuidMediterraneanSea = UUID.fromString("bde8a624-23c4-4ac3-b381-11287f5d656a"); |
... | ... | |
110 | 110 |
public static final UUID uuidIsraeliExclusiveEconomicZoneMediterranean = UUID.fromString("d947e1c1-6d7b-47e1-ad91-703d15c5c55b"); |
111 | 111 |
public static final UUID uuidPolishExclusiveEconomicZone = UUID.fromString("dc7f8339-528b-49ec-a8d9-c2be0441e933"); |
112 | 112 |
|
113 |
|
|
113 |
|
|
114 | 114 |
|
115 | 115 |
//feature uuids |
116 | 116 |
public static final UUID uuidRemark = UUID.fromString("648eab77-8469-4139-bbf4-3fb26ec15864"); |
... | ... | |
154 | 154 |
public static final UUID uuidCompleteness = UUID.fromString("141f4816-78c0-4da1-8a79-5c9031e6b149"); |
155 | 155 |
public static final UUID uuidUnacceptReason = UUID.fromString("3883fb79-374d-4120-964b-9666307e3567"); |
156 | 156 |
public static final UUID uuidQualityStatus = UUID.fromString("4de84c6e-41bd-4a0e-894d-77e9ec3103d2"); |
157 |
|
|
157 |
|
|
158 | 158 |
//MarkerTypes |
159 | 159 |
public static final UUID uuidMarkerMarine = UUID.fromString("5da78a28-5668-4ed5-b788-10c69343f91e"); |
160 | 160 |
public static final UUID uuidMarkerBrackish = UUID.fromString("2da39f5d-67d6-4779-b40d-923dca85fe14"); |
161 | 161 |
public static final UUID uuidMarkerFreshwater = UUID.fromString("1190b182-e1d3-4986-8cc3-a6de3c115cf7"); |
162 | 162 |
public static final UUID uuidMarkerTerrestrial = UUID.fromString("5ed92edb-e2c6-48da-8367-6e82071c888f"); |
163 |
|
|
164 |
|
|
163 |
|
|
164 |
|
|
165 | 165 |
//language uuids |
166 | 166 |
public static final UUID uuidLangAuns = UUID.fromString("7bb29f8f-d74b-4f7d-b673-c52debb7ae20"); //au |
167 | 167 |
public static final UUID uuidLangChukchiLouravetlany = UUID.fromString("f85797cc-5ab3-454d-b9eb-beb75bc8eb37"); //cl |
168 |
public static final UUID uuidLangChleuh = UUID.fromString("85132635-d696-4fc0-af12-207175b11773"); //cu
|
|
168 |
public static final UUID uuidLangChleuh = UUID.fromString("85132635-d696-4fc0-af12-207175b11773"); //cu |
|
169 | 169 |
public static final UUID uuidLangEnglishCanadian = UUID.fromString("43d244c4-e8cb-4c7f-951a-14d71666999c"); //ec |
170 | 170 |
public static final UUID uuidLangEnglishUs = UUID.fromString("037bc818-b992-48ce-a40b-994980bc46d7"); //eu |
171 | 171 |
public static final UUID uuidLangEvenKamchatcka= UUID.fromString("6ff3e21e-cabe-4583-b416-11b7120c5c0a"); //ek |
... | ... | |
181 | 181 |
public static final UUID uuidLangTamul = UUID.fromString("9f55f493-9f2b-427c-bb55-d970822726c9"); //tm |
182 | 182 |
public static final UUID uuidLangNentsiNenets = UUID.fromString("4697b87e-2718-4986-8f9b-361dd47b0c90"); //ne |
183 | 183 |
|
184 |
|
|
185 |
|
|
184 |
|
|
185 |
|
|
186 | 186 |
//... |
187 |
|
|
188 |
|
|
187 |
|
|
188 |
|
|
189 | 189 |
public static NomenclaturalCode kingdomId2NomCode(Integer kingdomId){ |
190 | 190 |
switch (kingdomId){ |
191 | 191 |
case 1: return null; |
... | ... | |
197 | 197 |
case 7: return NomenclaturalCode.ICNAFP; //Chromista ?? |
198 | 198 |
case 147415: return NomenclaturalCode.ICNB; //Monera |
199 | 199 |
default: return null; |
200 |
|
|
200 |
|
|
201 | 201 |
} |
202 |
|
|
202 |
|
|
203 | 203 |
} |
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 | 208 |
/* (non-Javadoc) |
209 | 209 |
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getNameTypeDesignationStatusByKey(java.lang.String) |
210 | 210 |
*/ |
... | ... | |
218 | 218 |
case 1: return NameTypeDesignationStatus.ORIGINAL_DESIGNATION(); |
219 | 219 |
case 2: return NameTypeDesignationStatus.SUBSEQUENT_DESIGNATION(); |
220 | 220 |
case 3: return NameTypeDesignationStatus.MONOTYPY(); |
221 |
default:
|
|
221 |
default: |
|
222 | 222 |
String warning = "Unknown name type designation status id " + key; |
223 | 223 |
logger.warn(warning); |
224 | 224 |
return null; |
... | ... | |
238 | 238 |
} |
239 | 239 |
|
240 | 240 |
|
241 |
public Language getLanguageByKey(String ermsAbbrev) throws IllegalArgumentException { |
|
241 |
@Override |
|
242 |
public Language getLanguageByKey(String ermsAbbrev) throws IllegalArgumentException { |
|
242 | 243 |
Set<String> unhandledLanguages = new HashSet<String>(); |
243 |
if (CdmUtils.isEmpty(ermsAbbrev)){return null;
|
|
244 |
if (StringUtils.isBlank(ermsAbbrev)){return null;
|
|
244 | 245 |
}else if (ermsAbbrev.equals("ab")){return Language.ALBANIAN(); |
245 | 246 |
}else if (ermsAbbrev.equals("af")){return Language.AFRIKAANS(); |
246 | 247 |
}else if (ermsAbbrev.equals("al")){return Language.ALEUT(); |
... | ... | |
271 | 272 |
}else if (ermsAbbrev.equals("ep")){return Language.ESPERANTO(); |
272 | 273 |
}else if (ermsAbbrev.equals("es")){return Language.SPANISH_CASTILIAN(); |
273 | 274 |
// }else if (ermsAbbrev.equals("eu")){return Language.ENGLISH-UNITED STATES(); no iso //ENGLISH(); |
274 |
// }else if (ermsAbbrev.equals("ev")){return Language.EVENKI(); iso: evn //languages of Tungusic family
|
|
275 |
}else if (ermsAbbrev.equals("fa")){return Language.PERSIAN();
|
|
275 |
// }else if (ermsAbbrev.equals("ev")){return Language.EVENKI(); iso: evn //languages of Tungusic family |
|
276 |
}else if (ermsAbbrev.equals("fa")){return Language.PERSIAN(); |
|
276 | 277 |
// }else if (ermsAbbrev.equals("fc")){return Language.FRENCH-CANADIAN(); no iso //FRENCH(); |
277 | 278 |
}else if (ermsAbbrev.equals("fi")){return Language.FINNISH(); |
278 | 279 |
}else if (ermsAbbrev.equals("fj")){return Language.FIJIAN(); |
... | ... | |
297 | 298 |
}else if (ermsAbbrev.equals("it")){return Language.ITALIAN(); |
298 | 299 |
}else if (ermsAbbrev.equals("ja")){return Language.JAPANESE(); |
299 | 300 |
// }else if (ermsAbbrev.equals("ji")){return Language.JIVARA(); //?? |
300 |
// }else if (ermsAbbrev.equals("ka")){return Language.KAMCHADAL(); iso 639-3:itl //Itelmen, formerly also known as Kamchadal, is a language belonging to the Chukotko-Kamchatkan family traditionally spoken in the Kamchatka Peninsula.
|
|
301 |
// }else if (ermsAbbrev.equals("ka")){return Language.KAMCHADAL(); iso 639-3:itl //Itelmen, formerly also known as Kamchadal, is a language belonging to the Chukotko-Kamchatkan family traditionally spoken in the Kamchatka Peninsula. |
|
301 | 302 |
// }else if (ermsAbbrev.equals("ki")){return Language.CREOLES_PIDGINS_ENGLISH_BASED_OTHER() |
302 | 303 |
}else if (ermsAbbrev.equals("ko")){return Language.KOREAN(); |
303 | 304 |
// }else if (ermsAbbrev.equals("kr")){return Language.KORYAK(); //iso639-3: kpy |
... | ... | |
375 | 376 |
unhandledLanguages.add("tm"); |
376 | 377 |
unhandledLanguages.add("sh"); |
377 | 378 |
unhandledLanguages.add("yu"); |
378 |
|
|
379 |
|
|
379 | 380 |
unhandledLanguages.add("cu"); //Chleuh |
380 | 381 |
unhandledLanguages.add("ki"); //Krio, subset of Language.CREOLES_PIDGINS_ENGLISH_BASED_OTHER() |
381 | 382 |
unhandledLanguages.add("mo"); //Monégasque |
382 | 383 |
|
383 | 384 |
|
384 |
|
|
385 |
|
|
385 |
|
|
386 |
|
|
386 | 387 |
if (unhandledLanguages.contains(ermsAbbrev)){ |
387 | 388 |
logger.info("Unhandled language '" + ermsAbbrev + "' replaced by 'UNDETERMINED'" ); |
388 | 389 |
return Language.UNDETERMINED(); |
... | ... | |
392 | 393 |
throw new IllegalArgumentException(warning); |
393 | 394 |
} |
394 | 395 |
} |
395 |
|
|
396 |
|
|
396 | 397 |
/* (non-Javadoc) |
397 | 398 |
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getLanguageUuid(java.lang.String) |
398 | 399 |
*/ |
... | ... | |
418 | 419 |
}else if (key.equalsIgnoreCase("os")){return uuidLangOstyak; |
419 | 420 |
}else if (key.equalsIgnoreCase("tm")){return uuidLangTamul; |
420 | 421 |
} |
421 |
|
|
422 |
|
|
422 | 423 |
return super.getLanguageUuid(key); |
423 | 424 |
} |
424 |
|
|
425 |
|
|
425 |
|
|
426 |
|
|
426 | 427 |
|
427 | 428 |
/* (non-Javadoc) |
428 | 429 |
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getExtensionTypeByKey(java.lang.String) |
... | ... | |
449 | 450 |
} |
450 | 451 |
|
451 | 452 |
public static UUID uuidFromGuName(String guName){ |
452 |
if (CdmUtils.isEmpty(guName)){return null;
|
|
453 |
if (StringUtils.isBlank(guName)){return null;
|
|
453 | 454 |
}else if (guName.equalsIgnoreCase("European Marine Waters")){ return uuidEuropeanMarineWaters; |
454 | 455 |
}else if (guName.equalsIgnoreCase("Mediterranean Sea")){ return uuidMediterraneanSea; |
455 | 456 |
}else if (guName.equalsIgnoreCase("White Sea")){ return uuidWhiteSea; |
... | ... | |
501 | 502 |
}else if (guName.equalsIgnoreCase("Balear Sea")){ return uuidBalearSea; |
502 | 503 |
}else if (guName.equalsIgnoreCase("Turkish Exclusive Economic Zone")){ return uuidTurkishExclusiveEconomicZone; |
503 | 504 |
}else if (guName.equalsIgnoreCase("Danish Exclusive Economic Zone")){ return uuidDanishExclusiveEconomicZone; |
504 |
|
|
505 |
|
|
505 | 506 |
}else if (guName.equalsIgnoreCase("Bay of Biscay")){ return uuidBayOfBiscay; |
506 | 507 |
}else if (guName.equalsIgnoreCase("Greek Exclusive Economic Zone")){ return uuidGreekExclusiveEconomicZone; |
507 | 508 |
}else if (guName.equalsIgnoreCase("Tyrrhenian Sea")){ return uuidTyrrhenianSea; |
... | ... | |
510 | 511 |
}else if (guName.equalsIgnoreCase("Azores Exclusive Economic Zone")){ return uuidAzoresExclusiveEconomicZone; |
511 | 512 |
}else if (guName.equalsIgnoreCase("Israeli Exclusive Economic Zone [Mediterranean part]")){ return uuidIsraeliExclusiveEconomicZoneMediterranean; |
512 | 513 |
}else if (guName.equalsIgnoreCase("Polish Exclusive Economic Zone")){ return uuidPolishExclusiveEconomicZone; |
513 |
|
|
514 |
|
|
514 | 515 |
}else{ |
515 | 516 |
throw new IllegalArgumentException("Unknown area " + guName); |
516 | 517 |
} |
517 |
|
|
518 | 518 |
} |
519 | 519 |
|
520 |
|
|
520 |
|
|
521 | 521 |
public static UUID uuidFromGuId(Integer guId){ |
522 | 522 |
if (guId == null){return null; |
523 | 523 |
}else if (guId == 7788){ return uuidEuropeanMarineWaters; |
... | ... | |
571 | 571 |
}else if (guId == 10779){ return uuidBalearSea; |
572 | 572 |
}else if (guId == 10782){ return uuidTurkishExclusiveEconomicZone; |
573 | 573 |
}else if (guId == 11039){ return uuidDanishExclusiveEconomicZone; |
574 |
|
|
574 |
|
|
575 | 575 |
}else{ |
576 | 576 |
throw new IllegalArgumentException("Unknown area id " + guId); |
577 | 577 |
} |
578 | 578 |
|
579 | 579 |
} |
580 |
|
|
580 |
|
|
581 | 581 |
public static Feature noteType2Feature(String type){ |
582 |
if (CdmUtils.isEmpty(type)){return null;
|
|
582 |
if (StringUtils.isBlank(type)){return null;
|
|
583 | 583 |
}else if (type.equals("Remark")){return Feature.UNKNOWN(); |
584 | 584 |
}else if (type.equals("Additional information")){return Feature.UNKNOWN(); |
585 | 585 |
}else if (type.equals("Spelling")){return Feature.UNKNOWN(); |
... | ... | |
618 | 618 |
} |
619 | 619 |
} |
620 | 620 |
|
621 |
/* (non-Javadoc) |
|
622 |
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getFeatureByKey(java.lang.String) |
|
623 |
*/ |
|
624 | 621 |
@Override |
625 | 622 |
public Feature getFeatureByKey(String key) throws UndefinedTransformerMethodException { |
626 |
if (CdmUtils.isEmpty(key)){return null;
|
|
623 |
if (StringUtils.isBlank(key)){return null;
|
|
627 | 624 |
}else if (key.equalsIgnoreCase("Distribution")){return Feature.DISTRIBUTION(); |
628 | 625 |
}else if (key.equalsIgnoreCase("Ecology")){return Feature.ECOLOGY(); |
629 | 626 |
}else if (key.equalsIgnoreCase("Diagnosis")){return Feature.DIAGNOSIS(); |
... | ... | |
634 | 631 |
} |
635 | 632 |
} |
636 | 633 |
|
637 |
/* (non-Javadoc) |
|
638 |
* @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getFeatureUuid(java.lang.String) |
|
639 |
*/ |
|
640 | 634 |
@Override |
641 | 635 |
public UUID getFeatureUuid(String key) |
642 | 636 |
throws UndefinedTransformerMethodException { |
... | ... | |
672 | 666 |
return null; |
673 | 667 |
} |
674 | 668 |
} |
675 |
|
|
676 |
|
|
677 |
|
|
678 | 669 |
} |
Also available in: Unified diff
ref #1444 cleanup erms import code