Package org.dbwiki.exception.data

Examples of org.dbwiki.exception.data.WikiQueryException


  public ValueCondition(XPath targetPath, int quantifier, boolean negated, ValueOp operator, int evalQuantifier) throws org.dbwiki.exception.WikiException {
   
    super(targetPath, quantifier, negated);
   
    if (!targetPath.lastElement().entity().isAttribute()) {
      throw new WikiQueryException(WikiQueryException.InvalidPathExpression, "Cannot have value condition for non-attribute node " + targetPath.lastElement().entity());
    }
    _evalQuantifier = evalQuantifier;
    _operator = operator;
  }
View Full Code Here


      if (value.endsWith("'")) {
        strValue = value.replaceAll("\\\\", "\\").replaceAll("\\\'", "\'");
        strValue = strValue.substring(1, strValue.length() - 1);
        type = typeString;
      } else {
        throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Missing ' in " + value);
      }
    } else {
      try {
        numericValue = Double.parseDouble(value);
        type = typeInt;
      } catch (java.lang.NumberFormatException nfe) {
        throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Format of " + value + " not recognized");
      }
    }

    if (operatorDef.equals(EQ)) {
      if (type == typeInt) {
View Full Code Here

            int comma = query.indexOf(",");
            int closeParen = query.indexOf(")", comma);
            int colon = query.indexOf(":", closeParen);
           
            if(comma == -1 || closeParen == -1 || colon != closeParen+1)
              throw new WikiQueryException(WikiQueryException.UnknownQueryFormat, _queryString);
           
            xSize = query.substring(1, comma);
            ySize = query.substring(comma+1, closeParen);
            query = query.substring(colon+1);
          } else {
            query = query.substring(1);
          }
          QueryResultSet rs = database.query(query);
          body.openPARAGRAPH(CSS.CSSPageText);
          drawChart(ChartType.Column, xSize, ySize, rs, body);
        } else if(query.toLowerCase().startsWith("pie:") || query.toLowerCase().startsWith("pie(")) {
          // FIXME: should parse the arguments to charts in a more
          // sensible scalable way.
          query = query.substring("pie".length());
          String xSize = "800";
          String ySize = "600";
          if(query.startsWith("(")) {
            int comma = query.indexOf(",");
            int closeParen = query.indexOf(")", comma);
            int colon = query.indexOf(":", closeParen);

            if(comma == -1 || closeParen == -1 || colon != closeParen+1)
              throw new WikiQueryException(WikiQueryException.UnknownQueryFormat, _queryString);

            xSize = query.substring(1, comma);
            ySize = query.substring(comma+1, closeParen);
            query = query.substring(colon+1);
          } else {
View Full Code Here

    //
    _database = database;
    try {
      _nodeID = Integer.decode("0x" + nodeHexID);
    } catch (java.lang.NumberFormatException exception) {
      throw new WikiQueryException(WikiQueryException.InvalidNIDQuery, nodeHexID);
    }
  }
View Full Code Here

      } else if (query.toLowerCase().startsWith(QueryStatement.QueryWikiPath.toLowerCase() + "://")) {
        return new WikiPathQueryStatement(database, query.substring(QueryStatement.QueryWikiPath.length() + 2));
      } else if (query.toLowerCase().startsWith("select ")) {
        return new XAQLQueryStatement(database, query);
      } else {
        throw new WikiQueryException(WikiQueryException.UnknownQueryFormat, query);
      }
    } else {
      throw new WikiQueryException(WikiQueryException.InvalidQueryFormat, "(null)");
    }
  }
View Full Code Here

    XAQLSyntaxParser parser = Parboiled.createParser(XAQLSyntaxParser.class);
   
    ParsingResult<XAQLToken> result = new ReportingParseRunner<XAQLToken>(parser.QueryStatement()).run(new DefaultInputBuffer(queryExpression.toCharArray()));

    if (result.hasErrors()) {
      throw new WikiQueryException(WikiQueryException.InvalidWikiQuery, queryExpression + "\n" + ErrorUtils.printParseErrors(result));
        } else {
        //result.parseTreeRoot.getValue().print("", "\t");
          _query = new QueryStatementGenerator().getStatement(database, result.parseTreeRoot.getValue());
        }
  }
View Full Code Here

    XAQLSyntaxParser parser = Parboiled.createParser(XAQLSyntaxParser.class);
   
    ParsingResult<XAQLToken> result = new ReportingParseRunner<XAQLToken>(parser.XPathStatement()).run(new DefaultInputBuffer(pathExpression.toCharArray()));
   
    if (result.hasErrors()) {
      throw new WikiQueryException(WikiQueryException.InvalidWikiQuery, pathExpression + "\n" + ErrorUtils.printParseErrors(result));
        } else {
          _targetPath = new AbsoluteTargetPathGenerator().getTargetPath(database.schema().root(), database.versionIndex(), result.parseTreeRoot.getValue().children().firstElement().children().iterator());
        }
  }
View Full Code Here

          String dateString = timestampToken.value().substring(timestampToken.value().indexOf('\'') + 1, timestampToken.value().lastIndexOf('\''));
          Version version = null;
          try {
            version = versionIndex.getVersionAt(org.dbwiki.lib.DateTime.getDate(dateString));
          } catch (java.text.ParseException perseException) {
            throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Invalid date expression: " + dateString);
          }
          if (version != null) {
            timestamp = timestamp + version.number();
          } else {
            timestamp = timestamp + "0";
View Full Code Here

    XAQLToken token = pathTokens.next();
   
    String entityName = token.children().firstElement().value();
    SchemaNode entity = ((GroupSchemaNode)parentEntity).children().get(entityName);
    if (entity == null) {
      throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Unknown entity " + entityName + " as child of " + parentEntity.label());
    }
   
    XPathComponent pathElement = null;
    if (token.children().size() == 2) {
      XAQLToken conditionToken = token.children().get(1);
      if (conditionToken.type() == XAQLToken.INDEX_CONDITION) {
        int index = -1;
        try {
          index = Integer.parseInt(conditionToken.children().firstElement().value());
        } catch (java.lang.NumberFormatException nfe) {
          throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Invalid number format " + conditionToken.children().firstElement().value());
        }
        pathElement = new XPathComponent(entity, new IndexCondition(index));
      } else {
        Condition condition = null;
        if (conditionToken.children().size() > 1) {
View Full Code Here

    XAQLToken token = pathTokens.next();
   
    String entityName = token.children().firstElement().value();
    if (!rootEntity.label().equals(entityName)) {
      throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Unknown entity " + entityName + " as root of the database");
    }
   
    XPathComponent pathElement = null;
    if (token.children().size() == 2) {
      XAQLToken conditionToken = token.children().get(1);
      if (conditionToken.type() == XAQLToken.INDEX_CONDITION) {
        int index = -1;
        try {
          index = Integer.parseInt(conditionToken.children().firstElement().value());
        } catch (java.lang.NumberFormatException nfe) {
          throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Invalid number format " + conditionToken.children().firstElement().value());
        }
        pathElement = new XPathComponent(rootEntity, new IndexCondition(index));
      } else {
        Condition condition = null;
        if (conditionToken.children().size() > 1) {
View Full Code Here

TOP

Related Classes of org.dbwiki.exception.data.WikiQueryException

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.