@Test public void createQuery() { CypherQuery query = TaxonSearchUtil.getCypherQuery("Animalia", new HashMap()); assertThat(query.getVersionedQuery(), Is.is("CYPHER 2.3 START someTaxon = node:taxons({pathQuery}) MATCH someTaxon-[:SAME_AS*0..1]->taxon WHERE exists(taxon.externalId) WITH DISTINCT(taxon.externalId) as externalId, taxon.externalUrl as externalUrl RETURN externalId as taxon_external_id,externalUrl as taxon_external_url")); assertThat(query.getParams().toString(), Is.is("{pathQuery=name:\\\"Animalia\\\"}")); CypherTestUtil.validate(query); }
public static CypherQuery getCypherQuery(String taxonPath, Map parameterMap) { final String pathQuery = CypherQueryBuilder.lucenePathQuery(Collections.singletonList(taxonPath), true); StringBuilder query = new StringBuilder("START someTaxon = node:taxons({pathQuery}) "); Map<ResultField, String> selectors = new HashMap<ResultField, String>() { { put(ResultField.TAXON_EXTERNAL_ID, "externalId"); put(ResultField.TAXON_EXTERNAL_URL, "externalUrl"); } }; ResultField[] returnFieldsCloseMatches = new ResultField[]{ ResultField.TAXON_EXTERNAL_ID, ResultField.TAXON_EXTERNAL_URL }; List<String> requestedFields = new ArrayList<>(); if (parameterMap != null) { requestedFields.addAll(CypherQueryBuilder.collectRequestedFields(parameterMap)); } query.append(" MATCH someTaxon-[:SAME_AS*0..1]->taxon WHERE exists(taxon.externalId) WITH DISTINCT(taxon.externalId) as externalId, taxon.externalUrl as externalUrl "); CypherReturnClauseBuilder.appendReturnClauseDistinctz(query, CypherReturnClauseBuilder.actualReturnFields(requestedFields, Arrays.asList(returnFieldsCloseMatches), selectors.keySet()), selectors); return new CypherQuery(query.toString(), new HashMap<String, String>() { { put("pathQuery", pathQuery); } }, CypherUtil.CYPHER_VERSION_2_3); }
TaxonSearchUtil { public static CypherQuery getCypherQuery(String taxonPath, Map parameterMap) { final String pathQuery = CypherQueryBuilder.lucenePathQuery(Collections.singletonList(taxonPath), true); StringBuilder query = new StringBuilder("START someTaxon = node:taxons({pathQuery}) "); Map<ResultField, String> selectors = new HashMap<ResultField, String>() { { put(ResultField.TAXON_EXTERNAL_ID, "externalId"); put(ResultField.TAXON_EXTERNAL_URL, "externalUrl"); } }; ResultField[] returnFieldsCloseMatches = new ResultField[]{ ResultField.TAXON_EXTERNAL_ID, ResultField.TAXON_EXTERNAL_URL }; List<String> requestedFields = new ArrayList<>(); if (parameterMap != null) { requestedFields.addAll(CypherQueryBuilder.collectRequestedFields(parameterMap)); } query.append(" MATCH someTaxon-[:SAME_AS*0..1]->taxon WHERE exists(taxon.externalId) WITH DISTINCT(taxon.externalId) as externalId, taxon.externalUrl as externalUrl "); CypherReturnClauseBuilder.appendReturnClauseDistinctz(query, CypherReturnClauseBuilder.actualReturnFields(requestedFields, Arrays.asList(returnFieldsCloseMatches), selectors.keySet()), selectors); return new CypherQuery(query.toString(), new HashMap<String, String>() { { put("pathQuery", pathQuery); } }, CypherUtil.CYPHER_VERSION_2_3); } }
TaxonSearchUtil { public static CypherQuery getCypherQuery(String taxonPath, Map parameterMap) { final String pathQuery = CypherQueryBuilder.lucenePathQuery(Collections.singletonList(taxonPath), true); StringBuilder query = new StringBuilder("START someTaxon = node:taxons({pathQuery}) "); Map<ResultField, String> selectors = new HashMap<ResultField, String>() { { put(ResultField.TAXON_EXTERNAL_ID, "externalId"); put(ResultField.TAXON_EXTERNAL_URL, "externalUrl"); } }; ResultField[] returnFieldsCloseMatches = new ResultField[]{ ResultField.TAXON_EXTERNAL_ID, ResultField.TAXON_EXTERNAL_URL }; List<String> requestedFields = new ArrayList<>(); if (parameterMap != null) { requestedFields.addAll(CypherQueryBuilder.collectRequestedFields(parameterMap)); } query.append(" MATCH someTaxon-[:SAME_AS*0..1]->taxon WHERE exists(taxon.externalId) WITH DISTINCT(taxon.externalId) as externalId, taxon.externalUrl as externalUrl "); CypherReturnClauseBuilder.appendReturnClauseDistinctz(query, CypherReturnClauseBuilder.actualReturnFields(requestedFields, Arrays.asList(returnFieldsCloseMatches), selectors.keySet()), selectors); return new CypherQuery(query.toString(), new HashMap<String, String>() { { put("pathQuery", pathQuery); } }, CypherUtil.CYPHER_VERSION_2_3); }  }
TaxonSearchUtil { public static CypherQuery getCypherQuery(String taxonPath, Map parameterMap) { final String pathQuery = CypherQueryBuilder.lucenePathQuery(Collections.singletonList(taxonPath), true); StringBuilder query = new StringBuilder("START someTaxon = node:taxons({pathQuery}) "); Map<ResultField, String> selectors = new HashMap<ResultField, String>() { { put(ResultField.TAXON_EXTERNAL_ID, "externalId"); put(ResultField.TAXON_EXTERNAL_URL, "externalUrl"); } }; ResultField[] returnFieldsCloseMatches = new ResultField[]{ ResultField.TAXON_EXTERNAL_ID, ResultField.TAXON_EXTERNAL_URL }; List<String> requestedFields = new ArrayList<>(); if (parameterMap != null) { requestedFields.addAll(CypherQueryBuilder.collectRequestedFields(parameterMap)); } query.append(" MATCH someTaxon-[:SAME_AS*0..1]->taxon WHERE exists(taxon.externalId) WITH DISTINCT(taxon.externalId) as externalId, taxon.externalUrl as externalUrl "); CypherReturnClauseBuilder.appendReturnClauseDistinctz(query, CypherReturnClauseBuilder.actualReturnFields(requestedFields, Arrays.asList(returnFieldsCloseMatches), selectors.keySet()), selectors); return new CypherQuery(query.toString(), new HashMap<String, String>() { { put("pathQuery", pathQuery); } }, CypherUtil.CYPHER_VERSION_2_3); }  static Collection<String> linksForTaxonName(@PathVariable("taxonPath") String taxonPath, HttpServletRequest request, LinkMapper linkMapper); static void addLinksFromNode(Collection<String> links, JsonNode jsonNode, LinkMapper linkMapper); static CypherQuery createPagedQuery(String taxonPath, HttpServletRequest request); static CypherQuery getCypherQuery(String taxonPath, Map parameterMap); }
TaxonSearchUtil { public static CypherQuery getCypherQuery(String taxonPath, Map parameterMap) { final String pathQuery = CypherQueryBuilder.lucenePathQuery(Collections.singletonList(taxonPath), true); StringBuilder query = new StringBuilder("START someTaxon = node:taxons({pathQuery}) "); Map<ResultField, String> selectors = new HashMap<ResultField, String>() { { put(ResultField.TAXON_EXTERNAL_ID, "externalId"); put(ResultField.TAXON_EXTERNAL_URL, "externalUrl"); } }; ResultField[] returnFieldsCloseMatches = new ResultField[]{ ResultField.TAXON_EXTERNAL_ID, ResultField.TAXON_EXTERNAL_URL }; List<String> requestedFields = new ArrayList<>(); if (parameterMap != null) { requestedFields.addAll(CypherQueryBuilder.collectRequestedFields(parameterMap)); } query.append(" MATCH someTaxon-[:SAME_AS*0..1]->taxon WHERE exists(taxon.externalId) WITH DISTINCT(taxon.externalId) as externalId, taxon.externalUrl as externalUrl "); CypherReturnClauseBuilder.appendReturnClauseDistinctz(query, CypherReturnClauseBuilder.actualReturnFields(requestedFields, Arrays.asList(returnFieldsCloseMatches), selectors.keySet()), selectors); return new CypherQuery(query.toString(), new HashMap<String, String>() { { put("pathQuery", pathQuery); } }, CypherUtil.CYPHER_VERSION_2_3); }  static Collection<String> linksForTaxonName(@PathVariable("taxonPath") String taxonPath, HttpServletRequest request, LinkMapper linkMapper); static void addLinksFromNode(Collection<String> links, JsonNode jsonNode, LinkMapper linkMapper); static CypherQuery createPagedQuery(String taxonPath, HttpServletRequest request); static CypherQuery getCypherQuery(String taxonPath, Map parameterMap);  }