summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzhang2011-12-04 22:13:15 (EST)
committer mwu2011-12-04 22:13:15 (EST)
commit404d3a5dd71d1f1be84832c4790e32bc71b99c57 (patch)
treed0ec687ef9b825abd3d3e6462d7e93ba2eb0e3bc
parent6dca5082ffaca91c1afdf63ae8e0b30884f14116 (diff)
downloadorg.eclipse.birt-404d3a5dd71d1f1be84832c4790e32bc71b99c57.zip
org.eclipse.birt-404d3a5dd71d1f1be84832c4790e32bc71b99c57.tar.gz
org.eclipse.birt-404d3a5dd71d1f1be84832c4790e32bc71b99c57.tar.bz2
Checkin: Invalid sort when preview crosstab containing sort on derived
measure[45765]; Fail to preview crosstab containing derived measure only [45762]
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/DataRequestSessionImpl.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/DataRequestSessionImpl.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/DataRequestSessionImpl.java
index 4b4e014..56ecd71 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/DataRequestSessionImpl.java
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/DataRequestSessionImpl.java
@@ -66,11 +66,13 @@ import org.eclipse.birt.data.engine.api.querydefn.GroupDefinition;
import org.eclipse.birt.data.engine.api.querydefn.QueryDefinition;
import org.eclipse.birt.data.engine.api.querydefn.ScriptExpression;
import org.eclipse.birt.data.engine.core.DataException;
+import org.eclipse.birt.data.engine.expression.ExpressionCompilerUtil;
import org.eclipse.birt.data.engine.impl.CubeCreationQueryDefinition;
import org.eclipse.birt.data.engine.impl.DataEngineImpl;
import org.eclipse.birt.data.engine.impl.MemoryUsageSetting;
import org.eclipse.birt.data.engine.olap.api.IPreparedCubeQuery;
import org.eclipse.birt.data.engine.olap.api.query.ICubeQueryDefinition;
+import org.eclipse.birt.data.engine.olap.api.query.IDerivedMeasureDefinition;
import org.eclipse.birt.data.engine.olap.api.query.IMeasureDefinition;
import org.eclipse.birt.data.engine.olap.api.query.ISubCubeQueryDefinition;
import org.eclipse.birt.data.engine.olap.data.api.DimLevel;
@@ -1626,6 +1628,7 @@ public class DataRequestSessionImpl extends DataRequestSession
Map appContext ) throws BirtException
{
refactorCubeQueryDefinition( query );
+ populateMeasureDefinitionForCalculateMeasures( query );
setMeasureDataTypeForCubeQuery ( query );
QueryAdapter.adaptQuery( query );
@@ -1643,6 +1646,48 @@ public class DataRequestSessionImpl extends DataRequestSession
return this.dataEngine.prepare( query, appContext );
}
+ private void populateMeasureDefinitionForCalculateMeasures ( ICubeQueryDefinition query ) throws DataException, AdapterException
+ {
+ List calculatedMeasures = query.getDerivedMeasures( );
+ if ( calculatedMeasures == null || calculatedMeasures.size( ) == 0)
+ return;
+ List measures = query.getMeasures( );
+ List measureNameList = new ArrayList( );
+ for ( int i = 0; i < measures.size( ); i++ )
+ {
+ measureNameList.add( ( (IMeasureDefinition) measures.get( i ) ).getName( ));
+ }
+ List derivedMeasureNameList = new ArrayList();
+ for ( int i = 0 ; i < calculatedMeasures.size( );i++)
+ {
+ derivedMeasureNameList.add( ( (IDerivedMeasureDefinition) calculatedMeasures.get( i ) ).getName( ) );
+ }
+ for ( int i = 0; i < calculatedMeasures.size( ); i++ )
+ {
+ IDerivedMeasureDefinition dmd = (IDerivedMeasureDefinition) calculatedMeasures.get( i );
+ List measureNames = ExpressionCompilerUtil.extractColumnExpression( dmd.getExpression( ),
+ ExpressionUtil.MEASURE_INDICATOR );
+ for ( int j = 0; j < measureNames.size( ); j++ )
+ {
+ if ( !measureNameList.contains( measureNames.get( j ).toString( ) )
+ && !derivedMeasureNameList.contains( measureNames.get( j )
+ .toString( ) ) )
+ {
+ IMeasureDefinition md = query.createMeasure( measureNames.get( j )
+ .toString( ) );
+ if ( this.cubeHandleMap != null
+ && this.cubeHandleMap.containsKey( query.getName( ) ) )
+ {
+ CubeHandle cubeHandle = (CubeHandle) this.cubeHandleMap.get( query.getName( ) );
+ MeasureHandle measureHandle = cubeHandle.getMeasure( measureNames.get( j )
+ .toString( ) );
+ md.setAggrFunction( DataAdapterUtil.adaptModelAggregationType( measureHandle.getFunction( ) ) );
+ }
+ }
+ }
+ }
+ }
+
private void setMeasureDataTypeForCubeQuery( ICubeQueryDefinition query )
{
List measures = query.getMeasures( );