Search in sources :

Example 6 with Archive

use of org.gbif.dwc.Archive in project eol-globi-data by jhpoelen.

the class DatasetImporterForDwCATest method hasAssociatedTaxaExtension.

@Test
public void hasAssociatedTaxaExtension() throws IOException, URISyntaxException {
    URI sampleArchive = getClass().getResource("AEC-DBCNet_DwC-A20160308-sample.zip").toURI();
    Archive archive = DwCAUtil.archiveFor(sampleArchive, "target/tmp");
    assertThat(DatasetImporterForDwCA.findResourceExtension(archive, EXTENSION_ASSOCIATED_TAXA), Is.is(notNullValue()));
}
Also used : Archive(org.gbif.dwc.Archive) URI(java.net.URI) Test(org.junit.Test)

Example 7 with Archive

use of org.gbif.dwc.Archive in project eol-globi-data by jhpoelen.

the class DatasetImporterForDwCATest method hasResourceRelationshipsOccurrenceToOccurrenceMissingTargetReference.

@Test
public void hasResourceRelationshipsOccurrenceToOccurrenceMissingTargetReference() throws IOException, URISyntaxException {
    URI sampleArchive = getClass().getResource("fmnh-rr-unresolved-targetid-test.zip").toURI();
    Archive archive = DwCAUtil.archiveFor(sampleArchive, "target/tmp");
    AtomicInteger numberOfFoundLinks = new AtomicInteger(0);
    importResourceRelationshipExtension(archive, new InteractionListener() {

        @Override
        public void on(Map<String, String> interaction) throws StudyImporterException {
            numberOfFoundLinks.incrementAndGet();
            assertThat(interaction.get(relatedResourceID.qualifiedName()), is("http://n2t.net/ark:/65665/37d63a454-d948-4b1d-89db-89809887ef41"));
            assertThat(interaction.get(SOURCE_TAXON_NAME), is("Trichobius parasparsus Wenzel, 1976"));
            assertThat(interaction.get(SOURCE_OCCURRENCE_ID), is("8afec7db-7b19-44f7-8ac8-8d98614e71d2"));
            assertThat(interaction.get(INTERACTION_TYPE_NAME), is("Ectoparasite of"));
            assertThat(interaction.get(INTERACTION_TYPE_ID), is(nullValue()));
            assertThat(interaction.get(DatasetImporterForTSV.BASIS_OF_RECORD_NAME), is("PreservedSpecimen"));
            assertThat(interaction.get(TaxonUtil.TARGET_TAXON_NAME), is(nullValue()));
            assertThat(interaction.get(DatasetImporterForTSV.TARGET_OCCURRENCE_ID), is("http://n2t.net/ark:/65665/37d63a454-d948-4b1d-89db-89809887ef41"));
            assertThat(interaction.get(DatasetImporterForTSV.TARGET_CATALOG_NUMBER), is(nullValue()));
            assertThat(interaction.get(DatasetImporterForTSV.TARGET_COLLECTION_CODE), is(nullValue()));
            assertThat(interaction.get(DatasetImporterForTSV.TARGET_INSTITUTION_CODE), is(nullValue()));
            assertThat(interaction.get(DatasetImporterForTSV.REFERENCE_CITATION), is("A. L. Tuttle | M. D. Tuttle"));
            assertThat(interaction.get(DatasetImporterForTSV.RESOURCE_TYPES), is("http://rs.tdwg.org/dwc/terms/ResourceRelationship | http://rs.tdwg.org/dwc/terms/Occurrence"));
        }
    });
    assertThat(numberOfFoundLinks.get(), is(1));
}
Also used : InteractionListener(org.eol.globi.process.InteractionListener) Archive(org.gbif.dwc.Archive) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) URI(java.net.URI) Test(org.junit.Test)

Example 8 with Archive

use of org.gbif.dwc.Archive in project eol-globi-data by jhpoelen.

the class DatasetImporterForDwCATest method hasResourceRelationshipsExtension.

@Test
public void hasResourceRelationshipsExtension() throws IOException, URISyntaxException {
    URI sampleArchive = getClass().getResource("fmnh-rr-test.zip").toURI();
    Archive archive = DwCAUtil.archiveFor(sampleArchive, "target/tmp");
    assertThat(DatasetImporterForDwCA.findResourceExtension(archive, EXTENSION_RESOURCE_RELATIONSHIP), Is.is(notNullValue()));
}
Also used : Archive(org.gbif.dwc.Archive) URI(java.net.URI) Test(org.junit.Test)

