Search in sources :

Example 56 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class ExporterSiteMapForCitationsTest method writeSiteMapWithCitations.

@Test
public void writeSiteMapWithCitations() throws StudyImporterException, IOException {
    final Study study = nodeFactory.getOrCreateStudy(new StudyImpl("title", new DOI("some", "doi"), "citation123&bla"));
    assertThat(study.getExternalId(), is("https://doi.org/10.some/doi"));
    final File baseDirCitations = createBaseDir("target/sitemap/citations");
    final GraphExporter siteMapForCitationsExporter = new ExporterSiteMapForCitations();
    siteMapForCitationsExporter.export(getGraphDb(), baseDirCitations);
    final String substring = "http://www.globalbioticinteractions.org/?accordingTo=" + "https://doi.org/10.some/doi";
    assertSiteMap(baseDirCitations, substring, "https://depot.globalbioticinteractions.org/snapshot/target/data/sitemap/citations/sitemap.xml.gz");
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl) File(java.io.File) DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 57 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class NodeFactoryNeo4jTest method createStudy.

@Test
public void createStudy() throws NodeFactoryException {
    StudyNode study = getNodeFactory().getOrCreateStudy(new StudyImpl("myTitle", new DOI("myDoi", "123"), null));
    assertThat(study.getDOI().toString(), is("10.myDoi/123"));
    assertThat(study.getExternalId(), is("https://doi.org/10.myDoi/123"));
}
Also used : StudyImpl(org.eol.globi.domain.StudyImpl) StudyNode(org.eol.globi.domain.StudyNode) DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 58 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class NodeFactoryNeo4jTest method createStudyWithDifferentExternalIdInDifferentNamespace.

@Test
public void createStudyWithDifferentExternalIdInDifferentNamespace() throws NodeFactoryException {
    StudyImpl study1 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
    study1.setOriginatingDataset(new DatasetImpl("name/space", URI.create("foo:bar"), is -> is));
    study1.setExternalId("foo:bar");
    StudyNode study1Created = getNodeFactory().getOrCreateStudy(study1);
    StudyImpl study2 = new StudyImpl("myTitle", new DOI("myDoi", "123"), null);
    study2.setOriginatingDataset(new DatasetImpl("name/spacz", URI.create("foo:bar"), is -> is));
    study2.setExternalId("foo:baz");
    StudyNode study2Created = getNodeFactory().getOrCreateStudy(study2);
    assertThat(study1Created.getExternalId(), is("foo:bar"));
    assertThat(study1Created.getOriginatingDataset().getNamespace(), is("name/space"));
    assertThat(study2Created.getExternalId(), is("foo:baz"));
    assertThat(study2Created.getOriginatingDataset().getNamespace(), is("name/spacz"));
}
Also used : NodeUtil(org.eol.globi.util.NodeUtil) Location(org.eol.globi.domain.Location) Date(java.util.Date) Direction(org.neo4j.graphdb.Direction) ExternalIdUtil(org.eol.globi.util.ExternalIdUtil) StringUtils(org.apache.commons.lang3.StringUtils) StudyImpl(org.eol.globi.domain.StudyImpl) InteractType(org.eol.globi.domain.InteractType) TaxonImpl(org.eol.globi.domain.TaxonImpl) Is.is(org.hamcrest.core.Is.is) URI(java.net.URI) LocationNode(org.eol.globi.domain.LocationNode) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) PropertyAndValueDictionary(org.eol.globi.domain.PropertyAndValueDictionary) EnvironmentNode(org.eol.globi.domain.EnvironmentNode) SpecimenConstant(org.eol.globi.domain.SpecimenConstant) SpecimenNode(org.eol.globi.domain.SpecimenNode) DateUtil(org.eol.globi.util.DateUtil) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Term(org.eol.globi.domain.Term) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) Specimen(org.eol.globi.domain.Specimen) TermImpl(org.eol.globi.domain.TermImpl) LocationImpl(org.eol.globi.domain.LocationImpl) CoreMatchers.not(org.hamcrest.CoreMatchers.not) Environment(org.eol.globi.domain.Environment) DatasetConstant(org.globalbioticinteractions.dataset.DatasetConstant) TermLookupService(org.eol.globi.service.TermLookupService) RelTypes(org.eol.globi.domain.RelTypes) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) DOI(org.globalbioticinteractions.doi.DOI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TermLookupServiceException(org.eol.globi.service.TermLookupServiceException) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) DatasetNode(org.eol.globi.domain.DatasetNode) NodeBacked(org.eol.globi.domain.NodeBacked) Iterator(java.util.Iterator) Assert.assertNotNull(org.junit.Assert.assertNotNull) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) IOException(java.io.IOException) StudyNode(org.eol.globi.domain.StudyNode) Relationship(org.neo4j.graphdb.Relationship) Dataset(org.globalbioticinteractions.dataset.Dataset) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) Interaction(org.eol.globi.domain.Interaction) TaxonNode(org.eol.globi.domain.TaxonNode) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) DOI(org.globalbioticinteractions.doi.DOI) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 59 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class NodeFactoryIT method createStudy.

@Test
public void createStudy() throws NodeFactoryException {
    Study study = nodeFactory.getOrCreateStudy(new StudyImpl("bla", new DOI("1111", "j.1469-7998.1966.tb02907.x"), ExternalIdUtil.toCitation(null, "descr", null)));
    assertThat(study.getDOI().toURI().toString(), is("https://doi.org/10.1111/j.1469-7998.1966.tb02907.x"));
    assertThat(study.getCitation(), is("descr"));
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl) DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 60 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class ExportCitationsTest method exportCitations.

@Test
public void exportCitations() throws IOException, NodeFactoryException {
    StringWriter writer = new StringWriter();
    getNodeFactory().getOrCreateStudy(new StudyImpl("some title", new DOI("some", "doi"), "some citation"));
    getNodeFactory().getOrCreateStudy(new StudyImpl("some other title", new DOI("some", "otherdoi"), "some other citation"));
    ExportUtil.export(ExportUtil.AppenderWriter.of(writer), getGraphDb(), ExportCitations.CYPHER_QUERY);
    assertThat(writer.toString(), Is.is("doi\tcitation" + "\n10.some/doi\tsome citation" + "\n10.some/otherdoi\tsome other citation\n"));
}
Also used : StringWriter(java.io.StringWriter) StudyImpl(org.eol.globi.domain.StudyImpl) DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Aggregations

DOI (org.globalbioticinteractions.doi.DOI)74 Test (org.junit.Test)50 StudyImpl (org.eol.globi.domain.StudyImpl)28 IOException (java.io.IOException)15 Study (org.eol.globi.domain.Study)15 Specimen (org.eol.globi.domain.Specimen)13 StudyNode (org.eol.globi.domain.StudyNode)12 Matchers.containsString (org.hamcrest.Matchers.containsString)12 TaxonImpl (org.eol.globi.domain.TaxonImpl)11 URI (java.net.URI)10 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 DatasetImpl (org.globalbioticinteractions.dataset.DatasetImpl)8 MalformedDOIException (org.globalbioticinteractions.doi.MalformedDOIException)8 Location (org.eol.globi.domain.Location)7 LocationImpl (org.eol.globi.domain.LocationImpl)7 ArrayList (java.util.ArrayList)6 Dataset (org.globalbioticinteractions.dataset.Dataset)6 Reader (java.io.Reader)5 StringReader (java.io.StringReader)5