Package ch.epfl.labos.iu.orm.queryll2.path

Examples of ch.epfl.labos.iu.orm.queryll2.path.CFG


   protected JPQLQuery<?> handleLambdaSubQueryArg(int argIndex, Type argType)
         throws TypedValueVisitorException
   {
      if (argIndex == 1)
         return stream;
      throw new TypedValueVisitorException("Lambda trying to access unknown lambda parameter");
   }
View Full Code Here


      this.argHandler = argumentHandler;
   }
  
   @Override public JPQLQuery<?> defaultValue(TypedValue val, SymbExPassDown in) throws TypedValueVisitorException
   {
      throw new TypedValueVisitorException("Unhandled symbolic execution operation: " + val);
   }
View Full Code Here

         // Extract the lambda used
         LambdaAnalysis lambda = null;
         if (val.args.size() > 0)
         {
            if (!(val.args.get(0) instanceof LambdaFactory))
               throw new TypedValueVisitorException("Expecting a lambda factory for aggregate method");
            LambdaFactory lambdaFactory = (LambdaFactory)val.args.get(0);
            try {
               lambda = LambdaAnalysis.analyzeMethod(config.metamodel, config.alternateClassLoader, config.isObjectEqualsSafe,
                     lambdaFactory.getLambdaMethod(), lambdaFactory.getCapturedArgs(), true);
            } catch (Exception e)
            {
               throw new TypedValueVisitorException("Could not analyze the lambda code", e);
            }
         }

         try {
            JPQLQuery<?> transformedQuery;
            if (sig.equals(MethodChecker.streamDistinct))
            {
               DistinctTransform transform = new DistinctTransform(config);
               transformedQuery = transform.apply(subQuery, argHandler);
            }
            else if (sig.equals(MethodChecker.streamSelect))
            {
               SelectTransform transform = new SelectTransform(config, false);
               transformedQuery = transform.apply(subQuery, lambda, argHandler);
            }
            else if (sig.equals(MethodChecker.streamWhere))
            {
               WhereTransform transform = new WhereTransform(config, false);
               transformedQuery = transform.apply(subQuery, lambda, argHandler);
            }
            else if (sig.equals(MethodChecker.streamJoin))
            {
               JoinTransform transform = new JoinTransform(config, false);
               transformedQuery = transform.apply(subQuery, lambda, argHandler);
            }
            else
               throw new TypedValueVisitorException("Unknown stream operation: " + sig);

            return transformedQuery;
         }
         catch (QueryTransformException e)
         {
            throw new TypedValueVisitorException("Subquery could not be transformed.", e);
         }
//         // Return the aggregated columns that we've now calculated
//         if (transformedQuery.getClass() == SelectOnly.class)
//         {
//            SelectOnly<?> select = (SelectOnly<?>)transformedQuery;
View Full Code Here

   protected JPQLQuery<?> handleInQueryStreamSource(
         TypedValue methodBase, TypedValue entity)
         throws TypedValueVisitorException
   {
      if (!(methodBase instanceof TypedValue.ArgValue))
         throw new TypedValueVisitorException("InQueryStreamSource comes from unknown source");
      int index = ((TypedValue.ArgValue)methodBase).getIndex();
      if (!argHandler.checkIsInQueryStreamSource(index))
         throw new TypedValueVisitorException("InQueryStreamSource comes from unknown source");
      if (!(entity instanceof ConstantValue.ClassConstant))
         throw new TypedValueVisitorException("Streaming an unknown type");
      Type type = ((ConstantValue.ClassConstant)entity).val;
      String entityName = config.metamodel.entityNameFromClassName(type.getClassName());
      if (entityName == null)
         throw new TypedValueVisitorException("Streaming an unknown type");
      return JPQLQuery.findAllEntities(entityName);
   }
View Full Code Here

   protected JPQLQuery<?> handleLambdaSubQueryArg(int argIndex, Type argType)
         throws TypedValueVisitorException
   {
      if (argIndex == 0)
         return select;
      throw new TypedValueVisitorException("Lambda trying to access unknown lambda parameter");
   }
View Full Code Here

      this.argHandler = argumentHandler;
   }
  
   @Override public ColumnExpressions<?> defaultValue(TypedValue val, SymbExPassDown in) throws TypedValueVisitorException
   {
      throw new TypedValueVisitorException("Unhandled symbolic execution operation: " + val);
   }
View Full Code Here

            new ConstantExpression("'"+ val.val.replaceAll("'", "''") +"'"));
   }
  
   @Override public ColumnExpressions<?> nullConstantValue(NullConstant val, SymbExPassDown in) throws TypedValueVisitorException
   {
      throw new TypedValueVisitorException("Unexpected NULL value");
   }
View Full Code Here

   {
      // We need to handle casts between primitive types carefully
      // because JPQL doesn't really support them directly
      if (val.isPrimitive())
      {
         throw new TypedValueVisitorException("Casts of primitive values are not support in JPQL");
      }
      // TODO: Check if cast is consistent with the reader
//      SQLColumnValues toReturn = val.operand.visit(this, in);
//      if (!toReturn.reader.isCastConsistent(val.getType().getInternalName()))
//         throw new TypedValueVisitorException("Attempting to cast to an inconsistent type");
View Full Code Here

   }

   private <U> ColumnExpressions<U> binaryOpWithNull(String opString, TypedValue leftVal, TypedValue rightVal, SymbExPassDown passdown) throws TypedValueVisitorException
   {
      if (!("=".equals(opString) || "<>".equals(opString)))
         throw new TypedValueVisitorException("Unhandled operation involving NULL");
      if (leftVal instanceof ConstantValue.NullConstant && rightVal instanceof ConstantValue.NullConstant)
         throw new TypedValueVisitorException("Cannot handle comparisons involving two NULLs");
      TypedValue operandVal;
      if (leftVal instanceof ConstantValue.NullConstant)
         operandVal = rightVal;
      else
         operandVal = leftVal;
View Full Code Here

   }
  
   @Override public ColumnExpressions<?> mathOpValue(TypedValue.MathOpValue val, SymbExPassDown in) throws TypedValueVisitorException
   {
      if (val.op == TypedValue.MathOpValue.Op.cmp)
         throw new TypedValueVisitorException("cmp operator was not converted to a boolean operator");
      if (val.op == TypedValue.MathOpValue.Op.mod)
      {
         if (val.left.getType().equals(Type.INT_TYPE) || val.right.getType().equals(Type.INT_TYPE))
         {
            SymbExPassDown passdown = SymbExPassDown.with(val, false);
            ColumnExpressions<?> left = (ColumnExpressions<?>)val.left.visit(this, passdown);
            ColumnExpressions<?> right = (ColumnExpressions<?>)val.right.visit(this, passdown);
            return ColumnExpressions.singleColumn(left.reader,
                  FunctionExpression.twoParam("MOD", left.getOnlyColumn(), right.getOnlyColumn()));
         }
         throw new TypedValueVisitorException("mod operator cannot be used for the given types.");
      }
      SymbExPassDown passdown = SymbExPassDown.with(val, false);
      return binaryOpWithNumericPromotion(val.sqlOpString(), val.left, val.right, passdown);
   }
View Full Code Here

TOP

Related Classes of ch.epfl.labos.iu.orm.queryll2.path.CFG

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.