use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class ExportTaxonMapTest method exportOnePredatorTwoPrey.
@Test
public void exportOnePredatorTwoPrey() throws NodeFactoryException, IOException {
final PropertyEnricher taxonEnricher = new PropertyEnricher() {
@Override
public Map<String, String> enrich(Map<String, String> properties) {
Taxon taxon = new TaxonImpl();
TaxonUtil.mapToTaxon(properties, taxon);
if ("Homo sapiens".equals(taxon.getName())) {
taxon.setExternalId("homoSapiensId");
taxon.setPath("one two three");
} else if ("Canis lupus".equals(taxon.getName())) {
taxon.setExternalId("canisLupusId");
taxon.setPath("four\tfive six");
}
return TaxonUtil.taxonToMap(taxon);
}
@Override
public void shutdown() {
}
};
taxonIndex = ExportTestUtil.taxonIndexWithEnricher(taxonEnricher, getGraphDb());
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("title", "source", null, "citation"));
Taxon taxon = new TaxonImpl("Homo sapiens");
taxon.setExternalId("homoSapiensId");
taxon.setPath("one two three");
taxon.setExternalUrl("http://some/thing");
taxon.setThumbnailUrl("http://thing/some");
nodeFactory.createSpecimen(study, taxon);
Taxon human = taxonIndex.getOrCreateTaxon(taxon);
TaxonImpl dog = new TaxonImpl("Canis lupus");
dog.setExternalId("canisLupusId");
dog.setPath("four\tfive six");
nodeFactory.createSpecimen(study, dog);
final TaxonImpl altTaxonWithPath = new TaxonImpl("Alternate Homo sapiens", "alt:123");
altTaxonWithPath.setPath("some path here");
NodeUtil.connectTaxa(altTaxonWithPath, (TaxonNode) human, getGraphDb(), RelTypes.SAME_AS);
NodeUtil.connectTaxa(new TaxonImpl("Alternate Homo sapiens no path", "alt:123"), (TaxonNode) human, getGraphDb(), RelTypes.SAME_AS);
NodeUtil.connectTaxa(new TaxonImpl("Similar Homo sapiens", "alt:456"), (TaxonNode) human, getGraphDb(), RelTypes.SIMILAR_TO);
resolveNames();
StringWriter writer = new StringWriter();
new ExportTaxonMap().exportStudy(study, writer, true);
assertThat(writer.toString(), is("providedTaxonId\tprovidedTaxonName\tresolvedTaxonId\tresolvedTaxonName" + "\nhomoSapiensId\tHomo sapiens\thomoSapiensId\tHomo sapiens" + "\nhomoSapiensId\tHomo sapiens\talt:123\tAlternate Homo sapiens" + "\ncanisLupusId\tCanis lupus\tcanisLupusId\tCanis lupus"));
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class ExportTestUtil method createTestData.
public static Study createTestData(Double length, NodeFactory factory) throws NodeFactoryException, ParseException {
Study myStudy = factory.createStudy(new StudyImpl("myStudy", null, null, null));
Specimen specimen1 = factory.createSpecimen(myStudy, new TaxonImpl("Homo sapiens", "EOL:45634"));
specimen1.setStomachVolumeInMilliLiter(666.0);
specimen1.setLifeStage(new TermImpl("GLOBI:JUVENILE", "JUVENILE"));
specimen1.setPhysiologicalState(new TermImpl("GLOBI:DIGESTATE", "DIGESTATE"));
specimen1.setBodyPart(new TermImpl("GLOBI:BONE", "BONE"));
factory.setUnixEpochProperty(specimen1, ExportTestUtil.utcTestDate());
final Specimen specimen2 = factory.createSpecimen(myStudy, new TaxonImpl("Canis lupus", "EOL:123"));
specimen2.setVolumeInMilliLiter(124.0);
specimen1.ate(specimen2);
final Specimen specimen3 = factory.createSpecimen(myStudy, new TaxonImpl("Canis lupus", "EOL:123"));
specimen3.setVolumeInMilliLiter(18.0);
specimen1.ate(specimen3);
if (null != length) {
specimen1.setLengthInMm(length);
}
Location location = factory.getOrCreateLocation(new LocationImpl(88.0, -120.0, -60.0, null));
specimen1.caughtIn(location);
return myStudy;
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class ExporterAssociationAggregatesTest method exportNoMatchTaxa.
@Test
public void exportNoMatchTaxa() throws IOException, NodeFactoryException, ParseException {
String[] studyTitles = { "myStudy1", "myStudy2" };
for (String studyTitle : studyTitles) {
Study myStudy = nodeFactory.getOrCreateStudy(new StudyImpl(studyTitle, "data source description", null, ExternalIdUtil.toCitation("contributor", "description", "pubYear")));
Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl(PropertyAndValueDictionary.NO_MATCH, null));
specimen.ate(nodeFactory.createSpecimen(myStudy, new TaxonImpl(PropertyAndValueDictionary.NO_MATCH, null)));
}
resolveNames();
ExporterAssociationAggregates exporter = new ExporterAssociationAggregates();
StringWriter row = new StringWriter();
for (String studyTitle : studyTitles) {
Study myStudy1 = nodeFactory.findStudy(studyTitle);
exporter.exportStudy(myStudy1, row, false);
}
assertThat(row.getBuffer().toString(), equalTo(""));
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class ExporterAssociationAggregatesTest method createTestData.
private void createTestData(Double length, String studyTitle) throws NodeFactoryException, ParseException {
Study myStudy = nodeFactory.getOrCreateStudy(new StudyImpl(studyTitle, "data source description", null, ExternalIdUtil.toCitation("contributor", "description", "pubYear")));
Specimen specimen = nodeFactory.createSpecimen(myStudy, setPathAndId(new TaxonImpl("Homo sapiens", null)));
specimen.setStomachVolumeInMilliLiter(666.0);
specimen.setLifeStage(new TermImpl("GlOBI:JUVENILE", "JUVENILE"));
specimen.setPhysiologicalState(new TermImpl("GlOBI:DIGESTATE", "DIGESTATE"));
specimen.setBodyPart(new TermImpl("GLOBI:BONE", "BONE"));
nodeFactory.setUnixEpochProperty(specimen, new Date(ExportTestUtil.utcTestTime()));
TaxonImpl taxon = new TaxonImpl("Canis lupus", null);
Specimen otherSpecimen = nodeFactory.createSpecimen(myStudy, setPathAndId(taxon));
otherSpecimen.setVolumeInMilliLiter(124.0);
specimen.ate(otherSpecimen);
specimen.ate(otherSpecimen);
if (null != length) {
specimen.setLengthInMm(length);
}
Location location = nodeFactory.getOrCreateLocation(new LocationImpl(44.0, 120.0, -60.0, null));
specimen.caughtIn(location);
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class ExportUnmatchedTaxonNamesTest method exportOnePredatorTwoPrey.
@Test
public void exportOnePredatorTwoPrey() throws NodeFactoryException, IOException {
taxonIndex = ExportTestUtil.taxonIndexWithEnricher(null, getGraphDb());
String title = "my study\"";
String citation = "citation my study";
Study study = nodeFactory.getOrCreateStudy(new StudyImpl(title, "my first source", null, citation));
taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens", null));
Specimen predatorSpecimen = nodeFactory.createSpecimen(study, human());
taxonIndex.getOrCreateTaxon(new TaxonImpl("Canis lupus", null));
Specimen preySpecimen6 = nodeFactory.createSpecimen(study, dog());
predatorSpecimen.interactsWith(preySpecimen6, InteractType.ATE);
Specimen preySpecimen5 = nodeFactory.createSpecimen(study, dog());
predatorSpecimen.interactsWith(preySpecimen5, InteractType.ATE);
Specimen preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Caniz", null));
predatorSpecimen.ate(preySpecimen);
Specimen predatorSpecimen23 = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens2", null));
Specimen preySpecimen4 = nodeFactory.createSpecimen(study, dog());
predatorSpecimen23.interactsWith(preySpecimen4, InteractType.ATE);
Specimen predatorSpecimen22 = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens2", null));
Specimen preySpecimen3 = nodeFactory.createSpecimen(study, dog());
predatorSpecimen22.interactsWith(preySpecimen3, InteractType.ATE);
Study study2 = nodeFactory.getOrCreateStudy(new StudyImpl("my study2", "my source2", null, "citation study2"));
Specimen predatorSpecimen21 = nodeFactory.createSpecimen(study2, new TaxonImpl("Homo sapiens2", null));
Specimen preySpecimen2 = nodeFactory.createSpecimen(study2, dog());
predatorSpecimen21.interactsWith(preySpecimen2, InteractType.ATE);
Specimen predatorSpecimen2 = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens3", PropertyAndValueDictionary.NO_MATCH));
Specimen preySpecimen1 = nodeFactory.createSpecimen(study, dog());
predatorSpecimen2.interactsWith(preySpecimen1, InteractType.ATE);
resolveNames();
StringWriter writer = new StringWriter();
new ExportUnmatchedTaxonNames().exportStudy(study, writer, true);
assertThat(writer.toString(), is("unmatched taxon name\tunmatched taxon id\tname status\tsimilar to taxon name\tsimilar to taxon path\tsimilar to taxon id\tstudy\tsource" + "\nCaniz\t\t\t\t\t\tcitation my study\tmy first source" + "\nHomo sapiens2\t\t\t\t\t\tcitation my study\tmy first source" + "\nHomo sapiens3\tno:match\t\t\t\t\tcitation my study\tmy first source"));
}
Aggregations