@Test public void generateCollectionReport() throws NodeFactoryException { DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("http: Dataset originatingDatasetNode = nodeFactory.getOrCreateDataset(originatingDataset); StudyImpl study1 = new StudyImpl("a title", null, "citation"); study1.setOriginatingDataset(originatingDatasetNode); createStudy(study1); StudyImpl study2 = new StudyImpl("another title", null, "citation"); study2.setOriginatingDataset(originatingDatasetNode); createStudy(study2); resolveNames(); new ReportGenerator(getGraphDb(), cacheService).generateReportForCollection(); Transaction transaction = getGraphDb().beginTx(); IndexHits<Node> reports = getGraphDb() .index() .forNodes("reports") .query("*:*"); assertThat(reports.size(), is(1)); Node reportNode = reports.getSingle(); assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1)); assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1)); assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(2)); assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(8)); assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3)); assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2)); transaction.success(); transaction.close(); }
private void generateCollectionReport(DB reportCache) { final Set<Long> distinctTaxonIds = reportCache.createHashSet("distinctTaxonIds").make(); final Set<Long> distinctTaxonIdsNoMatch = reportCache.createHashSet("distinctTaxonIdsNoMatch").make(); final Counter counter = new Counter(); final Counter studyCounter = new Counter(); final Set<String> distinctSources = reportCache.createHashSet("distinctSources").make(); final Set<String> distinctDatasets = reportCache.createHashSet("distinctDatasets").make(); NodeUtil.findStudies(getGraphDb(), study -> { countInteractionsAndTaxa(study, distinctTaxonIds, counter, distinctTaxonIdsNoMatch); studyCounter.count(); final Dataset originatingDataset = study.getOriginatingDataset(); if (originatingDataset != null) { final String namespace = originatingDataset.getNamespace(); distinctSources.add(namespace); distinctDatasets.add(namespace); } }); try (Transaction tx = getGraphDb().beginTx()) { 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(); } }
ReportGenerator { private void generateCollectionReport(DB reportCache) { final Set<Long> distinctTaxonIds = reportCache.createHashSet("distinctTaxonIds").make(); final Set<Long> distinctTaxonIdsNoMatch = reportCache.createHashSet("distinctTaxonIdsNoMatch").make(); final Counter counter = new Counter(); final Counter studyCounter = new Counter(); final Set<String> distinctSources = reportCache.createHashSet("distinctSources").make(); final Set<String> distinctDatasets = reportCache.createHashSet("distinctDatasets").make(); NodeUtil.findStudies(getGraphDb(), study -> { countInteractionsAndTaxa(study, distinctTaxonIds, counter, distinctTaxonIdsNoMatch); studyCounter.count(); final Dataset originatingDataset = study.getOriginatingDataset(); if (originatingDataset != null) { final String namespace = originatingDataset.getNamespace(); distinctSources.add(namespace); distinctDatasets.add(namespace); } }); try (Transaction tx = getGraphDb().beginTx()) { 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(); } } }
ReportGenerator { private void generateCollectionReport(DB reportCache) { final Set<Long> distinctTaxonIds = reportCache.createHashSet("distinctTaxonIds").make(); final Set<Long> distinctTaxonIdsNoMatch = reportCache.createHashSet("distinctTaxonIdsNoMatch").make(); final Counter counter = new Counter(); final Counter studyCounter = new Counter(); final Set<String> distinctSources = reportCache.createHashSet("distinctSources").make(); final Set<String> distinctDatasets = reportCache.createHashSet("distinctDatasets").make(); NodeUtil.findStudies(getGraphDb(), study -> { countInteractionsAndTaxa(study, distinctTaxonIds, counter, distinctTaxonIdsNoMatch); studyCounter.count(); final Dataset originatingDataset = study.getOriginatingDataset(); if (originatingDataset != null) { final String namespace = originatingDataset.getNamespace(); distinctSources.add(namespace); distinctDatasets.add(namespace); } }); try (Transaction tx = getGraphDb().beginTx()) { 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(); } } ReportGenerator(GraphDatabaseService graphService);  ReportGenerator(GraphDatabaseService graphService, CacheService cacheService); }
ReportGenerator { private void generateCollectionReport(DB reportCache) { final Set<Long> distinctTaxonIds = reportCache.createHashSet("distinctTaxonIds").make(); final Set<Long> distinctTaxonIdsNoMatch = reportCache.createHashSet("distinctTaxonIdsNoMatch").make(); final Counter counter = new Counter(); final Counter studyCounter = new Counter(); final Set<String> distinctSources = reportCache.createHashSet("distinctSources").make(); final Set<String> distinctDatasets = reportCache.createHashSet("distinctDatasets").make(); NodeUtil.findStudies(getGraphDb(), study -> { countInteractionsAndTaxa(study, distinctTaxonIds, counter, distinctTaxonIdsNoMatch); studyCounter.count(); final Dataset originatingDataset = study.getOriginatingDataset(); if (originatingDataset != null) { final String namespace = originatingDataset.getNamespace(); distinctSources.add(namespace); distinctDatasets.add(namespace); } }); try (Transaction tx = getGraphDb().beginTx()) { 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(); } } ReportGenerator(GraphDatabaseService graphService);  ReportGenerator(GraphDatabaseService graphService, CacheService cacheService); void run(); void generateReportForSourceIndividuals(); void generateReportForSourceOrganizations(); }
ReportGenerator { private void generateCollectionReport(DB reportCache) { final Set<Long> distinctTaxonIds = reportCache.createHashSet("distinctTaxonIds").make(); final Set<Long> distinctTaxonIdsNoMatch = reportCache.createHashSet("distinctTaxonIdsNoMatch").make(); final Counter counter = new Counter(); final Counter studyCounter = new Counter(); final Set<String> distinctSources = reportCache.createHashSet("distinctSources").make(); final Set<String> distinctDatasets = reportCache.createHashSet("distinctDatasets").make(); NodeUtil.findStudies(getGraphDb(), study -> { countInteractionsAndTaxa(study, distinctTaxonIds, counter, distinctTaxonIdsNoMatch); studyCounter.count(); final Dataset originatingDataset = study.getOriginatingDataset(); if (originatingDataset != null) { final String namespace = originatingDataset.getNamespace(); distinctSources.add(namespace); distinctDatasets.add(namespace); } }); try (Transaction tx = getGraphDb().beginTx()) { 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(); } } ReportGenerator(GraphDatabaseService graphService);  ReportGenerator(GraphDatabaseService graphService, CacheService cacheService); void run(); void generateReportForSourceIndividuals(); void generateReportForSourceOrganizations(); static final String GLOBI_COLLECTION_NAME; }