summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpshi2011-11-29 21:55:11 (EST)
committer mwu2011-11-29 21:55:11 (EST)
commitd8085050f6bca2541cb738417755b1b5f17ee316 (patch)
tree6904153710df6d50f360f9fe0c1a2bd9b32add93
parentf3a9582d4e5be1f7aafd8454563d40be16d680cb (diff)
downloadorg.eclipse.birt-d8085050f6bca2541cb738417755b1b5f17ee316.zip
org.eclipse.birt-d8085050f6bca2541cb738417755b1b5f17ee316.tar.gz
org.eclipse.birt-d8085050f6bca2541cb738417755b1b5f17ee316.tar.bz2
fix ted 45600, there is a bug in trail function when aggregate on
year. Update unit test.
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingTest.java32
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing16.txt4
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing17.txt2
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingFunction.java5
4 files changed, 42 insertions, 1 deletions
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingTest.java b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingTest.java
index 3258a7f..f372179 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingTest.java
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingTest.java
@@ -313,6 +313,38 @@ public class TrailingTest extends BaseTestCase
checkOutputFile( );
}
+ public void testTrailing16( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2003
+ };
+ String[] types = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR
+ };
+ TimeMember timeMember = new TimeMember( values, types );
+ List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR,
+ -120 )
+ .getResult( timeMember );
+ printMembers( timeMembers );
+ checkOutputFile( );
+ }
+
+ public void testTrailing17( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2003
+ };
+ String[] types = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR
+ };
+ TimeMember timeMember = new TimeMember( values, types );
+ List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR,
+ 120 )
+ .getResult( timeMember );
+ printMembers( timeMembers );
+ checkOutputFile( );
+ }
+
private void printMembers( List<TimeMember> timeMembers )
{
String[] levelTypes;
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing16.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing16.txt
new file mode 100644
index 0000000..9871368
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing16.txt
@@ -0,0 +1,4 @@
+year
+2003
+year
+2002
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing17.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing17.txt
new file mode 100644
index 0000000..b947b44
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing17.txt
@@ -0,0 +1,2 @@
+year
+2003
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingFunction.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingFunction.java
index ff9ae24..26232a7 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingFunction.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingFunction.java
@@ -122,7 +122,10 @@ public class TrailingFunction extends AbstractMDX implements IPeriodsFunction
// based on the calculateUnit.
if ( calculateUnit.equals( YEAR ) )
{
- cal1.add( Calendar.YEAR, -Math.abs( offset ) / offset );
+ if (levelType.equals( YEAR ))
+ {
+ cal1.add( Calendar.YEAR, -Math.abs( offset ) / offset );
+ }
}
else if ( calculateUnit.equals( QUARTER ) )
{