Revision c013af56
#3868 Handle notho ranks correctly while formatting
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/name/NonViralNameDefaultCacheStrategy.java | ||
---|---|---|
18 | 18 |
import org.apache.log4j.Logger; |
19 | 19 |
|
20 | 20 |
import eu.etaxonomy.cdm.common.CdmUtils; |
21 |
import eu.etaxonomy.cdm.common.UTF8; |
|
21 | 22 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
22 | 23 |
import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor; |
23 | 24 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
... | ... | |
63 | 64 |
protected String BasionymStart = "("; |
64 | 65 |
protected String BasionymEnd = ")"; |
65 | 66 |
protected String ExAuthorSeperator = " ex "; |
67 |
private static String NOTHO = "notho"; |
|
66 | 68 |
protected CharSequence BasionymAuthorCombinationAuthorSeperator = " "; |
67 | 69 |
|
68 | 70 |
@Override |
... | ... | |
649 | 651 |
infraGenericMarker = "'undefined infrageneric rank'"; |
650 | 652 |
} |
651 | 653 |
String infraGenEpi = CdmUtils.Nz(nonViralName.getInfraGenericEpithet()).trim(); |
654 |
if (nonViralName.isBinomHybrid()){ |
|
655 |
infraGenericMarker = CdmUtils.concat("", NOTHO, infraGenericMarker); |
|
656 |
} |
|
652 | 657 |
|
653 | 658 |
addInfraGenericPart(nonViralName, tags, infraGenericMarker, infraGenEpi); |
654 | 659 |
|
... | ... | |
659 | 664 |
|
660 | 665 |
/** |
661 | 666 |
* Default implementation for the infrageneric part of a name. |
662 |
* This is usually the infrageneric marker and the infrageneric epitheton. But may be implemented differently e.g. for zoological |
|
663 |
* names the infrageneric epitheton may be surrounded by brackets and the marker left out. |
|
667 |
* This is usually the infrageneric marker and the infrageneric epitheton. But may be |
|
668 |
* implemented differently e.g. for zoological names the infrageneric epitheton |
|
669 |
* may be surrounded by brackets and the marker left out. |
|
664 | 670 |
* @param nonViralName |
665 | 671 |
* @param tags |
666 | 672 |
* @param infraGenericMarker |
667 | 673 |
*/ |
668 |
protected void addInfraGenericPart(NonViralName<?> name, List<TaggedText> tags, String infraGenericMarker, String infraGenEpi) { |
|
674 |
protected void addInfraGenericPart( |
|
675 |
@SuppressWarnings("unused") NonViralName<?> name, |
|
676 |
List<TaggedText> tags, |
|
677 |
String infraGenericMarker, |
|
678 |
String infraGenEpi) { |
|
669 | 679 |
//add marker |
670 | 680 |
tags.add(new TaggedText(TagEnum.rank, infraGenericMarker)); |
671 | 681 |
|
... | ... | |
742 | 752 |
*/ |
743 | 753 |
protected List<TaggedText> getInfraSpeciesTaggedNameCache(NonViralName<?> nonViralName, boolean includeMarker){ |
744 | 754 |
List<TaggedText> tags = getGenusAndSpeciesTaggedPart(nonViralName); |
745 |
if (includeMarker){ |
|
755 |
if (includeMarker || nonViralName.isTrinomHybrid()){
|
|
746 | 756 |
String marker = (nonViralName.getRank().getAbbreviation()).trim().replace("null", ""); |
757 |
if (nonViralName.isTrinomHybrid()){ |
|
758 |
marker = CdmUtils.concat("", NOTHO, marker); |
|
759 |
} |
|
747 | 760 |
if (StringUtils.isNotBlank(marker)){ |
748 | 761 |
tags.add(new TaggedText(TagEnum.rank, marker)); |
749 | 762 |
} |
763 |
|
|
750 | 764 |
} |
751 | 765 |
String infrSpecEpi = CdmUtils.Nz(nonViralName.getInfraSpecificEpithet()); |
752 |
if (nonViralName.isTrinomHybrid()){ |
|
753 |
addHybridPrefix(tags); |
|
754 |
} |
|
755 | 766 |
|
756 | 767 |
infrSpecEpi = infrSpecEpi.trim().replace("null", ""); |
768 |
|
|
757 | 769 |
if (StringUtils.isNotBlank(infrSpecEpi)){ |
758 | 770 |
tags.add(new TaggedText(TagEnum.name, infrSpecEpi)); |
759 | 771 |
} |
... | ... | |
786 | 798 |
if (hasInfraGenericEpi){ |
787 | 799 |
String infrGenEpi = nonViralName.getInfraGenericEpithet().trim(); |
788 | 800 |
if (nonViralName.isBinomHybrid()){ |
789 |
// addHybridPrefix(tags); FIXME hybridSign should be tag, but then we need to handle "(" ")" differently.
|
|
790 |
infrGenEpi = NonViralNameParserImplRegExBase.hybridSign + infrGenEpi;
|
|
801 |
//maybe not correct but not really expected to happen
|
|
802 |
infrGenEpi = UTF8.HYBRID + infrGenEpi;
|
|
791 | 803 |
} |
792 | 804 |
infrGenEpi = "(" + infrGenEpi + ")"; |
793 | 805 |
tags.add(new TaggedText(TagEnum.name, infrGenEpi)); |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/NonViralNameDefaultCacheStrategyTest.java | ||
---|---|---|
268 | 268 |
|
269 | 269 |
Assert.assertEquals("Should be 'Abies alba subsp. beta'", subSpeciesNameString, subSpeciesName.getTitleCache()); |
270 | 270 |
subSpeciesName.setTrinomHybrid(true); |
271 |
Assert.assertEquals("Should be 'Abies alba subsp. \u00D7beta'", "Abies alba subsp. \u00D7beta", subSpeciesName.getTitleCache());
|
|
271 |
Assert.assertEquals("Should be 'Abies alba nothosubsp. beta or nbeta'", "Abies alba nothosubsp. beta", subSpeciesName.getTitleCache());
|
|
272 | 272 |
subSpeciesName.setMonomHybrid(true); |
273 |
Assert.assertEquals("Should be '\u00D7Abies alba subsp. \u00D7beta'", "\u00D7Abies alba subsp. \u00D7beta", subSpeciesName.getTitleCache()); |
|
273 |
Assert.assertEquals("Should be '\u00D7Abies alba nothosubsp. beta'", "\u00D7Abies alba nothosubsp. beta", subSpeciesName.getTitleCache()); |
|
274 |
|
|
275 |
Assert.assertEquals("Should be 'Genus subg. InfraGenericPart'", "Genus subg. InfraGenericPart", subGenusName.getTitleCache()); |
|
276 |
subGenusName.setBinomHybrid(true); |
|
277 |
Assert.assertEquals("Should be 'Genus nothosubg. InfraGenericPart'", "Genus nothosubg. InfraGenericPart", subGenusName.getTitleCache()); |
|
274 | 278 |
} |
275 | 279 |
|
276 | 280 |
@Test |
Also available in: Unified diff