Package com.orientechnologies.orient.core.exception

Examples of com.orientechnologies.orient.core.exception.OQueryParsingException


          // _fieldValues.put(iFieldName, newValue);
          return (RET) newValue;
        } catch (ParseException pe) {
          final String dateFormat = ((String) iValue).length() > config.dateFormat.length() ? config.dateTimeFormat
              : config.dateFormat;
          throw new OQueryParsingException("Error on conversion of date '" + iValue + "' using the format: " + dateFormat);
        }
      }
    }

    iValue = OType.convert(iValue, iFieldType);
View Full Code Here


        }
      }
    } catch (OQueryParsingException e) {
      if (e.getText() == null)
        // QUERY EXCEPTION BUT WITHOUT TEXT: NEST IT
        throw new OQueryParsingException("Error on parsing query", text, currentPos, e);

      throw e;
    } catch (Throwable t) {
      throw new OQueryParsingException("Error on parsing query", text, currentPos, t);
    }
  }
View Full Code Here

  private boolean extractTargets() {
    jumpWhiteSpaces();

    if (currentPos == -1)
      throw new OQueryParsingException("No query target found", text, 0);

    targetRecords = new ArrayList<String>();

    if (Character.isDigit(text.charAt(currentPos))) {
      // UNIQUE RID
      final StringBuilder word = new StringBuilder();
      currentPos = OSQLHelper.nextWord(text, textUpperCase, currentPos, word, true);

      targetRecords.add(word.toString());

    } else if (text.charAt(currentPos) == OStringSerializerHelper.COLLECTION_BEGIN) {
      // COLLECTION OF RIDS
      currentPos = OStringSerializerHelper.getCollection(text, currentPos, targetRecords);
    } else {
      String subjectName;
      String alias;
      String subjectToMatch;
      int newPos;

      final StringBuilder word = new StringBuilder();
      currentPos = OSQLHelper.nextWord(text, textUpperCase, currentPos, word, true);

      while (currentPos > -1 && (targetClasses == null && targetClusters == null && targetIndex == null)) {
        subjectName = word.toString();

        newPos = OSQLHelper.nextWord(text, textUpperCase, currentPos, word, true);
        if (newPos > -1 && word.toString().equals("AS")) {
          currentPos = newPos;

          newPos = OSQLHelper.nextWord(text, textUpperCase, currentPos, word, true);
          if (newPos == -1)
            throw new OQueryParsingException("No alias found. Example: SELECT FROM Customer AS c", text, currentPos);

          currentPos = newPos;

          alias = word.toString();
View Full Code Here

        // CHECK FOR PARAMETERS
        if (word.length() > op.keyword.length() && word.charAt(op.keyword.length()) == OStringSerializerHelper.PARENTHESIS_BEGIN) {
          int paramBeginPos = currentPos - (word.length() - op.keyword.length());
          currentPos = OStringSerializerHelper.getParameters(text, paramBeginPos, params);
        } else if (!word.equals(op.keyword))
          throw new OQueryParsingException("Malformed usage of operator '" + op.toString() + "'. Parsed operator is: " + word);

        try {
          return op.configure(params);
        } catch (Exception e) {
          throw new OQueryParsingException("Syntax error using the operator '" + op.toString() + "'. Syntax is: " + op.getSyntax());
        }
      }
    }

    throw new OQueryParsingException("Unknown operator " + word, text, currentPos);
  }
View Full Code Here

    if (iName.charAt(0) == OStringSerializerHelper.PARAMETER_NAMED) {
      name = iName.substring(1);

      // CHECK THE PARAMETER NAME IS CORRECT
      if (!OStringSerializerHelper.isAlphanumeric(name)) {
        throw new OQueryParsingException("Parameter name '" + name + "' is invalid, only alphanumeric characters are allowed");
      }
    } else
      name = iName;

    final OSQLFilterItemParameter param = new OSQLFilterItemParameter(name);
View Full Code Here

    }

    try {
      return formatter.parse(stringValue);
    } catch (ParseException pe) {
      throw new OQueryParsingException("Error on conversion of date '" + stringValue + "' using the format: "
          + formatter.toString());
    }
  }
