import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.taxon.Synonym;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.strategy.StrategyBase;
import eu.etaxonomy.cdm.strategy.cache.HTMLTagRules;
}
boolean isSynonym = taxonBase.isInstanceOf(Synonym.class);
- String secSeparator = (isSynonym? " syn." : "") + " sec. ";
+ String secSeparator = isMisapplication(taxonBase)? " sensu " : (isSynonym? " syn." : "") + " sec. ";
//not used: we currently use a post-separator in the name tags
// if (nameTags.get(nameTags.size() - 1).getType().equals(TagEnum.nomStatus)){
// secSeparator = "," + secSeparator;
return tags;
}
+ private boolean isMisapplication(T taxonBase) {
+ if (! taxonBase.isInstanceOf(Taxon.class)){
+ return false;
+ }else{
+ return CdmBase.deproxy(taxonBase, Taxon.class).isMisapplicationOnly();
+ }
+ }
+
private List<TaggedText> getNameTags(T taxonBase) {
List<TaggedText> tags = new ArrayList<>();
TaxonName name = CdmBase.deproxy(taxonBase.getName());
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
import eu.etaxonomy.cdm.model.reference.ReferenceType;
+import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
import eu.etaxonomy.cdm.test.TermTestBase;
Assert.assertEquals("Abies alba (L.) Mill. sec. MLW 1983", taxonBase.getTitleCache());
}
+
+ @Test
+ public void testMisapplication(){
+ //assert default (taxon without relation)
+ Taxon man = Taxon.NewInstance(name, sec);
+ ITaxonCacheStrategy<Taxon> cacheStrategy = man.getCacheStrategy();
+ assertEquals("Taxon titlecache must use sec", expectedNameTitleCache + " sec. Sp.Pl.", cacheStrategy.getTitleCache(man));
+
+ //make it a MAN only
+ Taxon mainTaxon = Taxon.NewInstance(TaxonNameFactory.NewBacterialInstance(Rank.SPECIES()), ReferenceFactory.newBook() );
+ mainTaxon.addMisappliedName(man, null, null);
+ assertEquals("Taxon titlecache must use sensu", expectedNameTitleCache + " sensu Sp.Pl.", cacheStrategy.getTitleCache(man));
+
+ //add another from relation
+ Taxon relatedTaxon = Taxon.NewInstance(TaxonNameFactory.NewBacterialInstance(Rank.SPECIES()), ReferenceFactory.newBook() );
+ TaxonRelationship rel = man.addTaxonRelation(relatedTaxon, TaxonRelationshipType.CONGRUENT_TO(), null, null);
+ assertEquals("Taxon titlecache must use sec", expectedNameTitleCache + " sec. Sp.Pl.", cacheStrategy.getTitleCache(man));
+ man.removeTaxonRelation(rel);
+ assertEquals("Taxon titlecache must use sensu", expectedNameTitleCache + " sensu Sp.Pl.", cacheStrategy.getTitleCache(man));
+
+ //add another to relation
+ rel = relatedTaxon.addTaxonRelation(man, TaxonRelationshipType.CONGRUENT_TO(), null, null);
+ assertEquals("Taxon titlecache must use sec", expectedNameTitleCache + " sec. Sp.Pl.", cacheStrategy.getTitleCache(man));
+ man.removeTaxonRelation(rel);
+ assertEquals("Taxon titlecache must use sensu", expectedNameTitleCache + " sensu Sp.Pl.", cacheStrategy.getTitleCache(man));
+
+ //add taxon node
+ Classification c = Classification.NewInstance("Test");
+ TaxonNode tn = c.addChildTaxon(man, null);
+ assertEquals("Taxon titlecache must use sec", expectedNameTitleCache + " sec. Sp.Pl.", cacheStrategy.getTitleCache(man));
+ man.removeTaxonNode(tn);
+ assertEquals("Taxon titlecache must use sensu", expectedNameTitleCache + " sensu Sp.Pl.", cacheStrategy.getTitleCache(man));
+ }
}
\ No newline at end of file