コード例 #1
0
  @Override
  public List<Object> getSqlFiltersParams(final Properties ctx) {
    final List<ISqlQueryFilter> filters = getSqlFilters();

    if (filters == null || filters.isEmpty()) {
      return Collections.emptyList();
    }

    final List<Object> params = new ArrayList<Object>();
    for (final ISqlQueryFilter sqlFilter : filters) {
      final String sqlFilterWhereClause = sqlFilter.getSql();
      if (!Check.isEmpty(sqlFilterWhereClause, true)) {
        params.addAll(sqlFilter.getSqlParams(ctx));
      }
    }

    return params;
  }
コード例 #2
0
  /**
   * Append <code>sqlFiltersToAppend</code> to given:
   *
   * <ul>
   *   <li><code>resultSqlWhereClause</code> string builder/buffer
   *   <li>and <code>resultSqlFilters</code> list.
   * </ul>
   *
   * @param resultSqlWhereClause
   * @param resultSqlFilters
   * @param sqlFiltersToAppend
   */
  private final void appendSqlWhereClause(
      final StringBuilder resultSqlWhereClause,
      final List<ISqlQueryFilter> resultSqlFilters,
      final List<ISqlQueryFilter> sqlFiltersToAppend) {
    //
    // If there are no SQL filters to append, return right away
    if (sqlFiltersToAppend == null || sqlFiltersToAppend.isEmpty()) {
      return;
    }

    //
    // Iterate SQL Filters to Append and
    // * update "resultSqlWhereClause" string buffer
    // * append the filter to resultSqlFilters
    for (final ISqlQueryFilter sqlFilterToAppend : sqlFiltersToAppend) {
      // Make sure our sqlFilter to append is not null
      // NOTE: we cannot skip it because maybe other logic was rellying on if "sqlFiltersToAppend"
      // is empty or null
      Check.assumeNotNull(sqlFiltersToAppend, "sqlFiltersToAppend not null");

      final String sqlFilterWhereClause = sqlFilterToAppend.getSql();

      //
      // Skip filters which have an empty SQL
      // Shall not happen but we cannot control ISqlQueryFilter implementations
      if (Check.isEmpty(sqlFilterWhereClause, true)) {
        continue;
      }

      //
      // Append the SQL where clause to given string buffer
      if (resultSqlWhereClause.length() > 0) {
        resultSqlWhereClause.append(and ? SQL_AND : SQL_OR);
      }
      resultSqlWhereClause.append("(").append(sqlFilterWhereClause).append(")");

      //
      // Append the SQL Filter to given SQL Filters current result
      resultSqlFilters.add(sqlFilterToAppend);
    }
  }