use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionsAccordingToWithSourceTaxaOnlyAndExcludeChildTaxa.
@Test
public void findInteractionsAccordingToWithSourceTaxaOnlyAndExcludeChildTaxa() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("excludeChildTaxa", new String[] { "true" });
put("accordingTo", new String[] { "inaturalist" });
put("sourceTaxon", 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}) OR (has(study.citation) AND study.citation =~ {accordingTo}) OR (has(study.source) AND study.source =~ {accordingTo}) WITH study " + EXPECTED_MATCH_CLAUSE_DISTINCT + "WHERE (has(sourceTaxon.name) AND sourceTaxon.name IN ['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=.*(\\\\Qinaturalist\\\\E).*, source_taxon_name=name:\\\"Arthropoda\\\"}")));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionsTaxaInteractionIndexTargetTaxaOnlyTaxonIdPrefix.
@Test
public void findInteractionsTaxaInteractionIndexTargetTaxaOnlyTaxonIdPrefix() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("targetTaxon", new String[] { "Arthropoda" });
put("interactionType", new String[] { "preyedUponBy" });
put("taxonIdPrefix", new String[] { "somePrefix" });
put("field", new String[] { "source_taxon_name", "target_taxon_name" });
}
};
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_DISTINCT_BY_NAME_ONLY);
Map<String, String> expected = new HashMap<String, String>() {
{
put("target_taxon_name", "path:\\\"Arthropoda\\\"");
put("source_taxon_prefix", "somePrefix.*");
put("target_taxon_prefix", "somePrefix.*");
}
};
assertThat(query.getParams(), is(expected));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionsAccordingToWithSourceTaxonIdAndNamesOnlyAndExactMatchOnlyIncludeObservations2.
@Test
public void findInteractionsAccordingToWithSourceTaxonIdAndNamesOnlyAndExactMatchOnlyIncludeObservations2() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("exactNameMatchOnly", new String[] { "true" });
put("sourceTaxon", new String[] { "EOL:123", "some name" });
put("targetTaxon", new String[] { "Insecta" });
put("field", new String[] { "source_taxon_name", "target_taxon_name" });
}
};
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_ALL);
assertThat(query.getQuery(), is("START sourceTaxon = node:taxons({source_taxon_name}) " + EXPECTED_MATCH_CLAUSE_ALL + "WHERE (has(targetTaxon.name) AND targetTaxon.name IN ['Insecta'])" + " RETURN sourceTaxon.name as source_taxon_name,targetTaxon.name as target_taxon_name"));
assertThat(query.getParams().toString(), is(is("{source_taxon_name=externalId:\\\"EOL:123\\\" OR name:\\\"some name\\\", target_taxon_name=name:\\\"Insecta\\\"}")));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionForLocationOnlyDistinct.
@Test
public void findInteractionForLocationOnlyDistinct() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("bbox", new String[] { "-67.87,12.79,-57.08,23.32" });
}
};
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_DISTINCT);
assertThat(query.getQuery(), is("START loc = node:locations('latitude:*') " + 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 " + EXPECTED_RETURN_CLAUSE_DISTINCT));
assertThat(query.getParams().isEmpty(), is(true));
}
use of org.eol.globi.util.CypherQuery in project eol-globi-data by jhpoelen.
the class CypherQueryBuilderTest method findInteractionForTargetTaxaOnlyNoLocation.
@Test
public void findInteractionForTargetTaxaOnlyNoLocation() throws IOException {
HashMap<String, String[]> params = new HashMap<String, String[]>() {
{
put("targetTaxon", new String[] { "Arthropoda" });
}
};
String expectedQuery = "START targetTaxon = node:taxonPaths({target_taxon_name}) " + EXPECTED_MATCH_CLAUSE_ALL + EXPECTED_RETURN_CLAUSE;
CypherQuery query = buildInteractionQuery(params, MULTI_TAXON_ALL);
assertThat(query.getQuery(), is(expectedQuery));
assertThat(query.getParams().toString(), is("{target_taxon_name=path:\\\"Arthropoda\\\"}"));
}
Aggregations