@Test public void should_return_range_query() throws Exception { HashMap<String, Object> options = new HashMap<>(); options.put("startDate", "2018-10-02T15:38:29.900Z"); options.put("endDate", "2018-10-02T15:38:42.547Z"); options.put("OriginatingAgency", "RATP"); JsonNode query = dslQueryHelper.createSearchQueryAccessionRegister(options); assertThat(query.get("$query").toString()).isEqualTo("{\"$and\":[{\"$eq\":{\"OriginatingAgency\":\"RATP\"}},{\"$range\":{\"CreationDate\":{\"$gte\":\"2018-10-02T15:38:29.900\",\"$lte\":\"2018-10-02T15:38:42.547\"}}}]}"); }
public JsonNode createSearchQueryAccessionRegister(Map<String, Object> options) throws InvalidCreateOperationException { String startDate = (String) options.get("startDate"); String endDate = (String) options.get("endDate"); String originatingAgency = (String) options.get("OriginatingAgency"); Date from = Date.from(LocalDateTime.parse(startDate, ISO_OFFSET_DATE_TIME).toInstant(UTC)); Date to = Date.from(LocalDateTime.parse(endDate, ISO_OFFSET_DATE_TIME).toInstant(UTC)); RangeQuery range = QueryHelper.range("CreationDate", from, true, to, true); CompareQuery eqOriginatingAgency = eq("OriginatingAgency", originatingAgency); Select select = new Select(); select.setQuery(and().add(eqOriginatingAgency, range)); return select.getFinalSelect(); }
DslQueryHelper { public JsonNode createSearchQueryAccessionRegister(Map<String, Object> options) throws InvalidCreateOperationException { String startDate = (String) options.get("startDate"); String endDate = (String) options.get("endDate"); String originatingAgency = (String) options.get("OriginatingAgency"); Date from = Date.from(LocalDateTime.parse(startDate, ISO_OFFSET_DATE_TIME).toInstant(UTC)); Date to = Date.from(LocalDateTime.parse(endDate, ISO_OFFSET_DATE_TIME).toInstant(UTC)); RangeQuery range = QueryHelper.range("CreationDate", from, true, to, true); CompareQuery eqOriginatingAgency = eq("OriginatingAgency", originatingAgency); Select select = new Select(); select.setQuery(and().add(eqOriginatingAgency, range)); return select.getFinalSelect(); } }
DslQueryHelper { public JsonNode createSearchQueryAccessionRegister(Map<String, Object> options) throws InvalidCreateOperationException { String startDate = (String) options.get("startDate"); String endDate = (String) options.get("endDate"); String originatingAgency = (String) options.get("OriginatingAgency"); Date from = Date.from(LocalDateTime.parse(startDate, ISO_OFFSET_DATE_TIME).toInstant(UTC)); Date to = Date.from(LocalDateTime.parse(endDate, ISO_OFFSET_DATE_TIME).toInstant(UTC)); RangeQuery range = QueryHelper.range("CreationDate", from, true, to, true); CompareQuery eqOriginatingAgency = eq("OriginatingAgency", originatingAgency); Select select = new Select(); select.setQuery(and().add(eqOriginatingAgency, range)); return select.getFinalSelect(); } DslQueryHelper(); }
DslQueryHelper { public JsonNode createSearchQueryAccessionRegister(Map<String, Object> options) throws InvalidCreateOperationException { String startDate = (String) options.get("startDate"); String endDate = (String) options.get("endDate"); String originatingAgency = (String) options.get("OriginatingAgency"); Date from = Date.from(LocalDateTime.parse(startDate, ISO_OFFSET_DATE_TIME).toInstant(UTC)); Date to = Date.from(LocalDateTime.parse(endDate, ISO_OFFSET_DATE_TIME).toInstant(UTC)); RangeQuery range = QueryHelper.range("CreationDate", from, true, to, true); CompareQuery eqOriginatingAgency = eq("OriginatingAgency", originatingAgency); Select select = new Select(); select.setQuery(and().add(eqOriginatingAgency, range)); return select.getFinalSelect(); } DslQueryHelper(); static DslQueryHelper getInstance(); JsonNode createSingleQueryDSL(Map<String, Object> searchCriteriaMap); JsonNode createSelectDSLQuery(Map<String, String> searchCriteriaMap); JsonNode createGetByIdDSLSelectMultipleQuery(Map<String, String> projectionCriteriaMap); JsonNode createSelectElasticsearchDSLQuery(Map<String, Object> searchCriteriaMap); JsonNode createUpdateByIdDSLQuery(Map<String, JsonNode> searchCriteriaMap,
        Map<String, JsonNode> updateRules); ObjectNode createMassiveUpdateDSLBaseQuery(JsonNode modifiedFields); UpdateMultiQuery getFullMetadataActionQuery(JsonNode metadataModifications); JsonNode createSearchQueryAccessionRegister(Map<String, Object> options); JsonNode createSelectAndUpdateDSLQuery(Map<String, Object> optionsMap); }
DslQueryHelper { public JsonNode createSearchQueryAccessionRegister(Map<String, Object> options) throws InvalidCreateOperationException { String startDate = (String) options.get("startDate"); String endDate = (String) options.get("endDate"); String originatingAgency = (String) options.get("OriginatingAgency"); Date from = Date.from(LocalDateTime.parse(startDate, ISO_OFFSET_DATE_TIME).toInstant(UTC)); Date to = Date.from(LocalDateTime.parse(endDate, ISO_OFFSET_DATE_TIME).toInstant(UTC)); RangeQuery range = QueryHelper.range("CreationDate", from, true, to, true); CompareQuery eqOriginatingAgency = eq("OriginatingAgency", originatingAgency); Select select = new Select(); select.setQuery(and().add(eqOriginatingAgency, range)); return select.getFinalSelect(); } DslQueryHelper(); static DslQueryHelper getInstance(); JsonNode createSingleQueryDSL(Map<String, Object> searchCriteriaMap); JsonNode createSelectDSLQuery(Map<String, String> searchCriteriaMap); JsonNode createGetByIdDSLSelectMultipleQuery(Map<String, String> projectionCriteriaMap); JsonNode createSelectElasticsearchDSLQuery(Map<String, Object> searchCriteriaMap); JsonNode createUpdateByIdDSLQuery(Map<String, JsonNode> searchCriteriaMap,
        Map<String, JsonNode> updateRules); ObjectNode createMassiveUpdateDSLBaseQuery(JsonNode modifiedFields); UpdateMultiQuery getFullMetadataActionQuery(JsonNode metadataModifications); JsonNode createSearchQueryAccessionRegister(Map<String, Object> options); JsonNode createSelectAndUpdateDSLQuery(Map<String, Object> optionsMap); static final String PROJECTION_DSL; }