Search in sources :

Example 41 with DatasetImpl

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

the class StudyImporterForHurlbertTest method doImport.

public StudyImporter doImport(final String namespace) throws StudyImporterException {
    StudyImporter importer = new StudyImporterForHurlbert(null, nodeFactory);
    Dataset dataset = new DatasetImpl(namespace, URI.create("some:uri")) {

        @Override
        public InputStream getResource(String name) {
            return StudyImporterForHurlbertTest.getResource();
        }
    };
    importer.setDataset(dataset);
    importStudy(importer);
    return importer;
}
Also used : Dataset(org.eol.globi.service.Dataset) DatasetImpl(org.eol.globi.service.DatasetImpl) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString)

Example 42 with DatasetImpl

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

the class StudyImporterForJSONLDTest method importStatic.

@Test
public void importStatic() throws StudyImporterException, URISyntaxException {
    StudyImporter importer = new StudyImporterForJSONLD(null, nodeFactory);
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"));
    dataset.setConfigURI(URI.create("classpath:/org/eol/globi/data/globi-jsonld/globi-dataset.jsonld"));
    importer.setDataset(dataset);
    importStudy(importer);
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    for (Study study : allStudies) {
        assertThat(study.getExternalId(), is("http://arctos.database.museum/guid/CUMV:Bird:25225"));
        assertThat(study.getCitation(), is("http://arctos.database.museum/guid/CUMV:Bird:25225"));
        assertThat(study.getSource(), startsWith("Christopher Mungall. 2015. Accessed at <classpath:/org/eol/globi/data/globi-jsonld/globi-dataset.jsonld> on "));
    }
    assertThat(taxonIndex.findTaxonById("NCBI:8782"), not(is(nullValue())));
}
Also used : Study(org.eol.globi.domain.Study) DatasetImpl(org.eol.globi.service.DatasetImpl) Test(org.junit.Test)

Example 43 with DatasetImpl

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

the class StudyImporterForGoMexSI2IT method importWithCommit.

protected StudyImporterForGoMexSI2 importWithCommit(String baseUrlLastCommit) throws StudyImporterException, IOException {
    StudyImporterForGoMexSI2 importer = new StudyImporterForGoMexSI2(new ParserFactoryLocal(), nodeFactory);
    final List<String> msgs = new ArrayList<String>();
    importer.setLogger(new ImportLogger() {

        @Override
        public void warn(LogContext study, String message) {
            LOG.warn(message);
            msgs.add("warn: " + message);
        }

        @Override
        public void info(LogContext study, String message) {
            LOG.info(message);
            msgs.add("info: " + message);
        }

        @Override
        public void severe(LogContext study, String message) {
            LOG.error(message);
            msgs.add("severe: " + message);
        }
    });
    JsonNode config = new ObjectMapper().readTree("{ \n" + "  \"citation\": \"testing source citation\",\n" + "  \"format\": \"gomexsi\"\n" + "}");
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create(baseUrlLastCommit));
    importer.setDataset(dataset);
    dataset.setConfig(config);
    importStudy(importer);
    return importer;
}
Also used : ArrayList(java.util.ArrayList) LogContext(org.eol.globi.domain.LogContext) JsonNode(org.codehaus.jackson.JsonNode) DatasetImpl(org.eol.globi.service.DatasetImpl) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 44 with DatasetImpl

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

the class ExportFlatInteractionsTest method init.

@Before
public void init() throws IOException {
    super.startGraphDb();
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"));
    factory = new NodeFactoryWithDatasetContext(nodeFactory, dataset);
}
Also used : DatasetImpl(org.eol.globi.service.DatasetImpl) NodeFactoryWithDatasetContext(org.eol.globi.data.NodeFactoryWithDatasetContext) Before(org.junit.Before)

Example 45 with DatasetImpl

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

the class LinkerDOITest method createStudyDOIlookupCitationEnabled.

@Test
public void createStudyDOIlookupCitationEnabled() throws NodeFactoryException {
    StudyImpl title = new StudyImpl("title", "some source", null, "some citation");
    DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
    ObjectNode objectNode = new ObjectMapper().createObjectNode();
    objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, true);
    originatingDataset.setConfig(objectNode);
    title.setOriginatingDataset(originatingDataset);
    StudyNode study = getNodeFactory().getOrCreateStudy(title);
    new LinkerDOI(getGraphDb()).linkStudy(new TestDOIResolver(), study);
    assertThat(study.getSource(), is("some source"));
    assertThat(study.getDOI(), is("doi:some citation"));
    assertThat(study.getCitation(), is("some citation"));
    assertThat(study.getTitle(), is("title"));
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.eol.globi.service.DatasetImpl) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Aggregations

DatasetImpl (org.eol.globi.service.DatasetImpl)45 Test (org.junit.Test)31 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)24 JsonNode (org.codehaus.jackson.JsonNode)16 Study (org.eol.globi.domain.Study)13 Relationship (org.neo4j.graphdb.Relationship)9 ArrayList (java.util.ArrayList)6 ObjectNode (org.codehaus.jackson.node.ObjectNode)6 StudyImpl (org.eol.globi.domain.StudyImpl)6 Dataset (org.eol.globi.service.Dataset)6 Node (org.neo4j.graphdb.Node)5 InputStream (java.io.InputStream)4 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)4 NodeFactoryWithDatasetContext (org.eol.globi.data.NodeFactoryWithDatasetContext)3 LogContext (org.eol.globi.domain.LogContext)3 Specimen (org.eol.globi.domain.Specimen)3 Taxon (org.eol.globi.domain.Taxon)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 URI (java.net.URI)2