@@ -62,12 +62,12 @@ private void replaceAggregateFunctionInExpression(Expression parentExpression, A
6262 } else {
6363 rootFeature = aggregateFunctionExpression .getRootFeature ();
6464 }
65- List <Feature > attributes = collectAttributes (rootFeature , aggregateFunctionExpression .getAttributeName ());
65+ List <Feature > attributes = collectAttributes (rootFeature , aggregateFunctionExpression .getAttribute (). getIdentifier ());
6666 Expression newExpression = null ;
6767 if (aggregateFunctionExpression instanceof SumAggregateFunctionExpression ) {
68- newExpression = getSum (attributes , aggregateFunctionExpression .getAttributeName ());
68+ newExpression = getSum (attributes , aggregateFunctionExpression .getAttribute (). getIdentifier ());
6969 } else if (aggregateFunctionExpression instanceof AvgAggregateFunctionExpression ) {
70- newExpression = getAvg (attributes , aggregateFunctionExpression .getAttributeName ());
70+ newExpression = getAvg (attributes , aggregateFunctionExpression .getAttribute (). getIdentifier ());
7171 }
7272 parentExpression .replaceExpressionSubPart (aggregateFunctionExpression , newExpression );
7373 }
@@ -80,44 +80,42 @@ private void replaceAggregateFunctionInExpressionConstraint(ExpressionConstraint
8080 } else {
8181 rootFeature = aggregateFunctionExpression .getRootFeature ();
8282 }
83- List <Feature > attributes = collectAttributes (rootFeature , aggregateFunctionExpression .getAttributeName ());
83+ List <Feature > attributes = collectAttributes (rootFeature , aggregateFunctionExpression .getAttribute (). getIdentifier ());
8484 Expression newExpression = null ;
8585 if (aggregateFunctionExpression instanceof SumAggregateFunctionExpression ) {
86- newExpression = getSum (attributes , aggregateFunctionExpression .getAttributeName ());
86+ newExpression = getSum (attributes , aggregateFunctionExpression .getAttribute (). getIdentifier ());
8787 } else if (aggregateFunctionExpression instanceof AvgAggregateFunctionExpression ) {
88- newExpression = getAvg (attributes , aggregateFunctionExpression .getAttributeName ());
88+ newExpression = getAvg (attributes , aggregateFunctionExpression .getAttribute (). getIdentifier ());
8989 }
9090 parentExpression .replaceExpressionSubPart (aggregateFunctionExpression , newExpression );
9191 }
9292
9393 private Expression getSum (List <Feature > relevantFeatures , String attributeName ) {
94- if (relevantFeatures .size () == 0 ) {
94+ if (relevantFeatures .isEmpty () ) {
9595 return new NumberExpression (0 );
9696 } else if (relevantFeatures .size () == 1 ) {
97- LiteralExpression literalExpression = new LiteralExpression (relevantFeatures .get (0 ), attributeName );
97+ LiteralExpression literalExpression = new LiteralExpression (relevantFeatures .get (0 ). getAttributes (). get ( attributeName ) );
9898 relevantFeatures .remove (0 );
9999
100100 return literalExpression ;
101101 } else {
102- LiteralExpression literalExpression = new LiteralExpression (relevantFeatures .get (0 ), attributeName );
102+ LiteralExpression literalExpression = new LiteralExpression (relevantFeatures .get (0 ). getAttributes (). get ( attributeName ) );
103103 relevantFeatures .remove (0 );
104104
105105 return new AddExpression (literalExpression , getSum (relevantFeatures , attributeName ));
106106 }
107107 }
108108
109109 private Expression getAvg (List <Feature > relevantFeatures , String attributeName ) {
110- if (relevantFeatures .size () == 0 ) {
110+ if (relevantFeatures .isEmpty () ) {
111111 return new NumberExpression (0 );
112112 } else {
113113 for (Feature feature : relevantFeatures ) {
114- feature .getAttributes ().put ("avg_counter__" , new Attribute <Long >("avg_counter__" , 1L ));
114+ feature .getAttributes ().put ("avg_counter__" , new Attribute <Long >("avg_counter__" , 1L , feature ));
115115 }
116116 Expression n = getSum (new LinkedList <>(relevantFeatures ), "avg_counter__" );
117117 Expression sum = getSum (relevantFeatures , attributeName );
118- Expression avg = new ParenthesisExpression (new DivExpression (new ParenthesisExpression (sum ), new ParenthesisExpression (n )));
119-
120- return avg ;
118+ return new ParenthesisExpression (new DivExpression (new ParenthesisExpression (sum ), new ParenthesisExpression (n )));
121119 }
122120 }
123121
0 commit comments