Revision f8226169
Added by Andreas Müller over 4 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTaxonExport.java | ||
---|---|---|
698 | 698 |
return success; |
699 | 699 |
} |
700 | 700 |
|
701 |
private Integer findKingdomIdFromTreeIndex(TaxonBase<?> taxonBase,PesiExportState state) { |
|
701 |
private static Integer findKingdomIdFromTreeIndex(TaxonBase<?> taxonBase,PesiExportState state) {
|
|
702 | 702 |
Taxon taxon; |
703 | 703 |
if (taxonBase instanceof Synonym){ |
704 | 704 |
taxon = ((Synonym) taxonBase).getAcceptedTaxon(); |
... | ... | |
727 | 727 |
kingdomID = state.getTreeIndexKingdomMap().get(treeIndexKingdom); |
728 | 728 |
} |
729 | 729 |
} |
730 |
if(Rank.DOMAIN().equals(taxon.getName().getRank())){ |
|
731 |
return null; |
|
732 |
} |
|
730 | 733 |
if(kingdomID == null){ |
731 | 734 |
logger.warn("Kingdom could not be defined for treeindex " + treeIndex); |
732 | 735 |
} |
... | ... | |
881 | 884 |
TaxonName taxonName = acceptedTaxon.getName(); |
882 | 885 |
|
883 | 886 |
if (taxonName.isZoological()) { |
884 |
NomenclaturalCode nomenclaturalCode = taxonName.getNameType(); |
|
885 |
kingdomFk = PesiTransformer.nomenclaturalCode2Kingdom(nomenclaturalCode); |
|
887 |
kingdomFk = findKingdomIdFromTreeIndex(taxonBase, state); |
|
886 | 888 |
|
887 | 889 |
Set<TaxonNode> taxonNodes = acceptedTaxon.getTaxonNodes(); |
888 | 890 |
TaxonNode singleNode = null; |
... | ... | |
1316 | 1318 |
*/ |
1317 | 1319 |
private boolean invokeRankDataAndTypeNameFkAndKingdomFk(TaxonName taxonName, NomenclaturalCode nomenclaturalCode, |
1318 | 1320 |
Integer taxonFk, Integer typeNameFk, Integer kingdomFk, PesiExportState state) { |
1319 |
try { |
|
1321 |
|
|
1322 |
Integer rankFk = null; |
|
1323 |
try { |
|
1320 | 1324 |
int index = 1; |
1321 |
Integer rankFk = getRankFk(taxonName, nomenclaturalCode);
|
|
1325 |
rankFk = getRankFk(taxonName, nomenclaturalCode); |
|
1322 | 1326 |
if (rankFk != null) { |
1323 | 1327 |
rankTypeExpertsUpdateStmt.setInt(index++, rankFk); |
1324 | 1328 |
} else { |
... | ... | |
1488 | 1492 |
* @see MethodMapper |
1489 | 1493 |
*/ |
1490 | 1494 |
private static String getRankCache(TaxonName taxonName, NomenclaturalCode nomenclaturalCode, PesiExportState state) { |
1491 |
if (nomenclaturalCode != null) { |
|
1492 |
return state.getTransformer().getCacheByRankAndKingdom(taxonName.getRank(), PesiTransformer.nomenclaturalCode2Kingdom(nomenclaturalCode)); |
|
1493 |
}else{ |
|
1495 |
List<TaxonNode> nodes = getTaxonNodes(taxonName); |
|
1496 |
if (Rank.DOMAIN().equals(taxonName.getRank())){ |
|
1497 |
return state.getTransformer().getCacheByRankAndKingdom(Rank.DOMAIN(), null); |
|
1498 |
}else if (!nodes.isEmpty()) { |
|
1499 |
return state.getTransformer().getCacheByRankAndKingdom(taxonName.getRank(), findKingdomIdFromTreeIndex(nodes.iterator().next().getTaxon(), state)); //PesiTransformer.nomenclaturalCode2Kingdom(nomenclaturalCode)); |
|
1500 |
}else if (nomenclaturalCode != null){ |
|
1501 |
return state.getTransformer().getCacheByRankAndKingdom(taxonName.getRank(), PesiTransformer.nomenclaturalCode2Kingdom(nomenclaturalCode)); |
|
1502 |
}else{ |
|
1494 | 1503 |
logger.warn("No nomenclatural code defined for name " + taxonName.getUuid()); |
1495 | 1504 |
return null; |
1496 | 1505 |
} |
1497 | 1506 |
} |
1498 | 1507 |
|
1499 | 1508 |
/** |
1509 |
* @param taxonName |
|
1510 |
* @return |
|
1511 |
*/ |
|
1512 |
private static List<TaxonNode> getTaxonNodes(TaxonName taxonName) { |
|
1513 |
List<TaxonNode> result = new ArrayList<>(); |
|
1514 |
for (TaxonBase<?> tb:taxonName.getTaxonBases()){ |
|
1515 |
Taxon taxon; |
|
1516 |
//TODO handle ERMS taxon relationships |
|
1517 |
if (tb.isInstanceOf(Taxon.class)){ |
|
1518 |
taxon = CdmBase.deproxy(tb, Taxon.class); |
|
1519 |
}else{ |
|
1520 |
taxon = CdmBase.deproxy(tb, Synonym.class).getAcceptedTaxon(); |
|
1521 |
} |
|
1522 |
if (taxon != null){ |
|
1523 |
for (TaxonNode node : taxon.getTaxonNodes()){ |
|
1524 |
result.add(node); |
|
1525 |
} |
|
1526 |
} |
|
1527 |
} |
|
1528 |
return result; |
|
1529 |
} |
|
1530 |
|
|
1531 |
/** |
|
1500 | 1532 |
* Returns the <code>DisplayName</code> attribute. |
1501 | 1533 |
* @param taxon The {@link TaxonBase Taxon}. |
1502 | 1534 |
* @return The <code>DisplayName</code> attribute. |
Also available in: Unified diff
ref #1444, ref #8508, ref #8509 improve rank handling in ERMS pipeline (II)