コード例 #1
0
  /**
   * Check invalid operator's
   *
   * @param column
   * @throws QueryExecutionException
   */
  private void checkInValid(String tableName, Column column) throws QueryExecutionException {

    Operator[] unAvailableQueryOperators =
        getUnAvailableQueryOperators(column.getAvailableQueryOperators());

    for (Operator operator : unAvailableQueryOperators) {

      StringBuffer query = new StringBuffer();
      query.append("SELECT ").append(tableName).append(".*");
      query.append(" FROM ").append(tableName);
      query.append(" WHERE ");
      query.append(tableName).append(".").append(column.getName());
      switch (operator) {
        case EQUAL_TO:
          query.append("= 1");
          break;
        case GREATER_THAN:
          query.append("> 1");
          break;
        case GREATER_THAN_OR_EQUAL_TO:
          query.append(">= 1");
          break;
        case LESS_THAN:
          query.append("< 1");
          break;
        case LESS_THAN_OR_EQUAL_TO:
          query.append("<= 1");
          break;
        case LIKE:
          query.append(" LIKE 'mooo' ");
          break;
        case NOT_EQUAL_TO:
          query.append(" <> 1");
          break;
        default:
          fail("unknown operator " + operator);
          break;
      }
      try {
        org.xcmis.spi.query.Query cmisQuery = new org.xcmis.spi.query.Query(query.toString(), true);
        storageA.query(cmisQuery);
        fail(
            "InvalidArgumentException should be thrown for invalid operator "
                + operator
                + " for columnt ='"
                + column.getName()
                + "'");
      } catch (InvalidArgumentException e) {
        // ok
      }
    }
  }
コード例 #2
0
  /**
   * Check valid operator's
   *
   * @param column
   * @throws InvalidQueryException
   * @throws QueryExecutionException
   */
  private void checkValid(String tableName, Column column)
      throws QueryExecutionException, InvalidQueryException {

    for (Operator operator : column.getAvailableQueryOperators()) {

      StringBuffer query = new StringBuffer();
      query.append("SELECT ").append(tableName).append(".*");
      query.append(" FROM ").append(tableName);
      query.append(" WHERE ");
      query.append(tableName).append(".").append(column.getName());
      switch (operator) {
        case EQUAL_TO:
          query.append("= 1");
          break;
        case GREATER_THAN:
          query.append("> 1");
          break;
        case GREATER_THAN_OR_EQUAL_TO:
          query.append(">= 1");
          break;
        case LESS_THAN:
          query.append("< 1");
          break;
        case LESS_THAN_OR_EQUAL_TO:
          query.append("<= 1");
          break;
        case LIKE:
          query.append(" LIKE 'mooo' ");
          break;
        case NOT_EQUAL_TO:
          query.append(" <> 1");
          break;
        default:
          fail("unknown operator " + operator);
          break;
      }
      org.xcmis.spi.query.Query cmisQuery = new org.xcmis.spi.query.Query(query.toString(), true);
      storageA.query(cmisQuery);
    }
  }