use of org.eol.globi.domain.SpecimenNode in project eol-globi-data by jhpoelen.
the class StudyImporterForGoMexSI2IT method assertSpecimenProperties.
private static void assertSpecimenProperties(GraphDatabaseService service) {
Index<Node> taxa = service.index().forNodes("taxons");
boolean detectedAtLeastOneLifeState = false;
boolean detectedAtLeastOnePhysiologicalState = false;
boolean detectedAtLeastOnePreyBodyPart = false;
boolean detectedAtLeastOneBodyLength = false;
boolean detectedAtLeastOneLocation = false;
boolean detectedAtLeastOneFrequencyOfOccurrence = false;
boolean detectedAtLeastOneTotalNumberConsumed = false;
boolean detectedAtLeastOneTotalVolume = false;
boolean detectedAtLeastOneGoMexSIProperty = false;
assertThat(taxa, is(notNullValue()));
for (Node taxonNode : taxa.query("name", "*")) {
Iterable<Relationship> classifiedAs = taxonNode.getRelationships(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
for (Relationship classifiedA : classifiedAs) {
Node specimenNode = classifiedA.getStartNode();
detectedAtLeastOneLifeState |= specimenNode.hasProperty(SpecimenConstant.LIFE_STAGE_LABEL);
detectedAtLeastOnePhysiologicalState |= specimenNode.hasProperty(SpecimenConstant.PHYSIOLOGICAL_STATE_LABEL);
detectedAtLeastOnePreyBodyPart |= specimenNode.hasProperty(SpecimenConstant.BODY_PART_LABEL);
detectedAtLeastOneBodyLength |= specimenNode.hasProperty(SpecimenConstant.LENGTH_IN_MM);
detectedAtLeastOneFrequencyOfOccurrence |= specimenNode.hasProperty(SpecimenConstant.FREQUENCY_OF_OCCURRENCE);
detectedAtLeastOneTotalNumberConsumed |= specimenNode.hasProperty(SpecimenConstant.TOTAL_COUNT);
detectedAtLeastOneTotalVolume |= specimenNode.hasProperty(SpecimenConstant.TOTAL_VOLUME_IN_ML);
detectedAtLeastOneGoMexSIProperty |= specimenNode.hasProperty(StudyImporterForGoMexSI2.GOMEXSI_NAMESPACE + "PRED_DATABASE_NAME");
detectedAtLeastOneGoMexSIProperty |= specimenNode.hasProperty(StudyImporterForGoMexSI2.GOMEXSI_NAMESPACE + "PREY_DATABASE_NAME");
if (specimenNode.hasRelationship(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.COLLECTED))) {
detectedAtLeastOneLocation = true;
}
}
}
assertThat(detectedAtLeastOneLifeState, is(true));
assertThat(detectedAtLeastOnePhysiologicalState, is(true));
assertThat(detectedAtLeastOnePreyBodyPart, is(true));
assertThat(detectedAtLeastOneLocation, is(true));
assertThat(detectedAtLeastOneBodyLength, is(true));
assertThat(detectedAtLeastOneFrequencyOfOccurrence, is(true));
assertThat(detectedAtLeastOneTotalNumberConsumed, is(true));
assertThat(detectedAtLeastOneTotalVolume, is(true));
assertThat(detectedAtLeastOneGoMexSIProperty, is(true));
}
use of org.eol.globi.domain.SpecimenNode in project eol-globi-data by jhpoelen.
the class StudyImporterForINaturalistTest method importTestResponse.
@Test
public void importTestResponse() throws IOException, StudyImporterException {
importer.parseJSON(getClass().getResourceAsStream("inaturalist/sample_inaturalist_response.json"), new ArrayList<Integer>() {
{
add(47);
}
}, new HashMap<Integer, InteractType>() {
{
put(13, InteractType.ATE);
}
});
resolveNames();
assertThat(NodeUtil.findAllStudies(getGraphDb()).size(), is(22));
Study anotherStudy = nodeFactory.findStudy("INAT:831");
assertThat(anotherStudy, is(notNullValue()));
assertThat(anotherStudy.getCitation(), containsString("Ken-ichi Ueda. 2008. Argiope eating Orthoptera. iNaturalist.org. Accessed at <https://www.inaturalist.org/observations/831> on "));
assertThat(anotherStudy.getExternalId(), is("https://www.inaturalist.org/observations/831"));
anotherStudy = nodeFactory.findStudy("INAT:97380");
assertThat(anotherStudy, is(notNullValue()));
assertThat(anotherStudy.getCitation(), containsString("annetanne. 2012. Misumena vatia eating Eristalis nemorum."));
assertThat(anotherStudy.getExternalId(), is("https://www.inaturalist.org/observations/97380"));
Taxon sourceTaxonNode = taxonIndex.findTaxonByName("Arenaria interpres");
assertThat(sourceTaxonNode, is(not(nullValue())));
Iterable<Relationship> relationships = ((NodeBacked) sourceTaxonNode).getUnderlyingNode().getRelationships(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
for (Relationship relationship : relationships) {
Node sourceSpecimen = relationship.getStartNode();
assertThat(new SpecimenNode(sourceSpecimen).getBasisOfRecord().getName(), is("HumanObservation"));
assertThat(new SpecimenNode(sourceSpecimen).getBasisOfRecord().getId(), is("TEST:HumanObservation"));
assertThat(new SpecimenNode(sourceSpecimen).getExternalId(), containsString(TaxonomyProvider.ID_PREFIX_INATURALIST));
Relationship ateRel = sourceSpecimen.getSingleRelationship(NodeUtil.asNeo4j(InteractType.ATE), Direction.OUTGOING);
Node preySpecimen = ateRel.getEndNode();
assertThat(preySpecimen, is(not(nullValue())));
Relationship preyClassification = preySpecimen.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING);
String actualPreyName = (String) preyClassification.getEndNode().getProperty("name");
assertThat(actualPreyName, is("Crepidula fornicata"));
Relationship locationRel = sourceSpecimen.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.COLLECTED_AT), Direction.OUTGOING);
assertThat((Double) locationRel.getEndNode().getProperty("latitude"), is(41.249813));
assertThat((Double) locationRel.getEndNode().getProperty("longitude"), is(-72.542556));
Relationship collectedRel = sourceSpecimen.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.COLLECTED), Direction.INCOMING);
assertThat((Long) collectedRel.getProperty(SpecimenConstant.DATE_IN_UNIX_EPOCH), is(any(Long.class)));
}
}
use of org.eol.globi.domain.SpecimenNode in project eol-globi-data by jhpoelen.
the class StudyImporterForRobledoTest method createAndPopulateStudy.
@Test
public void createAndPopulateStudy() throws StudyImporterException, NodeFactoryException {
StudyImporterForRobledo importer = new StudyImporterForRobledo(new ParserFactoryLocal(), nodeFactory);
importStudy(importer);
Study study = getStudySingleton(getGraphDb());
assertNotNull(taxonIndex.findTaxonByName("Heliconia imbricata"));
assertNotNull(taxonIndex.findTaxonByName("Renealmia alpinia"));
assertNotNull(nodeFactory.findStudy(study.getTitle()));
int count = 0;
Iterable<Relationship> specimenRels = NodeUtil.getSpecimens(study);
for (Relationship specimenRel : specimenRels) {
Specimen specimen1 = new SpecimenNode(specimenRel.getEndNode());
Location sampleLocation = specimen1.getSampleLocation();
assertThat(sampleLocation, is(notNullValue()));
assertThat(sampleLocation.getAltitude(), is(35.0));
assertThat(Math.round(sampleLocation.getLongitude()), is(-84L));
assertThat(Math.round(sampleLocation.getLatitude()), is(10L));
count++;
}
assertThat(count, is(93));
}
Aggregations