summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzhang2012-06-11 05:15:19 (EDT)
committer mwu2012-06-11 05:15:19 (EDT)
commit224390430d775ebd193377b70618b12e866f77b9 (patch)
tree8b656f69981c4cdea3256a0944975f431e4f4f23
parenta3b298f956ec79dc5425f7ac535651b47daf50d5 (diff)
downloadorg.eclipse.birt-224390430d775ebd193377b70618b12e866f77b9.zip
org.eclipse.birt-224390430d775ebd193377b70618b12e866f77b9.tar.gz
org.eclipse.birt-224390430d775ebd193377b70618b12e866f77b9.tar.bz2
Exception is thrown out when preview a crosstab with a filter on derived
measure and the filter is not recalculating totals. [49125]
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryExecutor.java23
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java70
2 files changed, 93 insertions, 0 deletions
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryExecutor.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryExecutor.java
index 8c0fd60..58f0cc9 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryExecutor.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryExecutor.java
@@ -430,6 +430,29 @@ public class CubeQueryExecutor
{
return CubeQueryExecutor.DIMENSION_FILTER;
}
+
+ if ( !filter.updateAggregation( ) )
+ {
+ List derivedBindingNameList = new ArrayList( );
+ for ( int i = 0; i < bindingName.size( ); i++ )
+ {
+ IBinding binding = getBinding( bindingName.get( i )
+ .toString( ), this.defn.getBindings( ) );
+ if ( binding != null )
+ {
+ List temp = ExpressionCompilerUtil.extractColumnExpression( binding.getExpression( ),
+ ScriptConstants.DATA_BINDING_SCRIPTABLE );
+ if ( temp != null && temp.size( ) > 0 )
+ derivedBindingNameList.addAll( temp );
+ }
+ }
+ if ( derivedBindingNameList.size( ) > 0 )
+ {
+ if ( existAggregationBinding( derivedBindingNameList,
+ this.defn.getBindings( ) ) )
+ return CubeQueryExecutor.AGGR_MEASURE_FILTER;
+ }
+ }
return CubeQueryExecutor.FACTTABLE_FILTER;
}
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java
index b560c6a..21a3cce 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/query/view/QueryExecutor.java
@@ -32,9 +32,12 @@ import org.eclipse.birt.data.engine.api.IBinding;
import org.eclipse.birt.data.engine.api.ICollectionConditionalExpression;
import org.eclipse.birt.data.engine.api.IFilterDefinition;
import org.eclipse.birt.data.engine.api.IScriptExpression;
+import org.eclipse.birt.data.engine.api.querydefn.ConditionalExpression;
+import org.eclipse.birt.data.engine.api.querydefn.ScriptExpression;
import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.birt.data.engine.core.security.FileSecurity;
import org.eclipse.birt.data.engine.executor.cache.CacheUtil;
+import org.eclipse.birt.data.engine.expression.ExpressionCompilerUtil;
import org.eclipse.birt.data.engine.i18n.ResourceConstants;
import org.eclipse.birt.data.engine.impl.StopSign;
import org.eclipse.birt.data.engine.impl.document.stream.VersionManager;
@@ -285,6 +288,72 @@ public class QueryExecutor
return new CubeResultSet( rs, view, cubeQueryExecutorHelper );
}
+ private IBinding getBinding( String bindingName, List bindings ) throws DataException
+ {
+ for( int j = 0; j < bindings.size( ); j++ )
+ {
+ IBinding binding = (IBinding) bindings.get( j );
+ if( bindingName.equals( binding.getBindingName( ) ) )
+ {
+ return binding;
+ }
+ }
+ return null;
+ }
+
+ private void replaceFilterTextOnCalculateMeasures( IFilterDefinition filter, List bindings ) throws DataException
+ {
+ if( filter.getExpression( ) instanceof ConditionalExpression )
+ {
+ ConditionalExpression filterExpr = (ConditionalExpression) filter.getExpression( );
+ List referenceBindingName = ExpressionCompilerUtil.extractColumnExpression( filterExpr.getExpression( ),
+ ScriptConstants.DATA_BINDING_SCRIPTABLE );
+ if ( referenceBindingName.size( ) > 0 )
+ {
+ for ( int i = 0; i < referenceBindingName.size( ); i++ )
+ {
+ IBinding binding = getBinding( referenceBindingName.get( i )
+ .toString( ), bindings );
+ if ( binding != null )
+ {
+ ( (ScriptExpression) filterExpr.getExpression( ) ).setText( ( (ScriptExpression) binding.getExpression( ) ).getText( ) );
+ }
+ }
+
+ }
+
+ referenceBindingName = ExpressionCompilerUtil.extractColumnExpression( filterExpr.getOperand1( ),
+ ScriptConstants.DATA_BINDING_SCRIPTABLE );
+ if ( referenceBindingName.size( ) > 0 )
+ {
+ for ( int i = 0; i < referenceBindingName.size( ); i++ )
+ {
+ IBinding binding = getBinding( referenceBindingName.get( i )
+ .toString( ), bindings );
+ if ( binding != null )
+ {
+ ( (ScriptExpression) filterExpr.getOperand1( ) ).setText( ( (ScriptExpression) binding.getExpression( ) ).getText( ) );
+ }
+ }
+ }
+
+ referenceBindingName = ExpressionCompilerUtil.extractColumnExpression( filterExpr.getOperand2( ),
+ ScriptConstants.DATA_BINDING_SCRIPTABLE );
+ if ( referenceBindingName.size( ) > 0 )
+ {
+ for ( int i = 0; i < referenceBindingName.size( ); i++ )
+ {
+ IBinding binding = getBinding( referenceBindingName.get( i )
+ .toString( ), bindings );
+ if ( binding != null )
+ {
+ ( (ScriptExpression) filterExpr.getOperand2( ) ).setText( ( (ScriptExpression) binding.getExpression( ) ).getText( ) );
+ }
+ }
+ }
+ }
+ }
+
private IAggregationResultSet[] applyNoAggrUpdateFilters ( List finalFilters, CubeQueryExecutor executor , IAggregationResultSet[] rs , ICube cube, IBindingValueFetcher fetcher,boolean fromCubeOperation ) throws DataException, IOException
{
if( !finalFilters.isEmpty( ) )
@@ -335,6 +404,7 @@ public class QueryExecutor
}
else if ( type == executor.AGGR_MEASURE_FILTER )
{
+ replaceFilterTextOnCalculateMeasures ( filter, executor.getCubeQueryDefinition( ).getBindings( ) );
aggrEvalList.add( new AggrMeasureFilterEvalHelper( executor.getOuterResults( ),
executor.getScope( ),
executor.getCubeQueryDefinition( ),