use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class IndexInteractionsTest method indexInteractions.
@Test
public void indexInteractions() throws NodeFactoryException {
TaxonIndex taxonIndex = getOrCreateTaxonIndex();
// see https://github.com/jhpoelen/eol-globi-data/wiki/Nanopubs
StudyImpl study = new StudyImpl("some study", "some source", "http://doi.org/123.23/222", "some study citation");
NodeFactoryWithDatasetContext factory = new NodeFactoryWithDatasetContext(nodeFactory, new DatasetImpl("some/namespace", URI.create("https://some.uri")));
Study interaction = factory.getOrCreateStudy(study);
TaxonImpl donaldTaxon = new TaxonImpl("donald duck", "NCBI:1234");
Specimen donald = factory.createSpecimen(interaction, donaldTaxon);
donald.classifyAs(taxonIndex.getOrCreateTaxon(donaldTaxon));
TaxonImpl mickeyTaxon = new TaxonImpl("mickey mouse", "NCBI:4444");
Taxon mickeyTaxonNCBI = taxonIndex.getOrCreateTaxon(new TaxonImpl("mickey mouse", "EOL:567"));
NodeUtil.connectTaxa(mickeyTaxon, (TaxonNode) mickeyTaxonNCBI, getGraphDb(), RelTypes.SAME_AS);
Specimen mickey = factory.createSpecimen(interaction, mickeyTaxon);
mickey.classifyAs(taxonIndex.getOrCreateTaxon(mickeyTaxon));
donald.ate(mickey);
new IndexInteractions(getGraphDb()).link();
NodeFactoryNeo4j nodeFactoryNeo4j = new NodeFactoryNeo4j(getGraphDb());
StudyImpl study1 = new StudyImpl("some study", "some source", null, "come citation");
study1.setOriginatingDataset(new DatasetImpl("some/namespace", URI.create("some:uri")));
StudyNode someStudy = nodeFactoryNeo4j.getOrCreateStudy(study1);
assertThat(interaction.getOriginatingDataset().getNamespace(), is(someStudy.getOriginatingDataset().getNamespace()));
assertThat(interaction.getTitle(), is(someStudy.getTitle()));
Iterable<Relationship> specimens = NodeUtil.getSpecimens(someStudy);
RelationshipType hasParticipant = NodeUtil.asNeo4j(RelTypes.HAS_PARTICIPANT);
Set<Long> ids = new HashSet<>();
List<Long> idList = new ArrayList<>();
for (Relationship specimen : specimens) {
assertThat(specimen.getEndNode().hasRelationship(Direction.INCOMING, hasParticipant), Is.is(true));
Relationship singleRelationship = specimen.getEndNode().getSingleRelationship(hasParticipant, Direction.INCOMING);
long id = singleRelationship.getStartNode().getId();
ids.add(id);
idList.add(id);
}
assertThat(ids.size(), Is.is(1));
assertThat(idList.size(), Is.is(2));
Node interactionNode = getGraphDb().getNodeById(idList.get(0));
assertTrue(interactionNode.hasRelationship(Direction.OUTGOING, NodeUtil.asNeo4j(RelTypes.DERIVED_FROM)));
assertTrue(interactionNode.hasRelationship(Direction.OUTGOING, NodeUtil.asNeo4j(RelTypes.ACCESSED_AT)));
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class LinkerDOITest method createStudyDOIlookupCitationDisabled.
@Test
public void createStudyDOIlookupCitationDisabled() throws NodeFactoryException {
StudyImpl study1 = new StudyImpl("title", "some source", null, "some citation");
study1.setExternalId("some:id");
DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, false);
originatingDataset.setConfig(objectNode);
study1.setOriginatingDataset(originatingDataset);
Study study = getNodeFactory().getOrCreateStudy(study1);
assertThat(study.getSource(), is("some source"));
assertThat(study.getDOI(), is(nullValue()));
assertThat(study.getCitation(), is("some citation"));
assertThat(study.getTitle(), is("title"));
assertThat(study.getExternalId(), is("some:id"));
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class LinkerDOITest method doLink.
@Test
public void doLink() throws NodeFactoryException, PropertyEnricherException {
StudyNode study = getNodeFactory().getOrCreateStudy(new StudyImpl("title", "some source", null, "some citation"));
new LinkerDOI(getGraphDb()).link();
Study studyResolved = nodeFactory.getOrCreateStudy(study);
assertThat(studyResolved.getDOI(), is(nullValue()));
assertThat(study.getDOI(), is(nullValue()));
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class LinkerDOITest method shouldResolveStudy.
@Test
public void shouldResolveStudy() {
StudyImpl study = new StudyImpl("some title", "some source", "doi:some/doi", "some citation");
assertFalse(LinkerDOI.shouldResolve(study));
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class LinkerDOITest method addDOIToStudy.
@Test
public void addDOIToStudy() throws NodeFactoryException {
DOIResolver doiResolver = new DOIResolver() {
@Override
public Map<String, String> resolveDoiFor(Collection<String> references) throws IOException {
Map<String, String> doiMap = new HashMap<>();
for (String reference : references) {
doiMap.put(reference, resolveDoiFor(reference));
}
return doiMap;
}
@Override
public String resolveDoiFor(String reference) throws IOException {
return "doi:1234";
}
};
StudyNode study = getNodeFactory().getOrCreateStudy(new StudyImpl("my title", "some source", null, ExternalIdUtil.toCitation("my contr", "some description", null)));
new LinkerDOI(getGraphDb()).linkStudy(doiResolver, study);
assertThat(study.getDOI(), is("doi:1234"));
assertThat(study.getExternalId(), is("http://dx.doi.org/1234"));
assertThat(study.getCitation(), is("my contr. some description"));
study = getNodeFactory().getOrCreateStudy(new StudyImpl("my other title", "some source", null, ExternalIdUtil.toCitation("my contr", "some description", null)));
new LinkerDOI(getGraphDb()).linkStudy(new DOIResolverThatExplodes(), study);
assertThat(study.getDOI(), nullValue());
assertThat(study.getExternalId(), nullValue());
assertThat(study.getCitation(), is("my contr. some description"));
}
Aggregations