Package com.google.visualization.datasource.base

Examples of com.google.visualization.datasource.base.InvalidQueryException


     * @param types A list with parameters types.
     * @throws InvalidQueryException Thrown if the parameters are invalid.
     */
    public void validateParameters(List<ValueType> types) throws InvalidQueryException {
        if(types.size() != 2) {
            throw new InvalidQueryException("Number of parameters for the dateDiff "
                    + "function is wrong: " + types.size());
        }
        else if((!isDateOrDateTimeValue(types.get(0)))
                || (!isDateOrDateTimeValue(types.get(1)))) {
            throw new InvalidQueryException("Can't perform the function 'dateDiff' "
                    + "on values that are not a Date or a DateTime values");
        }
    }
View Full Code Here


    public void addLabel(AbstractColumn column, String label) throws InvalidQueryException {
        if(columnLabels.keySet().contains(column)) {
            String messageToLogAndUser = "Column [" + column.toString() + "] is "
                    + "specified more than once in LABEL.";
            log.error(messageToLogAndUser);
            throw new InvalidQueryException(messageToLogAndUser);
        }
        columnLabels.put(column, label);
    }
View Full Code Here

     * @param types A list with parameters types.
     * @throws InvalidQueryException Thrown if the parameters are invalid.
     */
    public void validateParameters(List<ValueType> types) throws InvalidQueryException {
        if(types.size() != 2) {
            throw new InvalidQueryException("The function " + FUNCTION_NAME
                    + " requires 2 parmaeters ");
        }
        for(ValueType type : types) {
            if(type != ValueType.NUMBER) {
                throw new InvalidQueryException("Can't perform the function "
                        + FUNCTION_NAME + " on values that are not numbers");
            }
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void validateParameters(List<ValueType> types) throws InvalidQueryException {
        if(types.size() != 1) {
            throw new InvalidQueryException(FUNCTION_NAME +
                    " requires 1 parmaeter");
        }
        if(types.get(0) != ValueType.TEXT) {
            throw new InvalidQueryException(FUNCTION_NAME +
                    " takes a text parameter");
        }
    }
View Full Code Here

     * @throws InvalidQueryException Thrown if the parameters are invalid.
     */
    public void validateParameters(List<ValueType> types)
            throws InvalidQueryException {
        if(types.size() != 0) {
            throw new InvalidQueryException("The " + FUNCTION_NAME + " function should not get "
                    + "any parameters");
        }
    }
View Full Code Here

            case MIN:
                break;
            case AVG:
            case SUM:
                if(valueType != ValueType.NUMBER) {
                    throw new InvalidQueryException(MessagesEnum.AVG_SUM_ONLY_NUMERIC.getMessage(userLocale));
                }
                break;
            default:
                throw new RuntimeException(MessagesEnum.INVALID_AGG_TYPE.getMessageWithArgs(
                        userLocale, aggregationType.toString()));
View Full Code Here

     * @param types A list with parameters types.
     * @throws InvalidQueryException Thrown if the parameters are invalid.
     */
    public void validateParameters(List<ValueType> types) throws InvalidQueryException {
        if(types.size() != 2) {
            throw new InvalidQueryException("The function " + FUNCTION_NAME
                    + " requires 2 parmaeters ");
        }
        for(ValueType type : types) {
            if(type != ValueType.NUMBER) {
                throw new InvalidQueryException("Can't perform the function "
                        + FUNCTION_NAME + " on values that are not numbers");
            }
        }
    }
View Full Code Here

     * @param types A list with parameters types.
     * @throws InvalidQueryException Thrown if the parameters are invalid.
     */
    public void validateParameters(List<ValueType> types) throws InvalidQueryException {
        if(types.size() != 1) {
            throw new InvalidQueryException("Number of parameters for the date "
                    + "function is wrong: " + types.size());
        }
        else if((types.get(0) != ValueType.DATETIME)
                && (types.get(0) != ValueType.DATE)
                && (types.get(0) != ValueType.NUMBER)) {
            throw new InvalidQueryException("Can't perform the function 'date' "
                    + "on values that are not date, dateTime or number values");
        }
    }
View Full Code Here

   */
  public static DateValue stringToDate(String s) throws InvalidQueryException {
    String[] split = s.split("-");
    if (split.length != 3) {
      log.error(String.format(dateMessage, s));
      throw new InvalidQueryException(String.format(dateMessage, s));
    }
    try {
      int year = Integer.parseInt(split[0]);
      int month = Integer.parseInt(split[1]);
      month--; // normalize 1-12 to 0-11.
      int day = Integer.parseInt(split[2]);
      return new DateValue(year, month, day);
    } catch (NumberFormatException e) {
      log.error(String.format(dateMessage, s));
      throw new InvalidQueryException(String.format(dateMessage, s));
    } catch (IllegalArgumentException e) {
      log.error(String.format(dateMessage, s));
      throw new InvalidQueryException(String.format(dateMessage, s));
    }
  }
View Full Code Here

  public static TimeOfDayValue stringToTimeOfDay(String s)
      throws InvalidQueryException {
    String[] split = s.split(":");
    if (split.length != 3) {
      log.error(String.format(timeOfDayMessage, s));
      throw new InvalidQueryException(String.format(timeOfDayMessage, s));
    }
    try {
      int hour = Integer.parseInt(split[0]);
      int minute = Integer.parseInt(split[1]);
      int second;
      if (split[2].contains(".")) {
        String[] secondMilliSplit = split[2].split(".");
        if (secondMilliSplit.length != 2) {
          log.error(String.format(timeOfDayMessage, s));
          throw new InvalidQueryException(String.format(timeOfDayMessage, s));
        }
        second = Integer.parseInt(secondMilliSplit[0]);
        int milli = Integer.parseInt(secondMilliSplit[1]);
        return new TimeOfDayValue(hour, minute, second, milli);
      } else {
        second = Integer.parseInt(split[2]);
        return new TimeOfDayValue(hour, minute, second);
      }
    } catch (NumberFormatException e) {
      log.error(String.format(timeOfDayMessage, s));
      throw new InvalidQueryException(String.format(timeOfDayMessage, s));
    } catch (IllegalArgumentException e) {
      log.error(String.format(timeOfDayMessage, s));
      throw new InvalidQueryException(String.format(timeOfDayMessage, s));
    }
  }
View Full Code Here

TOP

Related Classes of com.google.visualization.datasource.base.InvalidQueryException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.