@Test public void testCreateUpdateDSLQuery() throws InvalidParseOperationException, InvalidCreateOperationException { final Map<String, JsonNode> queryMap = new HashMap<>(); queryMap.put("title", new TextNode("Archive2")); queryMap.put("date", new TextNode("09/09/2015")); final Map<String, JsonNode> rulesMap = new HashMap<>(); final JsonNode updateRequest = dslQueryHelper.createUpdateByIdDSLQuery(queryMap, rulesMap); assertNotNull(updateRequest); final RequestParserMultiple updateParser = RequestParserHelper.getParser(updateRequest); assertTrue(updateParser instanceof UpdateParserMultiple); assertTrue(updateParser.getRequest().getActions().size() == 2); assertTrue(updateParser.getRequest().getQueries().isEmpty()); assertTrue(updateParser.getRequest().getRoots().isEmpty()); }
public JsonNode createUpdateByIdDSLQuery(Map<String, JsonNode> searchCriteriaMap, Map<String, JsonNode> updateRules) throws InvalidParseOperationException, InvalidCreateOperationException { final UpdateMultiQuery update = new UpdateMultiQuery(); for (final Entry<String, JsonNode> entry : searchCriteriaMap.entrySet()) { final String searchKeys = entry.getKey(); final JsonNode searchValue = entry.getValue(); if (searchKeys.isEmpty()) { throw new InvalidParseOperationException("Parameters should not be empty or null"); } Map<String, JsonNode> action = new HashMap<>(); action.put(searchKeys, searchValue); update.addActions(new SetAction(action)); } for (final Entry<String, JsonNode> categoryRule : updateRules.entrySet()) { final String categoryKey = categoryRule.getKey(); final JsonNode categoryRules = categoryRule.getValue(); if (categoryRules.isEmpty(new DefaultSerializerProvider.Impl())) { update.addActions(new UnsetAction(MANAGEMENT_KEY + '.' + categoryKey)); } else { Map<String, JsonNode> action = new HashMap<>(); action.put(MANAGEMENT_KEY + '.' + categoryKey, categoryRules); update.addActions(new SetAction(action)); } } return update.getFinalUpdateById(); }
DslQueryHelper { public JsonNode createUpdateByIdDSLQuery(Map<String, JsonNode> searchCriteriaMap, Map<String, JsonNode> updateRules) throws InvalidParseOperationException, InvalidCreateOperationException { final UpdateMultiQuery update = new UpdateMultiQuery(); for (final Entry<String, JsonNode> entry : searchCriteriaMap.entrySet()) { final String searchKeys = entry.getKey(); final JsonNode searchValue = entry.getValue(); if (searchKeys.isEmpty()) { throw new InvalidParseOperationException("Parameters should not be empty or null"); } Map<String, JsonNode> action = new HashMap<>(); action.put(searchKeys, searchValue); update.addActions(new SetAction(action)); } for (final Entry<String, JsonNode> categoryRule : updateRules.entrySet()) { final String categoryKey = categoryRule.getKey(); final JsonNode categoryRules = categoryRule.getValue(); if (categoryRules.isEmpty(new DefaultSerializerProvider.Impl())) { update.addActions(new UnsetAction(MANAGEMENT_KEY + '.' + categoryKey)); } else { Map<String, JsonNode> action = new HashMap<>(); action.put(MANAGEMENT_KEY + '.' + categoryKey, categoryRules); update.addActions(new SetAction(action)); } } return update.getFinalUpdateById(); } }
DslQueryHelper { public JsonNode createUpdateByIdDSLQuery(Map<String, JsonNode> searchCriteriaMap, Map<String, JsonNode> updateRules) throws InvalidParseOperationException, InvalidCreateOperationException { final UpdateMultiQuery update = new UpdateMultiQuery(); for (final Entry<String, JsonNode> entry : searchCriteriaMap.entrySet()) { final String searchKeys = entry.getKey(); final JsonNode searchValue = entry.getValue(); if (searchKeys.isEmpty()) { throw new InvalidParseOperationException("Parameters should not be empty or null"); } Map<String, JsonNode> action = new HashMap<>(); action.put(searchKeys, searchValue); update.addActions(new SetAction(action)); } for (final Entry<String, JsonNode> categoryRule : updateRules.entrySet()) { final String categoryKey = categoryRule.getKey(); final JsonNode categoryRules = categoryRule.getValue(); if (categoryRules.isEmpty(new DefaultSerializerProvider.Impl())) { update.addActions(new UnsetAction(MANAGEMENT_KEY + '.' + categoryKey)); } else { Map<String, JsonNode> action = new HashMap<>(); action.put(MANAGEMENT_KEY + '.' + categoryKey, categoryRules); update.addActions(new SetAction(action)); } } return update.getFinalUpdateById(); } DslQueryHelper(); }
DslQueryHelper { public JsonNode createUpdateByIdDSLQuery(Map<String, JsonNode> searchCriteriaMap, Map<String, JsonNode> updateRules) throws InvalidParseOperationException, InvalidCreateOperationException { final UpdateMultiQuery update = new UpdateMultiQuery(); for (final Entry<String, JsonNode> entry : searchCriteriaMap.entrySet()) { final String searchKeys = entry.getKey(); final JsonNode searchValue = entry.getValue(); if (searchKeys.isEmpty()) { throw new InvalidParseOperationException("Parameters should not be empty or null"); } Map<String, JsonNode> action = new HashMap<>(); action.put(searchKeys, searchValue); update.addActions(new SetAction(action)); } for (final Entry<String, JsonNode> categoryRule : updateRules.entrySet()) { final String categoryKey = categoryRule.getKey(); final JsonNode categoryRules = categoryRule.getValue(); if (categoryRules.isEmpty(new DefaultSerializerProvider.Impl())) { update.addActions(new UnsetAction(MANAGEMENT_KEY + '.' + categoryKey)); } else { Map<String, JsonNode> action = new HashMap<>(); action.put(MANAGEMENT_KEY + '.' + categoryKey, categoryRules); update.addActions(new SetAction(action)); } } return update.getFinalUpdateById(); } 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 createUpdateByIdDSLQuery(Map<String, JsonNode> searchCriteriaMap, Map<String, JsonNode> updateRules) throws InvalidParseOperationException, InvalidCreateOperationException { final UpdateMultiQuery update = new UpdateMultiQuery(); for (final Entry<String, JsonNode> entry : searchCriteriaMap.entrySet()) { final String searchKeys = entry.getKey(); final JsonNode searchValue = entry.getValue(); if (searchKeys.isEmpty()) { throw new InvalidParseOperationException("Parameters should not be empty or null"); } Map<String, JsonNode> action = new HashMap<>(); action.put(searchKeys, searchValue); update.addActions(new SetAction(action)); } for (final Entry<String, JsonNode> categoryRule : updateRules.entrySet()) { final String categoryKey = categoryRule.getKey(); final JsonNode categoryRules = categoryRule.getValue(); if (categoryRules.isEmpty(new DefaultSerializerProvider.Impl())) { update.addActions(new UnsetAction(MANAGEMENT_KEY + '.' + categoryKey)); } else { Map<String, JsonNode> action = new HashMap<>(); action.put(MANAGEMENT_KEY + '.' + categoryKey, categoryRules); update.addActions(new SetAction(action)); } } return update.getFinalUpdateById(); } 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; }