use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class ReportController method datasetQuery.
private CypherQuery datasetQuery(HttpServletRequest request, String searchKey, final String searchValue) {
String searchMatch = searchKey + "={namespace}";
if (StringUtils.isBlank(searchValue)) {
searchMatch = "'" + searchKey + ":*'";
}
String cypherQuery = "START dataset = node:datasets(" + searchMatch + "), report = node:reports('sourceId:*') " + " WHERE ('globi:' + dataset.namespace) = report.sourceId " + " RETURN report.citation as " + ResultField.STUDY_CITATION + ", report.externalId as " + ResultField.STUDY_URL + ", report.doi as " + ResultField.STUDY_DOI + ", dataset.citation as " + ResultField.STUDY_SOURCE_CITATION + ", report.nInteractions as " + ResultField.NUMBER_OF_INTERACTIONS + ", report.nTaxa as " + ResultField.NUMBER_OF_DISTINCT_TAXA + ", report.nStudies as " + ResultField.NUMBER_OF_STUDIES + ", report.nSources as " + ResultField.NUMBER_OF_SOURCES + ", report.nTaxaNoMatch as " + ResultField.NUMBER_OF_DISTINCT_TAXA_NO_MATCH + ", report.sourceId as " + ResultField.STUDY_SOURCE_ID + ", dataset.doi as " + ResultField.STUDY_SOURCE_DOI + ", dataset.format as " + ResultField.STUDY_SOURCE_FORMAT + ", dataset.archiveURI as " + ResultField.STUDY_SOURCE_ARCHIVE_URI + ", dataset.lastSeenAt as " + ResultField.STUDY_SOURCE_LAST_SEEN_AT;
Map<String, String> params = StringUtils.isBlank(searchValue) ? CypherQueryBuilder.EMPTY_PARAMS : new HashMap<String, String>() {
{
put("namespace", searchValue);
}
};
return CypherQueryBuilder.createPagedQuery(request, new CypherQuery(cypherQuery, params, CypherUtil.CYPHER_VERSION_2_3));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class ReportController method studies.
@RequestMapping(value = "/reports/studies", method = RequestMethod.GET)
@ResponseBody
public CypherQuery studies(@RequestParam(required = false) final String source, final HttpServletRequest request) throws IOException {
String cypherQuery = "START report = node:reports(" + (StringUtils.isBlank(source) ? "'source:*'" : "source={source}") + ") " + " WHERE exists(report.title) " + " RETURN report.citation as " + ResultField.STUDY_CITATION + ", report.externalId as " + ResultField.STUDY_URL + ", report.doi as " + ResultField.STUDY_DOI + ", report.source as " + ResultField.STUDY_SOURCE_CITATION + ", report.nInteractions as " + ResultField.NUMBER_OF_INTERACTIONS + ", report.nTaxa as " + ResultField.NUMBER_OF_DISTINCT_TAXA + ", report.nStudies as " + ResultField.NUMBER_OF_STUDIES + ", report.nSources as " + ResultField.NUMBER_OF_SOURCES + ", report.nTaxaNoMatch as " + ResultField.NUMBER_OF_DISTINCT_TAXA_NO_MATCH;
Map<String, String> params = StringUtils.isBlank(source) ? CypherQueryBuilder.EMPTY_PARAMS : new HashMap<String, String>() {
{
put("source", source);
}
};
return CypherQueryBuilder.createPagedQuery(request, new CypherQuery(cypherQuery, params, CypherUtil.CYPHER_VERSION_2_3));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class ReportController method sourceQuery.
private CypherQuery sourceQuery(HttpServletRequest request, final String sourceId) {
String searchMatch = "sourceId" + "={sourceId}";
if (StringUtils.isBlank(sourceId)) {
searchMatch = "'" + "sourceId" + ":*'";
}
String cypherQuery = "START report = node:reports(" + searchMatch + ") " + " RETURN report.citation as " + ResultField.STUDY_CITATION + ", report.externalId as " + ResultField.STUDY_URL + ", report.doi as " + ResultField.STUDY_DOI + ", null as " + ResultField.STUDY_SOURCE_CITATION + ", report.nInteractions as " + ResultField.NUMBER_OF_INTERACTIONS + ", report.nTaxa as " + ResultField.NUMBER_OF_DISTINCT_TAXA + ", report.nStudies as " + ResultField.NUMBER_OF_STUDIES + ", report.nSources as " + ResultField.NUMBER_OF_SOURCES + ", report.nTaxaNoMatch as " + ResultField.NUMBER_OF_DISTINCT_TAXA_NO_MATCH + ", report.sourceId as " + ResultField.STUDY_SOURCE_ID;
String sourceIdActual = StringUtils.countMatches(sourceId, ":") > 0 ? sourceId : "globi:" + sourceId;
Map<String, String> params = StringUtils.isBlank(sourceId) ? CypherQueryBuilder.EMPTY_PARAMS : new HashMap<String, String>() {
{
put("sourceId", sourceIdActual);
}
};
return CypherQueryBuilder.createPagedQuery(request, new CypherQuery(cypherQuery, params, CypherUtil.CYPHER_VERSION_2_3));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class TaxonSearchUtil method linksForTaxonName.
public static Collection<String> linksForTaxonName(@PathVariable("taxonPath") String taxonPath, HttpServletRequest request, LinkMapper linkMapper) throws IOException {
final CypherQuery pagedQuery = createPagedQuery(taxonPath, request);
final String response = CypherUtil.executeRemote(pagedQuery);
JsonNode rowsAndMetas = RequestHelper.getRowsAndMetas(response);
Collection<String> links = new HashSet<>();
if (rowsAndMetas != null) {
for (JsonNode rowAndMeta : rowsAndMetas) {
addLinksFromNode(links, RequestHelper.getRow(rowAndMeta), linkMapper);
}
}
return links;
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class ReportControllerTest method distinctSourceRoot.
@Test
public void distinctSourceRoot() throws IOException {
CypherQuery source = new ReportController().sourceRoot(null);
assertThat(source.getVersionedQuery(), is(CYPHER_VERSION + "START dataset = node:datasets('namespace:*'), report = node:reports('sourceId:*') " + "WHERE ('globi:' + dataset.namespace) = report.sourceId " + "RETURN report.citation as study_citation, " + "report.externalId as study_url, " + "report.doi as study_doi, " + "dataset.citation as study_source_citation, " + "report.nInteractions as number_of_interactions, " + "report.nTaxa as number_of_distinct_taxa, " + "report.nStudies as number_of_studies, " + "report.nSources as number_of_sources, " + "report.nTaxaNoMatch as number_of_distinct_taxa_no_match, " + "report.sourceId as study_source_id, " + "dataset.doi as study_source_doi, " + "dataset.format as study_source_format, " + "dataset.archiveURI as study_source_archive_uri, " + "dataset.lastSeenAt as study_source_last_seen_at " + "SKIP 0 " + "LIMIT 1024"));
assertThat(source.getParams().size(), is(0));
validate(source);
}
Aggregations