summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzhang2011-10-18 22:49:22 (EDT)
committer xgu2011-10-18 22:49:22 (EDT)
commitbb639df7fea1fd9f87a98a1728e5465fa001d55e (patch)
tree2c58baca5790e16edc779009369749c58e8999c2
parent67f172f7ded499656bbb0e78c773e035d7f51e2e (diff)
downloadorg.eclipse.birt-bb639df7fea1fd9f87a98a1728e5465fa001d55e.zip
org.eclipse.birt-bb639df7fea1fd9f87a98a1728e5465fa001d55e.tar.gz
org.eclipse.birt-bb639df7fea1fd9f87a98a1728e5465fa001d55e.tar.bz2
Checkin: enhance MDX function by using com.ibm.icu.util.Calendar to set
the locale and timezone info.
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunctionTest.java2
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions4.txt3
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions4.txt9
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/AbstractMDX.java5
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunction.java7
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunction.java8
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunction.java8
7 files changed, 24 insertions, 18 deletions
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunctionTest.java b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunctionTest.java
index b01e059..e9d32b5 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunctionTest.java
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunctionTest.java
@@ -172,7 +172,7 @@ public class PreviousNPeriodsFunctionTest extends TestCase
TimeMember resultMember = TimeFunctionFactory.createParallelPeriodFunction( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH, 5 ).getResult( member );
int[] result = new int[]{
- 2002, 7, 2
+ 2002, 7, 3
};
assertEquals( resultMember.getMemberValue( )[0], result[0] );
assertEquals( resultMember.getMemberValue( )[1], result[1] );
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions4.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions4.txt
index cb438ce..54b5c09 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions4.txt
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions4.txt
@@ -1,7 +1,8 @@
2002 3 8 3
2002 3 8 2
+2002 3 8 1
2002 3 7 5
2002 3 7 4
2002 3 7 3
2002 3 7 2
-2002 3 7 1
+2002 3 7 1 \ No newline at end of file
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions4.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions4.txt
index 0c75f23..94b2e01 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions4.txt
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions4.txt
@@ -2,23 +2,23 @@
2004 3 8 3
2004 3 8 2
2004 3 8 1
-2004 3 7 5
2004 3 7 4
2004 3 7 3
2004 3 7 2
+2004 3 7 1
2004 2 6 5
2004 2 6 4
2004 2 6 3
2004 2 6 2
2004 2 6 1
-2004 2 5 5
2004 2 5 4
2004 2 5 3
2004 2 5 2
-2004 2 4 5
+2004 2 5 1
2004 2 4 4
2004 2 4 3
2004 2 4 2
+2004 2 4 1
2004 1 3 5
2004 1 3 4
2004 1 3 3
@@ -28,8 +28,7 @@
2004 1 2 3
2004 1 2 2
2004 1 2 1
-2004 1 1 5
2004 1 1 4
2004 1 1 3
2004 1 1 2
-2003 4 12 5
+2004 1 1 1
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/AbstractMDX.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/AbstractMDX.java
index d77a9df..f290732 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/AbstractMDX.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/AbstractMDX.java
@@ -37,6 +37,7 @@ abstract public class AbstractMDX
{
if ( levelTypes[i].equals( TimeMember.TIME_LEVEL_TYPE_YEAR ) )
{
+ //cal.get(Calendar.YEAR );
cal.set( Calendar.YEAR, values[i] );
type = YEAR;
}
@@ -62,15 +63,15 @@ abstract public class AbstractMDX
else if ( levelTypes[i].equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR ) )
{
+ cal.get( Calendar.WEEK_OF_YEAR );
cal.set( Calendar.WEEK_OF_YEAR, values[i] );
type = WEEK;
}
-
else if ( levelTypes[i].equals( TimeMember.TIME_LEVEL_TYPE_DAY_OF_WEEK ) )
{
// here seems a com.ibm.icu.util.Calendar bug, if do not call cal.get()
// sometimes cal.set() will change date to a wrong result.
- cal.get( Calendar.DAY_OF_WEEK);
+ cal.get( Calendar.DAY_OF_WEEK );
cal.set( Calendar.DAY_OF_WEEK, values[i] );
type = DAY;
}
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunction.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunction.java
index 20c0dcb..871edf5 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunction.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunction.java
@@ -1,7 +1,7 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
+import com.ibm.icu.util.Calendar;
+import com.ibm.icu.util.GregorianCalendar;
public class PreviousNPeriodsFunction extends AbstractMDX implements IParallelPeriod
{
@@ -29,7 +29,8 @@ public class PreviousNPeriodsFunction extends AbstractMDX implements IParallelPe
String[] levels = member.getLevelType( );
int[] values = member.getMemberValue( );
- Calendar cal = new GregorianCalendar( );
+ Calendar cal = new GregorianCalendar( TimeMemberUtil.getTimeZone( ),
+ TimeMemberUtil.getDefaultLocale( ) );
translateToCal( cal, levels, values );
if ( levelName.equals( TimeMember.TIME_LEVEL_TYPE_YEAR ) )
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunction.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunction.java
index 7ed94ed..f6cf54e 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunction.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunction.java
@@ -1,10 +1,11 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
import java.util.List;
+import com.ibm.icu.util.Calendar;
+import com.ibm.icu.util.GregorianCalendar;
+
public class QuarterToDateFunction extends AbstractMDX implements IPeriodsFunction
{
@@ -13,7 +14,8 @@ public class QuarterToDateFunction extends AbstractMDX implements IPeriodsFuncti
String[] levels = member.getLevelType( );
int[] values = member.getMemberValue( );
- Calendar cal = new GregorianCalendar();
+ Calendar cal = new GregorianCalendar( TimeMemberUtil.getTimeZone( ),
+ TimeMemberUtil.getDefaultLocale( ) );
String calculateUnit = this.translateToCal( cal, levels, values ) ;
List<TimeMember> list = new ArrayList<TimeMember>( );
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunction.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunction.java
index 1a0c97f..5c8c7ff 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunction.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunction.java
@@ -1,10 +1,11 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
import java.util.List;
+import com.ibm.icu.util.Calendar;
+import com.ibm.icu.util.GregorianCalendar;
+
public class YearToDateFunction extends AbstractMDX implements IPeriodsFunction
{
@@ -13,7 +14,8 @@ public class YearToDateFunction extends AbstractMDX implements IPeriodsFunction
String[] levels = member.getLevelType( );
int[] values = member.getMemberValue( );
- Calendar cal = new GregorianCalendar();
+ Calendar cal = new GregorianCalendar( TimeMemberUtil.getTimeZone( ),
+ TimeMemberUtil.getDefaultLocale( ) );
String calculateUnit = this.translateToCal( cal, levels, values ) ;
List<TimeMember> list = new ArrayList<TimeMember>( );