summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpeng.shi2011-09-28 00:26:39 (EDT)
committer xgu2011-09-28 00:26:39 (EDT)
commitde93a17eaa7d318d0937b9d5c7698214838587ec (patch)
tree2fa83780735fcd0c0eba2889ec402ae9543e95af
parent6d99e36389a09aa5e9d294204e48ba328aeccc51 (diff)
downloadorg.eclipse.birt-de93a17eaa7d318d0937b9d5c7698214838587ec.zip
org.eclipse.birt-de93a17eaa7d318d0937b9d5c7698214838587ec.tar.gz
org.eclipse.birt-de93a17eaa7d318d0937b9d5c7698214838587ec.tar.bz2
improve the trailingFunction and the test case
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingTest.java4
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingFunction.java22
2 files changed, 19 insertions, 7 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 f97a3aa..1d4e289 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
@@ -104,7 +104,7 @@ public class TrailingTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( "week",
+ List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH,
3 )
.getResult( timeMember );
printMembers( timeMembers );
@@ -127,7 +127,7 @@ public class TrailingTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( "day",
+ List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR,
3 )
.getResult( timeMember );
printMembers( timeMembers );
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 00e73f1..9b8978e 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
@@ -41,24 +41,36 @@ public class TrailingFunction extends AbstractMDX implements IPeriodsFunction
int[] tmp;
for ( int i = 0; i < offset - 1; i++ )
{
- if ( levelType.equals( YEAR ) )
+ if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_YEAR ) )
{
cal.add( Calendar.YEAR, -1 );
}
- else if ( levelType.equals( MONTH ) )
+ else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_MONTH ) )
{
cal.add( Calendar.MONTH, -1 );
}
- else if ( levelType.equals( QUARTER ) )
+ else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_QUARTER ) )
{
// Calendar not support quarter, so add 3 month
cal.add( Calendar.MONTH, -3 );
}
- else if ( levelType.equals( WEEK ) )
+ else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH ) )
{
cal.add( Calendar.WEEK_OF_YEAR, -1 );
}
- else if ( levelType.equals( DAY ) )
+ else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR ) )
+ {
+ cal.add( Calendar.WEEK_OF_YEAR, -1 );
+ }
+ else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_DAY_OF_MONTH) )
+ {
+ cal.add( Calendar.DATE, -1 );
+ }
+ else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_DAY_OF_WEEK) )
+ {
+ cal.add( Calendar.DATE, -1 );
+ }
+ else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR ) )
{
cal.add( Calendar.DATE, -1 );
}