Examples of Evaluator


Examples of org.teiid.query.eval.Evaluator

              }
         
          List filteredTuples = new ArrayList();
          for(int i=0; i<tuples.length; i++) {
                  try {
              if(new Evaluator(lookupMap, null, null).evaluate(query.getCriteria(), tuples[i])) {
                          filteredTuples.add(tuples[i]);
                      }
                  } catch(ExpressionEvaluationException e) {
                      throw new TeiidComponentException(e, e.getMessage());
                  }
          }
         
          tuples = new List[filteredTuples.size()];
          filteredTuples.toArray(tuples);
      }
    } else if ( command instanceof Insert || command instanceof Update || command instanceof Delete) {
      // add single update command to a list to be executed
      updateCommands.add(command);
    } else if ( command instanceof BatchedUpdateCommand ) {
      // add all update commands to a list to be executed
        updateCommands.addAll(((BatchedUpdateCommand) command).getUpdateCommands());
    }
   
    // if we had update commands added to the list, execute them now
    if ( updateCommands.size() > 0 ) {
        List<List<Integer>> filteredTuples = new ArrayList<List<Integer>>();
      for ( int c = 0; c < updateCommands.size(); c++ ) {
        Command cmd = updateCommands.get(c);
        if (cmd instanceof TranslatableProcedureContainer) {
          TranslatableProcedureContainer update = (TranslatableProcedureContainer)cmd;
          if ( update.getCriteria() != null ) {
              // Build lookupMap from BOTH all the elements and the projected symbols - both may be needed here
                  Map<Object, Integer> lookupMap = new HashMap<Object, Integer>();
                  for(int i=0; i<elements.size(); i++) {
                      Object element = elements.get(i);
                        mapElementToIndex(lookupMap, element, new Integer(i), group);       
                  }
                  for(int i=0; i<projectedSymbols.size(); i++) {
                    Object element = projectedSymbols.get(i);
                        mapElementToIndex(lookupMap, element, new Integer(columnMap[i]), group);
                  }
             
              int updated = 0;
              for(int i=0; i<tuples.length; i++) {
                      try {
                  if(new Evaluator(lookupMap, null, null).evaluate(update.getCriteria(), tuples[i])) {
                              updated++;
                          }
                      } catch(ExpressionEvaluationException e) {
                          throw new TeiidComponentException(e, e.getMessage());
                      }
View Full Code Here

Examples of org.yaac.server.egql.evaluator.Evaluator

  @Override
  public PropertyInfo parsePropertyExp(String keyString, String exp, List<String> filePaths) throws YaacException {
    try {
      // property can also be used during evaluation
      Evaluator e = EGQLUtil.parser(exp).bool_exp().e;
      if (!e.aggregationChildren().isEmpty()) { 
        // aggregation function is not allowed here
        throw new YaacException(ErrorCode.E301, null);
      }
     
      // load targeting entity
      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
      final Entity entity = datastore.get(KeyFactory.stringToKey(keyString));
     
      // file context
      final List<FileDownloadPath> files = filePaths == null ? new ArrayList<FileDownloadPath>() :
        transform(filePaths, new Function<String, FileDownloadPath>(){
        @Override
        public FileDownloadPath apply(String pathStr) {
          return AutoBeanUtil.decode(FileDownloadPath.class, pathStr);
        }
      });
     
      EvaluationResult r = e.evaluate(new ProcessDataRecord() {
        @Override
        public FileDownloadPath lookupFileReference(Integer index) {
          return files.get(index);
        }
       
        @Override
        public EvaluationResult lookup(String name) {
          if (isNullOrEmpty(name)) {
            return null;
          } else // normal case, include key selection and property selection
            Object payload = Datastore.KEY_RESERVED_NAME.equals(name) ? entity.getKey() : entity.getProperty(name);
            return new EvaluationResult(entity.getKey(), name, null, payload)
          }
        }
       
        @Override
        public Iterable<EvaluationResult> asIterable() {
          // should not be called
          throw new IllegalArgumentException();
        }
      });
     
      PropertyInfo info = DatastoreUtil.convert(keyString, null, null, r.getPayload(), r.getWarnings());
      return info;
    } catch (RecognitionException e) {
      // can't parse input
      logger.log(Level.SEVERE, e.getMessage(), e);
      throw new YaacException(null, e.getMessage());
    } catch (EntityNotFoundException e) {
      logger.log(Level.SEVERE, e.getMessage(), e);
      throw new YaacException(ErrorCode.E302, null);
    }
  }
View Full Code Here

Examples of org.zkoss.zk.xel.Evaluator

      if (expectedType == Object.class || expectedType == String.class)
        return expr;
      return Classes.coerce(expectedType, expr);
    }

    final Evaluator eval = getEvaluator(page, null);
    final Expression expression = eval.parseExpression(expr, expectedType);
    return self instanceof Page ?
      eval.evaluate((Page)self, expression):
      eval.evaluate((Component)self, expression);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.