/**
   * Expands any interpolation contained within the JsonValue object in-place.
   *
   * @param json JsonValue to parse for macros
   */
  public static void expand(JsonValue json) {
    Iterator<String> iter = json.keys().iterator();
    while (iter.hasNext()) {
      String key = iter.next();

      String expanded = parse(json.get(key));
      if (expanded != null) {
        json.put(key, expanded);
      }
    }
  }
Ejemplo n.º 2
0
    void setConfiguredQueries(Map<String, String> replacements, JsonValue queriesConfig) {
      configured.clear();
      for (String queryName : queriesConfig.keys()) {
        String rawQuery = queriesConfig.get(queryName).required().asString();

        TokenHandler tokenHandler = new TokenHandler();
        // Replace the table name tokens.
        String tempQueryString = tokenHandler.replaceSomeTokens(rawQuery, replacements);

        // Convert to ? for prepared statement, populate token replacement info
        List<String> tokenNames = tokenHandler.extractTokens(tempQueryString);
        String queryString = tokenHandler.replaceTokens(tempQueryString, "?", PREFIX_LIST);

        QueryInfo queryInfo = new QueryInfo(queryString, tokenNames);
        configured.put(queryName, queryInfo);
        logger.info(
            "Configured query converted to JDBC query {} and tokens {}", queryString, tokenNames);
      }
    }