summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzhang2011-11-17 04:55:59 (EST)
committer mwu2011-11-17 04:55:59 (EST)
commitb84210389fa16ced7b9f85571e6bde0ca78cc541 (patch)
tree53df7140776b2daad99f0d928258f189e1882d39
parent2a825db5b91188b6e5837037de06e277f197a0f0 (diff)
downloadorg.eclipse.birt-b84210389fa16ced7b9f85571e6bde0ca78cc541.zip
org.eclipse.birt-b84210389fa16ced7b9f85571e6bde0ca78cc541.tar.gz
org.eclipse.birt-b84210389fa16ced7b9f85571e6bde0ca78cc541.tar.bz2
Checkin: Support "CurrentYear,CurrentQuarter,CurrentMonth" time function
id DtE side and adding or updating some test cases
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateTest.java38
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunctionTest.java62
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunctionTest.java83
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD4.txt4
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD6.txt44
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD8.txt60
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD9.txt12
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions5.txt13
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions6.txt92
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions7.txt3
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions4.txt6
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions5.txt53
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions6.txt366
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions7.txt12
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions8.txt4
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/timefunction/ITimePeriod.java6
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/timefunction/TimePeriod.java13
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/impl/document/BindingIOUtil.java4
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/AggregationCalculator.java2
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/TimeFunctionCalculator.java2
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/AbstractMDX.java8
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/IPeriodsFunction.java2
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateFunction.java32
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunction.java42
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TimeFunctionFactory.java17
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunction.java53
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/ModelAdapter.java6
27 files changed, 986 insertions, 53 deletions
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateTest.java b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateTest.java
index 15ca2bd..da58e79 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateTest.java
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateTest.java
@@ -139,6 +139,44 @@ public class MonthToDateTest extends BaseTestCase
printMembers( timeMembers );
checkOutputFile( );
}
+
+ public void testMTD8( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2011, 3, 9, 6
+ };
+ String[] types = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR,
+ TimeMember.TIME_LEVEL_TYPE_QUARTER,
+ TimeMember.TIME_LEVEL_TYPE_MONTH,
+ TimeMember.TIME_LEVEL_TYPE_DAY_OF_MONTH
+ };
+ TimeMember timeMember = new TimeMember( values, types );
+ MonthToDateFunction func = new MonthToDateFunction( );
+ func.setIsCurrent( true );
+ List<TimeMember> timeMembers = func.getResult( timeMember );
+ printMembers( timeMembers );
+ checkOutputFile( );
+ }
+
+ public void testMTD9( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2011, 4, 10, 2
+ };
+ String[] types = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR,
+ TimeMember.TIME_LEVEL_TYPE_QUARTER,
+ TimeMember.TIME_LEVEL_TYPE_MONTH,
+ TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH
+ };
+ TimeMember timeMember = new TimeMember( values, types );
+ MonthToDateFunction func = new MonthToDateFunction( );
+ func.setIsCurrent( true );
+ List<TimeMember> timeMembers = func.getResult( timeMember );
+ printMembers( timeMembers );
+ checkOutputFile( );
+ }
private void printMembers( List<TimeMember> timeMembers )
{
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunctionTest.java b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunctionTest.java
index acde73d..4cfc07e 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunctionTest.java
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunctionTest.java
@@ -47,7 +47,7 @@ public class QuarterToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER ).getResult( member );
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER, false ).getResult( member );
printResult( resultMember );
this.checkOutputFile( );
}
@@ -63,7 +63,7 @@ public class QuarterToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER ).getResult( member );
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER, false ).getResult( member );
printResult( resultMember );
this.checkOutputFile( );
}
@@ -80,7 +80,7 @@ public class QuarterToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER ).getResult( member );
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER, false ).getResult( member );
printResult( resultMember );
this.checkOutputFile( );
}
@@ -98,7 +98,7 @@ public class QuarterToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER ).getResult( member );
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER, false ).getResult( member );
printResult( resultMember );
this.checkOutputFile( );
}
@@ -116,7 +116,59 @@ public class QuarterToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER ).getResult( member );
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER, false ).getResult( member );
+ printResult( resultMember );
+ this.checkOutputFile( );
+ }
+
+ public void testFunctions5( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2002, 3, 8, 3
+ };
+ String[] levels = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR,
+ TimeMember.TIME_LEVEL_TYPE_QUARTER,
+ TimeMember.TIME_LEVEL_TYPE_MONTH,
+ TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH
+ };
+ TimeMember member = new TimeMember( values, levels );
+
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER, true ).getResult( member );
+ printResult( resultMember );
+ this.checkOutputFile( );
+ }
+
+ public void testFunctions6( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2002, 3, 8, 18
+ };
+ String[] levels = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR,
+ TimeMember.TIME_LEVEL_TYPE_QUARTER,
+ TimeMember.TIME_LEVEL_TYPE_MONTH,
+ TimeMember.TIME_LEVEL_TYPE_DAY_OF_MONTH
+ };
+ TimeMember member = new TimeMember( values, levels );
+
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER, true ).getResult( member );
+ printResult( resultMember );
+ this.checkOutputFile( );
+ }
+
+ public void testFunctions7( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2002, 8
+ };
+ String[] levels = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR,
+ TimeMember.TIME_LEVEL_TYPE_MONTH
+ };
+ TimeMember member = new TimeMember( values, levels );
+
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER, true ).getResult( member );
printResult( resultMember );
this.checkOutputFile( );
}
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunctionTest.java b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunctionTest.java
index ea60514..0ad4ab5 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunctionTest.java
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunctionTest.java
@@ -47,7 +47,7 @@ public class YearToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR )
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, false )
.getResult( member );
printResult( resultMember );
@@ -65,7 +65,7 @@ public class YearToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR )
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, false )
.getResult( member );
printResult( resultMember );
this.checkOutputFile( );
@@ -83,7 +83,7 @@ public class YearToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR )
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, false )
.getResult( member );
printResult( resultMember );
this.checkOutputFile( );
@@ -102,7 +102,7 @@ public class YearToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR )
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, false )
.getResult( member );
printResult( resultMember );
@@ -122,7 +122,80 @@ public class YearToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR )
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, false )
+ .getResult( member );
+ printResult( resultMember );
+ this.checkOutputFile( );
+ }
+
+ public void testFunctions5( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2004, 3, 8, 4
+ };
+ String[] levels = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR,
+ TimeMember.TIME_LEVEL_TYPE_QUARTER,
+ TimeMember.TIME_LEVEL_TYPE_MONTH,
+ TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH
+ };
+ TimeMember member = new TimeMember( values, levels );
+
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, true )
+ .getResult( member );
+ printResult( resultMember );
+ this.checkOutputFile( );
+ }
+
+ public void testFunctions6( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2004, 3, 8, 18
+ };
+ String[] levels = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR,
+ TimeMember.TIME_LEVEL_TYPE_QUARTER,
+ TimeMember.TIME_LEVEL_TYPE_MONTH,
+ TimeMember.TIME_LEVEL_TYPE_DAY_OF_MONTH
+ };
+ TimeMember member = new TimeMember( values, levels );
+
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, true )
+ .getResult( member );
+
+ printResult( resultMember );
+ this.checkOutputFile( );
+ }
+
+ public void testFunctions7( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2002, 8
+ };
+ String[] levels = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR,
+ TimeMember.TIME_LEVEL_TYPE_MONTH
+ };
+ TimeMember member = new TimeMember( values, levels );
+
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, true )
+ .getResult( member );
+ printResult( resultMember );
+ this.checkOutputFile( );
+ }
+
+ public void testFunctions8( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2002, 2
+ };
+ String[] levels = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR,
+ TimeMember.TIME_LEVEL_TYPE_QUARTER
+ };
+ TimeMember member = new TimeMember( values, levels );
+
+ List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, true )
.getResult( member );
printResult( resultMember );
this.checkOutputFile( );
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD4.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD4.txt
index a6cc6ef..e25bbc3 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD4.txt
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD4.txt
@@ -1,8 +1,8 @@
year quarter month week-of-month
-2002 1 2 1
+2002 1 1 5
year quarter month week-of-month
2002 1 2 2
year quarter month week-of-month
2002 1 2 3
year quarter month week-of-month
-2002 1 2 4
+2002 1 2 4 \ 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/MonthToDateTest.testMTD6.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD6.txt
index 01eb477..86167d6 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD6.txt
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD6.txt
@@ -1,44 +1,44 @@
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 0 35 5 1 244
+2011 3 9 1 36 5 1 244
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 0 35 6 2 245
+2011 3 9 1 36 6 2 245
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 0 35 7 3 246
+2011 3 9 1 36 7 3 246
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 1 36 1 4 247
+2011 3 9 2 37 1 4 247
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 1 36 2 5 248
+2011 3 9 2 37 2 5 248
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 1 36 3 6 249
+2011 3 9 2 37 3 6 249
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 1 36 4 7 250
+2011 3 9 2 37 4 7 250
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 1 36 5 8 251
+2011 3 9 2 37 5 8 251
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 1 36 6 9 252
+2011 3 9 2 37 6 9 252
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 1 36 7 10 253
+2011 3 9 2 37 7 10 253
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 2 37 1 11 254
+2011 3 9 3 38 1 11 254
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 2 37 2 12 255
+2011 3 9 3 38 2 12 255
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 2 37 3 13 256
+2011 3 9 3 38 3 13 256
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 2 37 4 14 257
+2011 3 9 3 38 4 14 257
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 2 37 5 15 258
+2011 3 9 3 38 5 15 258
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 2 37 6 16 259
+2011 3 9 3 38 6 16 259
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 2 37 7 17 260
+2011 3 9 3 38 7 17 260
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 3 38 1 18 261
+2011 3 9 4 39 1 18 261
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 3 38 2 19 262
+2011 3 9 4 39 2 19 262
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 3 38 3 20 263
+2011 3 9 4 39 3 20 263
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 3 38 4 21 264
+2011 3 9 4 39 4 21 264
year quarter month week-of-month week-of-year day-of-week day-of-month day-of-year
-2011 3 9 3 38 5 22 265
+2011 3 9 4 39 5 22 265
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD8.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD8.txt
new file mode 100644
index 0000000..7e28c6c
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD8.txt
@@ -0,0 +1,60 @@
+year quarter month day-of-month
+2011 3 9 1
+year quarter month day-of-month
+2011 3 9 2
+year quarter month day-of-month
+2011 3 9 3
+year quarter month day-of-month
+2011 3 9 4
+year quarter month day-of-month
+2011 3 9 5
+year quarter month day-of-month
+2011 3 9 6
+year quarter month day-of-month
+2011 3 9 7
+year quarter month day-of-month
+2011 3 9 8
+year quarter month day-of-month
+2011 3 9 9
+year quarter month day-of-month
+2011 3 9 10
+year quarter month day-of-month
+2011 3 9 11
+year quarter month day-of-month
+2011 3 9 12
+year quarter month day-of-month
+2011 3 9 13
+year quarter month day-of-month
+2011 3 9 14
+year quarter month day-of-month
+2011 3 9 15
+year quarter month day-of-month
+2011 3 9 16
+year quarter month day-of-month
+2011 3 9 17
+year quarter month day-of-month
+2011 3 9 18
+year quarter month day-of-month
+2011 3 9 19
+year quarter month day-of-month
+2011 3 9 20
+year quarter month day-of-month
+2011 3 9 21
+year quarter month day-of-month
+2011 3 9 22
+year quarter month day-of-month
+2011 3 9 23
+year quarter month day-of-month
+2011 3 9 24
+year quarter month day-of-month
+2011 3 9 25
+year quarter month day-of-month
+2011 3 9 26
+year quarter month day-of-month
+2011 3 9 27
+year quarter month day-of-month
+2011 3 9 28
+year quarter month day-of-month
+2011 3 9 29
+year quarter month day-of-month
+2011 3 9 30 \ 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/MonthToDateTest.testMTD9.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD9.txt
new file mode 100644
index 0000000..df47e33
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD9.txt
@@ -0,0 +1,12 @@
+year quarter month week-of-month
+2011 3 9 5
+year quarter month week-of-month
+2011 4 10 2
+year quarter month week-of-month
+2011 4 10 3
+year quarter month week-of-month
+2011 4 10 4
+year quarter month week-of-month
+2011 4 10 5
+year quarter month week-of-month
+2011 4 10 6 \ 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/QuarterToDateFunctionTest.testFunctions5.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions5.txt
new file mode 100644
index 0000000..1c29622
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions5.txt
@@ -0,0 +1,13 @@
+2002 3 8 3
+2002 3 8 2
+2002 3 8 1
+2002 3 7 4
+2002 3 7 3
+2002 3 7 2
+2002 3 7 1
+2002 3 8 4
+2002 3 8 5
+2002 3 9 1
+2002 3 9 2
+2002 3 9 3
+2002 3 9 4 \ 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/QuarterToDateFunctionTest.testFunctions6.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions6.txt
new file mode 100644
index 0000000..5cb6985
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions6.txt
@@ -0,0 +1,92 @@
+2002 3 8 18
+2002 3 8 17
+2002 3 8 16
+2002 3 8 15
+2002 3 8 14
+2002 3 8 13
+2002 3 8 12
+2002 3 8 11
+2002 3 8 10
+2002 3 8 9
+2002 3 8 8
+2002 3 8 7
+2002 3 8 6
+2002 3 8 5
+2002 3 8 4
+2002 3 8 3
+2002 3 8 2
+2002 3 8 1
+2002 3 7 31
+2002 3 7 30
+2002 3 7 29
+2002 3 7 28
+2002 3 7 27
+2002 3 7 26
+2002 3 7 25
+2002 3 7 24
+2002 3 7 23
+2002 3 7 22
+2002 3 7 21
+2002 3 7 20
+2002 3 7 19
+2002 3 7 18
+2002 3 7 17
+2002 3 7 16
+2002 3 7 15
+2002 3 7 14
+2002 3 7 13
+2002 3 7 12
+2002 3 7 11
+2002 3 7 10
+2002 3 7 9
+2002 3 7 8
+2002 3 7 7
+2002 3 7 6
+2002 3 7 5
+2002 3 7 4
+2002 3 7 3
+2002 3 7 2
+2002 3 7 1
+2002 3 8 19
+2002 3 8 20
+2002 3 8 21
+2002 3 8 22
+2002 3 8 23
+2002 3 8 24
+2002 3 8 25
+2002 3 8 26
+2002 3 8 27
+2002 3 8 28
+2002 3 8 29
+2002 3 8 30
+2002 3 8 31
+2002 3 9 1
+2002 3 9 2
+2002 3 9 3
+2002 3 9 4
+2002 3 9 5
+2002 3 9 6
+2002 3 9 7
+2002 3 9 8
+2002 3 9 9
+2002 3 9 10
+2002 3 9 11
+2002 3 9 12
+2002 3 9 13
+2002 3 9 14
+2002 3 9 15
+2002 3 9 16
+2002 3 9 17
+2002 3 9 18
+2002 3 9 19
+2002 3 9 20
+2002 3 9 21
+2002 3 9 22
+2002 3 9 23
+2002 3 9 24
+2002 3 9 25
+2002 3 9 26
+2002 3 9 27
+2002 3 9 28
+2002 3 9 29
+2002 3 9 30 \ 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/QuarterToDateFunctionTest.testFunctions7.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions7.txt
new file mode 100644
index 0000000..1cfaa55
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/QuarterToDateFunctionTest.testFunctions7.txt
@@ -0,0 +1,3 @@
+2002 8
+2002 7
+2002 9 \ 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 8d766cd..047a18b 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
@@ -6,7 +6,7 @@
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
@@ -19,7 +19,7 @@
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
2004 1 3 2
@@ -32,4 +32,4 @@
2004 1 1 4
2004 1 1 3
2004 1 1 2
-2004 1 1 1 \ No newline at end of file
+2003 4 12 5 \ 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.testFunctions5.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions5.txt
new file mode 100644
index 0000000..5a3e93e
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions5.txt
@@ -0,0 +1,53 @@
+2004 3 8 4
+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 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 4 4
+2004 2 4 3
+2004 2 4 2
+2004 1 3 5
+2004 1 3 4
+2004 1 3 3
+2004 1 3 2
+2004 1 3 1
+2004 1 2 4
+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 3 8 5
+2004 3 9 2
+2004 3 9 3
+2004 3 9 4
+2004 3 9 5
+2004 4 10 2
+2004 4 10 3
+2004 4 10 4
+2004 4 10 5
+2004 4 11 1
+2004 4 11 2
+2004 4 11 3
+2004 4 11 4
+2004 4 11 5
+2004 4 12 2
+2004 4 12 3
+2004 4 12 4
+2004 4 12 5
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions6.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions6.txt
new file mode 100644
index 0000000..08cf102
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions6.txt
@@ -0,0 +1,366 @@
+2004 3 8 18
+2004 3 8 17
+2004 3 8 16
+2004 3 8 15
+2004 3 8 14
+2004 3 8 13
+2004 3 8 12
+2004 3 8 11
+2004 3 8 10
+2004 3 8 9
+2004 3 8 8
+2004 3 8 7
+2004 3 8 6
+2004 3 8 5
+2004 3 8 4
+2004 3 8 3
+2004 3 8 2
+2004 3 8 1
+2004 3 7 31
+2004 3 7 30
+2004 3 7 29
+2004 3 7 28
+2004 3 7 27
+2004 3 7 26
+2004 3 7 25
+2004 3 7 24
+2004 3 7 23
+2004 3 7 22
+2004 3 7 21
+2004 3 7 20
+2004 3 7 19
+2004 3 7 18
+2004 3 7 17
+2004 3 7 16
+2004 3 7 15
+2004 3 7 14
+2004 3 7 13
+2004 3 7 12
+2004 3 7 11
+2004 3 7 10
+2004 3 7 9
+2004 3 7 8
+2004 3 7 7
+2004 3 7 6
+2004 3 7 5
+2004 3 7 4
+2004 3 7 3
+2004 3 7 2
+2004 3 7 1
+2004 2 6 30
+2004 2 6 29
+2004 2 6 28
+2004 2 6 27
+2004 2 6 26
+2004 2 6 25
+2004 2 6 24
+2004 2 6 23
+2004 2 6 22
+2004 2 6 21
+2004 2 6 20
+2004 2 6 19
+2004 2 6 18
+2004 2 6 17
+2004 2 6 16
+2004 2 6 15
+2004 2 6 14
+2004 2 6 13
+2004 2 6 12
+2004 2 6 11
+2004 2 6 10
+2004 2 6 9
+2004 2 6 8
+2004 2 6 7
+2004 2 6 6
+2004 2 6 5
+2004 2 6 4
+2004 2 6 3
+2004 2 6 2
+2004 2 6 1
+2004 2 5 31
+2004 2 5 30
+2004 2 5 29
+2004 2 5 28
+2004 2 5 27
+2004 2 5 26
+2004 2 5 25
+2004 2 5 24
+2004 2 5 23
+2004 2 5 22
+2004 2 5 21
+2004 2 5 20
+2004 2 5 19
+2004 2 5 18
+2004 2 5 17
+2004 2 5 16
+2004 2 5 15
+2004 2 5 14
+2004 2 5 13
+2004 2 5 12
+2004 2 5 11
+2004 2 5 10
+2004 2 5 9
+2004 2 5 8
+2004 2 5 7
+2004 2 5 6
+2004 2 5 5
+2004 2 5 4
+2004 2 5 3
+2004 2 5 2
+2004 2 5 1
+2004 2 4 30
+2004 2 4 29
+2004 2 4 28
+2004 2 4 27
+2004 2 4 26
+2004 2 4 25
+2004 2 4 24
+2004 2 4 23
+2004 2 4 22
+2004 2 4 21
+2004 2 4 20
+2004 2 4 19
+2004 2 4 18
+2004 2 4 17
+2004 2 4 16
+2004 2 4 15
+2004 2 4 14
+2004 2 4 13
+2004 2 4 12
+2004 2 4 11
+2004 2 4 10
+2004 2 4 9
+2004 2 4 8
+2004 2 4 7
+2004 2 4 6
+2004 2 4 5
+2004 2 4 4
+2004 2 4 3
+2004 2 4 2
+2004 2 4 1
+2004 1 3 31
+2004 1 3 30
+2004 1 3 29
+2004 1 3 28
+2004 1 3 27
+2004 1 3 26
+2004 1 3 25
+2004 1 3 24
+2004 1 3 23
+2004 1 3 22
+2004 1 3 21
+2004 1 3 20
+2004 1 3 19
+2004 1 3 18
+2004 1 3 17
+2004 1 3 16
+2004 1 3 15
+2004 1 3 14
+2004 1 3 13
+2004 1 3 12
+2004 1 3 11
+2004 1 3 10
+2004 1 3 9
+2004 1 3 8
+2004 1 3 7
+2004 1 3 6
+2004 1 3 5
+2004 1 3 4
+2004 1 3 3
+2004 1 3 2
+2004 1 3 1
+2004 1 2 29
+2004 1 2 28
+2004 1 2 27
+2004 1 2 26
+2004 1 2 25
+2004 1 2 24
+2004 1 2 23
+2004 1 2 22
+2004 1 2 21
+2004 1 2 20
+2004 1 2 19
+2004 1 2 18
+2004 1 2 17
+2004 1 2 16
+2004 1 2 15
+2004 1 2 14
+2004 1 2 13
+2004 1 2 12
+2004 1 2 11
+2004 1 2 10
+2004 1 2 9
+2004 1 2 8
+2004 1 2 7
+2004 1 2 6
+2004 1 2 5
+2004 1 2 4
+2004 1 2 3
+2004 1 2 2
+2004 1 2 1
+2004 1 1 31
+2004 1 1 30
+2004 1 1 29
+2004 1 1 28
+2004 1 1 27
+2004 1 1 26
+2004 1 1 25
+2004 1 1 24
+2004 1 1 23
+2004 1 1 22
+2004 1 1 21
+2004 1 1 20
+2004 1 1 19
+2004 1 1 18
+2004 1 1 17
+2004 1 1 16
+2004 1 1 15
+2004 1 1 14
+2004 1 1 13
+2004 1 1 12
+2004 1 1 11
+2004 1 1 10
+2004 1 1 9
+2004 1 1 8
+2004 1 1 7
+2004 1 1 6
+2004 1 1 5
+2004 1 1 4
+2004 1 1 3
+2004 1 1 2
+2004 1 1 1
+2004 3 8 19
+2004 3 8 20
+2004 3 8 21
+2004 3 8 22
+2004 3 8 23
+2004 3 8 24
+2004 3 8 25
+2004 3 8 26
+2004 3 8 27
+2004 3 8 28
+2004 3 8 29
+2004 3 8 30
+2004 3 8 31
+2004 3 9 1
+2004 3 9 2
+2004 3 9 3
+2004 3 9 4
+2004 3 9 5
+2004 3 9 6
+2004 3 9 7
+2004 3 9 8
+2004 3 9 9
+2004 3 9 10
+2004 3 9 11
+2004 3 9 12
+2004 3 9 13
+2004 3 9 14
+2004 3 9 15
+2004 3 9 16
+2004 3 9 17
+2004 3 9 18
+2004 3 9 19
+2004 3 9 20
+2004 3 9 21
+2004 3 9 22
+2004 3 9 23
+2004 3 9 24
+2004 3 9 25
+2004 3 9 26
+2004 3 9 27
+2004 3 9 28
+2004 3 9 29
+2004 3 9 30
+2004 4 10 1
+2004 4 10 2
+2004 4 10 3
+2004 4 10 4
+2004 4 10 5
+2004 4 10 6
+2004 4 10 7
+2004 4 10 8
+2004 4 10 9
+2004 4 10 10
+2004 4 10 11
+2004 4 10 12
+2004 4 10 13
+2004 4 10 14
+2004 4 10 15
+2004 4 10 16
+2004 4 10 17
+2004 4 10 18
+2004 4 10 19
+2004 4 10 20
+2004 4 10 21
+2004 4 10 22
+2004 4 10 23
+2004 4 10 24
+2004 4 10 25
+2004 4 10 26
+2004 4 10 27
+2004 4 10 28
+2004 4 10 29
+2004 4 10 30
+2004 4 10 31
+2004 4 11 1
+2004 4 11 2
+2004 4 11 3
+2004 4 11 4
+2004 4 11 5
+2004 4 11 6
+2004 4 11 7
+2004 4 11 8
+2004 4 11 9
+2004 4 11 10
+2004 4 11 11
+2004 4 11 12
+2004 4 11 13
+2004 4 11 14
+2004 4 11 15
+2004 4 11 16
+2004 4 11 17
+2004 4 11 18
+2004 4 11 19
+2004 4 11 20
+2004 4 11 21
+2004 4 11 22
+2004 4 11 23
+2004 4 11 24
+2004 4 11 25
+2004 4 11 26
+2004 4 11 27
+2004 4 11 28
+2004 4 11 29
+2004 4 11 30
+2004 4 12 1
+2004 4 12 2
+2004 4 12 3
+2004 4 12 4
+2004 4 12 5
+2004 4 12 6
+2004 4 12 7
+2004 4 12 8
+2004 4 12 9
+2004 4 12 10
+2004 4 12 11
+2004 4 12 12
+2004 4 12 13
+2004 4 12 14
+2004 4 12 15
+2004 4 12 16
+2004 4 12 17
+2004 4 12 18
+2004 4 12 19
+2004 4 12 20
+2004 4 12 21
+2004 4 12 22
+2004 4 12 23
+2004 4 12 24
+2004 4 12 25
+2004 4 12 26
+2004 4 12 27
+2004 4 12 28
+2004 4 12 29
+2004 4 12 30
+2004 4 12 31
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions7.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions7.txt
new file mode 100644
index 0000000..ea2b4f2
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions7.txt
@@ -0,0 +1,12 @@
+2002 8
+2002 7
+2002 6
+2002 5
+2002 4
+2002 3
+2002 2
+2002 1
+2002 9
+2002 10
+2002 11
+2002 12 \ 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.testFunctions8.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions8.txt
new file mode 100644
index 0000000..e5050b8
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/YearToDateFunctionTest.testFunctions8.txt
@@ -0,0 +1,4 @@
+2002 2
+2002 1
+2002 3
+2002 4 \ No newline at end of file
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/timefunction/ITimePeriod.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/timefunction/ITimePeriod.java
index 7c7d195..662674b 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/timefunction/ITimePeriod.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/timefunction/ITimePeriod.java
@@ -27,4 +27,10 @@ public interface ITimePeriod
* @return
*/
public TimePeriodType getType( );
+
+ /**
+ * Represent whether it should be calculated in the scope of a current period
+ * @return
+ */
+ public boolean isCurrent( );
}
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/timefunction/TimePeriod.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/timefunction/TimePeriod.java
index 1400508..20622f1 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/timefunction/TimePeriod.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/api/timefunction/TimePeriod.java
@@ -17,6 +17,7 @@ public class TimePeriod implements ITimePeriod
{
public int countOfUnit =0;
public TimePeriodType type;
+ public boolean isCurrent = false;
public TimePeriod( int countOfUnit, TimePeriodType type )
{
@@ -24,6 +25,13 @@ public class TimePeriod implements ITimePeriod
this.type = type;
}
+ public TimePeriod( int countOfUnit, TimePeriodType type, boolean isCurrent )
+ {
+ this.countOfUnit = countOfUnit;
+ this.type = type;
+ this.isCurrent = isCurrent;
+ }
+
public int countOfUnit( )
{
return this.countOfUnit;
@@ -32,5 +40,10 @@ public class TimePeriod implements ITimePeriod
public TimePeriodType getType() {
return type;
}
+
+ public boolean isCurrent()
+ {
+ return this.isCurrent;
+ }
}
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/impl/document/BindingIOUtil.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/impl/document/BindingIOUtil.java
index af2fb7d..5bf151a 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/impl/document/BindingIOUtil.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/impl/document/BindingIOUtil.java
@@ -94,6 +94,7 @@ public class BindingIOUtil
IOUtil.writeBool( dos, true );
IOUtil.writeString( dos, baseTimePeriod.getType( ).toString( ) );
IOUtil.writeInt( dos, baseTimePeriod.countOfUnit( ) );
+ IOUtil.writeBool( dos,baseTimePeriod.isCurrent() );
}
else
{
@@ -166,8 +167,9 @@ public class BindingIOUtil
{
TimePeriodType periodType = getPeriodType( IOUtil.readString( dis ) );
int unit = IOUtil.readInt( dis );
+ boolean isCurrent = IOUtil.readBool ( dis );
TimePeriod basedTimePeriod = new TimePeriod( unit,
- periodType );
+ periodType, isCurrent );
time.setBaseTimePeriod( basedTimePeriod );
}
boolean containsRelativePeriod = IOUtil.readBool( dis );
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/AggregationCalculator.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/AggregationCalculator.java
index d0114a8..5b165ba 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/AggregationCalculator.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/AggregationCalculator.java
@@ -188,7 +188,7 @@ public class AggregationCalculator
toDatelevelType = toLevelType( function.getBaseTimePeriod( ).getType( ) );
if( function.getBaseTimePeriod( ).countOfUnit() == 0 )
{
- periodsFunction = TimeFunctionFactory.createPeriodsToDateFunction(toDatelevelType);
+ periodsFunction = TimeFunctionFactory.createPeriodsToDateFunction( toDatelevelType, function.getBaseTimePeriod( ).isCurrent() );
}
else
{
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/TimeFunctionCalculator.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/TimeFunctionCalculator.java
index 4dde495..c00e871 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/TimeFunctionCalculator.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/TimeFunctionCalculator.java
@@ -277,7 +277,7 @@ public class TimeFunctionCalculator
toDatelevelType = toLevelType( function.getBaseTimePeriod( ).getType( ) );
if( function.getBaseTimePeriod( ).countOfUnit() == 0 )
{
- periodsFunction[i] = TimeFunctionFactory.createPeriodsToDateFunction(toDatelevelType);
+ periodsFunction[i] = TimeFunctionFactory.createPeriodsToDateFunction( toDatelevelType, function.getBaseTimePeriod( ).isCurrent() );
}
else
{
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 f290732..b47acbe 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
@@ -19,6 +19,8 @@ abstract public class AbstractMDX
protected static final String MONTH = "month";
protected static final String WEEK = "week";
protected static final String DAY = "day";
+
+ protected boolean isCurrent = false;
/**
* translate the TimeMember.values to Calendar return the base
@@ -57,6 +59,7 @@ abstract public class AbstractMDX
else if ( levelTypes[i].equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH ) )
{
+ cal.get( Calendar.WEEK_OF_MONTH );
cal.set( Calendar.WEEK_OF_MONTH, values[i] );
type = WEEK;
}
@@ -148,4 +151,9 @@ abstract public class AbstractMDX
return tmp;
}
+
+ public void setIsCurrent( boolean isCurrent )
+ {
+ this.isCurrent = isCurrent;
+ }
}
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/IPeriodsFunction.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/IPeriodsFunction.java
index cce2aa5..f42f8c7 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/IPeriodsFunction.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/IPeriodsFunction.java
@@ -6,5 +6,5 @@ import java.util.List;
public interface IPeriodsFunction
{
//return a set of members of the Time hierarchy
- List<TimeMember> getResult( TimeMember member );
+ List<TimeMember> getResult( TimeMember member );
}
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateFunction.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateFunction.java
index 506c69a..e4c8e04 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateFunction.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateFunction.java
@@ -33,8 +33,14 @@ public class MonthToDateFunction extends AbstractMDX
Calendar cal = new GregorianCalendar( TimeMemberUtil.getTimeZone( ),
TimeMemberUtil.getDefaultLocale( ) );
-
+ cal.setMinimalDaysInFirstWeek(1);
+
String baseType = translateToCal( cal, levelTypes, values );
+ Calendar isCurrentCal = null;
+ if ( isCurrent )
+ {
+ isCurrentCal = (Calendar) cal.clone( );
+ }
int[] tmp;
if ( baseType.equals( MONTH ) )
{
@@ -54,6 +60,18 @@ public class MonthToDateFunction extends AbstractMDX
TimeMember timeMember = new TimeMember( tmp, levelTypes );
timeMembers.add( timeMember );
}
+ if( isCurrent )
+ {
+ int currentMonth = isCurrentCal.get( Calendar.MONTH );
+ isCurrentCal.add( Calendar.WEEK_OF_MONTH, 1 );
+ while( currentMonth == isCurrentCal.get( Calendar.MONTH ))
+ {
+ int[] newValues = getValueFromCal( isCurrentCal, levelTypes );
+ TimeMember newMember = new TimeMember( newValues, levelTypes );
+ timeMembers.add( newMember );
+ isCurrentCal.add( Calendar.WEEK_OF_MONTH, 1 );
+ }
+ }
}
else if ( baseType.equals( DAY ) )
{
@@ -65,6 +83,18 @@ public class MonthToDateFunction extends AbstractMDX
TimeMember timeMember = new TimeMember( tmp, levelTypes );
timeMembers.add( timeMember );
}
+ if( isCurrent )
+ {
+ int currentMonth = isCurrentCal.get( Calendar.MONTH );
+ isCurrentCal.add( Calendar.DAY_OF_MONTH, 1 );
+ while( currentMonth == isCurrentCal.get( Calendar.MONTH ))
+ {
+ int[] newValues = getValueFromCal( isCurrentCal, levelTypes );
+ TimeMember newMember = new TimeMember( newValues, levelTypes );
+ timeMembers.add( newMember );
+ isCurrentCal.add( Calendar.DAY_OF_MONTH, 1 );
+ }
+ }
}
return timeMembers;
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 bdf043b..ea53a7d 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
@@ -18,7 +18,11 @@ public class QuarterToDateFunction extends AbstractMDX implements IPeriodsFuncti
TimeMemberUtil.getDefaultLocale( ) );
cal.setMinimalDaysInFirstWeek(1);
String calculateUnit = this.translateToCal( cal, levels, values ) ;
-
+ Calendar isCurrentCal = null;
+ if ( isCurrent )
+ {
+ isCurrentCal = (Calendar) cal.clone( );
+ }
List<TimeMember> list = new ArrayList<TimeMember>( );
if ( calculateUnit.equals( QUARTER ) )
@@ -39,6 +43,18 @@ public class QuarterToDateFunction extends AbstractMDX implements IPeriodsFuncti
list.add( newMember );
cal.add( Calendar.MONTH, -1 );
}
+ if( isCurrent )
+ {
+ int currentQuarter = isCurrentCal.get( Calendar.MONTH ) / 3 + 1;
+ isCurrentCal.add( Calendar.MONTH, 1 );
+ while( currentQuarter == isCurrentCal.get( Calendar.MONTH ) / 3 + 1)
+ {
+ int[] newValues = getValueFromCal( isCurrentCal, levels );
+ newMember = new TimeMember( newValues, levels );
+ list.add( newMember );
+ isCurrentCal.add( Calendar.MONTH, 1 );
+ }
+ }
}
else if ( calculateUnit.equals( WEEK ) )
{
@@ -58,6 +74,18 @@ public class QuarterToDateFunction extends AbstractMDX implements IPeriodsFuncti
list.add( newMember );
cal.add( Calendar.WEEK_OF_YEAR, -1 );
}
+ if( isCurrent )
+ {
+ int currentQuarter = isCurrentCal.get( Calendar.MONTH ) / 3 + 1;
+ isCurrentCal.add( Calendar.WEEK_OF_YEAR, 1 );
+ while( currentQuarter == isCurrentCal.get( Calendar.MONTH ) / 3 + 1)
+ {
+ int[] newValues = getValueFromCal( isCurrentCal, levels );
+ newMember = new TimeMember( newValues, levels );
+ list.add( newMember );
+ isCurrentCal.add( Calendar.WEEK_OF_YEAR, 1 );
+ }
+ }
}
else if ( calculateUnit.equals( DAY ) )
{
@@ -76,6 +104,18 @@ public class QuarterToDateFunction extends AbstractMDX implements IPeriodsFuncti
list.add( newMember );
cal.add( Calendar.DAY_OF_YEAR, -1 );
}
+ if( isCurrent )
+ {
+ int currentQuarter = isCurrentCal.get( Calendar.MONTH ) / 3 + 1;
+ isCurrentCal.add( Calendar.DAY_OF_YEAR, 1 );
+ while( currentQuarter == isCurrentCal.get( Calendar.MONTH ) / 3 + 1)
+ {
+ int[] newValues = getValueFromCal( isCurrentCal, levels );
+ newMember = new TimeMember( newValues, levels );
+ list.add( newMember );
+ isCurrentCal.add( Calendar.DAY_OF_YEAR, 1 );
+ }
+ }
}
return list;
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TimeFunctionFactory.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TimeFunctionFactory.java
index cde6164..5284af8 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TimeFunctionFactory.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TimeFunctionFactory.java
@@ -15,19 +15,22 @@ package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
public class TimeFunctionFactory
{
- public static IPeriodsFunction createPeriodsToDateFunction( String levelType )
+ public static IPeriodsFunction createPeriodsToDateFunction( String levelType, boolean isCurrent )
{
+ IPeriodsFunction function = null;
if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_YEAR ) )
- return new YearToDateFunction( );
+ function = new YearToDateFunction( );
else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_QUARTER ) )
- return new QuarterToDateFunction( );
+ function = new QuarterToDateFunction( );
else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_MONTH ) )
- return new MonthToDateFunction( );
+ function = new MonthToDateFunction( );
else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH ) )
- return new WeekToDateFunciton( );
+ function = new WeekToDateFunciton( );
else if ( levelType.equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR ) )
- return new WeekToDateFunciton( );
- return null;
+ function = new WeekToDateFunciton( );
+ if ( isCurrent )
+ ( (AbstractMDX) function ).setIsCurrent( isCurrent );
+ return function;
}
public static IPeriodsFunction createTrailingFunction( String levelType, int Offset )
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 f056a6d..629d6cb 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
@@ -18,6 +18,11 @@ public class YearToDateFunction extends AbstractMDX implements IPeriodsFunction
TimeMemberUtil.getDefaultLocale( ) );
cal.setMinimalDaysInFirstWeek(1);
String calculateUnit = this.translateToCal( cal, levels, values ) ;
+ Calendar isCurrentCal = null;
+ if ( isCurrent )
+ {
+ isCurrentCal = (Calendar) cal.clone( );
+ }
List<TimeMember> list = new ArrayList<TimeMember>( );
if ( calculateUnit.equals( YEAR ) )
@@ -36,6 +41,18 @@ public class YearToDateFunction extends AbstractMDX implements IPeriodsFunction
list.add( newMember );
cal.add( Calendar.MONTH, -3 );
}
+ if( isCurrent )
+ {
+ int year = isCurrentCal.get( Calendar.YEAR );
+ isCurrentCal.add( Calendar.MONTH, 3 );
+ while( year == isCurrentCal.get( Calendar.YEAR ))
+ {
+ int[] newValues = getValueFromCal( isCurrentCal, levels );
+ newMember = new TimeMember( newValues, levels );
+ list.add( newMember );
+ isCurrentCal.add( Calendar.MONTH, 3 );
+ }
+ }
}
else if ( calculateUnit.equals( MONTH ) )
{
@@ -48,6 +65,18 @@ public class YearToDateFunction extends AbstractMDX implements IPeriodsFunction
list.add( newMember );
cal.add( Calendar.MONTH, -1 );
}
+ if( isCurrent )
+ {
+ int year = isCurrentCal.get( Calendar.YEAR );
+ isCurrentCal.add( Calendar.MONTH, 1 );
+ while( year == isCurrentCal.get( Calendar.YEAR ))
+ {
+ int[] newValues = getValueFromCal( isCurrentCal, levels );
+ newMember = new TimeMember( newValues, levels );
+ list.add( newMember );
+ isCurrentCal.add( Calendar.MONTH, 1 );
+ }
+ }
}
else if ( calculateUnit.equals( WEEK ) )
{
@@ -60,6 +89,18 @@ public class YearToDateFunction extends AbstractMDX implements IPeriodsFunction
list.add( newMember );
cal.add( Calendar.WEEK_OF_YEAR, -1 );
}
+ if( isCurrent )
+ {
+ int year = isCurrentCal.get( Calendar.YEAR );
+ isCurrentCal.add( Calendar.WEEK_OF_YEAR, 1 );
+ while( year == isCurrentCal.get( Calendar.YEAR ))
+ {
+ int[] newValues = getValueFromCal( isCurrentCal, levels );
+ newMember = new TimeMember( newValues, levels );
+ list.add( newMember );
+ isCurrentCal.add( Calendar.WEEK_OF_YEAR, 1 );
+ }
+ }
}
else if ( calculateUnit.equals( DAY ) )
{
@@ -72,6 +113,18 @@ public class YearToDateFunction extends AbstractMDX implements IPeriodsFunction
list.add( newMember );
cal.add( Calendar.DAY_OF_YEAR, -1 );
}
+ if( isCurrent )
+ {
+ int year = isCurrentCal.get( Calendar.YEAR );
+ isCurrentCal.add( Calendar.DAY_OF_YEAR, 1 );
+ while( year == isCurrentCal.get( Calendar.YEAR ))
+ {
+ int[] newValues = getValueFromCal( isCurrentCal, levels );
+ newMember = new TimeMember( newValues, levels );
+ list.add( newMember );
+ isCurrentCal.add( Calendar.DAY_OF_YEAR, 1 );
+ }
+ }
}
return list;
diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/ModelAdapter.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/ModelAdapter.java
index af57512..9c22074 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/ModelAdapter.java
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/ModelAdapter.java
@@ -473,11 +473,11 @@ public class ModelAdapter implements IModelAdapter
TimePeriod baseTimePeriod = null;
if ( IBuildInBaseTimeFunction.CURRENT_QUARTER.equals( calculateType ) )
{
- baseTimePeriod = new TimePeriod( 0, TimePeriodType.QUARTER );
+ baseTimePeriod = new TimePeriod( 0, TimePeriodType.QUARTER, true );
}
else if ( IBuildInBaseTimeFunction.CURRENT_MONTH.equals( calculateType ) )
{
- baseTimePeriod = new TimePeriod( 0, TimePeriodType.MONTH );
+ baseTimePeriod = new TimePeriod( 0, TimePeriodType.MONTH, true );
}
else if ( IBuildInBaseTimeFunction.TRAILING_30_DAYS.equals( calculateType ) )
{
@@ -509,7 +509,7 @@ public class ModelAdapter implements IModelAdapter
}
else if ( IBuildInBaseTimeFunction.CURRENT_YEAR.equals( calculateType ) )
{
- baseTimePeriod = new TimePeriod( 0, TimePeriodType.YEAR );
+ baseTimePeriod = new TimePeriod( 0, TimePeriodType.YEAR, true );
}
else if ( IBuildInBaseTimeFunction.WEEK_TO_DATE.equals( calculateType ) )
{