View Full Code Here

            final List<String> arguments;

            if (op.minArguments > 0) {
              arguments = OStringSerializerHelper.getParameters(part);
              if (arguments.size() < op.minArguments || arguments.size() > op.maxArguments)
                throw new OQueryParsingException(iQueryToParse.text, "Syntax error: field operator '" + op.keyword + "' needs "
                    + (op.minArguments == op.maxArguments ? op.minArguments : op.minArguments + "-" + op.maxArguments)
                    + " argument(s) while has been received " + arguments.size(), iQueryToParse.currentPos + separatorPos);
            } else
              arguments = null;

            // SPECIAL OPERATION FOUND: ADD IT IN TO THE CHAIN
            if (operationsChain == null)
              operationsChain = new ArrayList<OPair<Integer, List<String>>>();

            operationsChain.add(new OPair<Integer, List<String>>(op.id, arguments));

            separatorPos = partUpperCase.indexOf(OStringSerializerHelper.PARENTHESIS_END)
                + OSQLFilterFieldOperator.CHAIN_SEPARATOR.length();
            operatorFound = true;
            break;
          }

        if (!operatorFound) {
          separatorPos = partUpperCase.indexOf(OSQLFilterFieldOperator.CHAIN_SEPARATOR, 0);

          // CHECK IF IT'S A FIELD
          int posOpenBrace = part.indexOf('(');
          if (posOpenBrace == -1 || posOpenBrace > separatorPos && separatorPos > -1) {
            // YES, SEEMS A FIELD
            String chainedFieldName = separatorPos > -1 ? part.substring(0, separatorPos) : part;

            if (operationsChain == null)
              operationsChain = new ArrayList<OPair<Integer, List<String>>>();

            final List<String> list = new ArrayList<String>();
            list.add(chainedFieldName);
            if (chainedFieldName.charAt(0) == '@')
              operationsChain.add(new OPair<Integer, List<String>>(OSQLFilterFieldOperator.ATTRIB.id, list));
            else
              operationsChain.add(new OPair<Integer, List<String>>(OSQLFilterFieldOperator.FIELD.id, list));
          } else
            // ERROR: OPERATOR NOT FOUND OR MISPELLED
            throw new OQueryParsingException(iQueryToParse.text,
                "Syntax error: field operator not recognized between the supported ones: "
                    + Arrays.toString(OSQLFilterFieldOperator.OPERATORS), iQueryToParse.currentPos + separatorPos);
        }

        if (separatorPos >= partUpperCase.length())
View Full Code Here

    else if (compiledFilter.getTargetIndex() != null)
      searchInIndex();
    else if (compiledFilter.getTargetRecords() != null)
      searchInRecords();
    else
      throw new OQueryParsingException("No source found in query: specify class, clusters or single records");

    applyOrderBy();
    applyFlatten();
    return processResult();
  }
View Full Code Here

  protected void parseOrderBy(final StringBuilder word) {
    int newPos = OSQLHelper.nextWord(text, textUpperCase, currentPos, word, true);

    if (!KEYWORD_BY.equals(word.toString()))
      throw new OQueryParsingException("Expected keyword " + KEYWORD_BY);

    currentPos = newPos;

    String fieldName;
    String fieldOrdering;
View Full Code Here

    if (!word.toString().equals(KEYWORD_SELECT))
      return -1;

    int fromPosition = textUpperCase.indexOf(KEYWORD_FROM_2FIND, currentPos);
    if (fromPosition == -1)
      throw new OQueryParsingException("Missed " + KEYWORD_FROM, text, currentPos);

    Object projectionValue;
    final String projectionString = text.substring(currentPos, fromPosition).trim();
    if (projectionString.length() > 0 && !projectionString.equals("*")) {
      // EXTRACT PROJECTIONS
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.exception.OQueryParsingException

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.