Package com.google.visualization.datasource.base

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


   *
   * @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


        for(String columnId : mentionedColumnIds) {
            if(!dataTable.containsColumn(columnId)) {
                String messageToLogAndUser = MessagesEnum.NO_COLUMN.getMessageWithArgs(
                        dataTable.getLocaleForUserMessages(), columnId);
                log.error(messageToLogAndUser);
                throw new InvalidQueryException(messageToLogAndUser);
            }
        }

        // Check that all aggregation columns are valid (i.e., the aggregation type
        // matches the columns type).
        Set<AggregationColumn> mentionedAggregations = query.getAllAggregations();
        for(AggregationColumn agg : mentionedAggregations) {
            try {
                agg.validateColumn(dataTable);
            }
            catch(RuntimeException e) {
                log.error("A runtime exception has occured", e);
                throw new InvalidQueryException(e.getMessage());
            }
        }

        // Check that all scalar function columns are valid. (i.e., the scalar
        // function matches the columns types).
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

    public static DateTimeValue stringToDatetime(String s)
            throws InvalidQueryException {
        String[] mainSplit = s.split(" ");
        if(mainSplit.length != 2) {
            log.error(String.format(dateTimeMessage, s));
            throw new InvalidQueryException(String.format(dateTimeMessage, s));
        }
        String[] dateSplit = mainSplit[0].split("-");
        String[] timeSplit = mainSplit[1].split(":");
        if((dateSplit.length != 3) || (timeSplit.length != 3)) {
            log.error(String.format(dateTimeMessage, s));
            throw new InvalidQueryException(String.format(dateTimeMessage, s));
        }
        try {
            int year = Integer.parseInt(dateSplit[0]);
            int month = Integer.parseInt(dateSplit[1]);
            month--; // normalize 1-12 to 0-11.
            int day = Integer.parseInt(dateSplit[2]);
            int hour = Integer.parseInt(timeSplit[0]);
            int minute = Integer.parseInt(timeSplit[1]);
            int second;
            int milli = 0;
            if(timeSplit[2].contains(".")) {
                String[] secondMilliSplit = timeSplit[2].split("\\.");
                if(secondMilliSplit.length != 2) {
                    log.error(String.format(dateTimeMessage, s));
                    throw new InvalidQueryException(String.format(dateTimeMessage, s));
                }
                second = Integer.parseInt(secondMilliSplit[0]);
                milli = Integer.parseInt(secondMilliSplit[1]);
            }
            else {
                second = Integer.parseInt(timeSplit[2]);
            }
            return new DateTimeValue(year, month, day, hour, minute, second, milli);
        }
        catch(NumberFormatException e) {
            log.error(String.format(dateTimeMessage, s));
            throw new InvalidQueryException(String.format(dateTimeMessage, s));
        }
        catch(IllegalArgumentException e) {
            log.error(String.format(dateTimeMessage, s));
            throw new InvalidQueryException(String.format(dateTimeMessage, s));
        }
    }
View Full Code Here

                query = QueryParser.parseString(tqValue);
            }
            catch(ParseException ex) {
                String messageToUserAndLog = ex.getMessage();
                log.error("Parsing error: " + messageToUserAndLog);
                throw new InvalidQueryException(MessagesEnum.PARSE_ERROR.getMessageWithArgs(ulocale,
                        messageToUserAndLog));
            }
            query.setLocaleForUserMessages(ulocale);
            query.validate();
        }
View Full Code Here

     * @param types A list of parameter 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() != 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

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

                if(col.equals(selectionColumns.get(j))) {
                    String[] args = {col.toString(), clauseName};
                    String messageToLogAndUser = MessagesEnum.COLUMN_ONLY_ONCE.getMessageWithArgs(userLocale,
                            args);
                    log.error(messageToLogAndUser);
                    throw new InvalidQueryException(messageToLogAndUser);
                }
            }
        }
    }
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.