summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzhang2011-12-02 00:53:13 (EST)
committer mwu2011-12-02 00:53:13 (EST)
commit30709d9ed45f89ef2fc157507cec068367281bfd (patch)
tree175d8efd53ce7d18f0ffe6ac4fe83f9976e31f3e
parent7a50435fc6151539e34c38693c20bb0a1560eac5 (diff)
downloadorg.eclipse.birt-30709d9ed45f89ef2fc157507cec068367281bfd.zip
org.eclipse.birt-30709d9ed45f89ef2fc157507cec068367281bfd.tar.gz
org.eclipse.birt-30709d9ed45f89ef2fc157507cec068367281bfd.tar.bz2
Checkin: Exception when add filter for derived measure in DA [45568]
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryDefinitionIOUtil.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryDefinitionIOUtil.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryDefinitionIOUtil.java
index e6fcf71..0300486 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryDefinitionIOUtil.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/impl/query/CubeQueryDefinitionIOUtil.java
@@ -39,6 +39,7 @@ import org.eclipse.birt.data.engine.olap.api.query.ICubeFilterDefinition;
import org.eclipse.birt.data.engine.olap.api.query.ICubeOperation;
import org.eclipse.birt.data.engine.olap.api.query.ICubeQueryDefinition;
import org.eclipse.birt.data.engine.olap.api.query.ICubeSortDefinition;
+import org.eclipse.birt.data.engine.olap.api.query.IDerivedMeasureDefinition;
import org.eclipse.birt.data.engine.olap.api.query.IDimensionDefinition;
import org.eclipse.birt.data.engine.olap.api.query.IEdgeDefinition;
import org.eclipse.birt.data.engine.olap.api.query.IEdgeDrillFilter;
@@ -122,6 +123,9 @@ public class CubeQueryDefinitionIOUtil
//save computed measures
saveComputedMeasures( dos, qd.getComputedMeasures( ) );
+ //save calculated measures
+ saveCalculatedMeasures( dos, qd.getDerivedMeasures( ) );
+
//save edges
saveEdges( dos, qd );
@@ -141,6 +145,61 @@ public class CubeQueryDefinitionIOUtil
}
}
+ private static void saveCalculatedMeasures( DataOutputStream dos, List<IDerivedMeasureDefinition> derivedMeasures ) throws IOException, DataException
+ {
+ if ( writeSize( dos, derivedMeasures ) > 0 )
+ {
+ for ( IDerivedMeasureDefinition m : derivedMeasures )
+ {
+ saveCalculatedMeasure( dos, m );
+ }
+ }
+ }
+
+ private static void loadCalculatedMeasures( DataInputStream dis, ICubeQueryDefinition qd, int version ) throws DataException, IOException
+ {
+ if ( version < VersionManager.getLatestVersion( ) )
+ return;
+ int size = IOUtil.readInt( dis );
+ for ( int i = 0; i < size; i++)
+ {
+ IDerivedMeasureDefinition md = loadCaculatedMeasure( dis );
+ IMeasureDefinition md1 = qd.createDerivedMeasure(
+ md.getName( ),
+ md.getDataType( ),
+ md.getExpression( ));
+ md1.setAggrFunction( md.getAggrFunction( ) );
+ }
+
+ }
+
+ private static void saveCalculatedMeasure( DataOutputStream dos,IDerivedMeasureDefinition m ) throws IOException, DataException
+ {
+ if ( m == null )
+ {
+ IOUtil.writeBool( dos, false );
+ return;
+ }
+ saveMeasure( dos, m );
+ IOUtil.writeInt( dos, m.getDataType( ) );
+ ExprUtil.saveBaseExpr( dos, m.getExpression( ) );
+ }
+
+ private static IDerivedMeasureDefinition loadCaculatedMeasure( DataInputStream dis ) throws DataException, IOException
+ {
+ IMeasureDefinition md = loadMeasure( dis );
+ if ( md == null )
+ {
+ return null;
+ }
+ String name = md.getName( );
+ int type = IOUtil.readInt( dis );
+ IBaseExpression expr = ExprUtil.loadBaseExpr( dis );
+ IDerivedMeasureDefinition dmd = new DerivedMeasureDefinition( name, type, expr );
+ dmd.setAggrFunction( md.getAggrFunction( ) );
+ return dmd;
+ }
+
private static void saveVersion( String queryResultID, IDocArchiveWriter writer ) throws IOException
{
RAOutputStream outputStream = writer.createRandomAccessStream( queryResultID + "_VERSION" );
@@ -199,6 +258,9 @@ public class CubeQueryDefinitionIOUtil
//load computed measures
loadComputedMeasures( dis, cqd );
+ //load calculated measures
+ loadCalculatedMeasures( dis, cqd , version );
+
//load edges
loadEdges( dis, cqd );