use of eu.etaxonomy.cdm.strategy.cache.TaggedText in project cdmlib by cybertaxonomy.
the class NameServiceImpl method getTaggedName.
@Override
public List<TaggedText> getTaggedName(UUID uuid) {
TaxonName taxonName = dao.load(uuid);
List<TaggedText> taggedName = taxonName.getTaggedName();
return taggedName;
}
use of eu.etaxonomy.cdm.strategy.cache.TaggedText in project cdmlib by cybertaxonomy.
the class TaxonRelationshipsDTOTest method test.
@Test
@Ignore
public void test() {
// 2
Reference sec2 = ReferenceFactory.newGeneric();
sec2.setAuthorship(Person.NewInstance("Mue.", "Mueller", "I.", "Inger"));
sec2.setDatePublished(TimePeriodParser.parseStringVerbatim("1987"));
Taxon from2 = Taxon.NewInstance(fromName, sec2);
TaxonRelationship rel2 = toTaxon.addMisappliedName(from2, sec2, "333");
// 3
// same as rel1 except for sec
TaxonRelationship rel3 = toTaxon.addMisappliedName(from2, taxonRel.getCitation(), taxonRel.getCitationMicroReference());
Taxon taxon2 = Taxon.NewInstance(fromName, sec2);
Taxon taxon2Dupl = Taxon.NewInstance(fromName, toSec);
// 4
TaxonRelationship rel4 = toTaxon.addMisappliedName(taxon2, null, null);
TaxonRelationship rel5 = toTaxon.addMisappliedName(taxon2Dupl, null, null);
TaxonRelationshipsDTO dto = new TaxonRelationshipsDTO();
dto.addRelation(taxonRel, Direction.relatedFrom, languages);
dto.addRelation(rel2, Direction.relatedFrom, languages);
TaxonRelationDTO relToDuplicate = dto.addRelation(rel3, Direction.relatedFrom, languages);
dto.addRelation(rel4, Direction.relatedFrom, languages);
TaxonRelationDTO duplicateWithoutRelSec2 = dto.addRelation(rel5, Direction.relatedFrom, languages);
dto.createMisapplicationString();
List<List<TaggedText>> misapplications = dto.getMisapplications();
// 2/5 were deduplicated
Assert.assertEquals("2 of 5 misapplications must be deduplicated", 3, misapplications.size());
List<TaggedText> deduplicated = misapplications.get(0);
Assert.assertEquals(13, deduplicated.size());
Assert.assertSame(relToDuplicate.getTaggedText().get(6), deduplicated.get(8));
Assert.assertEquals(11, misapplications.get(1).size());
deduplicated = misapplications.get(2);
Assert.assertEquals(9, deduplicated.size());
Assert.assertSame(duplicateWithoutRelSec2.getTaggedText().get(6), deduplicated.get(8));
}
use of eu.etaxonomy.cdm.strategy.cache.TaggedText in project cdmlib by cybertaxonomy.
the class TypeDesignationSetFormatterTest method testNameTypeDesignationTaggedText.
@Test
public void testNameTypeDesignationTaggedText() throws RegistrationValidationException {
@SuppressWarnings("rawtypes") List<TypeDesignationBase> tds = new ArrayList<>();
tds.add(ntd);
TaxonName typifiedName = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
typifiedName.setTitleCache("Prionus L.", true);
typifiedName.addTypeDesignation(ntd, false);
TypeDesignationSetManager manager = new TypeDesignationSetManager(tds);
TypeDesignationSetFormatter formatter = new TypeDesignationSetFormatter(true, true, true);
String text = formatter.format(manager);
Assert.assertEquals("Prionus L.\u202F\u2013\u202FNametype: Prionus coriatius L.", text);
List<TaggedText> taggedText = formatter.toTaggedText(manager);
Assert.assertEquals("first entry should be the typified name", new TaggedText(TagEnum.name, "Prionus L.", TypedEntityReference.fromEntity(typifiedName, false)), taggedText.get(0));
Assert.assertEquals("fourth entry should be the name type nameCache", new TaggedText(TagEnum.name, "Prionus"), // maybe in future the entityReference should be TypedEntityReference.fromEntity(ntd.getTypeName(), false)
taggedText.get(3));
Assert.assertEquals("fourth entry should be the name type nameCache", new TaggedText(TagEnum.name, "coriatius"), // maybe in future the entityReference should be TypedEntityReference.fromEntity(ntd.getTypeName(), false)
taggedText.get(4));
Assert.assertEquals("fifth entry should be the name type authorship cache", new TaggedText(TagEnum.authors, "L."), taggedText.get(5));
// protected titleCache
ntd.getTypeName().setTitleCache("Prionus coriatius L.", true);
taggedText = formatter.toTaggedText(manager);
Assert.assertEquals("fourth entry should be the name type titleCache", new TaggedText(TagEnum.name, "Prionus coriatius L."), // maybe in future the entityReference should be TypedEntityReference.fromEntity(ntd.getTypeName(), false)
taggedText.get(3));
Assert.assertEquals("there should be 4 tags only", 4, taggedText.size());
}
use of eu.etaxonomy.cdm.strategy.cache.TaggedText in project cdmlib by cybertaxonomy.
the class TypeDesignationSetFormatterTest method testSpecimenTypeDesignationTaggedTextWithStatus.
@Test
public void testSpecimenTypeDesignationTaggedTextWithStatus() throws RegistrationValidationException {
@SuppressWarnings("rawtypes") List<TypeDesignationBase> tds = new ArrayList<>();
tds.add(std_HT);
TaxonName typifiedName = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
typifiedName.setTitleCache("Prionus coriatius L.", true);
typifiedName.addTypeDesignation(std_HT, false);
// TODO not yet handled in cache strategy as we do not have tagged text here
Reference statusSource = ReferenceFactory.newBook();
statusSource.setTitle("Status test");
std_HT.getTypeSpecimen().addStatus(OccurrenceStatus.NewInstance(DefinedTerm.getTermByUuid(DefinedTerm.uuidDestroyed), statusSource, "335"));
TypeDesignationSetManager manager = new TypeDesignationSetManager(tds);
TypeDesignationSetFormatter formatter = new TypeDesignationSetFormatter(true, true, true);
String text = formatter.format(manager);
Assert.assertEquals("Prionus coriatius L.\u202F\u2013\u202FType: Testland, near Bughausen, A.Kohlbecker 81989, 2017 (holotype: OHA 1234, destroyed)", text);
List<TaggedText> taggedText = formatter.toTaggedText(manager);
Assert.assertEquals("first entry should be the typified name", new TaggedText(TagEnum.name, "Prionus coriatius L.", TypedEntityReference.fromEntity(typifiedName, false)), taggedText.get(0));
// Assert.assertEquals("fourth entry should be the name type nameCache",
// new TaggedText(TagEnum.name, "Prionus"), taggedText.get(3)); //maybe in future the entityReference should be TypedEntityReference.fromEntity(ntd.getTypeName(), false)
// Assert.assertEquals("fourth entry should be the name type nameCache",
// new TaggedText(TagEnum.name, "coriatius"), taggedText.get(4)); //maybe in future the entityReference should be TypedEntityReference.fromEntity(ntd.getTypeName(), false)
// Assert.assertEquals("fifth entry should be the name type authorship cache",
// new TaggedText(TagEnum.authors, "L."), taggedText.get(5));
//
// //protected titleCache
// ntd.getTypeName().setTitleCache("Prionus coriatius L.", true);
// taggedText = formatter.toTaggedText(manager);
// Assert.assertEquals("fourth entry should be the name type titleCache",
// new TaggedText(TagEnum.name, "Prionus coriatius L."), taggedText.get(3)); //maybe in future the entityReference should be TypedEntityReference.fromEntity(ntd.getTypeName(), false)
// Assert.assertEquals("there should be 4 tags only", 4, taggedText.size());
}
use of eu.etaxonomy.cdm.strategy.cache.TaggedText in project cdmlib by cybertaxonomy.
the class TaxonRelationshipFormatterTest method testGetFamilyNames.
@Test
public void testGetFamilyNames() {
// Test start condition with single person
List<TaggedText> tags = formatter.getTaggedText(taxonRel, reverse, languages);
String str = TaggedCacheHelper.createString(tags);
Assert.assertFalse("Formatted text should not contain the team correctly formatted", str.contains("Macfarlane & Cheek"));
// use team
Team secRelTeam = Team.NewInstance();
secRelTeam.addTeamMember(macFarlane);
secRelTeam.addTeamMember(cheek);
relSec.setAuthorship(secRelTeam);
tags = formatter.getTaggedText(taxonRel, reverse, languages);
str = TaggedCacheHelper.createString(tags);
System.out.println(str);
Assert.assertTrue(str.contains("rel. sec. Macfarlane & Cheek 1919"));
// add third member
secRelTeam.addTeamMember(toSecAuthor);
tags = formatter.getTaggedText(taxonRel, reverse, languages);
str = TaggedCacheHelper.createString(tags);
System.out.println(str);
Assert.assertTrue(str.contains("rel. sec. Macfarlane & al. 1919"));
// add et al.
secRelTeam.setHasMoreMembers(true);
tags = formatter.getTaggedText(taxonRel, reverse, languages);
str = TaggedCacheHelper.createString(tags);
System.out.println(str);
Assert.assertTrue(str.contains("rel. sec. Macfarlane & al. 1919"));
}
Aggregations