Package org.apache.olingo.odata2.api.uri.expression

Examples of org.apache.olingo.odata2.api.uri.expression.CommonExpression


  @Test
  public void testMoreThanOneBinaryExpression() {
    // complex query -
    String parsedStr = ODataJPATestConstants.EMPTY_STRING;
    CommonExpression exp1 =
        getBinaryExpressionMockedObj(BinaryOperator.GE, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_1);
    CommonExpression exp2 =
        getBinaryExpressionMockedObj(BinaryOperator.NE, ExpressionKind.PROPERTY, SALES_ABC, SAMPLE_DATA_XYZ);
    try {
      parsedStr =
          ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(exp1, BinaryOperator.AND, exp2),
              TABLE_ALIAS);
View Full Code Here


  public void testAllBinaryOperators() { // Test for all Binary Operators
    // complex query -
    String parsedStr1 = ODataJPATestConstants.EMPTY_STRING;
    String parsedStr2 = ODataJPATestConstants.EMPTY_STRING;

    CommonExpression exp1 =
        getBinaryExpressionMockedObj(BinaryOperator.LT, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_1);
    CommonExpression exp2 =
        getBinaryExpressionMockedObj(BinaryOperator.LE, ExpressionKind.PROPERTY, SALES_ABC, SAMPLE_DATA_XYZ);

    try {
      parsedStr1 =
          ODataExpressionParser.parseToJPAWhereExpression((BinaryExpression) getBinaryExpression(exp1,
              BinaryOperator.AND, exp2), TABLE_ALIAS);
      assertEquals(EXPECTED_STR_4, parsedStr1);

      CommonExpression exp3 =
          getBinaryExpressionMockedObj(BinaryOperator.GT, ExpressionKind.PROPERTY, SAMPLE_DATA_LINE_ITEMS,
              SAMPLE_DATA_2);
      CommonExpression exp4 =
          getBinaryExpressionMockedObj(BinaryOperator.GE, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_AMAZON);

      parsedStr2 =
          ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(exp3, BinaryOperator.AND, exp4),
              TABLE_ALIAS);
View Full Code Here

    return parseFilterString(filterExpression, false);
  }

  public FilterExpression parseFilterString(final String filterExpression, final boolean allowOnlyBinary)
      throws ExpressionParserException, ExpressionParserInternalError {
    CommonExpression node = null;
    curExpression = filterExpression;
    try {
      // Throws TokenizerException and FilterParserException. FilterParserException is caught somewhere above
      tokenList = new Tokenizer(filterExpression).tokenize();
      if (!tokenList.hasTokens()) {
        return new FilterExpressionImpl(filterExpression);
      }
    } catch (TokenizerException tokenizerException) {
      // Tested with TestParserExceptions.TestPMparseFilterString
      throw FilterParserExceptionImpl.createERROR_IN_TOKENIZER(tokenizerException, curExpression);
    }

    try {
      CommonExpression nodeLeft = readElement(null);
      node = readElements(nodeLeft, 0);
    } catch (ExpressionParserException filterParserException) {
      // Add empty filterTree to Exception
      // Tested for original throw point
      filterParserException.setFilterTree(new FilterExpressionImpl(filterExpression));
View Full Code Here

    return new FilterExpressionImpl(filterExpression, node);
  }

  protected CommonExpression readElements(final CommonExpression leftExpression, final int priority)
      throws ExpressionParserException, ExpressionParserInternalError {
    CommonExpression leftNode = leftExpression;
    CommonExpression rightNode;
    BinaryExpression binaryNode;

    ActualBinaryOperator operator = readBinaryOperator();
    ActualBinaryOperator nextOperator;
View Full Code Here

   */
  protected CommonExpression readParenthesis() throws ExpressionParserException, ExpressionParserInternalError {
    // The existing of a '(' is verified BEFORE this method is called --> so it's a internal error
    Token openParenthesis = tokenList.expectToken(TokenKind.OPENPAREN, true);

    CommonExpression firstExpression = readElement(null);
    CommonExpression parenthesisExpression = readElements(firstExpression, 0);

    // check for ')'
    try {
      tokenList.expectToken(TokenKind.CLOSEPAREN); // TokenizerMessage
    } catch (TokenizerExpectError e) {
View Full Code Here

   * @throws TokenizerExpectError
   * The next token did not match the expected token
   */
  protected MethodExpression readParameters(final InfoMethod methodInfo, final MethodExpressionImpl methodExpression,
      final Token methodToken) throws ExpressionParserException, ExpressionParserInternalError {
    CommonExpression expression;
    boolean expectAnotherExpression = false;
    boolean readComma = true;

    // The existing of a '(' is verified BEFORE this method is called --> so it's a internal error
    Token openParenthesis = tokenList.expectToken(TokenKind.OPENPAREN, true); // throws FilterParserInternalError
View Full Code Here

    case MEMBER:
      String memberExpStr = EMPTY;
      int i = 0;
      MemberExpression member = null;
      CommonExpression tempExp = whereExpression;
      while (tempExp != null && tempExp.getKind() == ExpressionKind.MEMBER) {
        member = (MemberExpression) tempExp;
        if (i > 0) {
          memberExpStr = JPQLStatement.DELIMITER.PERIOD + memberExpStr;
        }
        i++;
View Full Code Here

   * @throws TokenizerMessage
   */
  protected CommonExpression
      readElement(final CommonExpression leftExpression, final ActualBinaryOperator leftOperator)
          throws ExpressionParserException, ExpressionParserInternalError {
    CommonExpression node = null;
    Token token;
    Token lookToken;
    lookToken = tokenList.lookToken();
    if (lookToken == null) {
      return null;
View Full Code Here

  protected CommonExpression readUnaryoperator(final Token lookToken, final InfoUnaryOperator unaryOperator)
      throws ExpressionParserException, ExpressionParserInternalError {
    tokenList.expectToken(lookToken.getUriLiteral(), true);

    CommonExpression operand = readElement(null);
    UnaryExpression unaryExpression = new UnaryExpressionImpl(unaryOperator, operand);
    validateUnaryOperatorTypes(unaryExpression); // throws ExpressionInvalidOperatorTypeException

    return unaryExpression;
  }
View Full Code Here

      final MemberExpression memberExpression = (MemberExpression) expression;
      final PropertyExpression propertyExpression = (PropertyExpression) memberExpression.getProperty();
      final EdmProperty memberProperty = (EdmProperty) propertyExpression.getEdmProperty();
      final EdmSimpleType memberType = (EdmSimpleType) memberExpression.getEdmType();
      List<EdmProperty> propertyPath = new ArrayList<EdmProperty>();
      CommonExpression currentExpression = memberExpression;
      while (currentExpression != null) {
        final PropertyExpression currentPropertyExpression =
            (PropertyExpression) (currentExpression.getKind() == ExpressionKind.MEMBER ?
                ((MemberExpression) currentExpression).getProperty() : currentExpression);
        final EdmTyped currentProperty = currentPropertyExpression.getEdmProperty();
        final EdmTypeKind kind = currentProperty.getType().getKind();
        if (kind == EdmTypeKind.SIMPLE || kind == EdmTypeKind.COMPLEX) {
          propertyPath.add(0, (EdmProperty) currentProperty);
        } else {
          throw new ODataNotImplementedException();
        }
        currentExpression =
            currentExpression.getKind() == ExpressionKind.MEMBER ? ((MemberExpression) currentExpression).getPath()
                : null;
      }
      return memberType.valueToString(getPropertyValue(data, propertyPath), EdmLiteralKind.DEFAULT, memberProperty
          .getFacets());
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.uri.expression.CommonExpression

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.