Package org.yaac.server.egql.evaluator

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


    super();
    this.conditions = conditions;
  }

  public Boolean evaluate(ProcessDataRecord record) {
    EvaluationResult result = conditions.evaluate(record);
    return (Boolean) result.getPayload();
  }
View Full Code Here


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

        }
      }
    };
   
    for (String propertyName : input.keySet()) {
      EvaluationResult r = input.get(propertyName);
      if (r.getPayload() instanceof EvaluationResult []) {  // expand *
        for (EvaluationResult elem : (EvaluationResult [])r.getPayload()) {
          result.put(duplicateResolver.apply(elem.propertyTitle()), elem)
        }
      } else { // simply copy to new result
        result.put(duplicateResolver.apply(propertyName), r);
      }
View Full Code Here

    super();
    this.conditions = conditions;
  }
 
  public boolean evaluate(ProcessDataRecord record) {
    EvaluationResult result = conditions.evaluate(record);
   
    if (result.getPayload() instanceof Boolean) {
      return (Boolean)result.getPayload()
    } else {
      // it is possible that because of some error the evaluation result is not boolean
      return false;
    }
  }
View Full Code Here

        parser("(2 + 3) * 4").expression().e);
  }
 
  @Test
  public void testEvaluationResult() throws Exception {   
    Assert.assertEquals(new EvaluationResult(new BigDecimal("4")),
        evaluate("1 + 3"));
    Assert.assertEquals(new EvaluationResult(new BigDecimal("14")),
        evaluate("1 * 2 + 3 * 4"));
    Assert.assertEquals(new EvaluationResult(new BigDecimal("20")),
        evaluate("1 * (2 + 3) * 4"));
    Assert.assertEquals(new EvaluationResult(new BigDecimal("4.1")),
        evaluate("1.5 + 2.6"));
  }
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

  }
 
  @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.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.