Package org.yaac.server.egql.processor.ProcessData

Examples of org.yaac.server.egql.processor.ProcessData.ProcessDataRecord


    DatastoreServiceFactory.getAsyncDatastoreService().put(entities);
   
    this.insertCount += entities.size();
   
    if (context.getStatus() == ResultStatus.FINISHED) {  // append result on finish
      return new ProcessData().addRecord(new ProcessDataRecord() {
        @Override
        public FileDownloadPath lookupFileReference(Integer index) {
          // should not be called
          throw new IllegalArgumentException();
        }
View Full Code Here


    QueryResultList<Entity> entities = datastore.prepare(new Query(kind)).asQueryResultList(fetchOptions);
    this.startCursor = entities.getCursor().toWebSafeString()// update context
   
    ProcessData output = new ProcessData();
    for (final Entity entity : entities) {
      output.addRecord(new ProcessDataRecord() {
       
        @Override
        public EvaluationResult lookup(String name) {
          if (isNullOrEmpty(name)) {
            return null;
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);
        }
       
View Full Code Here

       
        for (Evaluator e : selectItems) {
          resultRow.put(e.getText(), e.evaluate(record));
        }
       
        output.addRecord(new ProcessDataRecord() {
          Map<String, EvaluationResult> expandedRow = expandSelectAllAndResolveDuplicateName(resultRow);
         
          @Override
          public EvaluationResult lookup(String name) {
            return expandedRow.get(name);
          }
         
          @Override
          public Iterable<EvaluationResult> asIterable() {
            return expandedRow.values();
          }

          @Override
          public FileDownloadPath lookupFileReference(Integer index) {
            throw new IllegalArgumentException();
          }
        });
      }
    }
   
    // last batch finished, append group by clause
    if (context.getStatus() == ResultStatus.FINISHED) {
      // if a statement is finished, then append all group by results
      for (final Map<String, Object> rowKey : this.groupByRecords) {
       
        ProcessDataRecord record = new ProcessDataRecord() {         
          @Override
          public EvaluationResult lookup(String name) {
            // must resolve aggregators first, because count(1) is a valid property name in appengine
            Map<AggregationEvaluator, Aggregator> aggMap = groupByTable.row(rowKey);
            for (AggregationEvaluator e : aggMap.keySet()) {
              if (e.getText().equals(name)) {
                Aggregator agg = aggMap.get(e);
               
                if (agg == null) {
                  // for aggregation ONLY query
                  //  when there is no record, the empty group by function is still trying to resolve aggregator
                  return new EvaluationResult(null).withTitle(e.getText())
                } else {
                  return new EvaluationResult(agg.getResult()).withTitle(e.getText());
                }
              }
            }
           
            // fallback with other evaluators
            return new EvaluationResult(rowKey.get(name)).withTitle(name);
          }
         
          @Override
          public Iterable<EvaluationResult> asIterable() {
            return transform(rowKey.keySet(), new Function<String, EvaluationResult>(){
              @Override
              public EvaluationResult apply(String name) {
                return new EvaluationResult(rowKey.get(name)).withTitle(name);
              }
            });
          }

          @Override
          public FileDownloadPath lookupFileReference(Integer index) {
            throw new IllegalArgumentException();
          }
        };
       
        // process having clause
        if (stmt.rejectedByHavingClause(record)) {
          continue;
        }
       
        final Map<String, EvaluationResult> resultRow = newLinkedHashMap();
       
        for (Evaluator e : selectItems) {
          resultRow.put(e.getText(), e.evaluate(record));
        }
       
        output.addRecord(new ProcessDataRecord() {
          Map<String, EvaluationResult> expandedRow = expandSelectAllAndResolveDuplicateName(resultRow);
         
          @Override
          public EvaluationResult lookup(String name) {
            return expandedRow.get(name);
View Full Code Here

*/
public class EvaluationWithContextTest {

  @Test
  public void test1() throws Exception {   
    ProcessDataRecord record = mock(ProcessDataRecord.class);
    when(record.lookup("a")).thenReturn(new EvaluationResult(null, null, null, new BigDecimal("1.5")));
   
    assertEquals(new EvaluationResult(new BigDecimal("5.5")), evaluate("4 + a", record));
  }
View Full Code Here

    assertEquals(new EvaluationResult(new BigDecimal("5.5")), evaluate("4 + a", record));
  }
 
  @Test
  public void test2() throws Exception {   
    ProcessDataRecord record = mock(ProcessDataRecord.class);
    when(record.lookup("a")).thenReturn(new EvaluationResult(null, null, null, new BigDecimal("1.5")));
    when(record.lookup("b")).thenReturn(new EvaluationResult(null, null, null, new BigDecimal("4.5")));
   
    assertEquals(new BigDecimal("3"), evaluate("b / a", record).getPayload());
  }
View Full Code Here

TOP

Related Classes of org.yaac.server.egql.processor.ProcessData.ProcessDataRecord

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.