use of org.eol.globi.domain.StudyNode in project eol-globi-data by jhpoelen.
the class LinkerDOITest method createStudyDOIlookup.
@Test
public void createStudyDOIlookup() throws NodeFactoryException {
StudyNode study = getNodeFactory().getOrCreateStudy(new StudyImpl("title", "some source", null, "some citation"));
new LinkerDOI(getGraphDb()).linkStudy(new DOIResolverThatExplodes(), study);
assertThat(study.getSource(), is("some source"));
assertThat(study.getCitation(), is("some citation"));
assertThat(study.getTitle(), is("title"));
}
use of org.eol.globi.domain.StudyNode in project eol-globi-data by jhpoelen.
the class LinkerDOITest method assertLinkMany.
public void assertLinkMany(int numberOfStudies) throws NodeFactoryException {
StudyNode study = getNodeFactory().getOrCreateStudy(new StudyImpl("title", "some source", null, DOIResolverImplIT.HOCKING));
getNodeFactory().getOrCreateStudy(new StudyImpl("title1", "some source", null, DOIResolverImplIT.MEDAN));
assertThat(study.getDOI(), is(nullValue()));
for (int i = 0; i < numberOfStudies; i++) {
getNodeFactory().getOrCreateStudy(new StudyImpl("id" + i, "some source", null, "foo bar this is not a citation" + i));
}
new LinkerDOI(getGraphDb()).link();
StudyNode studyResolved = getNodeFactory().getOrCreateStudy(study);
assertThat(studyResolved.getDOI(), is(DOIResolverImplIT.HOCKING_DOI));
}
use of org.eol.globi.domain.StudyNode in project eol-globi-data by jhpoelen.
the class ReportGenerator method generateReportForStudySources.
void generateReportForStudySources(SourceHandler sourceHandler) {
final Set<String> groupByKeys = new HashSet<String>();
NodeUtil.findStudies(getGraphDb(), new StudyNodeListener() {
@Override
public void onStudy(StudyNode study) {
String groupByKey = sourceHandler.parse(study);
if (StringUtils.isNotBlank(groupByKey)) {
groupByKeys.add(groupByKey);
}
}
});
for (final String groupByKey : groupByKeys) {
final Set<Long> distinctTaxonIds = new HashSet<>();
final Set<Long> distinctTaxonIdsNoMatch = new HashSet<>();
final Counter counter = new Counter();
final Counter studyCounter = new Counter();
final Set<String> distinctSources = new HashSet<String>();
final Set<String> distinctDatasets = new HashSet<String>();
NodeUtil.findStudies(getGraphDb(), new StudyNodeListener() {
@Override
public void onStudy(StudyNode study) {
if (sourceHandler.matches(study, groupByKey)) {
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
countInteractionsAndTaxa(specimens, distinctTaxonIds, counter, distinctTaxonIdsNoMatch);
studyCounter.count();
distinctSources.add(study.getSource());
distinctDatasets.add(study.getSourceId());
}
}
});
Transaction tx = getGraphDb().beginTx();
try {
final Node node = getGraphDb().createNode();
node.setProperty(sourceHandler.getGroupByKeyName(), groupByKey);
node.setProperty(PropertyAndValueDictionary.COLLECTION, GLOBI_COLLECTION_NAME);
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS, counter.getCount() / 2);
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA, distinctTaxonIds.size());
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH, distinctTaxonIdsNoMatch.size());
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES, studyCounter.getCount());
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES, distinctSources.size());
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS, distinctDatasets.size());
getGraphDb().index().forNodes("reports").add(node, sourceHandler.getGroupByKeyName(), groupByKey);
tx.success();
} finally {
tx.finish();
}
}
}
use of org.eol.globi.domain.StudyNode in project eol-globi-data by jhpoelen.
the class ReportGenerator method generateReportForCollection.
void generateReportForCollection() {
final Set<Long> distinctTaxonIds = new HashSet<Long>();
final Set<Long> distinctTaxonIdsNoMatch = new HashSet<Long>();
final Counter counter = new Counter();
final Counter studyCounter = new Counter();
final Set<String> distinctSources = new HashSet<String>();
final Set<String> distinctDatasets = new HashSet<String>();
NodeUtil.findStudies(getGraphDb(), new StudyNodeListener() {
@Override
public void onStudy(StudyNode study) {
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
countInteractionsAndTaxa(specimens, distinctTaxonIds, counter, distinctTaxonIdsNoMatch);
studyCounter.count();
distinctSources.add(study.getSource());
distinctDatasets.add(study.getSourceId());
}
});
Transaction tx = getGraphDb().beginTx();
try {
final Node node = getGraphDb().createNode();
node.setProperty(PropertyAndValueDictionary.COLLECTION, GLOBI_COLLECTION_NAME);
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS, counter.getCount() / 2);
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA, distinctTaxonIds.size());
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH, distinctTaxonIdsNoMatch.size());
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES, studyCounter.getCount());
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES, distinctSources.size());
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS, distinctDatasets.size());
getGraphDb().index().forNodes("reports").add(node, PropertyAndValueDictionary.COLLECTION, GLOBI_COLLECTION_NAME);
tx.success();
} finally {
tx.finish();
}
}
use of org.eol.globi.domain.StudyNode in project eol-globi-data by jhpoelen.
the class ReportGenerator method generateReportForStudy.
protected void generateReportForStudy(StudyNode study, Set<Long> ids, Counter interactionCounter, HashSet<Long> idsNoMatch) {
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
countInteractionsAndTaxa(specimens, ids, interactionCounter, idsNoMatch);
Transaction tx = getGraphDb().beginTx();
try {
Node node = getGraphDb().createNode();
if (StringUtils.isNotBlank(study.getSource())) {
node.setProperty(StudyConstant.SOURCE, study.getSource());
}
if (StringUtils.isNotBlank(study.getSourceId())) {
node.setProperty(StudyConstant.SOURCE_ID, study.getSourceId());
}
if (StringUtils.isNotBlank(study.getCitation())) {
node.setProperty(StudyConstant.CITATION, study.getCitation());
}
if (StringUtils.isNotBlank(study.getDOI())) {
node.setProperty(StudyConstant.DOI, study.getDOI());
}
if (StringUtils.isNotBlank(study.getExternalId())) {
node.setProperty(PropertyAndValueDictionary.EXTERNAL_ID, study.getExternalId());
}
node.setProperty(StudyConstant.TITLE, study.getTitle());
node.setProperty(PropertyAndValueDictionary.COLLECTION, GLOBI_COLLECTION_NAME);
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS, interactionCounter.getCount() / 2);
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA, ids.size());
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH, idsNoMatch.size());
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES, 1);
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES, 1);
node.setProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS, 1);
getGraphDb().index().forNodes("reports").add(node, StudyConstant.TITLE, study.getTitle());
getGraphDb().index().forNodes("reports").add(node, StudyConstant.SOURCE, study.getTitle());
tx.success();
} finally {
tx.finish();
}
}
Aggregations