use of eu.etaxonomy.cdm.model.name.NomenclaturalStatus in project cdmlib by cybertaxonomy.
the class CsvNameExport method createNewRecord.
private HashMap<String, String> createNewRecord(TaxonNode childNode, CsvNameExportState state) {
HashMap<String, String> nameRecord = new HashMap<>();
nameRecord.put("classification", childNode.getClassification().getTitleCache());
if (!childNode.getTaxon().getName().getRank().isLower(Rank.GENUS())) {
return null;
}
TaxonNode familyNode = getHigherNode(childNode, Rank.FAMILY());
Taxon taxon;
String nameString;
IBotanicalName name;
if (familyNode == null) {
nameRecord.put("familyTaxon", null);
nameRecord.put("familyName", null);
nameRecord.put("descriptionsFam", null);
} else {
familyNode = CdmBase.deproxy(familyNode);
familyNode.getTaxon().setProtectedTitleCache(true);
nameRecord.put("familyTaxon", familyNode.getTaxon().getTitleCache());
if (familyMap.get(familyNode.getTaxon().getUuid()) != null) {
nameRecord.putAll(familyMap.get(familyNode.getTaxon().getUuid()));
} else {
taxon = (Taxon) getTaxonService().load(familyNode.getTaxon().getUuid());
taxon = CdmBase.deproxy(taxon);
name = CdmBase.deproxy(taxon.getName());
nameRecord.put("familyName", name.getNameCache());
extractDescriptions(nameRecord, taxon, Feature.INTRODUCTION(), "descriptionsFam", state);
familyMap.put(familyNode.getTaxon().getUuid(), nameRecord);
}
}
TaxonNode genusNode = getHigherNode(childNode, Rank.GENUS());
if (genusNode != null) {
genusNode = CdmBase.deproxy(genusNode);
genusNode.getTaxon().setProtectedTitleCache(true);
nameRecord.put("genusTaxon", genusNode.getTaxon().getTitleCache());
if (genusMap.get(genusNode.getTaxon().getUuid()) != null) {
nameRecord.putAll(genusMap.get(genusNode.getTaxon().getUuid()));
} else {
taxon = (Taxon) getTaxonService().load(genusNode.getTaxon().getUuid());
taxon = CdmBase.deproxy(taxon);
name = CdmBase.deproxy(taxon.getName());
if (name.getNameCache() != null) {
nameRecord.put("genusName", name.getNameCache());
} else {
nameRecord.put("genusName", name.getGenusOrUninomial());
}
extractDescriptions(nameRecord, taxon, getNotesFeature(state), "descriptionsGen", state);
genusMap.put(genusNode.getTaxon().getUuid(), nameRecord);
}
} else {
nameRecord.put("genusTaxon", null);
nameRecord.put("genusName", null);
nameRecord.put("descriptionsGen", null);
}
// taxon = (Taxon) getTaxonService().load(childNode.getTaxon().getUuid());
taxon = CdmBase.deproxy(childNode.getTaxon());
// if (taxon.isPublish()){
INonViralName nonViralName = taxon.getName();
nameString = createTaggedNameString(nonViralName, false);
nameRecord.put("childTaxon", taxon.getTitleCache());
if (taxon.getSec() != null) {
nameRecord.put("secRef", taxon.getSec().getTitleCache());
} else {
nameRecord.put("secRef", null);
}
getTaxonRelations(nameRecord, taxon);
name = CdmBase.deproxy(taxon.getName());
nameRecord.put("childName", nameString);
nameRecord.put("nameId", String.valueOf(name.getId()));
nameRecord.put("nameCache", name.getNameCache());
nameRecord.put("titleName", name.getTitleCache());
if (name.getNomenclaturalReference() != null) {
nameRecord.put("NomRefTitleCache", name.getNomenclaturalReference().getTitleCache());
} else {
nameRecord.put("NomRefTitleCache", null);
}
nameRecord.put("fullName", name.getNameCache());
nameRecord.put("fullTitleCache", name.getFullTitleCache());
Set<TypeDesignationBase> typeDesSet = name.getTypeDesignations();
Iterator<TypeDesignationBase> it = typeDesSet.iterator();
String typeNameString = NOT_DESIGNATED;
String statusString = null;
if (it.hasNext()) {
TypeDesignationBase<?> typeDes = CdmBase.deproxy(it.next());
if (typeDes instanceof NameTypeDesignation) {
NameTypeDesignation nameTypeDes = CdmBase.deproxy(typeDes, NameTypeDesignation.class);
IBotanicalName typeName = CdmBase.deproxy(nameTypeDes.getTypeName());
if (typeName != null) {
typeNameString = "<i>" + typeName.getNameCache() + "</i> " + typeName.getAuthorshipCache();
if (nameTypeDes.getTypeStatus() != null) {
NameTypeDesignationStatus status = CdmBase.deproxy(nameTypeDes.getTypeStatus());
statusString = status.getTitleCache();
}
}
}
}
nameRecord.put("typeName", typeNameString);
StringBuffer homotypicalSynonyms = new StringBuffer();
TreeMap<HomotypicalGroup, List<Synonym>> heterotypicSynonymsList = new TreeMap<>(new HomotypicalGroupComparator());
List<Synonym> homotypicSynonymsList = new ArrayList<>();
StringBuffer heterotypicalSynonyms = new StringBuffer();
List<Synonym> homotypicSynonyms;
HomotypicalGroup group;
IBotanicalName synonymName;
String doubtfulTitleCache;
for (Synonym synonym : taxon.getSynonyms()) {
synonymName = CdmBase.deproxy(synonym.getName());
group = CdmBase.deproxy(synonymName.getHomotypicalGroup());
synonymName.generateFullTitle();
if (synonym.isDoubtful()) {
if (!synonymName.getFullTitleCache().startsWith("?")) {
doubtfulTitleCache = "?" + synonymName.getFullTitleCache();
synonymName = synonymName.clone();
synonymName.setFullTitleCache(doubtfulTitleCache, true);
}
}
if (!group.equals(name.getHomotypicalGroup())) {
if (heterotypicSynonymsList.containsKey(group)) {
heterotypicSynonymsList.get(group).add(synonym);
} else {
homotypicSynonyms = new ArrayList<>();
homotypicSynonyms.add(synonym);
heterotypicSynonymsList.put(group, homotypicSynonyms);
homotypicSynonyms = null;
}
} else {
synonymName.generateFullTitle();
homotypicSynonymsList.add(synonym);
}
}
String synonymString;
boolean first = true;
for (List<Synonym> list : heterotypicSynonymsList.values()) {
Collections.sort(list, new HomotypicGroupTaxonComparator(null));
first = true;
for (TaxonBase<?> synonym : list) {
NomenclaturalStatus status = null;
if (!synonym.getName().getStatus().isEmpty()) {
status = CdmBase.deproxy(synonym.getName().getStatus().iterator().next());
if (status.getType().isInvalid()) {
heterotypicalSynonyms.append(" <invalid> ");
synonymName = CdmBase.deproxy(synonym.getName());
synonymString = createSynonymNameString(synonymName, state.getConfig().isInvalidNamesQuoted());
heterotypicalSynonyms.append(synonymString);
continue;
}
}
if (first) {
heterotypicalSynonyms.append(" <heterotypic> ");
} else {
heterotypicalSynonyms.append(" <homonym> ");
}
first = false;
synonymName = CdmBase.deproxy(synonym.getName());
synonymString = createSynonymNameString(synonymName, false);
heterotypicalSynonyms.append(synonymString);
}
}
first = true;
Collections.sort(homotypicSynonymsList, new HomotypicGroupTaxonComparator(null));
NomenclaturalStatus status = null;
for (TaxonBase<?> synonym : homotypicSynonymsList) {
if (!synonym.getName().getStatus().isEmpty()) {
status = CdmBase.deproxy(synonym.getName().getStatus().iterator().next());
if (status.getType().isInvalid()) {
homotypicalSynonyms.append(" <invalid> ");
synonymName = CdmBase.deproxy(synonym.getName());
synonymString = createSynonymNameString(synonymName, true);
homotypicalSynonyms.append(synonymString);
continue;
} else if (!first) {
homotypicalSynonyms.append(" <homonym> ");
}
} else if (!first) {
homotypicalSynonyms.append(" <homonym> ");
}
first = false;
synonymName = CdmBase.deproxy(synonym.getName());
synonymString = createSynonymNameString(synonymName, false);
homotypicalSynonyms.append(synonymString);
}
nameRecord.put("synonyms_homotypic", homotypicalSynonyms.toString());
nameRecord.put("synonyms_heterotypic", heterotypicalSynonyms.toString());
nameRecord.put("status", statusString);
Set<NameRelationship> nameRelations = name.getNameRelations();
INonViralName relatedName = null;
String nameRelType = null;
String relNameString = null;
if (nameRelations.size() > 0) {
NameRelationship nameRel = nameRelations.iterator().next();
IBotanicalName fromName = CdmBase.deproxy(nameRel.getFromName());
if (fromName.equals(taxon.getName())) {
relatedName = nameRel.getToName();
} else {
relatedName = nameRel.getFromName();
}
nameRel = CdmBase.deproxy(nameRel);
nameRelType = nameRel.getType().getTitleCache();
relNameString = createTaggedNameString(relatedName, getStatus(relatedName));
}
nameRecord.put("relatedName", relNameString);
nameRecord.put("nameRelType", nameRelType);
extractDescriptions(nameRecord, taxon, Feature.DISTRIBUTION(), "descriptions", state);
return nameRecord;
}
use of eu.etaxonomy.cdm.model.name.NomenclaturalStatus in project cdmlib by cybertaxonomy.
the class TestCdmDbComparator method retrieveAllTables.
private Map<String, List<String>> retrieveAllTables(CdmApplicationController appCtr) {
Map<String, List<String>> tables = new HashMap<>(table_list.length);
List<String> agentTableContent = new ArrayList<>(MAX_ROWS);
List<? extends AgentBase> agents = appCtr.getAgentService().list(null, MAX_ROWS, 0, null, null);
for (AgentBase agent : agents) {
// TODO: Want the entire row as string not just toString() of the object.
agentTableContent.add(agent.toString());
}
tables.put("agents", agentTableContent);
// List<Annotation> annotations = appCtr.getTermService().getAllAnnotations(MAX_ROWS, 0);
List<String> definedTermBaseTableContent = new ArrayList<>(MAX_ROWS);
List<DefinedTermBase> definedTermBases = appCtr.getTermService().list(null, MAX_ROWS, 0, null, null);
for (DefinedTermBase definedTermBase : definedTermBases) {
definedTermBaseTableContent.add(definedTermBase.toString());
}
tables.put("definedTermBases", definedTermBaseTableContent);
// List<DescriptionBase> descriptionBases = appCtr.getDescriptionService().getAllDescriptionBases(MAX_ROWS, 0);
// List<DescriptionElementBase> descriptionElementBases = appCtr.getDescriptionService().getAllDescriptionElementBases(MAX_ROWS, 0);
// List<HomotypicalGroup> homotypicalGroups = appCtr.getNameService().getAllHomotypicalGroups(MAX_ROWS, 0);
List<LanguageString> languageStrings = appCtr.getTermService().getAllLanguageStrings(MAX_ROWS, 0);
// List<Marker> markers = appCtr.getTermService().getAllMarkers(MAX_ROWS, 0);
// List<NameRelationship> nameRelationships = appCtr.getNameService().getAllNameRelationships(MAX_ROWS, 0);
List<NomenclaturalStatus> nomenclaturalStatus = appCtr.getNameService().getAllNomenclaturalStatus(MAX_ROWS, 0);
// List<OriginalSource> originalSources = appCtr.getNameService().getAllOriginalSources(MAX_ROWS, 0);
List<Reference> references = appCtr.getReferenceService().list(null, MAX_ROWS, 0, null, null);
List<Representation> representations = appCtr.getTermService().getAllRepresentations(MAX_ROWS, 0);
List<SpecimenOrObservationBase> specimenOrObservationBases = appCtr.getOccurrenceService().list(null, MAX_ROWS, 0, null, null);
// List<TaxonBase> taxonBases = appCtr.getTaxonService().getAllTaxa(MAX_ROWS, 0);
// List<TaxonName> taxonNames = appCtr.getNameService().getAllNames(MAX_ROWS, 0);
// List<TaxonRelationship> taxonRelationships = appCtr.getTaxonService().getAllTaxonRelationships(MAX_ROWS, 0);
List<TermVocabulary> termVocabularies = appCtr.getVocabularyService().list(null, MAX_ROWS, 0, null, null);
List<TypeDesignationBase<?>> typeDesignationBases = appCtr.getNameService().getAllTypeDesignations(MAX_ROWS, 0);
return tables;
}
use of eu.etaxonomy.cdm.model.name.NomenclaturalStatus in project cdmlib by cybertaxonomy.
the class FullCoverageDataGenerator method createTaxonName.
private void createTaxonName(List<CdmBase> cdmBases) {
TaxonName bacName = TaxonNameFactory.NewBacterialInstance(Rank.GENUS());
bacName.setSubGenusAuthorship("sub Genus author");
bacName.setNameApprobation("nameApprobation");
handleIdentifiableEntity(bacName);
TaxonName botName = TaxonNameFactory.NewCultivarInstance(Rank.SUBSPECIES());
botName.setAnamorphic(true);
botName.setCultivarEpithet("cultivarEpithet");
botName.setGenusOrUninomial("Genus");
botName.setInfraGenericEpithet("InfraGeneric");
botName.setSpecificEpithet("specificEpithet");
botName.setInfraSpecificEpithet("infraSpecificEpithet");
Person combinationAuthorship = Person.NewInstance();
botName.setCombinationAuthorship(combinationAuthorship);
Person exCombinationAuthorship = Person.NewInstance();
botName.setExCombinationAuthorship(exCombinationAuthorship);
Person basionymAuthorship = Person.NewInstance();
botName.setBasionymAuthorship(basionymAuthorship);
Person exBasionymAuthorship = Person.NewInstance();
botName.setExBasionymAuthorship(exBasionymAuthorship);
handleIdentifiableEntity(botName);
handleAnnotatableEntity(botName.getHomotypicalGroup());
TaxonName botName2 = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
HybridRelationship hybridRel = botName2.addHybridChild(botName, HybridRelationshipType.FIRST_PARENT(), "Rule 1.2.3");
hybridRel.setCitation(ReferenceFactory.newBook());
hybridRel.setCitationMicroReference("p. 123");
handleAnnotatableEntity(hybridRel);
TaxonName zooName = TaxonNameFactory.NewZoologicalInstance(Rank.GENUS());
zooName.setBreed("breed");
zooName.setPublicationYear(1922);
zooName.setOriginalPublicationYear(1987);
zooName.setAppendedPhrase("appended phrase");
zooName.addDescription(TaxonNameDescription.NewInstance());
zooName.setNomenclaturalMicroReference("p. 123");
zooName.setNomenclaturalReference(getReference());
NameRelationship rel = zooName.addRelationshipFromName(botName, NameRelationshipType.LATER_HOMONYM(), "ruleConsidered", NomenclaturalCodeEdition.ICN_2017_SHENZHEN);
NomenclaturalStatus status = NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONSERVED(), getReference(), "p. 222");
zooName.addStatus(status);
handleAnnotatableEntity(rel);
handleAnnotatableEntity(status);
handleIdentifiableEntity(zooName);
// TypeDesignation
TaxonName speciesZooName = TaxonNameFactory.NewZoologicalInstance(Rank.SPECIES());
NameTypeDesignation nameDesig = zooName.addNameTypeDesignation(speciesZooName, getReference(), "111", "original name", NameTypeDesignationStatus.AUTOMATIC(), true, true, true, true);
handleAnnotatableEntity(nameDesig);
SpecimenTypeDesignation specimenDesig = speciesZooName.addSpecimenTypeDesignation(getSpecimen(), SpecimenTypeDesignationStatus.HOLOTYPE(), getReference(), "p,22", "original name", false, true);
handleAnnotatableEntity(specimenDesig);
speciesZooName.addTextualTypeDesignation("A textual type designation", Language.ENGLISH(), true, getReference(), "123", "Species orginalus", false);
TaxonName viralName = TaxonNameFactory.NewViralInstance(Rank.GENUS());
viralName.setAcronym("acronym");
handleIdentifiableEntity(viralName);
// Registration
Registration registration = Registration.NewInstance("registration identifier", "specificIdentifier", speciesZooName, null);
registration.addTypeDesignation(specimenDesig);
registration.setRegistrationDate(DateTime.now());
Registration blockingRegistration = Registration.NewInstance();
registration.addBlockedBy(blockingRegistration);
registration.setInstitution(Institution.NewInstance());
User submitter = User.NewInstance("submitter", "12345");
registration.setSubmitter(submitter);
handleAnnotatableEntity(registration);
;
cdmBases.add(submitter);
cdmBases.add(bacName);
cdmBases.add(botName);
cdmBases.add(viralName);
cdmBases.add(zooName);
cdmBases.add(botName2);
}
use of eu.etaxonomy.cdm.model.name.NomenclaturalStatus in project cdmlib by cybertaxonomy.
the class TaxonXTreatmentExtractor method compareStatus.
/**
* @return
*/
private boolean compareStatus(TaxonBase<?> t, NomenclaturalStatusType statusType) {
// logger.info("compareStatus");
boolean statusMatch = false;
// found one taxon
Set<NomenclaturalStatus> status = t.getName().getStatus();
if (statusType != null && status.size() > 0) {
// the statusType is known for both taxon
for (NomenclaturalStatus st : status) {
NomenclaturalStatusType stype = st.getType();
if (stype.toString().equalsIgnoreCase(statusType.toString())) {
statusMatch = true;
}
}
} else {
if (statusType == null && status.size() == 0) {
// there is no statusType, we can assume it's the same
statusMatch = true;
}
}
return statusMatch;
}
use of eu.etaxonomy.cdm.model.name.NomenclaturalStatus in project cdmlib by cybertaxonomy.
the class HomotypicGroupTaxonComparatorTest method testCompare_BasionymGroupsSomeWithYears.
@Test
public void testCompare_BasionymGroupsSomeWithYears() {
// 2 basionym groups, 1 new combination with year (botName2) and 1 basionym with year (botName5)
// The later should come first according to the rules, though alphabetically being
// basionym botName4
botName2.setNomenclaturalReference(ref2);
botName5.setNomenclaturalReference(ref3);
HomotypicalGroup homotypicalGroup = botName2.getHomotypicalGroup();
taxon1.addHeterotypicSynonymName(botName3);
taxon1.addHeterotypicSynonymName(botName5, null, null, homotypicalGroup);
botName3.addBasionym(botName5);
synonym2 = taxon1.addHeterotypicSynonymName(botName2);
taxon1.addHeterotypicSynonymName(botName4, null, null, homotypicalGroup);
botName2.addBasionym(botName4);
list.addAll(taxon1.getSynonyms());
Collections.sort(list, new HomotypicGroupTaxonComparator(null));
Assert.assertEquals("basionym with date should comes first", botName5, list.get(0).getName());
Assert.assertEquals(botName3, list.get(1).getName());
Assert.assertEquals(botName4, list.get(2).getName());
Assert.assertEquals(botName2, list.get(3).getName());
// even with nom. illeg. the name with date should come first
NomenclaturalStatus illegStatus = NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ILLEGITIMATE());
botName5.addStatus(illegStatus);
Assert.assertEquals("basionym with date should comes first", botName5, list.get(0).getName());
Assert.assertEquals(botName3, list.get(1).getName());
Assert.assertEquals(botName4, list.get(2).getName());
Assert.assertEquals(botName2, list.get(3).getName());
// add replaced synonym relation between basionyms
botName5.addReplacedSynonym(botName4, null, null, null, null);
Collections.sort(list, new HomotypicGroupTaxonComparator(null));
Assert.assertEquals("basionym of second group should come first now as it is the replaced synonym", botName4, list.get(0).getName());
Assert.assertEquals(botName2, list.get(1).getName());
Assert.assertEquals("replacement name should come after replaced synonym but first in basionym group", botName5, list.get(2).getName());
Assert.assertEquals(botName3, list.get(3).getName());
}
Aggregations