Search in sources :

Example 1 with GeoNamesService

use of org.eol.globi.service.GeoNamesService in project eol-globi-data by jhpoelen.

the class StudyImporterForGitHubDataIT method importAll.

@Test
public void importAll() throws StudyImporterException {
    StudyImporterForGitHubData importer = createImporter();
    final List<String> geoTerms = new ArrayList<String>();
    importer.setGeoNamesService(new GeoNamesService() {

        @Override
        public boolean hasTermForLocale(String locality) {
            return true;
        }

        @Override
        public LatLng findLatLng(String termsOrLocale) throws IOException {
            geoTerms.add(termsOrLocale);
            return new LatLng(10, 10);
        }
    });
    importStudy(importer);
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    List<String> refs = new ArrayList<String>();
    List<String> DOIs = new ArrayList<String>();
    List<String> externalIds = new ArrayList<String>();
    List<String> sources = new ArrayList<String>();
    for (Study study : allStudies) {
        DOIs.add(study.getDOI());
        externalIds.add(study.getExternalId());
        refs.add(study.getCitation());
        sources.add(study.getSource());
    }
    assertThat(refs, hasItem("Gittenberger, A., Gittenberger, E. (2011). Cryptic, adaptive radiation of endoparasitic snails: sibling species of Leptoconchus (Gastropoda: Coralliophilidae) in corals. Org Divers Evol, 11(1), 21–41. doi:10.1007/s13127-011-0039-1"));
    assertThat(DOIs, hasItem("doi:10.1007/s13127-011-0039-1"));
    assertThat(DOIs, hasItem("doi:10.3354/meps09511"));
    assertThat(DOIs, hasItem("doi:10.2307/3544990"));
    assertThat(externalIds, hasItem("http://dx.doi.org/10.2307/3544990"));
    assertThat(sources, hasItem(containsString("Accessed at")));
    assertThat(sources, hasItem(containsString("Miller")));
    assertThat(sources, hasItem(containsString("http://gomexsi.tamucc.edu")));
    assertThat(geoTerms, hasItem("GEONAMES:8556192"));
    assertThat(taxonIndex.findTaxonByName("Leptoconchus incycloseris"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Sandalolitha dentata"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Pterois volitans/miles"), is(notNullValue()));
}
Also used : Study(org.eol.globi.domain.Study) GeoNamesService(org.eol.globi.service.GeoNamesService) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) IOException(java.io.IOException) LatLng(org.eol.globi.geo.LatLng) Test(org.junit.Test)

Example 2 with GeoNamesService

use of org.eol.globi.service.GeoNamesService in project eol-globi-data by jhpoelen.

the class StudyImporterForRaymondIT method importStudy.

@Test
public void importStudy() throws StudyImporterException {
    StudyImporterForRaymond importer = new StudyImporterForRaymond(new ParserFactoryLocal(), nodeFactory);
    importer.setGeoNamesService(new GeoNamesService() {

        @Override
        public boolean hasTermForLocale(String locality) {
            return true;
        }

        @Override
        public LatLng findLatLng(String locality) throws IOException {
            return new LatLng(0, 0);
        }
    });
    importer.setDataset(new DatasetLocal());
    importStudy(importer);
    importer.setGeoNamesService(new GeoNamesServiceImpl());
    Collection<String> unmappedLocations = new HashSet<String>();
    for (String location : importer.getLocations()) {
        if (!importer.getGeoNamesService().hasTermForLocale(location)) {
            unmappedLocations.add(location);
        }
    }
    assertThat(unmappedLocations, containsInAnyOrder("Not described", "South African waters", "Ocean location", "subantarctic waters", "oceanic habitat in Southern Ocean. 68� 07\u0019 S & 70�13\u0019 S", "Subantarctic Pacific Ocean"));
}
Also used : GeoNamesServiceImpl(org.eol.globi.service.GeoNamesServiceImpl) GeoNamesService(org.eol.globi.service.GeoNamesService) IOException(java.io.IOException) LatLng(org.eol.globi.geo.LatLng) DatasetLocal(org.eol.globi.service.DatasetLocal) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with GeoNamesService

use of org.eol.globi.service.GeoNamesService in project eol-globi-data by jhpoelen.

the class StudyImporterForCruaudTest method importAll.

@Test
public void importAll() throws NodeFactoryException, StudyImporterException {
    StudyImporterForCruaud importer = new StudyImporterForCruaud(new ParserFactoryLocal(), nodeFactory);
    importer.setGeoNamesService(new GeoNamesService() {

        @Override
        public boolean hasTermForLocale(String locality) {
            return true;
        }

        @Override
        public LatLng findLatLng(String locality) throws IOException {
            return new LatLng(0, 0);
        }
    });
    importStudy(importer);
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    assertThat(allStudies.size(), is(1));
    assertThat(taxonIndex.findTaxonByName("Agaon sp."), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Ficus chapaensis"), is(notNullValue()));
    assertThat(allStudies.get(0).getSource(), is(notNullValue()));
}
Also used : Study(org.eol.globi.domain.Study) GeoNamesService(org.eol.globi.service.GeoNamesService) IOException(java.io.IOException) LatLng(org.eol.globi.geo.LatLng) Test(org.junit.Test)

Example 4 with GeoNamesService

use of org.eol.globi.service.GeoNamesService in project eol-globi-data by jhpoelen.

the class StudyImporterForSPIRETest method createImporter.

private StudyImporterForSPIRE createImporter() {
    StudyImporterForSPIRE studyImporterForSPIRE = new StudyImporterForSPIRE(null, nodeFactory);
    studyImporterForSPIRE.setDataset(new DatasetLocal());
    studyImporterForSPIRE.setGeoNamesService(new GeoNamesService() {

        @Override
        public boolean hasTermForLocale(String locality) {
            return "something".equals(locality);
        }

        @Override
        public LatLng findLatLng(String locality) throws IOException {
            return hasTermForLocale(locality) ? new LatLng(1.0, 2.0) : null;
        }
    });
    return studyImporterForSPIRE;
}
Also used : GeoNamesService(org.eol.globi.service.GeoNamesService) IOException(java.io.IOException) LatLng(org.eol.globi.geo.LatLng) DatasetLocal(org.eol.globi.service.DatasetLocal)

Aggregations

IOException (java.io.IOException)4 LatLng (org.eol.globi.geo.LatLng)4 GeoNamesService (org.eol.globi.service.GeoNamesService)4 Test (org.junit.Test)3 Study (org.eol.globi.domain.Study)2 DatasetLocal (org.eol.globi.service.DatasetLocal)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 GeoNamesServiceImpl (org.eol.globi.service.GeoNamesServiceImpl)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1