Testing out concept - aggregation formula on fetch clause

This commit is contained in:
rob bygrave committed 2019-01-22 15:56:20 +13:00
1 parent 9dbd903a73
commit 141f0a8b16
7 files changed
+39 -14

No files matched your search

@@ -2586,9 +2586,10 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return a 'dynamic property' used to read a formula.
*/
private STreeProperty findSqlTreeFormula(String formulaExpression) {
private STreeProperty findSqlTreeFormula(String formula, String path) {
return dynamicProperty.computeIfAbsent(formulaExpression, (formula) -> new FormulaPropertyPath(this, formula).build());
String key = formula + "-" + path;
return dynamicProperty.computeIfAbsent(key, (fullKey) -> new FormulaPropertyPath(this, formula, path).build());
}
/**
@@ -2597,9 +2598,9 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* The property can be a dynamic formula or a well known bean property.
*/
@Override
public STreeProperty findPropertyWithDynamic(String propName) {
public STreeProperty findPropertyWithDynamic(String propName, String path) {
if (propName.indexOf('(') > -1) {
return findSqlTreeFormula(propName);
return findSqlTreeFormula(propName, path);
}
return _findBeanProperty(propName);
}
@@ -20,15 +20,17 @@ class FormulaPropertyPath {
private final String internalExpression;
private final String path;
private boolean countDistinct;
private String cast;
private String alias;
FormulaPropertyPath(BeanDescriptor<?> descriptor, String formula) {
FormulaPropertyPath(BeanDescriptor<?> descriptor, String formula, String path) {
this.descriptor = descriptor;
this.formula = formula;
this.path = path;
int openBracket = formula.indexOf('(');
int closeBracket = formula.lastIndexOf(')');
@@ -94,6 +96,11 @@ class FormulaPropertyPath {
DeployPropertyParser parser = descriptor.parser().setCatchFirst(true);
String parsed = parser.parse(internalExpression);
if (path != null) {
// fetch("machineStats", "sum(hours), sum(totalKms)")
parsed = parsed.replace("${}", "${" + path + "}");
}
ElPropertyDeploy firstProp = parser.getFirstProp();
ScalarType<?> scalarType;