Package org.datanucleus.query.expression

Examples of org.datanucleus.query.expression.InvokeExpression


            }
            return true;
        }
        else if (expr instanceof InvokeExpression)
        {
            InvokeExpression invExpr = (InvokeExpression)expr;
            if (isExpressionGroupingOrAggregate(invExpr, exprGrouping))
            {
                return true;
            }
            Expression invokedExpr = invExpr.getLeft();
            if (invokedExpr != null && !containsOnlyGroupingOrAggregates(invokedExpr, exprGrouping))
            {
                // Check invoked object
                return false;
            }
            List<Expression> invArgs = invExpr.getArguments();
            if (invArgs != null)
            {
                // Check invocation arguments
                Iterator<Expression> iter= invArgs.iterator();
                while (iter.hasNext())
View Full Code Here


     */
    private static boolean isExpressionGroupingOrAggregate(Expression expr, Expression[] exprGrouping)
    {
        if (expr instanceof InvokeExpression)
        {
            InvokeExpression invExpr = (InvokeExpression)expr;
            if (invExpr.getLeft() == null)
            {
                // Aggregate method
                String methodName = invExpr.getOperation();
                if (methodName.equals("avg") || methodName.equals("AVG") ||
                    methodName.equals("count") || methodName.equals("COUNT") ||
                    methodName.equals("sum") || methodName.equals("SUM") ||
                    methodName.equals("min") || methodName.equals("MIN") ||
                    methodName.equals("max") || methodName.equals("MAX"))
                {
                    return true;
                }
            }

            for (int j=0;j<exprGrouping.length;j++)
            {
                if (exprGrouping[j] instanceof InvokeExpression)
                {
                    if (invExpr.toString().equalsIgnoreCase(exprGrouping[j].toString()))
                    {
                        // e.g. 'bestFried.birthDate.getMonth()' is exactly the same as an expression in grouping
                        return true;
                    }
                }
View Full Code Here

                return paramExpr;
            }
        }
        if (rootExpr instanceof InvokeExpression)
        {
            InvokeExpression invokeExpr = (InvokeExpression)rootExpr;
            List<Expression> args = invokeExpr.getArguments();
            if (args != null)
            {
                Iterator<Expression> argIter = args.iterator();
                while (argIter.hasNext())
                {
View Full Code Here

            VariableExpression varExpr = (VariableExpression)expr;
            return varExpr.getId();
        }
        else if (expr instanceof InvokeExpression)
        {
            InvokeExpression invExpr = (InvokeExpression)expr;
            StringBuffer str = new StringBuffer();
            if (invExpr.getLeft() != null)
            {
                str.append(JDOQLQueryHelper.getJDOQLForExpression(invExpr.getLeft())).append(".");
            }
            str.append(invExpr.getOperation());
            str.append("(");
            List<Expression> args = invExpr.getArguments();
            if (args != null)
            {
                Iterator<Expression> iter = args.iterator();
                while (iter.hasNext())
                {
View Full Code Here

            getParametersForQueryExpression(expr.getLeft(), params);
            getParametersForQueryExpression(expr.getRight(), params);
        }
        else if (expr instanceof InvokeExpression)
        {
            InvokeExpression invokeExpr = (InvokeExpression)expr;
            getParametersForQueryExpression(invokeExpr.getLeft(), params);
            List<org.datanucleus.query.expression.Expression> args = invokeExpr.getArguments();
            if (args != null && !args.isEmpty())
            {
                Iterator<org.datanucleus.query.expression.Expression> iter = args.iterator();
                while (iter.hasNext())
                {
View Full Code Here

    {
        PredicateImpl pred = new PredicateImpl();
        List args = new ArrayList();
        args.add(this.getQueryExpression());
        org.datanucleus.query.expression.Expression queryExpr =
            new InvokeExpression(((ExpressionImpl)collExpr).getQueryExpression(), "contains", args);
        pred.queryExpr = queryExpr;
        return pred;
    }
View Full Code Here

    }

    boolean keysOnly = true;
    for (Expression resultExpr : compilation.getExprResult()) {
      if (resultExpr instanceof InvokeExpression) {
        InvokeExpression invokeExpr = (InvokeExpression) resultExpr;
        if (invokeExpr.getOperation().toLowerCase().equals("count")) {
          // Only need key for this
        } else {
          // May need non-key for this
          keysOnly = false;
        }
View Full Code Here

      // Recurse!
      addExpression(expr.getLeft(), qd);
      addExpression(expr.getRight(), qd);
    } else if (expr instanceof InvokeExpression) {
      // InvokeExpression that return boolean
      InvokeExpression invokeExpr = ((InvokeExpression) expr);
      if (invokeExpr.getOperation().equals("contains") && invokeExpr.getArguments().size() == 1) {
        handleContainsOperation(invokeExpr, qd);
      }else if (invokeExpr.getOperation().equals("startsWith") && invokeExpr.getArguments().size() == 1) {
        handleStartsWithOperation(invokeExpr, qd);
      } else if (invokeExpr.getOperation().equals("matches")) {
        handleMatchesOperation(invokeExpr, qd);
      } else {
        throw newUnsupportedQueryMethodException(invokeExpr);
      }
    } else if (expr instanceof VariableExpression) {
View Full Code Here

    } else if (right instanceof ParameterExpression) {
      value = getParameterValue(qd.parameters, (ParameterExpression) right);
    } else if (right instanceof DyadicExpression) {
      value = getValueFromDyadicExpression(right);
    } else if (right instanceof InvokeExpression) {
      InvokeExpression invoke = (InvokeExpression) right;
      // can't support CURRENT_TIME because we don't have a Time meaning.
      // maybe we can store Time fields as int64 without the temporal meaning?
      if (invoke.getOperation().equals("CURRENT_TIMESTAMP") ||
          invoke.getOperation().equals("CURRENT_DATE")) {
        value = NOW_PROVIDER.now();
      } else {
        // We don't support any other InvokeExpressions right now but we can at least give a better error.
        throw newUnsupportedQueryMethodException((InvokeExpression) right);
      }
View Full Code Here

    ResultType resultType = null;
    if (compilation.getExprResult() != null) {
      // the only expression results we support are count() and PrimaryExpression
      for (Expression resultExpr : compilation.getExprResult()) {
        if (resultExpr instanceof InvokeExpression) {
          InvokeExpression invokeExpr = (InvokeExpression) resultExpr;
          if (!isCountOperation(invokeExpr.getOperation())) {
            Expression.Operator operator = new Expression.Operator(invokeExpr.getOperation(), 0);
            throw new UnsupportedDatastoreOperatorException(query.getSingleStringQuery(), operator);
          } else if (!projectionFields.isEmpty()) {
            throw newAggregateAndRowResultsException();
          } else {
            resultType = ResultType.COUNT;
View Full Code Here

TOP

Related Classes of org.datanucleus.query.expression.InvokeExpression

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.