Revision 86536e03
Added by Andreas Müller almost 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/cuba/CubaExcelImport.java | ||
---|---|---|
45 | 45 |
import eu.etaxonomy.cdm.model.description.TaxonInteraction; |
46 | 46 |
import eu.etaxonomy.cdm.model.description.TextData; |
47 | 47 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
48 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
|
49 | 48 |
import eu.etaxonomy.cdm.model.name.HomotypicalGroup; |
50 | 49 |
import eu.etaxonomy.cdm.model.name.IBotanicalName; |
51 | 50 |
import eu.etaxonomy.cdm.model.name.NameRelationship; |
... | ... | |
54 | 53 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus; |
55 | 54 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
56 | 55 |
import eu.etaxonomy.cdm.model.name.Rank; |
57 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
|
56 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
58 | 57 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
59 | 58 |
import eu.etaxonomy.cdm.model.reference.Reference; |
60 | 59 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
... | ... | |
397 | 396 |
if (missapliedMatcher.matches()){ |
398 | 397 |
boolean doubtful = missapliedMatcher.group(1) != null; |
399 | 398 |
String firstPart = missapliedMatcher.group(2); |
400 |
BotanicalName name = (BotanicalName)nameParser.parseSimpleName(firstPart, state.getConfig().getNomenclaturalCode(), Rank.SPECIES());
|
|
399 |
IBotanicalName name = (IBotanicalName)nameParser.parseSimpleName(firstPart, state.getConfig().getNomenclaturalCode(), Rank.SPECIES());
|
|
401 | 400 |
name.addSource(makeOriginalSource(state)); |
402 | 401 |
|
403 | 402 |
String secondPart = missapliedMatcher.group(3); |
... | ... | |
428 | 427 |
if (StringUtils.isNotBlank(afterInval)){ |
429 | 428 |
logger.warn(state.getCurrentLine() + ": After inval to be implemented: " + afterInval); |
430 | 429 |
} |
431 |
BotanicalName name = (BotanicalName)nameParser.parseSimpleName(firstPart, state.getConfig().getNomenclaturalCode(), Rank.SPECIES());
|
|
430 |
TaxonName name = (TaxonName)nameParser.parseSimpleName(firstPart, state.getConfig().getNomenclaturalCode(), Rank.SPECIES());
|
|
432 | 431 |
name.addSource(makeOriginalSource(state)); |
433 | 432 |
NomenclaturalStatus status = NomenclaturalStatus.NewInstance( NomenclaturalStatusType.INVALID()); |
434 | 433 |
name.addStatus(status); |
... | ... | |
437 | 436 |
}else if (sphalmMatcher.matches()){ |
438 | 437 |
String firstPart = sphalmMatcher.group(1); |
439 | 438 |
String sphalmPart = synonymStr.replace(firstPart, "").replace("“","").replace("”","").trim(); |
440 |
BotanicalName name = (BotanicalName)nameParser.parseSimpleName(firstPart, state.getConfig().getNomenclaturalCode(), Rank.SPECIES());
|
|
439 |
TaxonName name = (TaxonName)nameParser.parseSimpleName(firstPart, state.getConfig().getNomenclaturalCode(), Rank.SPECIES());
|
|
441 | 440 |
// NomenclaturalStatus status = NomenclaturalStatus.NewInstance( NomenclaturalStatusType.INVALID()); |
442 | 441 |
// name.addStatus(status); |
443 | 442 |
name.addSource(makeOriginalSource(state)); |
... | ... | |
457 | 456 |
boolean isDoubtful = firstPart.matches("^\\?\\s*.*"); |
458 | 457 |
firstPart = replaceHomonIlleg(firstPart); |
459 | 458 |
boolean isHomonym = firstPart.matches(".*" + HOMONYM_MARKER); |
460 |
BotanicalName synName = makeName(state, firstPart);
|
|
459 |
TaxonName synName = (TaxonName)makeName(state, firstPart);
|
|
461 | 460 |
if (synName.isProtectedTitleCache()){ |
462 | 461 |
logger.warn(line + "Heterotypic base synonym could not be parsed correctly: " + firstPart); |
463 | 462 |
} |
... | ... | |
471 | 470 |
checkFirstSynonym(state, list, isFirstSynonym, synonymStr, true); |
472 | 471 |
|
473 | 472 |
}else if (isSpecialHeterotypic(synonymStr)){ |
474 |
BotanicalName synName = makeName(state, synonymStr);
|
|
473 |
TaxonName synName = (TaxonName)makeName(state, synonymStr);
|
|
475 | 474 |
if (synName.isProtectedTitleCache()){ |
476 | 475 |
logger.warn(line + "Special heterotypic synonym could not be parsed correctly:" + synonymStr); |
477 | 476 |
} |
... | ... | |
609 | 608 |
for (String split : splits){ |
610 | 609 |
split = replaceHomonIlleg(split); |
611 | 610 |
boolean isHomonym = split.matches(".*" + HOMONYM_MARKER); |
612 |
TaxonNameBase<?,?> newName = makeName(state, split);
|
|
611 |
TaxonName<?,?> newName = (TaxonName)makeName(state, split);
|
|
613 | 612 |
newName.setHomotypicalGroup(homotypicGroup); //not really necessary as this is later set anyway |
614 | 613 |
if (newName.isProtectedTitleCache()){ |
615 | 614 |
logger.warn(state.getCurrentLine() + ": homotypic name part could not be parsed: " + split); |
... | ... | |
672 | 671 |
int i = 0; |
673 | 672 |
for (String split : splits){ |
674 | 673 |
split = split.replaceAll("^non\\s+", ""); |
675 |
BotanicalName newName = makeName(state, split);
|
|
674 |
TaxonName newName = (TaxonName)makeName(state, split);
|
|
676 | 675 |
// BotanicalName newName = (BotanicalName)nameParser.parseReferencedName(split, state.getConfig().getNomenclaturalCode(), Rank.SPECIES()); |
677 | 676 |
if (newName.isProtectedTitleCache()){ |
678 | 677 |
logger.warn(state.getCurrentLine() + ": homonym name could not be parsed: " + split); |
... | ... | |
694 | 693 |
for (String spliti : splitsi){ |
695 | 694 |
|
696 | 695 |
String split = spliti.replaceAll("^non\\s+", ""); |
697 |
BotanicalName newName = makeName(state, split); |
|
696 |
IBotanicalName newName = makeName(state, split);
|
|
698 | 697 |
if (newName.isProtectedTitleCache()){ |
699 | 698 |
logger.warn(state.getCurrentLine() + ": blocking name could not be parsed: " + split); |
700 | 699 |
} |
... | ... | |
708 | 707 |
} |
709 | 708 |
} |
710 | 709 |
if (candidates.size() == 1){ |
711 |
TaxonNameBase<?,?> blockedName = (TaxonNameBase<?,?>)candidates.iterator().next();
|
|
710 |
TaxonName<?,?> blockedName = (TaxonName<?,?>)candidates.iterator().next();
|
|
712 | 711 |
newName.addRelationshipToName(blockedName, NameRelationshipType.BLOCKING_NAME_FOR(), null); |
713 | 712 |
replacementNameCandidates.add(blockedName); |
714 | 713 |
}else{ |
... | ... | |
726 | 725 |
HomotypicalGroup homotypicGroup, |
727 | 726 |
List<IBotanicalName> replacementNameCandidates) { |
728 | 727 |
String line = state.getCurrentLine() +": "; |
729 |
List<BotanicalName> replacedCandidates = new ArrayList<>(); |
|
730 |
for (TaxonNameBase<?, ?> typifiedName : homotypicGroup.getTypifiedNames()){
|
|
731 |
BotanicalName candidate = (BotanicalName)typifiedName;
|
|
728 |
List<IBotanicalName> replacedCandidates = new ArrayList<>();
|
|
729 |
for (TaxonName<?, ?> typifiedName : homotypicGroup.getTypifiedNames()){ |
|
730 |
IBotanicalName candidate = typifiedName;
|
|
732 | 731 |
if (candidate.getBasionymAuthorship() == null){ |
733 | 732 |
if (candidate.getStatus().isEmpty()){ |
734 | 733 |
if (! replacementNameCandidates.contains(candidate)){ |
... | ... | |
738 | 737 |
} |
739 | 738 |
} |
740 | 739 |
if (replacedCandidates.size() == 1){ |
741 |
TaxonNameBase<?,?> replacedSynonym = replacedCandidates.iterator().next();
|
|
740 |
TaxonName<?,?> replacedSynonym = (TaxonName)replacedCandidates.iterator().next();
|
|
742 | 741 |
for (IBotanicalName replacementName : replacementNameCandidates){ |
743 | 742 |
replacementName.addReplacedSynonym(replacedSynonym, null, null, null); |
744 | 743 |
} |
... | ... | |
773 | 772 |
private void createBasionymRelationIfPossible(CubaImportState state, IBotanicalName name1, |
774 | 773 |
IBotanicalName name2, |
775 | 774 |
boolean name2isHomonym, boolean onlyIfNotYetExists) { |
776 |
TaxonNameBase<?,?> basionymName = TaxonNameBase.castAndDeproxy(name1);
|
|
777 |
TaxonNameBase<?,?> newCombination = TaxonNameBase.castAndDeproxy(name2);
|
|
775 |
TaxonName<?,?> basionymName = TaxonName.castAndDeproxy(name1);
|
|
776 |
TaxonName<?,?> newCombination = TaxonName.castAndDeproxy(name2);
|
|
778 | 777 |
//exactly one name must have a basionym author |
779 | 778 |
if (name1.getBasionymAuthorship() == null && name2.getBasionymAuthorship() == null |
780 | 779 |
|| name1.getBasionymAuthorship() != null && name2.getBasionymAuthorship() != null){ |
... | ... | |
783 | 782 |
|
784 | 783 |
//switch order if necessary |
785 | 784 |
if (! name2isHomonym && basionymName.getBasionymAuthorship() != null && newCombination.getBasionymAuthorship() == null){ |
786 |
basionymName = TaxonNameBase.castAndDeproxy(name2);
|
|
787 |
newCombination = TaxonNameBase.castAndDeproxy(name1);
|
|
785 |
basionymName = TaxonName.castAndDeproxy(name2); |
|
786 |
newCombination = TaxonName.castAndDeproxy(name1); |
|
788 | 787 |
} |
789 | 788 |
if (matchAuthor(basionymName.getCombinationAuthorship(), newCombination.getBasionymAuthorship()) |
790 | 789 |
&& BasionymRelationCreator.matchLastNamePart(basionymName, newCombination)){ |
... | ... | |
874 | 873 |
taxonStr.replace("auct.", "").trim(); |
875 | 874 |
} |
876 | 875 |
state.setTaxonIsAbsent(isAbsent); |
877 |
BotanicalName botanicalName = makeName(state, taxonStr); |
|
876 |
IBotanicalName botanicalName = makeName(state, taxonStr);
|
|
878 | 877 |
Reference sec = getSecReference(state); |
879 | 878 |
Taxon taxon = Taxon.NewInstance(botanicalName, sec); |
880 | 879 |
if (isAuct){ |
... | ... | |
891 | 890 |
if (genus != null){ |
892 | 891 |
higherNode = genus.getTaxonNodes().iterator().next(); |
893 | 892 |
}else{ |
894 |
BotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS()); |
|
893 |
IBotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
|
|
895 | 894 |
name.addSource(makeOriginalSource(state)); |
896 | 895 |
name.setGenusOrUninomial(genusStr); |
897 | 896 |
genus = Taxon.NewInstance(name, sec); |
... | ... | |
917 | 916 |
* @param taxonStr |
918 | 917 |
* @return |
919 | 918 |
*/ |
920 |
private BotanicalName makeName(CubaImportState state, String nameStrOrig) { |
|
919 |
private IBotanicalName makeName(CubaImportState state, String nameStrOrig) {
|
|
921 | 920 |
//normalize |
922 | 921 |
String nameStr = normalizeStatus(nameStrOrig); |
923 | 922 |
//orthVar |
... | ... | |
935 | 934 |
nameStr = nameStr.replace("nom. inval.", "").trim(); |
936 | 935 |
} |
937 | 936 |
|
938 |
BotanicalName result = (BotanicalName)nameParser.parseReferencedName(nameStr, nc, Rank.SPECIES());
|
|
937 |
TaxonName result = (TaxonName)nameParser.parseReferencedName(nameStr, nc, Rank.SPECIES());
|
|
939 | 938 |
result.addSource(makeOriginalSource(state)); |
940 | 939 |
if (isNomInval){ |
941 | 940 |
result.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.INVALID())); |
942 | 941 |
} |
943 | 942 |
if (orthVar != null){ |
944 |
BotanicalName orthVarName = (BotanicalName)result.clone();
|
|
943 |
TaxonName orthVarName = (TaxonName)result.clone();
|
|
945 | 944 |
orthVarName.addSource(makeOriginalSource(state)); |
946 | 945 |
//TODO |
947 | 946 |
Reference citation = null; |
... | ... | |
1077 | 1076 |
if (family != null){ |
1078 | 1077 |
familyNode = family.getTaxonNodes().iterator().next(); |
1079 | 1078 |
}else{ |
1080 |
BotanicalName name = makeFamilyName(state, familyStr);
|
|
1079 |
TaxonName name = (TaxonName)makeFamilyName(state, familyStr);
|
|
1081 | 1080 |
Reference sec = getSecReference(state); |
1082 | 1081 |
family = Taxon.NewInstance(name, sec); |
1083 | 1082 |
ITaxonTreeNode rootNode = getClassification(state); |
... | ... | |
1088 | 1087 |
|
1089 | 1088 |
if (isNotBlank(alternativeFamilyStr)){ |
1090 | 1089 |
NameRelationshipType type = NameRelationshipType.ALTERNATIVE_NAME(); |
1091 |
BotanicalName alternativeName = makeFamilyName(state, alternativeFamilyStr);
|
|
1092 |
BotanicalName familyName = (BotanicalName)family.getName();
|
|
1090 |
TaxonName alternativeName = (TaxonName)makeFamilyName(state, alternativeFamilyStr);
|
|
1091 |
IBotanicalName familyName = family.getName();
|
|
1093 | 1092 |
boolean hasRelation = false; |
1094 | 1093 |
for (NameRelationship nameRel : familyName.getRelationsToThisName()){ |
1095 | 1094 |
if (nameRel.getType().equals(type)){ |
... | ... | |
1179 | 1178 |
String key = famRef.getTitle() + ":"+ famStr; |
1180 | 1179 |
Taxon family = state.getHigherTaxon(key); |
1181 | 1180 |
if (family == null){ |
1182 |
BotanicalName name = makeFamilyName(state, famStr); |
|
1181 |
IBotanicalName name = makeFamilyName(state, famStr);
|
|
1183 | 1182 |
family = Taxon.NewInstance(name, famRef); |
1184 | 1183 |
state.putHigherTaxon(key, family); |
1185 | 1184 |
} |
... | ... | |
1193 | 1192 |
* @param famStr |
1194 | 1193 |
* @return |
1195 | 1194 |
*/ |
1196 |
private BotanicalName makeFamilyName(CubaImportState state, String famStr) { |
|
1197 |
BotanicalName name = state.getFamilyName(famStr); |
|
1195 |
private IBotanicalName makeFamilyName(CubaImportState state, String famStr) {
|
|
1196 |
IBotanicalName name = state.getFamilyName(famStr);
|
|
1198 | 1197 |
if (name == null){ |
1199 | 1198 |
name = TaxonNameFactory.NewBotanicalInstance(Rank.FAMILY()); |
1200 | 1199 |
name.setGenusOrUninomial(famStr); |
... | ... | |
1230 | 1229 |
classification.getRootNode().setUuid(rootUuid); |
1231 | 1230 |
} |
1232 | 1231 |
|
1233 |
BotanicalName plantaeName = TaxonNameFactory.NewBotanicalInstance(Rank.KINGDOM()); |
|
1232 |
IBotanicalName plantaeName = TaxonNameFactory.NewBotanicalInstance(Rank.KINGDOM());
|
|
1234 | 1233 |
plantaeName.setGenusOrUninomial("Plantae"); |
1235 | 1234 |
Taxon plantae = Taxon.NewInstance(plantaeName, sec); |
1236 | 1235 |
TaxonNode plantaeNode = classification.addChildTaxon(plantae, null, null); |
Also available in: Unified diff
fix #6368 rename table and class TaxonNameBase in app-import