Revision ac5fb7af
Added by Andreas Müller about 7 years ago
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/EfloraTaxonImport.java | ||
---|---|---|
58 | 58 |
import eu.etaxonomy.cdm.model.description.TextData; |
59 | 59 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
60 | 60 |
import eu.etaxonomy.cdm.model.name.HomotypicalGroup; |
61 |
import eu.etaxonomy.cdm.model.name.INonViralName; |
|
61 | 62 |
import eu.etaxonomy.cdm.model.name.NameRelationshipType; |
62 | 63 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
63 | 64 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
64 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
|
65 | 65 |
import eu.etaxonomy.cdm.model.name.Rank; |
66 | 66 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
67 | 67 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus; |
... | ... | |
610 | 610 |
if (strGoto == null){ |
611 | 611 |
return ""; |
612 | 612 |
} |
613 |
String strGenusName = CdmBase.deproxy(taxon.getName(), NonViralName.class).getGenusOrUninomial();
|
|
613 |
String strGenusName = taxon.getName().getGenusOrUninomial();
|
|
614 | 614 |
strGoto = strGoto.replaceAll("\\([^\\(\\)]*\\)", ""); //replace all brackets |
615 | 615 |
strGoto = strGoto.replaceAll("\\s+", " "); //replace multiple whitespaces by exactly one whitespace |
616 | 616 |
|
... | ... | |
622 | 622 |
split[i] = strGenusName; |
623 | 623 |
} |
624 | 624 |
// if (isInfraSpecificMarker(single)){ |
625 |
// String strSpeciesName = CdmBase.deproxy(taxon.getName(), NonViralName.class).getSpecificEpithet();
|
|
625 |
// String strSpeciesName = taxon.getName().getSpecificEpithet();
|
|
626 | 626 |
// split[i] = strGenusName + " " + strSpeciesName + " "; |
627 | 627 |
// } |
628 | 628 |
result = (result + " " + split[i]).trim(); |
... | ... | |
1152 | 1152 |
*/ |
1153 | 1153 |
//body/taxon/ |
1154 | 1154 |
private HomotypicalGroup handleNomTaxon(EfloraImportState state, Element elNom, Taxon taxon, HomotypicalGroup homotypicalGroup, boolean isSynonym) { |
1155 |
NonViralName name = makeName(taxon, homotypicalGroup, isSynonym); |
|
1156 |
String num = null; |
|
1155 |
INonViralName nvn = makeName(taxon, homotypicalGroup, isSynonym); |
|
1156 |
TaxonNameBase<?,?> name = TaxonNameBase.castAndDeproxy(nvn); |
|
1157 |
String num = null; |
|
1157 | 1158 |
|
1158 | 1159 |
boolean hasGenusInfo = false; |
1159 |
TeamOrPersonBase lastTeam = null; |
|
1160 |
TeamOrPersonBase<?> lastTeam = null;
|
|
1160 | 1161 |
|
1161 | 1162 |
//genus |
1162 | 1163 |
List<Element> elGenus = XmlHelp.getAttributedChildListWithValue(elNom, "name", "class", "genus"); |
... | ... | |
1262 | 1263 |
} |
1263 | 1264 |
|
1264 | 1265 |
|
1265 |
private void handleQuestionMark(NonViralName name, Taxon taxon) { |
|
1266 |
private void handleQuestionMark(INonViralName name, Taxon taxon) {
|
|
1266 | 1267 |
int count = name.getTaxonBases().size(); |
1267 | 1268 |
if (count != 1){ |
1268 | 1269 |
logger.warn("Name has " + count + " taxa. This is not handled for question mark"); |
1269 | 1270 |
}else{ |
1270 |
TaxonBase taxonBase = (TaxonBase)name.getTaxonBases().iterator().next();
|
|
1271 |
TaxonBase taxonBase = name.getTaxonBases().iterator().next(); |
|
1271 | 1272 |
taxonBase.setDoubtful(true); |
1272 | 1273 |
} |
1273 | 1274 |
} |
1274 | 1275 |
|
1275 | 1276 |
|
1276 | 1277 |
//merge with handleNomTaxon |
1277 |
private void handleHomonym(EfloraImportState state, Element elHomonym, NonViralName upperName) {
|
|
1278 |
private void handleHomonym(EfloraImportState state, Element elHomonym, TaxonNameBase upperName) {
|
|
1278 | 1279 |
verifyNoAttribute(elHomonym); |
1279 | 1280 |
|
1280 | 1281 |
//hommonym name |
... | ... | |
1326 | 1327 |
}else{ |
1327 | 1328 |
upperName.addRelationshipToName(homonymName, relType, null); |
1328 | 1329 |
} |
1329 |
|
|
1330 | 1330 |
} |
1331 | 1331 |
|
1332 | 1332 |
|
... | ... | |
1347 | 1347 |
} |
1348 | 1348 |
|
1349 | 1349 |
|
1350 |
private void handleNameNote(NonViralName name, String value) { |
|
1350 |
private void handleNameNote(INonViralName name, String value) {
|
|
1351 | 1351 |
logger.warn("Name note: " + value + ". Available in portal?"); |
1352 | 1352 |
Annotation annotation = Annotation.NewInstance(value, AnnotationType.EDITORIAL(), Language.DEFAULT()); |
1353 | 1353 |
name.addAnnotation(annotation); |
... | ... | |
1359 | 1359 |
* @param name |
1360 | 1360 |
* @param value |
1361 | 1361 |
*/ |
1362 |
protected TeamOrPersonBase handleNameUsage(Taxon taxon, NonViralName<?> name, String referenceTitle, TeamOrPersonBase lastTeam) {
|
|
1362 |
protected TeamOrPersonBase handleNameUsage(Taxon taxon, INonViralName name, String referenceTitle, TeamOrPersonBase lastTeam) {
|
|
1363 | 1363 |
Reference ref = ReferenceFactory.newGeneric(); |
1364 | 1364 |
referenceTitle = removeStartingSymbols(referenceTitle, ref); |
1365 | 1365 |
|
... | ... | |
1374 | 1374 |
|
1375 | 1375 |
TaxonDescription description = getDescription(taxon); |
1376 | 1376 |
TextData textData = TextData.NewInstance(Feature.CITATION()); |
1377 |
textData.addSource(OriginalSourceType.PrimaryTaxonomicSource, null, null, ref, microReference, name, null); |
|
1377 |
textData.addSource(OriginalSourceType.PrimaryTaxonomicSource, null, null, ref, microReference, (TaxonNameBase)name, null);
|
|
1378 | 1378 |
description.addElement(textData); |
1379 | 1379 |
return team; |
1380 | 1380 |
} |
... | ... | |
1489 | 1489 |
* @param name |
1490 | 1490 |
* @return |
1491 | 1491 |
*/ |
1492 |
protected String parseHomonym(String detail, NonViralName name) {
|
|
1492 |
protected String parseHomonym(String detail, TaxonNameBase name) {
|
|
1493 | 1493 |
String result; |
1494 | 1494 |
if (detail == null){ |
1495 | 1495 |
return detail; |
... | ... | |
1521 | 1521 |
homonymName.setSpecificEpithet(name.getSpecificEpithet()); |
1522 | 1522 |
homonymName.setInfraSpecificEpithet(name.getInfraSpecificEpithet()); |
1523 | 1523 |
Reference homonymNomRef = ReferenceFactory.newGeneric(); |
1524 |
homonymNomRef.setTitleCache(homonymString); |
|
1524 |
homonymNomRef.setTitleCache(homonymString, true);
|
|
1525 | 1525 |
String homonymNomRefDetail = parseReferenceYearAndDetail(homonymNomRef); |
1526 | 1526 |
homonymName.setNomenclaturalMicroReference(homonymNomRefDetail); |
1527 | 1527 |
String authorTitle = homonymNomRef.getTitleCache(); |
... | ... | |
1558 | 1558 |
* @param name |
1559 | 1559 |
* @param value |
1560 | 1560 |
*/ |
1561 |
protected TeamOrPersonBase handleNomenclaturalReference(NonViralName name, String value) {
|
|
1561 |
protected TeamOrPersonBase handleNomenclaturalReference(TaxonNameBase name, String value) {
|
|
1562 | 1562 |
Reference nomRef = ReferenceFactory.newGeneric(); |
1563 | 1563 |
nomRef.setTitleCache(value, true); |
1564 | 1564 |
parseNomStatus(nomRef, name); |
... | ... | |
1566 | 1566 |
name.setNomenclaturalReference(nomRef); |
1567 | 1567 |
microReference = parseHomonym(microReference, name); |
1568 | 1568 |
name.setNomenclaturalMicroReference(microReference); |
1569 |
TeamOrPersonBase team = name.getCombinationAuthorship();
|
|
1569 |
TeamOrPersonBase<?> team = name.getCombinationAuthorship();
|
|
1570 | 1570 |
if (team == null){ |
1571 | 1571 |
logger.warn("Name has nom. ref. but no author team. Name: " + name.getTitleCache() + ", Nom.Ref.: " + value); |
1572 | 1572 |
}else{ |
... | ... | |
1575 | 1575 |
return team; |
1576 | 1576 |
} |
1577 | 1577 |
|
1578 |
private void handleInfrAuthor(EfloraImportState state, Element elAuthor, NonViralName name, boolean overwrite) { |
|
1578 |
private void handleInfrAuthor(EfloraImportState state, Element elAuthor, INonViralName name, boolean overwrite) {
|
|
1579 | 1579 |
String strAuthor = elAuthor.getValue().trim(); |
1580 | 1580 |
if (strAuthor.endsWith(",")){ |
1581 | 1581 |
strAuthor = strAuthor.substring(0, strAuthor.length() -1); |
... | ... | |
1600 | 1600 |
* @param infraRank |
1601 | 1601 |
* @return |
1602 | 1602 |
*/ |
1603 |
private Rank handleInfRank(NonViralName name, List<Element> elInfraRank, Rank infraRank) { |
|
1603 |
private Rank handleInfRank(INonViralName name, List<Element> elInfraRank, Rank infraRank) {
|
|
1604 | 1604 |
if (elInfraRank.size() == 1){ |
1605 | 1605 |
String strRank = elInfraRank.get(0).getTextNormalize(); |
1606 | 1606 |
try { |
... | ... | |
1622 | 1622 |
} |
1623 | 1623 |
|
1624 | 1624 |
|
1625 |
private void handleInfrEpi(NonViralName<?> name, Rank infraRank, String value) {
|
|
1625 |
private void handleInfrEpi(INonViralName name, Rank infraRank, String value) {
|
|
1626 | 1626 |
if (infraRank != null && infraRank.isInfraSpecific()){ |
1627 | 1627 |
name.setInfraSpecificEpithet(value); |
1628 | 1628 |
if (CdmUtils.isCapital(value)){ |
... | ... | |
1647 | 1647 |
* @param isSynonym |
1648 | 1648 |
* @return |
1649 | 1649 |
*/ |
1650 |
private NonViralName makeName(Taxon taxon,HomotypicalGroup homotypicalGroup, boolean isSynonym) {
|
|
1651 |
NonViralName name;
|
|
1650 |
private TaxonNameBase makeName(Taxon taxon,HomotypicalGroup homotypicalGroup, boolean isSynonym) {
|
|
1651 |
TaxonNameBase<?,?> name;
|
|
1652 | 1652 |
if (isSynonym){ |
1653 | 1653 |
name = BotanicalName.NewInstance(Rank.SPECIES(), homotypicalGroup); |
1654 | 1654 |
SynonymType synonymType = SynonymType.HETEROTYPIC_SYNONYM_OF(); |
... | ... | |
1657 | 1657 |
} |
1658 | 1658 |
taxon.addSynonymName(name, synonymType); |
1659 | 1659 |
}else{ |
1660 |
name = (NonViralName)taxon.getName();
|
|
1660 |
name = taxon.getName(); |
|
1661 | 1661 |
} |
1662 | 1662 |
return name; |
1663 | 1663 |
} |
... | ... | |
1667 | 1667 |
* @param element |
1668 | 1668 |
* @param taxon |
1669 | 1669 |
*/ |
1670 |
private void handleInfraspecificEpithet(Element element, String attrValue, NonViralName<?> name) {
|
|
1670 |
private void handleInfraspecificEpithet(Element element, String attrValue, INonViralName name) {
|
|
1671 | 1671 |
String value = element.getTextNormalize(); |
1672 | 1672 |
if (value.indexOf("subsp.") != -1){ |
1673 | 1673 |
//TODO genus and species epi |
... | ... | |
1690 | 1690 |
* @param element |
1691 | 1691 |
* @param name |
1692 | 1692 |
*/ |
1693 |
private void handleBasionymAuthor(EfloraImportState state, Element elBasionymAuthor, NonViralName name, boolean overwrite) { |
|
1693 |
private void handleBasionymAuthor(EfloraImportState state, Element elBasionymAuthor, INonViralName name, boolean overwrite) {
|
|
1694 | 1694 |
String strAuthor = elBasionymAuthor.getValue().trim(); |
1695 | 1695 |
Pattern reBasionymAuthor = Pattern.compile("^\\(.*\\)$"); |
1696 | 1696 |
if (reBasionymAuthor.matcher(strAuthor).matches()){ |
... | ... | |
1714 | 1714 |
* @param name |
1715 | 1715 |
* @param elNom |
1716 | 1716 |
*/ |
1717 |
private void handleNameAuthors(Element elAuthor, NonViralName name) { |
|
1717 |
private void handleNameAuthors(Element elAuthor, INonViralName name) {
|
|
1718 | 1718 |
if (name.getCombinationAuthorship() != null){ |
1719 | 1719 |
logger.warn("Name already has a combination author. Name: " + name.getTitleCache() + ", Author: " + elAuthor.getTextNormalize()); |
1720 | 1720 |
} |
... | ... | |
1955 | 1955 |
* @param value |
1956 | 1956 |
* @param taxonNameBase |
1957 | 1957 |
*/ |
1958 |
private void handleSubGenus(String value, TaxonNameBase taxonNameBase) {
|
|
1958 |
private void handleSubGenus(String value, INonViralName taxonNameBase) {
|
|
1959 | 1959 |
String name = value.replace("Subgenus", "").trim(); |
1960 |
((NonViralName)taxonNameBase).setInfraGenericEpithet(name);
|
|
1960 |
taxonNameBase.setInfraGenericEpithet(name);
|
|
1961 | 1961 |
} |
1962 | 1962 |
|
1963 | 1963 |
/** |
1964 | 1964 |
* @param value |
1965 | 1965 |
* @param taxonNameBase |
1966 | 1966 |
*/ |
1967 |
private void handleSection(String value, TaxonNameBase taxonNameBase) {
|
|
1967 |
private void handleSection(String value, INonViralName taxonNameBase) {
|
|
1968 | 1968 |
String name = value.replace("Section", "").trim(); |
1969 |
((NonViralName)taxonNameBase).setInfraGenericEpithet(name);
|
|
1969 |
taxonNameBase.setInfraGenericEpithet(name);
|
|
1970 | 1970 |
} |
1971 | 1971 |
|
1972 | 1972 |
/** |
... | ... | |
2000 | 2000 |
* @param value |
2001 | 2001 |
* @param taxonNameBase |
2002 | 2002 |
*/ |
2003 |
protected void handleGenus(String value, TaxonNameBase taxonName) {
|
|
2003 |
protected void handleGenus(String value, INonViralName taxonName) {
|
|
2004 | 2004 |
Matcher matcher = rexGenusAuthor.matcher(value); |
2005 | 2005 |
if (matcher.find()){ |
2006 | 2006 |
String author = matcher.group(); |
... | ... | |
2010 | 2010 |
team.setTitleCache(author, true); |
2011 | 2011 |
Credit credit = Credit.NewInstance(team, null); |
2012 | 2012 |
taxonName.addCredit(credit); |
2013 |
// NonViralName nvn = (NonViralName)taxonName; |
|
2014 |
// nvn.setCombinationAuthorship(team); |
|
2015 |
// nvn.setGenusOrUninomial(genus); |
|
2013 |
// taxonName.setCombinationAuthorship(team); |
|
2014 |
// taxonName.setGenusOrUninomial(genus); |
|
2016 | 2015 |
}else{ |
2017 | 2016 |
logger.info("No Author match for " + value); |
2018 | 2017 |
} |
... | ... | |
2170 | 2169 |
* @param ref |
2171 | 2170 |
* @param nonViralName |
2172 | 2171 |
*/ |
2173 |
protected void parseNomStatus(Reference ref, NonViralName nonViralName) {
|
|
2172 |
protected void parseNomStatus(Reference ref, TaxonNameBase nonViralName) {
|
|
2174 | 2173 |
String titleToParse = ref.getTitleCache(); |
2175 | 2174 |
|
2176 | 2175 |
String noStatusTitle = parser.parseNomStatus(titleToParse, nonViralName, true); |
Also available in: Unified diff
ref #6369 adapt existing occurrences of interface to removed generics in cdmlib-app