use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionsTaxaInteractionIndexTargetTaxaOnly.
@Test
public void findInteractionsTaxaInteractionIndexTargetTaxaOnly() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("targetTaxon", new String[] { "Arthropoda" });
put("field", new String[] { "source_taxon_name", "target_taxon_name" });
}
};
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_DISTINCT_BY_NAME_ONLY);
assertThat(query.getQuery(), is("START targetTaxon = node:taxonPaths({target_taxon_name}) " + "MATCH sourceTaxon-[interaction:" + InteractUtil.interactionsCypherClause(INTERACTS_WITH) + "]->targetTaxon " + "RETURN sourceTaxon.name as source_taxon_name,targetTaxon.name as target_taxon_name"));
Map<String, String> expected = new HashMap<String, String>() {
{
put("target_taxon_name", "path:\\\"Arthropoda\\\"");
}
};
assertThat(query.getParams(), is(expected));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherProxyControllerTest method findShortestPaths.
@Test
public void findShortestPaths() throws IOException {
CypherQuery cypherQuery = new CypherProxyController().findShortestPathsNew(null, "Homo sapiens", "Rattus rattus");
String externalLink = new CypherQueryExecutor(cypherQuery).execute(null);
assertThat(externalLink, containsString("Rattus rattus"));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionForTargetTaxaPollinates.
@Test
public void findInteractionForTargetTaxaPollinates() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("sourceTaxon", new String[] { "Arthropoda" });
put("targetTaxon", new String[] { "Mammalia" });
put("interactionType", new String[] { "pollinatedBy" });
}
};
String expectedQuery = "START sourceTaxon = node:taxonPaths({source_taxon_name}) " + expectedMatchClause(expectedInteractionClause(POLLINATED_BY), false, true) + EXTERNAL_WHERE_CLAUSE_MAMMALIA + EXPECTED_RETURN_CLAUSE;
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_ALL);
assertThat(query.getQuery(), is(expectedQuery));
assertThat(query.getParams().toString(), is("{source_taxon_name=path:\\\"Arthropoda\\\", target_taxon_name=path:\\\"Mammalia\\\"}"));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionsAccordingToWithTargetTaxaOnly3.
@Test
public void findInteractionsAccordingToWithTargetTaxaOnly3() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("accordingTo", new String[] { "http://inaturalist.org/bla", "http://inaturalist.org/bla2" });
put("targetTaxon", new String[] { "Arthropoda" });
put("field", new String[] { "source_taxon_name", "target_taxon_name" });
}
};
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_DISTINCT);
assertThat(query.getQuery(), is("START study = node:studies('*:*') WHERE (has(study.externalId) AND study.externalId =~ {accordingTo}) WITH study " + EXPECTED_MATCH_CLAUSE_DISTINCT + "WHERE " + hasTargetTaxon("Arthropoda") + "WITH distinct targetTaxon, interaction.label as iType, sourceTaxon RETURN sourceTaxon.name as source_taxon_name,targetTaxon.name as target_taxon_name"));
assertThat(query.getParams().toString(), is(is("{accordingTo=(\\\\Qhttp://inaturalist.org/bla\\\\E|\\\\Qhttp://inaturalist.org/bla2\\\\E), target_taxon_name=path:\\\"Arthropoda\\\"}")));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionForSourceAndTargetTaxaLocationsDistinct.
@Test
public void findInteractionForSourceAndTargetTaxaLocationsDistinct() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("sourceTaxon", new String[] { "Actinopterygii", "Chordata" });
put("targetTaxon", new String[] { "Arthropoda" });
put("bbox", new String[] { "-67.87,12.79,-57.08,23.32" });
}
};
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_DISTINCT);
assertThat(query.getQuery(), is("START sourceTaxon = node:taxonPaths({source_taxon_name}) " + EXPECTED_MATCH_CLAUSE_SPATIAL + "WHERE has(loc.latitude) AND has(loc.longitude) AND loc.latitude < 23.32 AND loc.longitude > -67.87 AND loc.latitude > 12.79 AND loc.longitude < -57.08 AND " + hasTargetTaxon("Arthropoda") + EXPECTED_RETURN_CLAUSE_DISTINCT));
assertThat(query.getParams().toString(), is(is("{source_taxon_name=path:\\\"Actinopterygii\\\" OR path:\\\"Chordata\\\", target_taxon_name=path:\\\"Arthropoda\\\"}")));
}
Aggregations