Search in sources :

Example 1 with DwcUnofficialTerm

use of life.catalogue.coldp.DwcUnofficialTerm in project backend by CatalogueOfLife.

the class InterpreterBase method interpretUsage.

public NeoUsage interpretUsage(ParsedNameUsage pnu, Term taxStatusTerm, TaxonomicStatus defaultStatus, VerbatimRecord v, Term... idTerms) {
    NeoUsage u;
    // a synonym by status?
    EnumNote<TaxonomicStatus> status = SafeParser.parse(TaxonomicStatusParser.PARSER, v.get(taxStatusTerm)).orElse(() -> new EnumNote<>(defaultStatus, null), Issue.TAXONOMIC_STATUS_INVALID, v);
    if (status.val.isBareName()) {
        u = NeoUsage.createBareName(Origin.SOURCE, pnu.getName());
    } else if (status.val.isSynonym()) {
        u = NeoUsage.createSynonym(Origin.SOURCE, pnu.getName(), status.val);
        if (pnu.isExtinct()) {
            // flag this as synonyms cannot have the extinct flag
            v.addIssue(Issue.NAME_CONTAINS_EXTINCT_SYMBOL);
        }
    } else {
        u = NeoUsage.createTaxon(Origin.SOURCE, pnu.getName(), status.val);
        if (pnu.isExtinct()) {
            ((Taxon) u.usage).setExtinct(true);
        }
    }
    // shared usage props
    u.setId(v.getFirstRaw(idTerms));
    u.setVerbatimKey(v.getId());
    setTaxonomicNote(u.usage, pnu.getTaxonomicNote(), v);
    u.homotypic = TaxonomicStatusParser.isHomotypic(status);
    // flat classification via dwc or coldp
    u.classification = new Classification();
    if (v.hasDwcTerms()) {
        for (DwcTerm t : DwcTerm.HIGHER_RANKS) {
            u.classification.setByTerm(t, v.get(t));
        }
        for (DwcUnofficialTerm t : DwcUnofficialTerm.HIGHER_RANKS) {
            u.classification.setByTerm(t, v.get(t));
        }
    }
    if (v.hasColdpTerms()) {
        for (ColdpTerm t : ColdpTerm.DENORMALIZED_RANKS) {
            u.classification.setByTerm(t, v.get(t));
        }
    }
    return u;
}
Also used : DwcUnofficialTerm(life.catalogue.coldp.DwcUnofficialTerm) NeoUsage(life.catalogue.importer.neo.model.NeoUsage) ColdpTerm(life.catalogue.coldp.ColdpTerm) DwcTerm(org.gbif.dwc.terms.DwcTerm)

Example 2 with DwcUnofficialTerm

use of life.catalogue.coldp.DwcUnofficialTerm in project backend by CatalogueOfLife.

the class ClassificationTest method higherRanks.

@Test
public void higherRanks() {
    Classification c = new Classification();
    int hash = c.hashCode();
    for (ColdpTerm t : ColdpTerm.DENORMALIZED_RANKS) {
        assertTrue(c.setByTerm(t, "xyz"));
        assertNotEquals("unused term " + t, hash, c.hashCode());
        hash = c.hashCode();
    }
    for (DwcTerm t : DwcTerm.HIGHER_RANKS) {
        assertTrue("unused term " + t, c.setByTerm(t, "foo"));
        assertNotEquals("unused term " + t, hash, c.hashCode());
        hash = c.hashCode();
    }
    for (DwcUnofficialTerm t : DwcUnofficialTerm.HIGHER_RANKS) {
        assertTrue("unused term " + t, c.setByTerm(t, "bar"));
        assertNotEquals("unused term " + t, hash, c.hashCode());
        hash = c.hashCode();
    }
    for (Rank r : Classification.RANKS) {
        assertTrue("unused rank " + r, c.setByRank(r, "grrr"));
        assertEquals("grrr", c.getByRank(r));
        assertNotEquals("unused rank " + r, hash, c.hashCode());
        hash = c.hashCode();
    }
}
Also used : DwcUnofficialTerm(life.catalogue.coldp.DwcUnofficialTerm) Rank(org.gbif.nameparser.api.Rank) ColdpTerm(life.catalogue.coldp.ColdpTerm) DwcTerm(org.gbif.dwc.terms.DwcTerm) Test(org.junit.Test)

Aggregations

ColdpTerm (life.catalogue.coldp.ColdpTerm)2 DwcUnofficialTerm (life.catalogue.coldp.DwcUnofficialTerm)2 DwcTerm (org.gbif.dwc.terms.DwcTerm)2 NeoUsage (life.catalogue.importer.neo.model.NeoUsage)1 Rank (org.gbif.nameparser.api.Rank)1 Test (org.junit.Test)1