Search in sources :

Example 1 with ICdmRepository

use of eu.etaxonomy.cdm.api.application.ICdmRepository in project cdmlib by cybertaxonomy.

the class IpniServiceTest method testGetNamesAdvanced.

@Test
@DataSets({ @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"), @DataSet(value = "/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml") })
public void testGetNamesAdvanced() {
    ICdmRepository services = null;
    IpniServiceNamesConfigurator config = IpniServiceNamesConfigurator.NewInstance();
    // http://www.uk.ipni.org/ipni/advPlantNameSearch.do?find_family=&find_genus=Abies&find_species=alba&find_infrafamily=&find_infragenus=&find_infraspecies=&find_authorAbbrev=B*&find_includePublicationAuthors=on&find_includePublicationAuthors=off&find_includeBasionymAuthors=on&find_includeBasionymAuthors=off&find_publicationTitle=&find_isAPNIRecord=on&find_isAPNIRecord=false&find_isGCIRecord=on&find_isGCIRecord=false&find_isIKRecord=on&find_isIKRecord=false&find_rankToReturn=infraspec&output_format=normal&find_sortByFamily=on&find_sortByFamily=off&query_type=by_query&back_page=plantsearch
    String family = "";
    String genus = "Abies";
    String species = "alba";
    String infraFamily = "";
    String infraGenus = "";
    String infraSpecies = "";
    String authorAbbrev = "B*";
    String publicationTitle = "";
    IpniRank rankToReturn = IpniRank.valueOf(Rank.SUBSPECIES());
    List<IBotanicalName> nameList = service1.getNamesAdvanced(family, genus, species, infraFamily, infraGenus, infraSpecies, authorAbbrev, publicationTitle, rankToReturn, config, services);
    if (testInternetConnectivity(nameList)) {
        if (nameList == null) {
            Assert.fail("No results.");
        }
        Assert.assertEquals("There should be exactly 1 result for 'Abies', 'alba', 'B*', Infraspecific ", 1, nameList.size());
        IBotanicalName name = nameList.get(0);
        // title cache
        Assert.assertEquals("Title Cache for 'Abies', 'alba', 'ap*' should be 'Abies alba subsp. apennina Brullo, Scelsi & Spamp.'", "Abies alba subsp. apennina Brullo, Scelsi & Spamp.", name.getTitleCache());
    // for (IBotanicalName listName : nameList){
    // System.out.println(name.getFullTitleCache());
    // }
    }
}
Also used : IBotanicalName(eu.etaxonomy.cdm.model.name.IBotanicalName) ICdmRepository(eu.etaxonomy.cdm.api.application.ICdmRepository) IpniRank(eu.etaxonomy.cdm.ext.ipni.IpniService.IpniRank) Test(org.junit.Test) DataSets(org.unitils.dbunit.annotation.DataSets)

Example 2 with ICdmRepository

use of eu.etaxonomy.cdm.api.application.ICdmRepository in project cdmlib by cybertaxonomy.

the class IpniServiceTest method testPublications.

@Test
@DataSets({ @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"), @DataSet(value = "/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml") })
public void testPublications() {
    ICdmRepository services = null;
    IpniServicePublicationConfigurator config = null;
    List<Reference> refList = service1.getPublications("Species Plantarum, Edition 3", "Sp. Pl.", services, config);
    if (testInternetConnectivity(refList)) {
        if (refList == null) {
            Assert.fail("The list is empty, maybe the ipni service is not available.");
        }
        Assert.assertEquals("There should be exactly 1 result for 'Species Plantarum, Edition 3'", 1, refList.size());
        Reference ref = refList.get(0);
        // title cache
        // the author title may be improved in future
        Assert.assertEquals("Title Cache should be 'Linnaeus, Carl, Species Plantarum, Edition 3'", "Linnaeus, Carl, Species Plantarum, Edition 3. 1764", ref.getTitleCache());
        refList = service1.getPublications("Flora of Macar", null, services, config);
        if (refList == null) {
            Assert.fail("The list is empty, maybe the ipni service is not available.");
        }
        Assert.assertNotNull("Empty resultset should not throw exception and should not be null", refList);
        refList = service1.getPublications("Flora Europaea [ed. 2]", null, services, config);
        if (refList == null) {
            Assert.fail("The list is empty, maybe the ipni service is not available.");
        }
        Assert.assertEquals("There should be exactly 1 result for 'Flora Europaea [ed. 2]'", 1, refList.size());
        ref = refList.get(0);
        Assert.assertEquals("", "Tutin, Thomas Gaskell", ref.getAuthorship().getTitleCache());
    // for (Reference ref : refList){
    // System.out.println(ref.getTitleCache());
    // }
    }
}
Also used : Reference(eu.etaxonomy.cdm.model.reference.Reference) ICdmRepository(eu.etaxonomy.cdm.api.application.ICdmRepository) Test(org.junit.Test) DataSets(org.unitils.dbunit.annotation.DataSets)

Example 3 with ICdmRepository

use of eu.etaxonomy.cdm.api.application.ICdmRepository in project cdmlib by cybertaxonomy.

the class IpniServiceTest method testGetAuthors.

@Test
@DataSets({ @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"), @DataSet(value = "/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml") })
public void testGetAuthors() {
    ICdmRepository services = null;
    IpniServiceAuthorConfigurator config = new IpniServiceAuthorConfigurator();
    config.setFormat(DelimitedFormat.EXTENDED);
    List<Person> authorList = service1.getAuthors(null, "Greuter", null, null, services, config);
    // expected web service result: 3379-1%1.1%Greuter%Werner Rodolfo%Greuter%PS%1938-%>Greuter, Werner Rodolfo
    if (authorList == null) {
        Assert.fail("No results.");
    }
    if (testInternetConnectivity(authorList)) {
        Assert.assertEquals("There should be exactly 1 result for 'Greuter'", 1, authorList.size());
        Person author = authorList.get(0);
        // full title
        Assert.assertEquals("Full title for Greuter should be 'Werner Rodolfo Greuter'", "Werner Rodolfo Greuter", author.getFullTitle());
        // title cache
        Assert.assertEquals("Title cache for Greuter should be 'Greuter, W.R.'", "Greuter, W.R.", author.getTitleCache());
        // alternative names
        Assert.assertEquals("One extension for the alternative name should exist", 1, author.getExtensions().size());
        Extension alternativeName = author.getExtensions().iterator().next();
        Assert.assertEquals("Alternative name should be ", "Greuter, Werner Rodolfo", alternativeName.getValue());
        // dates
        String year = author.getLifespan().getYear();
        Assert.assertNotNull("Year should be not null", year);
        Assert.assertEquals("Year should be 1938", "1938", year);
        authorList = service1.getAuthors(null, "Greu*", null, null, null, config);
        // 3379-1%1.1%Greuter%Werner Rodolfo%Greuter%PS%1938-%>Greuter, Werner Rodolfo
        if (authorList == null) {
            Assert.fail("No results.");
        } else {
            Assert.assertEquals("There should be exactly 3 result for 'Greu*'. But maybe this changes over time", 3, authorList.size());
        }
        // for (Person person : authorList){
        // System.out.println(person.getTitleCache() + ";  " + person.getNomenclaturalTitle());
        // }
        // 
        config.setFormat(DelimitedFormat.MINIMAL);
        authorList = service1.getAuthors(null, "Greuter", null, null, services, config);
        Assert.assertEquals("There should be exactly 1 result for 'Greuter'", 1, authorList.size());
        author = authorList.get(0);
        Assert.assertTrue("No alternative names should exist in the minimal version", author.getExtensions().isEmpty());
    }
}
Also used : Extension(eu.etaxonomy.cdm.model.common.Extension) ICdmRepository(eu.etaxonomy.cdm.api.application.ICdmRepository) Person(eu.etaxonomy.cdm.model.agent.Person) Test(org.junit.Test) DataSets(org.unitils.dbunit.annotation.DataSets)

Example 4 with ICdmRepository

use of eu.etaxonomy.cdm.api.application.ICdmRepository in project cdmlib by cybertaxonomy.

the class IpniServiceTest method testNameID.

@Test
public void testNameID() {
    ICdmRepository services = null;
    IpniServiceNamesConfigurator config = null;
    InputStream content = service1.getNamesById("416415-1");
    Assert.assertNotNull(content);
}
Also used : InputStream(java.io.InputStream) ICdmRepository(eu.etaxonomy.cdm.api.application.ICdmRepository) Test(org.junit.Test)

Example 5 with ICdmRepository

use of eu.etaxonomy.cdm.api.application.ICdmRepository in project cdmlib by cybertaxonomy.

the class Abcd206Import method createKindOfUnitsMap.

/**
 */
private void createKindOfUnitsMap(Abcd206ImportState state) {
    ICdmRepository cdmRepository = state.getConfig().getCdmAppController();
    if (cdmRepository == null) {
        cdmRepository = this;
    }
    List<DefinedTerm> terms = cdmRepository.getTermService().listByTermType(TermType.KindOfUnit, null, 0, null, null);
    kindOfUnitsMap = new HashMap<>();
    for (DefinedTerm kindOfUnit : terms) {
        if (kindOfUnit != null && kindOfUnit.getLabel() != null) {
            String kindOfUnitLabel = kindOfUnit.getLabel().toLowerCase();
            kindOfUnitsMap.put(kindOfUnitLabel, kindOfUnit);
        }
    }
}
Also used : ICdmRepository(eu.etaxonomy.cdm.api.application.ICdmRepository) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) DefinedTerm(eu.etaxonomy.cdm.model.term.DefinedTerm)

Aggregations

ICdmRepository (eu.etaxonomy.cdm.api.application.ICdmRepository)18 Test (org.junit.Test)6 LanguageString (eu.etaxonomy.cdm.model.common.LanguageString)4 DataSets (org.unitils.dbunit.annotation.DataSets)4 ICdmDataSource (eu.etaxonomy.cdm.database.ICdmDataSource)3 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)3 DefinedTermBase (eu.etaxonomy.cdm.model.term.DefinedTermBase)3 DerivedUnitFacade (eu.etaxonomy.cdm.api.facade.DerivedUnitFacade)2 Person (eu.etaxonomy.cdm.model.agent.Person)2 IBotanicalName (eu.etaxonomy.cdm.model.name.IBotanicalName)2 TaxonName (eu.etaxonomy.cdm.model.name.TaxonName)2 DeterminationEvent (eu.etaxonomy.cdm.model.occurrence.DeterminationEvent)2 Reference (eu.etaxonomy.cdm.model.reference.Reference)2 TaxonNode (eu.etaxonomy.cdm.model.taxon.TaxonNode)2 DefinedTerm (eu.etaxonomy.cdm.model.term.DefinedTerm)2 TransactionStatus (org.springframework.transaction.TransactionStatus)2 FindOccurrencesConfigurator (eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator)1 IProgressMonitor (eu.etaxonomy.cdm.common.monitor.IProgressMonitor)1 IpniRank (eu.etaxonomy.cdm.ext.ipni.IpniService.IpniRank)1 GbifResponse (eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse)1