Revision 14ec817b
Added by Andreas Müller over 5 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonNameImport.java | ||
---|---|---|
46 | 46 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
47 | 47 |
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference; |
48 | 48 |
import eu.etaxonomy.cdm.model.reference.Reference; |
49 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
49 | 50 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
51 |
import eu.etaxonomy.cdm.strategy.parser.INonViralNameParser; |
|
52 |
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl; |
|
50 | 53 |
|
51 | 54 |
/** |
52 | 55 |
* @author a.mueller |
... | ... | |
559 | 562 |
Reference nomReference = |
560 | 563 |
getReferenceFromMaps(refDetailMap, refMap, nomRefDetailFk, nomRefFk); |
561 | 564 |
|
565 |
if(config.isDoPreliminaryRefDetailsWithNames() && refDetailPrelim){ |
|
566 |
makePrelimRefDetailRef(config, rs, taxonName, nameId); |
|
567 |
} |
|
562 | 568 |
|
563 | 569 |
//setNomRef |
564 | 570 |
if (nomReference == null ){ |
... | ... | |
580 | 586 |
return success; |
581 | 587 |
} |
582 | 588 |
|
583 |
private static TeamOrPersonBase getAuthorTeam(Map<String, Team> teamMap, Object teamIdObject, int nameId, BerlinModelImportConfigurator bmiConfig){ |
|
584 |
if (teamIdObject == null){ |
|
589 |
|
|
590 |
private INonViralNameParser<?> parser = NonViralNameParserImpl.NewInstance(); |
|
591 |
|
|
592 |
/** |
|
593 |
* @param config |
|
594 |
* @param rs |
|
595 |
* @param taxonName |
|
596 |
* @param nameId |
|
597 |
* @throws SQLException |
|
598 |
*/ |
|
599 |
private void makePrelimRefDetailRef(IImportConfigurator config, ResultSet rs, TaxonName taxonName, int nameId) throws SQLException { |
|
600 |
String fullNomRefCache = rs.getString("FullNomRefCache"); |
|
601 |
if (fullNomRefCache == null){ |
|
602 |
logger.warn("fullNomRefCache is null for preliminary refDetail. NameId: " + nameId); |
|
603 |
return; |
|
604 |
}else if (fullNomRefCache.trim().startsWith(": ")){ |
|
605 |
logger.warn("fullNomRefCache starts with for preliminary refDetail. NameId: " + nameId); |
|
606 |
return; |
|
607 |
}else if (fullNomRefCache.trim().startsWith("in ")){ |
|
608 |
String fullStr = taxonName.getTitleCache()+ " " + fullNomRefCache; |
|
609 |
INonViralName newName = parser.parseReferencedName(fullStr, config.getNomenclaturalCode(), taxonName.getRank()); |
|
610 |
if (newName.isProtectedFullTitleCache()){ |
|
611 |
Reference nomRef = ReferenceFactory.newGeneric(); |
|
612 |
nomRef.setAbbrevTitleCache(fullNomRefCache, true); |
|
613 |
taxonName.setNomenclaturalReference(nomRef); |
|
614 |
//check detail |
|
615 |
}else{ |
|
616 |
Reference nomRef = newName.getNomenclaturalReference(); |
|
617 |
taxonName.setNomenclaturalReference(nomRef); |
|
618 |
String detail = newName.getNomenclaturalMicroReference(); |
|
619 |
String oldDetail = taxonName.getNomenclaturalMicroReference(); |
|
620 |
if (isBlank(detail)){ |
|
621 |
if (isNotBlank(oldDetail)){ |
|
622 |
logger.warn("Detail could not be parsed but seems to exist. NameId: " + nameId); |
|
623 |
} |
|
624 |
}else{ |
|
625 |
if (isNotBlank(oldDetail) && !detail.equals(oldDetail)){ |
|
626 |
logger.warn("Details differ: " + detail + " <-> " + oldDetail + ". NameId: " + nameId); |
|
627 |
} |
|
628 |
taxonName.setNomenclaturalMicroReference(detail); |
|
629 |
} |
|
630 |
} |
|
631 |
}else{ |
|
632 |
String fullStrComma = taxonName.getTitleCache()+ ", " + fullNomRefCache; |
|
633 |
String fullStrIn = taxonName.getTitleCache()+ " in " + fullNomRefCache; |
|
634 |
INonViralName newNameComma = parser.parseReferencedName(fullStrComma, config.getNomenclaturalCode(), taxonName.getRank()); |
|
635 |
INonViralName newNameIn = parser.parseReferencedName(fullStrIn, config.getNomenclaturalCode(), taxonName.getRank()); |
|
636 |
|
|
637 |
INonViralName newName; |
|
638 |
boolean commaProtected = newNameComma.isProtectedFullTitleCache() || (newNameComma.getNomenclaturalReference() != null |
|
639 |
&& newNameComma.getNomenclaturalReference().isProtectedTitleCache()); |
|
640 |
boolean inProtected = newNameIn.isProtectedFullTitleCache() || (newNameIn.getNomenclaturalReference() != null |
|
641 |
&& newNameIn.getNomenclaturalReference().isProtectedTitleCache()); |
|
642 |
if (commaProtected && !inProtected){ |
|
643 |
newName = newNameIn; |
|
644 |
}else if (!commaProtected && inProtected){ |
|
645 |
newName = newNameComma; |
|
646 |
}else if (commaProtected && inProtected){ |
|
647 |
logger.warn("Can't parse preliminary refDetail: " + fullNomRefCache + " for name " + taxonName.getTitleCache() + "; nameId: " + nameId ); |
|
648 |
newName = newNameComma; |
|
649 |
}else{ |
|
650 |
logger.warn("Can't decide ref type for preliminary refDetail: " + fullNomRefCache + " for name " + taxonName.getTitleCache() + "; nameId: " + nameId ); |
|
651 |
newName = newNameComma; |
|
652 |
} |
|
653 |
|
|
654 |
|
|
655 |
if (newName.isProtectedFullTitleCache()){ |
|
656 |
Reference nomRef = ReferenceFactory.newGeneric(); |
|
657 |
nomRef.setAbbrevTitleCache(fullNomRefCache, true); |
|
658 |
taxonName.setNomenclaturalReference(nomRef); |
|
659 |
//check detail |
|
660 |
}else{ |
|
661 |
Reference nomRef = newName.getNomenclaturalReference(); |
|
662 |
taxonName.setNomenclaturalReference(nomRef); |
|
663 |
String detail = newName.getNomenclaturalMicroReference(); |
|
664 |
String oldDetail = taxonName.getNomenclaturalMicroReference(); |
|
665 |
if (isBlank(detail)){ |
|
666 |
if (isNotBlank(oldDetail)){ |
|
667 |
logger.warn("Detail could not be parsed but seems to exist. NameId: " + nameId); |
|
668 |
} |
|
669 |
}else{ |
|
670 |
if (isNotBlank(oldDetail) && !detail.equals(oldDetail)){ |
|
671 |
logger.warn("Details differ: " + detail + " <-> " + oldDetail + ". NameId: " + nameId); |
|
672 |
} |
|
673 |
taxonName.setNomenclaturalMicroReference(detail); |
|
674 |
} |
|
675 |
} |
|
676 |
} |
|
677 |
} |
|
678 |
|
|
679 |
|
|
680 |
private static TeamOrPersonBase<?> getAuthorTeam(Map<String, Team> teamMap, Integer teamIdInt, int nameId, BerlinModelImportConfigurator config){ |
|
681 |
if (teamIdInt == null){ |
|
585 | 682 |
return null; |
586 | 683 |
}else { |
587 | 684 |
String teamIdStr = String.valueOf(teamIdInt); |
Also available in: Unified diff
ref #7800 parse preliminary RefDetails (first start)