Example 9 with Archive

use of org.gbif.dwc.Archive in project eol-globi-data by jhpoelen.

the class DatasetImporterForDwCATest method hasAssociatedTaxa.

@Test
public void hasAssociatedTaxa() throws IOException, URISyntaxException {
    URI sampleArchive = getClass().getResource("AEC-DBCNet_DwC-A20160308-sample.zip").toURI();
    Archive archive = DwCAUtil.archiveFor(sampleArchive, "target/tmp");
    AtomicBoolean foundLink = new AtomicBoolean(false);
    importAssociatedTaxaExtension(archive, new InteractionListener() {

        @Override
        public void on(Map<String, String> interaction) throws StudyImporterException {
            assertThat(interaction.get(SOURCE_TAXON_NAME), is("Andrena wilkella"));
            assertThat(interaction.get(DatasetImporterForTSV.SOURCE_SEX_NAME), is("Female"));
            assertThat(interaction.get(SOURCE_LIFE_STAGE_NAME), is("Adult"));
            assertThat(interaction.get(TaxonUtil.TARGET_TAXON_NAME), is("Melilotus officinalis"));
            assertThat(interaction.get(INTERACTION_TYPE_NAME), is("associated with"));
            assertThat(interaction.get(INTERACTION_TYPE_ID), is("http://purl.obolibrary.org/obo/RO_0002437"));
            assertThat(interaction.get(DatasetImporterForTSV.BASIS_OF_RECORD_NAME), is("LabelObservation"));
            assertThat(interaction.get(DatasetImporterForTSV.DECIMAL_LATITUDE), is("42.40000"));
            assertThat(interaction.get(DatasetImporterForTSV.DECIMAL_LONGITUDE), is("-76.50000"));
            assertThat(interaction.get(DatasetImporterForTSV.LOCALITY_NAME), is("Tompkins County"));
            assertThat(interaction.get(SOURCE_OCCURRENCE_ID), is("urn:uuid:859e1708-d8e1-11e2-99a2-0026552be7ea"));
            assertThat(interaction.get(DatasetImporterForTSV.SOURCE_COLLECTION_CODE), is(nullValue()));
            assertThat(interaction.get(DatasetImporterForTSV.SOURCE_COLLECTION_ID), is(nullValue()));
            assertThat(interaction.get(DatasetImporterForTSV.SOURCE_INSTITUTION_CODE), is("CUIC"));
            assertThat(interaction.get(DatasetImporterForTSV.SOURCE_CATALOG_NUMBER), is("CUIC_ENT 00014070"));
            assertThat(interaction.get(DatasetImporterForTSV.REFERENCE_CITATION), is("Digital Bee Collections Network, 2014 (and updates). Version: 2016-03-08. National Science Foundation grant DBI 0956388"));
            assertThat(interaction.get(DatasetImporterForTSV.RESOURCE_TYPES), is("http://rs.tdwg.org/dwc/terms/Occurrence | http://purl.org/NET/aec/associatedTaxa"));
            foundLink.set(true);
        }
    });
    assertTrue(foundLink.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) InteractionListener(org.eol.globi.process.InteractionListener) Archive(org.gbif.dwc.Archive) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) URI(java.net.URI) Test(org.junit.Test)

Example 10 with Archive

use of org.gbif.dwc.Archive in project eol-globi-data by jhpoelen.

the class DwCAUtilTest method emitRecordsUnpacked.

@Test
public void emitRecordsUnpacked() throws IOException, URISyntaxException {
    URI archiveURI = getClass().getResource("vampire-moth-dwca-main/meta.xml").toURI();
    Archive dwcArchive = DwCAUtil.archiveFor(Paths.get(archiveURI).getParent().toUri(), null);
    assertHasRecords(dwcArchive);
}
Also used : Archive(org.gbif.dwc.Archive) URI(java.net.URI) Test(org.junit.Test)

Aggregations

Archive (org.gbif.dwc.Archive)11 URI (java.net.URI)10 Test (org.junit.Test)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 InteractionListener (org.eol.globi.process.InteractionListener)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 File (java.io.File)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 InteractionListenerClosable (org.eol.globi.process.InteractionListenerClosable)1 ArchiveFile (org.gbif.dwc.ArchiveFile)1 UnsupportedArchiveException (org.gbif.dwc.UnsupportedArchiveException)1