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

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


   {
      ORMEntity fromEntity = entityFor(fromEntityName);
      ORMEntity toEntity = entityFor(toEntityName);
      String fromInternalName = makeInternalName(fromEntity.entityPackage, fromEntity.name);
      String toInternalName = makeInternalName(toEntity.entityPackage, toEntity.name);
      MethodSignature from1Signature =
         makeMethodSignature(entityPackage,
                             fromEntity.name,
                             "get" + capitalizeFirstLetter(fromField),
                             Type.getObjectType(toInternalName));
      MethodSignature to1Signature =
         makeMethodSignature(entityPackage,
                             toEntity.name,
                             "get" + capitalizeFirstLetter(toField),
                             Type.getObjectType(fromInternalName));
View Full Code Here


   static MethodSignature makeMethodSignature(String packageName, String className, String methodName, Type returnType)
   {
      String owner = makeInternalName(packageName, className);
      String name = methodName;
      String desc = Type.getMethodDescriptor(returnType, new Type[0]);
      return new MethodSignature(owner, name, desc);
   }
View Full Code Here

      this.entityInfo = entityInfo;
   }
  
   @Override public Boolean virtualMethodCallValue(MethodCallValue.VirtualMethodCallValue val, Set<TypedValue> in) throws TypedValueVisitorException
   {
      MethodSignature sig = val.getSignature();
      if (entityInfo.dbSetMethods.contains(sig))
      {
         return true;   // The capture of the underlying dbset was probably already handled when the previous method was processed
      }
      else if (entityInfo.allEntityMethods.containsKey(sig))
View Full Code Here

      return null;
   }
  
   @Override public SQLQuery virtualMethodCallValue(MethodCallValue.VirtualMethodCallValue val, T in) throws TypedValueVisitorException
   {
      MethodSignature sig = val.getSignature();
      if (entityInfo.allEntityMethods.containsKey(sig))
      {
         String entityName = entityInfo.allEntityMethods.get(sig);
         EntityManagerBackdoor em = getAndCheckEntityManager(val.base);
         if (em == null)
View Full Code Here

            if (javaMember instanceof Field)
            {
               // We'll have to guess the getter name based on the name of the field.
               name = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
            }
            MethodSignature methodSig = new MethodSignature(
                  org.objectweb.asm.Type.getInternalName(javaMember.getDeclaringClass()),
                  name,
                  org.objectweb.asm.Type.getMethodDescriptor(org.objectweb.asm.Type.getType(fieldJavaType)));
            if (fieldJavaType.isEnum())
            {
               // Record the enum, and mark equals() using the enum as safe
               String enumTypeName = org.objectweb.asm.Type.getInternalName(fieldJavaType);
               enums.put(enumTypeName, Arrays.asList(((Class<Enum<?>>)fieldJavaType).getEnumConstants()));
               MethodSignature eqMethod = new MethodSignature(enumTypeName, "equals", "(Ljava/lang/Object;)Z");
               comparisonMethods.put(eqMethod, TypedValue.ComparisonValue.ComparisonOp.eq);
               safeMethods.add(eqMethod);
            }
            fieldMethods.put(methodSig, new MetamodelUtilAttribute(singularAttrib));
         }
         for (PluralAttribute<?,?,?> pluralAttrib: entity.getDeclaredPluralAttributes())
         {
            Member javaMember = pluralAttrib.getJavaMember();
            String name = javaMember.getName();
            if (javaMember instanceof Field)
            {
               // We'll have to guess the getter name based on the name of the field.
               name = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
            }
            MethodSignature methodSig = new MethodSignature(
                  org.objectweb.asm.Type.getInternalName(javaMember.getDeclaringClass()),
                  name,
                  org.objectweb.asm.Type.getMethodDescriptor(org.objectweb.asm.Type.getType(pluralAttrib.getJavaType())));
            nLinkMethods.put(methodSig, new MetamodelUtilAttribute(pluralAttrib));
         }
View Full Code Here

            || sig.equals(MethodChecker.streamJoin);
   }
  
   @Override public JPQLQuery<?> virtualMethodCallValue(MethodCallValue.VirtualMethodCallValue val, SymbExPassDown in) throws TypedValueVisitorException
   {
      MethodSignature sig = val.getSignature();
      if (MetamodelUtil.inQueryStream.equals(sig))
      {
         return handleInQueryStreamSource(val.base, val.args.get(0));
      }
      else if (isStreamMethod(sig))
      {
         SymbExPassDown passdown = SymbExPassDown.with(val, false);
        
         // Check out what stream we're aggregating
         JPQLQuery<?> subQuery = val.base.visit(this, passdown);
        
         // 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
View Full Code Here

   {
      // Figure out if it's an 1:N or N:M navigational link
      if (unknownVal instanceof MethodCallValue.VirtualMethodCallValue)
      {
         MethodCallValue.VirtualMethodCallValue val = (MethodCallValue.VirtualMethodCallValue)unknownVal;
         MethodSignature sig = val.getSignature();
         if ((expectingPluralLink && config.metamodel.isPluralAttributeLinkMethod(sig))
               || (!expectingPluralLink && config.metamodel.isSingularAttributeFieldMethod(sig) && config.metamodel.isFieldMethodAssociationType(sig)))
         {
            String linkName = expectingPluralLink ?
                  config.metamodel.nLinkMethodToLinkName(sig) : config.metamodel.fieldMethodToFieldName(sig);
View Full Code Here

      return null;
   }
  
   @Override public JPQLQuery<?> staticMethodCallValue(MethodCallValue.StaticMethodCallValue val, SymbExPassDown in) throws TypedValueVisitorException
   {
      MethodSignature sig = val.getSignature();
      if (sig.equals(TransformationClassAnalyzer.streamFrom))
      {
         JPQLQuery<?> nLink = handlePossibleNavigationalLink(val.args.get(0), true, in);
         if (nLink != null) return nLink;
      }
      else if (sig.equals(TransformationClassAnalyzer.streamOf))
      {
         JPQLQuery<?> nLink = handlePossibleNavigationalLink(val.args.get(0), false, in);
         if (nLink != null) return nLink;
      }
      return super.staticMethodCallValue(val, in);
View Full Code Here

            return true;
      }
      else if (val instanceof MethodCallValue.VirtualMethodCallValue)
      {
         MethodCallValue methodCall = (MethodCallValue.VirtualMethodCallValue)val;
         MethodSignature sig = methodCall.getSignature();
         if (sig.equals(TransformationClassAnalyzer.newBigDecimalLong)
               || sig.equals(TransformationClassAnalyzer.newBigDecimalInt)
               || sig.equals(TransformationClassAnalyzer.newBigDecimalBigInteger))
         {
            return true;
         }
         else if (sig.equals(TransformationClassAnalyzer.bigDecimalDoubleValue)
               || sig.equals(TransformationClassAnalyzer.bigIntegerDoubleValue))
         {
            return true;
         }

      }
      else if (val instanceof MethodCallValue.StaticMethodCallValue)
      {
         MethodCallValue methodCall = (MethodCallValue.StaticMethodCallValue)val;
         MethodSignature sig = methodCall.getSignature();
         if (sig.equals(TransformationClassAnalyzer.bigIntegerValueOfLong))
         {
            return true;
         }
      }
      return false;
View Full Code Here

         return skipWideningCast(castedVal.operand);
      }
      else if (val instanceof MethodCallValue.VirtualMethodCallValue)
      {
         MethodCallValue.VirtualMethodCallValue methodCall = (MethodCallValue.VirtualMethodCallValue)val;
         MethodSignature sig = methodCall.getSignature();
         if (sig.equals(TransformationClassAnalyzer.newBigDecimalLong)
               || sig.equals(TransformationClassAnalyzer.newBigDecimalInt)
               || sig.equals(TransformationClassAnalyzer.newBigDecimalBigInteger))
         {
            return skipWideningCast(methodCall.args.get(0));
         }
         else if (sig.equals(TransformationClassAnalyzer.bigDecimalDoubleValue)
               || sig.equals(TransformationClassAnalyzer.bigIntegerDoubleValue))
         {
            return skipWideningCast(methodCall.base);
         }
      }
      else if (val instanceof MethodCallValue.StaticMethodCallValue)
      {
         MethodCallValue methodCall = (MethodCallValue.StaticMethodCallValue)val;
         MethodSignature sig = methodCall.getSignature();
         if (sig.equals(TransformationClassAnalyzer.bigIntegerValueOfLong))
         {
            return skipWideningCast(methodCall.args.get(0));
         }
      }
      throw new IllegalArgumentException("Cannot skip an unknown widening cast type");
View Full Code Here

TOP

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

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.