summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzhang2011-12-04 23:46:41 (EST)
committer mwu2011-12-04 23:46:41 (EST)
commit4d10f595f3e724f4129e7c0ce4fd2259ff8a6ac5 (patch)
tree996a1325ca1effd5cf687f4b5aa6e39ba9910ffa
parentc7d6e63bf4045e6bc70f3a218b3edbfd6b2b2fa3 (diff)
downloadorg.eclipse.birt-4d10f595f3e724f4129e7c0ce4fd2259ff8a6ac5.zip
org.eclipse.birt-4d10f595f3e724f4129e7c0ce4fd2259ff8a6ac5.tar.gz
org.eclipse.birt-4d10f595f3e724f4129e7c0ce4fd2259ff8a6ac5.tar.bz2
Checkin: GrandTotal value for derived measure is wrong [45760]
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/PreparedCubeQueryDefinition.java38
1 files changed, 31 insertions, 7 deletions
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/PreparedCubeQueryDefinition.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/PreparedCubeQueryDefinition.java
index a179bb8..22533ca 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/PreparedCubeQueryDefinition.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/PreparedCubeQueryDefinition.java
@@ -33,9 +33,9 @@ import org.eclipse.birt.data.engine.expression.ExpressionCompilerUtil;
import org.eclipse.birt.data.engine.i18n.ResourceConstants;
import org.eclipse.birt.data.engine.impl.document.ExprUtil;
import org.eclipse.birt.data.engine.impl.util.DirectedGraph;
+import org.eclipse.birt.data.engine.impl.util.DirectedGraph.CycleFoundException;
import org.eclipse.birt.data.engine.impl.util.DirectedGraphEdge;
import org.eclipse.birt.data.engine.impl.util.GraphNode;
-import org.eclipse.birt.data.engine.impl.util.DirectedGraph.CycleFoundException;
import org.eclipse.birt.data.engine.olap.api.query.IComputedMeasureDefinition;
import org.eclipse.birt.data.engine.olap.api.query.ICubeOperation;
import org.eclipse.birt.data.engine.olap.api.query.ICubeQueryDefinition;
@@ -246,7 +246,7 @@ public class PreparedCubeQueryDefinition implements ICubeQueryDefinition
+ ")" );
expression.setText( getReplacedExpressionText( expression.getText( ),
measureMap,
- derivedMeasureMap, createdBindings ) );
+ derivedMeasureMap, createdBindings, binding, bindingsInCubeQuery ) );
expression.setText( expression.getText( ).substring( 1,
expression.getText( ).length( ) - 1 ) );
binding.getAggregatOns( ).clear( );
@@ -256,7 +256,7 @@ public class PreparedCubeQueryDefinition implements ICubeQueryDefinition
}
private String getReplacedExpressionText( String text, Map measureMap,
- Map derivedMeasureMap, Map createdBindings ) throws DataException
+ Map derivedMeasureMap, Map createdBindings, IBinding binding, List bindingsInCubeQuery ) throws DataException
{
List measureNames = ExpressionCompilerUtil.extractColumnExpression( new ScriptExpression( text.substring( 1,
text.length( ) - 1 ) ),
@@ -265,11 +265,35 @@ public class PreparedCubeQueryDefinition implements ICubeQueryDefinition
for ( int i = 0; i < measureNames.size( ); i++ )
{
if ( measureMap.containsKey( measureNames.get( i ).toString( ) ) )
- {
+ {
+ IBinding b = (IBinding)createdBindings.get( measureNames.get( i )
+ .toString( ));
+
+ String bindingName = b.getBindingName( );
+ if ( !Arrays.deepEquals( b.getAggregatOns( ).toArray( ),
+ binding.getAggregatOns( ).toArray( ) ) )
+ {
+ IBinding newBinding = new Binding(bindingName+"_"+binding.getBindingName( ));
+ newBinding.setDataType( b.getDataType( ) );
+ newBinding.setAggrFunction( b.getAggrFunction( ) );
+ newBinding.setExpression( b.getExpression( ) );
+ newBinding.getAggregatOns( ).addAll( binding.getAggregatOns( ) );
+ IBinding sameBinding = getSameBindingInQuery( newBinding,
+ bindingsInCubeQuery );
+ if ( sameBinding != null )
+ {
+ bindingName = sameBinding.getBindingName( );
+ }
+ else
+ {
+ bindingName = newBinding.getBindingName( );
+ realBindings.add( newBinding );
+ }
+ }
+
text = text.replace( ExpressionUtil.createJSMeasureExpression( measureNames.get( i )
.toString( ) ),
- ExpressionUtil.createJSDataExpression( ( (IBinding) createdBindings.get( measureNames.get( i )
- .toString( ) ) ).getBindingName( ) ) );
+ ExpressionUtil.createJSDataExpression( bindingName ));
}
else if ( derivedMeasureMap.containsKey( measureNames.get( i )
.toString( ) ) )
@@ -281,7 +305,7 @@ public class PreparedCubeQueryDefinition implements ICubeQueryDefinition
+ ")" );
text = getReplacedExpressionText( text,
measureMap,
- derivedMeasureMap, createdBindings );
+ derivedMeasureMap, createdBindings, binding, bindingsInCubeQuery);
}
}