Revision 33337032
Added by Andreas Müller over 4 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonImport.java | ||
---|---|---|
21 | 21 |
import org.apache.log4j.Logger; |
22 | 22 |
import org.springframework.stereotype.Component; |
23 | 23 |
|
24 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
25 |
import eu.etaxonomy.cdm.io.common.DbImportStateBase; |
|
24 | 26 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
25 | 27 |
import eu.etaxonomy.cdm.io.common.mapping.DbIgnoreMapper; |
26 | 28 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportAnnotationMapper; |
... | ... | |
32 | 34 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportStringMapper; |
33 | 35 |
import eu.etaxonomy.cdm.io.common.mapping.DbNotYetImplementedMapper; |
34 | 36 |
import eu.etaxonomy.cdm.io.common.mapping.IMappingImport; |
37 |
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException; |
|
35 | 38 |
import eu.etaxonomy.cdm.io.common.mapping.out.DbLastActionMapper; |
36 | 39 |
import eu.etaxonomy.cdm.io.pesi.erms.validation.ErmsTaxonImportValidator; |
37 | 40 |
import eu.etaxonomy.cdm.io.pesi.out.PesiTaxonExport; |
... | ... | |
39 | 42 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
40 | 43 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
41 | 44 |
import eu.etaxonomy.cdm.model.common.ExtensionType; |
45 |
import eu.etaxonomy.cdm.model.common.Language; |
|
42 | 46 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
43 | 47 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
48 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
|
44 | 49 |
import eu.etaxonomy.cdm.model.name.Rank; |
45 | 50 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
46 | 51 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
... | ... | |
225 | 230 |
// Object accTaxonId = rs.getObject("tu_acctaxon"); |
226 | 231 |
Integer meId = rs.getInt("id"); |
227 | 232 |
|
228 |
String tuName = rs.getString("tu_name"); |
|
233 |
TaxonName taxonName = fillTaxonName(rs, state, meId); |
|
234 |
|
|
235 |
//add original source for taxon name (taxon original source is added in mapper) |
|
236 |
Reference citation = state.getTransactionalSourceReference(); |
|
237 |
addOriginalSource(rs, taxonName, "id", NAME_NAMESPACE, citation); |
|
238 |
|
|
239 |
TaxonBase<?> result; |
|
240 |
//handle accepted<-> synonym, we create more accepted taxa as we need them within the tree or to attache factual data |
|
241 |
if (state.getAcceptedTaxaKeys().contains(meId)){ |
|
242 |
Taxon taxon = Taxon.NewInstance(taxonName, citation); |
|
243 |
if (statusId != 1){ |
|
244 |
logger.info("Taxon created as taxon but has status <> 1 ("+statusId+"): " + meId); |
|
245 |
handleNotAcceptedTaxon(taxon, statusId, state, rs); |
|
246 |
} |
|
247 |
result = taxon; |
|
248 |
}else{ |
|
249 |
result = Synonym.NewInstance(taxonName, citation); |
|
250 |
} |
|
251 |
|
|
252 |
handleNameStatus(result.getName(), rs, state); |
|
253 |
return result; |
|
254 |
} |
|
255 |
|
|
256 |
private void handleNameStatus(TaxonName name, ResultSet rs, ErmsImportState state) throws SQLException { |
|
257 |
NomenclaturalStatusType nomStatus = null; |
|
258 |
int tuStatus = rs.getInt("tu_status"); |
|
259 |
if (tuStatus == 3){ |
|
260 |
//nomen nudum |
|
261 |
nomStatus = NomenclaturalStatusType.NUDUM(); |
|
262 |
}else if (tuStatus == 5){ |
|
263 |
//"alternate representation" |
|
264 |
nomStatus = getNomenclaturalStatusType(state, ErmsTransformer.uuidNomStatusAlternateRepresentation, "alternate representation", "alternate representation", null, Language.ENGLISH(), null); |
|
265 |
}else if (tuStatus == 6){ |
|
266 |
//nomen dubium |
|
267 |
nomStatus = NomenclaturalStatusType.DOUBTFUL(); |
|
268 |
}else if (tuStatus == 7){ |
|
269 |
//temporary name |
|
270 |
nomStatus = getNomenclaturalStatusType(state, PesiTransformer.uuidNomStatusTemporaryName, "temporary name", "temporary name", null, Language.ENGLISH(), null); |
|
271 |
}else if (tuStatus == 8){ |
|
272 |
//species inquirenda |
|
273 |
nomStatus = getNomenclaturalStatusType(state, ErmsTransformer.uuidNomStatusSpeciesInquirenda, "species inquirenda", "species inquirenda", null, Language.LATIN(), null); |
|
274 |
} |
|
275 |
if (nomStatus == null){ |
|
276 |
String unacceptReason = rs.getString("tu_unacceptreason"); |
|
277 |
try { |
|
278 |
nomStatus = state.getTransformer().getNomenclaturalStatusByKey(unacceptReason); |
|
279 |
} catch (UndefinedTransformerMethodException e) {logger.warn("Unhandled method"); |
|
280 |
} |
|
281 |
} |
|
282 |
if (nomStatus != null){ |
|
283 |
name.addStatus(nomStatus, null, null); |
|
284 |
} |
|
285 |
} |
|
286 |
|
|
287 |
private TaxonName fillTaxonName(ResultSet rs, ErmsImportState state, Integer meId) throws SQLException { |
|
288 |
String tuName = rs.getString("tu_name"); |
|
229 | 289 |
String displayName = rs.getString("tu_displayname"); |
230 | 290 |
|
231 | 291 |
String parent1Name = rs.getString("parent1name"); |
... | ... | |
273 | 333 |
} |
274 | 334 |
taxonName.getTitleCache(); |
275 | 335 |
|
276 |
//add original source for taxon name (taxon original source is added in mapper |
|
277 |
Reference citation = state.getTransactionalSourceReference(); |
|
278 |
addOriginalSource(rs, taxonName, "id", NAME_NAMESPACE, citation); |
|
279 | 336 |
|
280 | 337 |
//old: if (statusId == 1){ |
281 | 338 |
if (state.getAcceptedTaxaKeys().contains(meId)){ |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTransformer.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.model.description.Feature; |
24 | 24 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus; |
25 | 25 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
26 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
|
26 | 27 |
import eu.etaxonomy.cdm.model.term.TermType; |
27 | 28 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
28 | 29 |
|
... | ... | |
49 | 50 |
//taxon relationship type uuids |
50 | 51 |
public static final UUID uuidTaxRelTypeIsTaxonSynonymOf = UUID.fromString("cc648276-0823-47b1-9deb-fa7c046e4afd"); |
51 | 52 |
|
53 |
//nomenclatural status tpye uuids |
|
54 |
public static final UUID uuidNomStatusSpeciesInquirenda = UUID.fromString("7790a4e2-d071-499c-8f25-a5ae34fd2dfb"); |
|
55 |
public static final UUID uuidNomStatusAlternateRepresentation = UUID.fromString("bb746f99-5c46-4b6b-963a-8aff1b04f22b"); |
|
56 |
|
|
52 | 57 |
//rank uuids |
53 | 58 |
public static final UUID uuidRankSuperdomain = UUID.fromString("66d4d773-4946-4e02-b758-8903563eaa26"); |
54 | 59 |
public static final UUID uuidRankSubterclass = UUID.fromString("39257363-913b-4b3a-a536-b415360dfc8c"); |
... | ... | |
639 | 644 |
return null; |
640 | 645 |
} |
641 | 646 |
} |
647 |
|
|
648 |
//handles the nomstatus type of unaccept reason |
|
649 |
@Override |
|
650 |
public NomenclaturalStatusType getNomenclaturalStatusByKey(String key) throws UndefinedTransformerMethodException{ |
|
651 |
if (isBlank(key)){ |
|
652 |
return null; |
|
653 |
}else if (key.matches(".*inval.*")){ |
|
654 |
return NomenclaturalStatusType.INVALID(); //1, test if correct for zoological names |
|
655 |
}else if (key.matches(".*not val*")){ |
|
656 |
return NomenclaturalStatusType.INVALID(); //1, test if correct for zoological names |
|
657 |
}else if (key.matches(".*illeg.*")){ |
|
658 |
return NomenclaturalStatusType.ILLEGITIMATE(); //2 |
|
659 |
}else if (key.matches(".*nud.*")){ |
|
660 |
return NomenclaturalStatusType.NUDUM(); //3 |
|
661 |
}else if (key.matches(".*rej\\..*")){ |
|
662 |
return NomenclaturalStatusType.REJECTED(); //4 |
|
663 |
}else if (key.matches(".*superfl.*")){ |
|
664 |
return NomenclaturalStatusType.SUPERFLUOUS(); //12 |
|
665 |
}else if (key.matches(".*Comb\\. nov.*")){ |
|
666 |
//?? |
|
667 |
return NomenclaturalStatusType.NOVUM(); // 16 |
|
668 |
}else if (key.matches(".*New name.*")){ |
|
669 |
//?? |
|
670 |
return NomenclaturalStatusType.NOVUM(); // 16 |
|
671 |
}else if (key.matches(".*new combination.*")){ |
|
672 |
//?? |
|
673 |
return NomenclaturalStatusType.COMB_NOV(); //comb. ined./21 |
|
674 |
}else{ |
|
675 |
return null; |
|
676 |
} |
|
677 |
} |
|
678 |
|
|
679 |
|
|
642 | 680 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaTransformer.java | ||
---|---|---|
17 | 17 |
import org.apache.log4j.Logger; |
18 | 18 |
|
19 | 19 |
import eu.etaxonomy.cdm.api.service.ITermService; |
20 |
import eu.etaxonomy.cdm.io.pesi.out.PesiTransformer; |
|
20 | 21 |
import eu.etaxonomy.cdm.model.common.Language; |
21 | 22 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
22 | 23 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
... | ... | |
446 | 447 |
// return abbrToUUID.get(abbr); |
447 | 448 |
// } |
448 | 449 |
|
449 |
public static UUID uuidNomStatusTempNamed = UUID.fromString("aa6ada5a-ca21-4fef-b76f-9ae237e9c4ae"); |
|
450 |
|
|
451 | 450 |
static NomenclaturalStatusType nomStatusTempNamed; |
452 | 451 |
|
453 | 452 |
private static DefinedTerm taxonomicSpecialistType; |
... | ... | |
470 | 469 |
|
471 | 470 |
public static NomenclaturalStatusType getNomStatusTempNamed(ITermService termService){ |
472 | 471 |
if (nomStatusTempNamed == null){ |
473 |
nomStatusTempNamed = (NomenclaturalStatusType)termService.find(uuidNomStatusTempNamed);
|
|
472 |
nomStatusTempNamed = (NomenclaturalStatusType)termService.find(PesiTransformer.uuidNomStatusTemporaryName);
|
|
474 | 473 |
if (nomStatusTempNamed == null){ |
475 | 474 |
nomStatusTempNamed = NomenclaturalStatusType.NewInstance("temporary named", "temporary named", "temp. named", Language.ENGLISH()); |
476 | 475 |
Representation repLatin = Representation.NewInstance("", "", "", Language.LATIN()); |
477 | 476 |
nomStatusTempNamed.addRepresentation(repLatin); |
478 |
nomStatusTempNamed.setUuid(uuidNomStatusTempNamed);
|
|
477 |
nomStatusTempNamed.setUuid(PesiTransformer.uuidNomStatusTemporaryName);
|
|
479 | 478 |
NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusTempNamed); |
480 | 479 |
termService.save(nomStatusTempNamed); |
481 | 480 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTransformer.java | ||
---|---|---|
26 | 26 |
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException; |
27 | 27 |
import eu.etaxonomy.cdm.io.common.mapping.out.ExportTransformerBase; |
28 | 28 |
import eu.etaxonomy.cdm.io.pesi.erms.ErmsTransformer; |
29 |
import eu.etaxonomy.cdm.io.pesi.faunaEuropaea.FaunaEuropaeaTransformer; |
|
30 | 29 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
31 | 30 |
import eu.etaxonomy.cdm.model.common.Language; |
32 | 31 |
import eu.etaxonomy.cdm.model.common.RelationshipBase; |
... | ... | |
116 | 115 |
public static int REF_PUBLICATION = 11; |
117 | 116 |
public static String REF_STR_UNRESOLVED = "unresolved"; |
118 | 117 |
|
118 |
|
|
119 | 119 |
// NameStatus |
120 |
public static UUID uuidNomStatusTemporaryName = UUID.fromString("aa6ada5a-ca21-4fef-b76f-9ae237e9c4ae"); |
|
121 |
|
|
120 | 122 |
public static int NAME_ST_NOM_INVAL = 1; |
121 | 123 |
public static int NAME_ST_NOM_ILLEG = 2; |
122 | 124 |
public static int NAME_ST_NOM_NUD = 3; |
... | ... | |
2107 | 2109 |
// The following are non-existent in CDM |
2108 | 2110 |
// }else if (status.equals(NomenclaturalStatusType.)) {return NAME_ST_COMB_AND_STAT_INED; |
2109 | 2111 |
// }else if (status.equals(NomenclaturalStatusType.)) {return NAME_ST_NOM_NOV_INED; |
2110 |
// }else if (status.equals(NomenclaturalStatusType.)) {return NAME_ST_ALTERNATE_REPRESENTATION;
|
|
2111 |
}else if (status.getUuid().equals(FaunaEuropaeaTransformer.uuidNomStatusTempNamed)) {return NAME_ST_TEMPORARY_NAME;
|
|
2112 |
// }else if (status.equals(NomenclaturalStatusType.)) {return NAME_ST_SPECIES_INQUIRENDA;
|
|
2112 |
}else if (status.getUuid().equals(ErmsTransformer.uuidNomStatusAlternateRepresentation)) {return NAME_ST_ALTERNATE_REPRESENTATION;
|
|
2113 |
}else if (status.getUuid().equals(uuidNomStatusTemporaryName)) {return NAME_ST_TEMPORARY_NAME;
|
|
2114 |
}else if (status.getUuid().equals(ErmsTransformer.uuidNomStatusSpeciesInquirenda)) {return NAME_ST_SPECIES_INQUIRENDA;
|
|
2113 | 2115 |
|
2114 | 2116 |
//TODO |
2115 | 2117 |
}else { |
Also available in: Unified diff
ref #1444, ref #8509, ref #8508 handle NomenclaturalStatusType in ERMS pipeline