Package org.yaac.server.egql.evaluator

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


    FunctionUtil.ensureParamSize(ops, 1);
  }

  @Override
  public EvaluationResult evaluate(ProcessDataRecord record) {
    EvaluationResult r = ops.get(0).evaluate(record);
   
    if (r.getPayload() instanceof String) {
      Link val = new Link((String) r.getPayload());
      return new EvaluationResult(val, r)
    } else {
      return r.withWarning(ErrorCode.W135);
    }
  }
View Full Code Here


  public EvaluationResult evaluate(ProcessDataRecord record) {
    List<Object> payloadList = newLinkedList();
    List<EvaluationResult> resultList = newLinkedList();
   
    for (Evaluator e : this.ops) {
      EvaluationResult r = e.evaluate(record);
     
      resultList.add(r);
      payloadList.add(r.getPayload());
    }
   
    return new EvaluationResult(payloadList, resultList);
  }
View Full Code Here

    FunctionUtil.ensureParamSize(ops, 1);
  }

  @Override
  public EvaluationResult evaluate(ProcessDataRecord record) {
    EvaluationResult r = ops.get(0).evaluate(record);
   
    if (r.getPayload() instanceof Number) {
      Number val = (Number) r.getPayload();
      return new EvaluationResult(val.longValue(), r)
    } else {
      return r.withWarning(ErrorCode.W138);
    }
  }
View Full Code Here

    FunctionUtil.ensureParamSize(ops, 1);
  }

  @Override
  public EvaluationResult evaluate(ProcessDataRecord record) {
    EvaluationResult r = ops.get(0).evaluate(record);
   
    if (r.getPayload() instanceof String) {
      BlobKey val = new BlobKey((String) r.getPayload());
      return new EvaluationResult(val, r)
    } else {
      return r.withWarning(ErrorCode.W140);
    }
  }
View Full Code Here

    FunctionUtil.ensureParamSize(ops, 2);
  }

  @Override
  public EvaluationResult evaluate(ProcessDataRecord record) {
    EvaluationResult r0 = ops.get(0).evaluate(record);
    EvaluationResult r1 = ops.get(1).evaluate(record);
   
    if (r0.getPayload() instanceof String && r1.getPayload() instanceof String) {
      try {
        Scheme scheme = Scheme.valueOf((String) r0.getPayload());
        IMHandle val = new IMHandle(scheme, (String)r1.getPayload());
        return new EvaluationResult(val, r0, r1);
      } catch (IllegalArgumentException e) {
        // input protocol does not match enum Scheme
        return r0.withWarning(ErrorCode.W142);
      }
    } else {
View Full Code Here

    FunctionUtil.ensureParamSize(ops, 1);
  }
 
  @Override
  public EvaluationResult evaluate(ProcessDataRecord record) {
    EvaluationResult r = ops.get(0).evaluate(record);
   
    if (r.getPayload() instanceof String) {
      PostalAddress val = new PostalAddress((String) r.getPayload());
      return new EvaluationResult(val, r)
    } else {
      return r.withWarning(ErrorCode.W130);
    }
  }
View Full Code Here

        }
       
        @Override
        public Iterable<EvaluationResult> asIterable() {
          return newArrayList(
              new EvaluationResult("Total number of records inserted : " + insertCount).withTitle("Info"));
        }
      });
    } else // simply return dummy data
      return new ProcessData();
    }
View Full Code Here

              resultList.add(lookup(propertyName));
            }
           
            EvaluationResult [] resultArray = new EvaluationResult[resultList.size()];
            resultList.toArray(resultArray);
            return new EvaluationResult(resultArray).withTitle(name);
          } 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() {
          List<EvaluationResult> result = newArrayListWithExpectedSize(entity.getProperties().size() + 1);
         
          result.add(new EvaluationResult(entity.getKey(), SharedConstants.Datastore.KEY_RESERVED_NAME,
              null, entity.getKey()));
         
          for (String propertyName : entity.getProperties().keySet()) {
            result.add(new EvaluationResult(entity.getKey(), propertyName, null, entity.getProperty(propertyName)));
          }
         
          return result;
        }
View Full Code Here

    }
   
    try {
      Key key = null;
      try {
        EvaluationResult r = EGQLUtil.parser(keyString).bool_exp().e.evaluate((ProcessDataRecord)null);
        key = (Key) r.getPayload();
      } catch (Exception e) {
        logger.info("failed to load key in formatted version, fallback to parse as keyString");
        // any exception, fallback
        key = KeyFactory.stringToKey(keyString);
      }
View Full Code Here

        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());
View Full Code Here

TOP

Related Classes of org.yaac.server.egql.evaluator.EvaluationResult

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.