summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpshi2011-12-05 22:04:12 (EST)
committer mwu2011-12-05 22:04:12 (EST)
commitcb8d24d5326f9fd3e5d30ead2d6c502575883c12 (patch)
treee0baab134bff98520bc531c3e09a0d5be7061966
parente73914279187283534258bab5c30a37c433f4b0b (diff)
downloadorg.eclipse.birt-cb8d24d5326f9fd3e5d30ead2d6c502575883c12.zip
org.eclipse.birt-cb8d24d5326f9fd3e5d30ead2d6c502575883c12.tar.gz
org.eclipse.birt-cb8d24d5326f9fd3e5d30ead2d6c502575883c12.tar.bz2
fix some bugs corresponding to week level, update the unit test
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateTest.java28
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunctionTest.java20
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunctionTest.java17
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingTest.java86
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/WeekToDateTest.java28
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunctionTest.java21
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD3.txt2
-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.testMTD9.txt2
-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/QuarterToDateFunctionTest.testFunctions5.txt3
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing13.txt6
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing18.txt8
-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.txt12
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/AggregationCalculator.java6
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/TimeFunctionCalculator.java10
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/AbstractMDX.java195
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/MonthToDateFunction.java54
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunction.java2
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/QuarterToDateFunction.java68
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingFunction.java10
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/WeekToDateFunciton.java22
-rw-r--r--data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/YearToDateFunction.java74
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/Messages.properties2
25 files changed, 468 insertions, 221 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 c8b2a1f..ec83633 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
@@ -2,9 +2,10 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
import java.io.IOException;
+import java.util.Date;
import java.util.List;
-import org.eclipse.birt.data.engine.olap.data.impl.aggregation.function.MonthToDateFunction;
+import org.eclipse.birt.data.engine.api.timefunction.ReferenceDate;
import org.eclipse.birt.data.engine.api.timefunction.TimeMember;
import testutil.BaseTestCase;
@@ -64,7 +65,12 @@ public class MonthToDateTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = new MonthToDateFunction( ).getResult( timeMember );
+
+ MonthToDateFunction monthToDate = new MonthToDateFunction( );
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2011, 8, 28 ) );
+ monthToDate.setReferenceDate( referenceDate );
+
+ List<TimeMember> timeMembers = monthToDate.getResult( timeMember );
printMembers( timeMembers );
checkOutputFile( );
@@ -82,7 +88,12 @@ public class MonthToDateTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = new MonthToDateFunction( ).getResult( timeMember );
+
+ MonthToDateFunction monthToDate = new MonthToDateFunction( );
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2002, 1, 27 ) );
+ monthToDate.setReferenceDate( referenceDate );
+
+ List<TimeMember> timeMembers = monthToDate.getResult( timeMember );
printMembers( timeMembers );
checkOutputFile( );
@@ -119,7 +130,12 @@ public class MonthToDateTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = new MonthToDateFunction( ).getResult( timeMember );
+
+ MonthToDateFunction monthToDate = new MonthToDateFunction( );
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2011, 8, 22 ) );
+ monthToDate.setReferenceDate( referenceDate );
+
+ List<TimeMember> timeMembers = monthToDate.getResult( timeMember );
printMembers( timeMembers );
checkOutputFile( );
}
@@ -172,6 +188,10 @@ public class MonthToDateTest extends BaseTestCase
};
TimeMember timeMember = new TimeMember( values, types );
MonthToDateFunction func = new MonthToDateFunction( );
+
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2011, 9, 12 ) );
+ func.setReferenceDate( referenceDate );
+
func.setIsCurrent( true );
List<TimeMember> timeMembers = func.getResult( timeMember );
printMembers( timeMembers );
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 ea92090..7ba2263 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
@@ -1,7 +1,10 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
import java.io.IOException;
+import java.util.Date;
+import org.eclipse.birt.data.engine.api.timefunction.IParallelPeriod;
+import org.eclipse.birt.data.engine.api.timefunction.ReferenceDate;
import org.eclipse.birt.data.engine.api.timefunction.TimeMember;
import junit.framework.TestCase;
@@ -171,8 +174,13 @@ public class PreviousNPeriodsFunctionTest extends TestCase
TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH
};
TimeMember member = new TimeMember( values, levels );
-
- TimeMember resultMember = TimeFunctionFactory.createParallelPeriodFunction( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH, -5 ).getResult( member );
+ IParallelPeriod parallelPeriod = TimeFunctionFactory.createParallelPeriodFunction( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH,
+ -5 );
+
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2002, 7, 20 ) );
+ ( (AbstractMDX) parallelPeriod ).setReferenceDate( referenceDate );
+
+ TimeMember resultMember = parallelPeriod.getResult( member );
int[] result = new int[]{
2002, 7, 3
};
@@ -211,7 +219,13 @@ public class PreviousNPeriodsFunctionTest extends TestCase
};
TimeMember member = new TimeMember( values, levels );
- TimeMember resultMember = TimeFunctionFactory.createParallelPeriodFunction( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR, -10 ).getResult( member );
+ IParallelPeriod parallelPeriod = TimeFunctionFactory.createParallelPeriodFunction( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR,
+ -10 );
+
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2002, 5, 5 ) );
+ ( (AbstractMDX) parallelPeriod ).setReferenceDate( referenceDate );
+
+ TimeMember resultMember = parallelPeriod.getResult( member );
int[] result = new int[]{
2002, 13
};
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 f80e5d4..bce0205 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
@@ -1,8 +1,11 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
import java.io.IOException;
+import java.util.Date;
import java.util.List;
+import org.eclipse.birt.data.engine.api.timefunction.IPeriodsFunction;
+import org.eclipse.birt.data.engine.api.timefunction.ReferenceDate;
import org.eclipse.birt.data.engine.api.timefunction.TimeMember;
import testutil.BaseTestCase;
@@ -117,7 +120,12 @@ public class QuarterToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER, false ).getResult( member );
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2002, 7, 20 ) );
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER,
+ false );
+ ( (AbstractMDX) periodsFunction ).setReferenceDate( referenceDate );
+
+ List<TimeMember> resultMember = periodsFunction.getResult( member );
printResult( resultMember );
this.checkOutputFile( );
}
@@ -135,7 +143,12 @@ public class QuarterToDateFunctionTest extends BaseTestCase
};
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER, true ).getResult( member );
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2002, 7, 20 ) );
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER,
+ true );
+ ( (AbstractMDX) periodsFunction ).setReferenceDate( referenceDate );
+
+ List<TimeMember> resultMember = periodsFunction.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/TrailingTest.java b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingTest.java
index f372179..8826e2c 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
@@ -2,8 +2,11 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
import java.io.IOException;
+import java.util.Date;
import java.util.List;
+import org.eclipse.birt.data.engine.api.timefunction.IPeriodsFunction;
+import org.eclipse.birt.data.engine.api.timefunction.ReferenceDate;
import org.eclipse.birt.data.engine.api.timefunction.TimeMember;
import testutil.BaseTestCase;
@@ -34,9 +37,12 @@ public class TrailingTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_YEAR,
- -3 )
- .getResult( timeMember );
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_YEAR,
+ -3 );
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2011, 8, 22 ) );
+ ( (AbstractMDX) periodsFunction ).setReferenceDate( referenceDate );
+
+ List<TimeMember> timeMembers = periodsFunction.getResult( timeMember );
printMembers( timeMembers );
checkOutputFile( );
}
@@ -57,9 +63,12 @@ public class TrailingTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER,
- -3 )
- .getResult( timeMember );
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_QUARTER,
+ -3 );
+ ReferenceDate referenceDate = new ReferenceDate ( new Date(2011,8,22));
+ ((AbstractMDX)periodsFunction).setReferenceDate( referenceDate );
+
+ List<TimeMember> timeMembers = periodsFunction.getResult( timeMember );
printMembers( timeMembers );
checkOutputFile( );
}
@@ -80,9 +89,14 @@ public class TrailingTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_MONTH,
- -3 )
- .getResult( timeMember );
+
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_MONTH,
+ -3 );
+ ReferenceDate referenceDate = new ReferenceDate ( new Date(2011,8,22));
+ ((AbstractMDX)periodsFunction).setReferenceDate( referenceDate );
+
+ List<TimeMember> timeMembers = periodsFunction.getResult( timeMember );
+
printMembers( timeMembers );
checkOutputFile( );
}
@@ -103,9 +117,13 @@ public class TrailingTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH,
- 3 )
- .getResult( timeMember );
+
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH,
+ 3 );
+ ReferenceDate referenceDate = new ReferenceDate ( new Date(2011,8,22));
+ ((AbstractMDX)periodsFunction).setReferenceDate( referenceDate );
+
+ List<TimeMember> timeMembers = periodsFunction.getResult( timeMember );
printMembers( timeMembers );
checkOutputFile( );
}
@@ -126,9 +144,14 @@ public class TrailingTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR,
- 3 )
- .getResult( timeMember );
+
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR,
+ 3 );
+ ReferenceDate referenceDate = new ReferenceDate ( new Date(2011,8,22));
+ ((AbstractMDX)periodsFunction).setReferenceDate( referenceDate );
+
+ List<TimeMember> timeMembers = periodsFunction.getResult( timeMember );
+
printMembers( timeMembers );
checkOutputFile( );
}
@@ -273,9 +296,13 @@ public class TrailingTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR,
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_MONTH,
- -3 )
- .getResult( timeMember );
+
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_MONTH,
+ -3 );
+ ReferenceDate referenceDate = new ReferenceDate ( new Date(2011,8,28));
+ ((AbstractMDX)periodsFunction).setReferenceDate( referenceDate );
+
+ List<TimeMember> timeMembers = periodsFunction.getResult( timeMember );
printMembers( timeMembers );
checkOutputFile( );
}
@@ -345,6 +372,29 @@ public class TrailingTest extends BaseTestCase
checkOutputFile( );
}
+ public void testTrailing18( ) throws IOException
+ {
+ int[] values = new int[]{
+ 2011, 1, 0, 53
+ };
+ String[] types = new String[]{
+ TimeMember.TIME_LEVEL_TYPE_YEAR,
+ TimeMember.TIME_LEVEL_TYPE_MONTH,
+ TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH,
+ TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR,
+ };
+ TimeMember timeMember = new TimeMember( values, types );
+
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createTrailingFunction( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR,
+ -3 );
+ ReferenceDate referenceDate = new ReferenceDate ( new Date(2011,8,28));
+
+ List<TimeMember> timeMembers = periodsFunction.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/WeekToDateTest.java b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/WeekToDateTest.java
index cbe81b9..bf91b80 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/WeekToDateTest.java
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/WeekToDateTest.java
@@ -2,8 +2,10 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
import java.io.IOException;
+import java.util.Date;
import java.util.List;
+import org.eclipse.birt.data.engine.api.timefunction.ReferenceDate;
import org.eclipse.birt.data.engine.api.timefunction.TimeMember;
import org.eclipse.birt.data.engine.olap.data.impl.aggregation.function.WeekToDateFunciton;
@@ -35,7 +37,10 @@ public class WeekToDateTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR
};
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = new WeekToDateFunciton( ).getResult( timeMember );
+ ReferenceDate referenceDate = new ReferenceDate(new Date(2011,8,22));
+ WeekToDateFunciton weekToDate = new WeekToDateFunciton( );
+ ((AbstractMDX)weekToDate).setReferenceDate( referenceDate );
+ List<TimeMember> timeMembers = weekToDate.getResult( timeMember );
printMembers( timeMembers );
checkOutputFile( );
}
@@ -50,8 +55,13 @@ public class WeekToDateTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR,
TimeMember.TIME_LEVEL_TYPE_DAY_OF_WEEK
};
+
+ ReferenceDate referenceDate = new ReferenceDate(new Date(2011,4,19));
+ WeekToDateFunciton weekToDate = new WeekToDateFunciton( );
+ ((AbstractMDX)weekToDate).setReferenceDate( referenceDate );
+
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = new WeekToDateFunciton( ).getResult( timeMember );
+ List<TimeMember> timeMembers = weekToDate.getResult( timeMember );
printMembers( timeMembers );
checkOutputFile( );
}
@@ -68,8 +78,13 @@ public class WeekToDateTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH,
TimeMember.TIME_LEVEL_TYPE_DAY_OF_WEEK
};
+
+ ReferenceDate referenceDate = new ReferenceDate(new Date(2002,1,9));
+ WeekToDateFunciton weekToDate = new WeekToDateFunciton( );
+ ((AbstractMDX)weekToDate).setReferenceDate( referenceDate );
+
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = new WeekToDateFunciton( ).getResult( timeMember );
+ List<TimeMember> timeMembers = weekToDate.getResult( timeMember );
printMembers( timeMembers );
checkOutputFile( );
}
@@ -85,8 +100,13 @@ public class WeekToDateTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_MONTH,
TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH
};
+
+ ReferenceDate referenceDate = new ReferenceDate(new Date(2011,1,5));
+ WeekToDateFunciton weekToDate = new WeekToDateFunciton( );
+ ((AbstractMDX)weekToDate).setReferenceDate( referenceDate );
+
TimeMember timeMember = new TimeMember( values, types );
- List<TimeMember> timeMembers = new WeekToDateFunciton( ).getResult( timeMember );
+ List<TimeMember> timeMembers = weekToDate.getResult( timeMember );
printMembers( timeMembers );
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 be8363c..0a89f20 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
@@ -2,8 +2,11 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
import java.io.IOException;
+import java.util.Date;
import java.util.List;
+import org.eclipse.birt.data.engine.api.timefunction.IPeriodsFunction;
+import org.eclipse.birt.data.engine.api.timefunction.ReferenceDate;
import org.eclipse.birt.data.engine.api.timefunction.TimeMember;
import testutil.BaseTestCase;
@@ -122,10 +125,15 @@ public class YearToDateFunctionTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_MONTH,
TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH
};
+
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2004, 7, 26 ) );
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR,
+ false );
+ ( (AbstractMDX) periodsFunction ).setReferenceDate( referenceDate );
+
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, false )
- .getResult( member );
+ List<TimeMember> resultMember = periodsFunction.getResult( member );
printResult( resultMember );
this.checkOutputFile( );
}
@@ -141,10 +149,15 @@ public class YearToDateFunctionTest extends BaseTestCase
TimeMember.TIME_LEVEL_TYPE_MONTH,
TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH
};
+
+ ReferenceDate referenceDate = new ReferenceDate( new Date( 2004, 7, 26 ) );
+ IPeriodsFunction periodsFunction = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR,
+ true );
+ ( (AbstractMDX) periodsFunction ).setReferenceDate( referenceDate );
+
TimeMember member = new TimeMember( values, levels );
- List<TimeMember> resultMember = TimeFunctionFactory.createPeriodsToDateFunction( TimeMember.TIME_LEVEL_TYPE_YEAR, true )
- .getResult( member );
+ List<TimeMember> resultMember = periodsFunction.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.testMTD3.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD3.txt
index 3f0fcdb..7f1d3a0 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD3.txt
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/MonthToDateTest.testMTD3.txt
@@ -1,4 +1,6 @@
year quarter month week-of-month
+2011 3 9 0
+year quarter month week-of-month
2011 3 9 1
year quarter month week-of-month
2011 3 9 2
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 f239fd7..29ad221 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,10 @@
year quarter month week-of-month
+2002 1 2 0
+year quarter month week-of-month
2002 1 2 1
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 \ No newline at end of file
+2002 1 2 4
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
index 970e143..c2a30c1 100644
--- 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
@@ -1,4 +1,6 @@
year quarter month week-of-month
+2011 4 10 0
+year quarter month week-of-month
2011 4 10 1
year quarter month week-of-month
2011 4 10 2
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 bbbc27a..a881f0c 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,8 +1,9 @@
-2002 2 6 5
+2002 3 7 1
2002 3 7 2
2002 3 7 3
2002 3 7 4
2002 3 7 5
+2002 3 8 0
2002 3 8 1
2002 3 8 2
2002 3 8 3
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
index eebf8bc..62b064e 100644
--- 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
@@ -1,8 +1,9 @@
-2002 2 6 5
+2002 3 7 1
2002 3 7 2
2002 3 7 3
2002 3 7 4
2002 3 7 5
+2002 3 8 0
2002 3 8 1
2002 3 8 2
2002 3 8 3
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing13.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing13.txt
index a3ddd3d..d8f6fb5 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing13.txt
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing13.txt
@@ -7,6 +7,8 @@ year quarter month week-of-month week-of-year
year quarter month week-of-month week-of-year
2011 3 9 1 36
year quarter month week-of-month week-of-year
+2011 3 9 0 35
+year quarter month week-of-month week-of-year
2011 3 8 5 35
year quarter month week-of-month week-of-year
2011 3 8 4 34
@@ -15,6 +17,8 @@ year quarter month week-of-month week-of-year
year quarter month week-of-month week-of-year
2011 3 8 2 32
year quarter month week-of-month week-of-year
+2011 3 8 1 31
+year quarter month week-of-month week-of-year
2011 3 7 5 31
year quarter month week-of-month week-of-year
2011 3 7 4 30
@@ -26,3 +30,5 @@ year quarter month week-of-month week-of-year
2011 3 7 1 27
year quarter month week-of-month week-of-year
2011 2 6 5 26
+year quarter month week-of-month week-of-year
+2011 3 7 0 26
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing18.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing18.txt
new file mode 100644
index 0000000..6ff73d4
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/golden/TrailingTest.testTrailing18.txt
@@ -0,0 +1,8 @@
+year month week-of-month week-of-year
+2011 1 0 53
+year month week-of-month week-of-year
+2010 12 5 52
+year month week-of-month week-of-year
+2011 1 0 52
+year month week-of-month week-of-year
+2010 12 4 51
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 d28f82f..a822079 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
@@ -1,3 +1,4 @@
+2004 1 1 0
2004 1 1 1
2004 1 1 2
2004 1 1 3
@@ -7,23 +8,28 @@
2004 1 2 3
2004 1 2 4
2004 1 2 5
+2004 1 3 1
2004 1 3 2
2004 1 3 3
2004 1 3 4
2004 1 3 5
+2004 2 4 0
2004 2 4 1
2004 2 4 2
2004 2 4 3
2004 2 4 4
+2004 2 5 0
2004 2 5 1
2004 2 5 2
2004 2 5 3
2004 2 5 4
2004 2 5 5
+2004 2 6 1
2004 2 6 2
2004 2 6 3
2004 2 6 4
2004 2 6 5
+2004 3 7 0
2004 3 7 1
2004 3 7 2
2004 3 7 3
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
index a234c13..a69f834 100644
--- 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
@@ -1,3 +1,4 @@
+2004 1 1 0
2004 1 1 1
2004 1 1 2
2004 1 1 3
@@ -7,23 +8,28 @@
2004 1 2 3
2004 1 2 4
2004 1 2 5
+2004 1 3 1
2004 1 3 2
2004 1 3 3
2004 1 3 4
2004 1 3 5
+2004 2 4 0
2004 2 4 1
2004 2 4 2
2004 2 4 3
2004 2 4 4
+2004 2 5 0
2004 2 5 1
2004 2 5 2
2004 2 5 3
2004 2 5 4
2004 2 5 5
+2004 2 6 1
2004 2 6 2
2004 2 6 3
2004 2 6 4
2004 2 6 5
+2004 3 7 0
2004 3 7 1
2004 3 7 2
2004 3 7 3
@@ -33,20 +39,24 @@
2004 3 8 3
2004 3 8 4
2004 3 8 5
+2004 3 9 1
2004 3 9 2
2004 3 9 3
2004 3 9 4
2004 3 9 5
+2004 4 10 0
2004 4 10 1
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 1
2004 4 12 2
2004 4 12 3
2004 4 12 4
-2004 4 12 5 \ No newline at end of file
+2004 4 12 5
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 72b61a0..0d45633 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
@@ -23,6 +23,7 @@ import org.eclipse.birt.data.engine.api.aggregation.AggregationManager;
import org.eclipse.birt.data.engine.api.aggregation.IAggrFunction;
import org.eclipse.birt.data.engine.api.timefunction.IParallelPeriod;
import org.eclipse.birt.data.engine.api.timefunction.ITimeFunction;
+import org.eclipse.birt.data.engine.api.timefunction.ReferenceDate;
import org.eclipse.birt.data.engine.api.timefunction.TimePeriodType;
import org.eclipse.birt.data.engine.api.timefunction.IPeriodsFunction;
import org.eclipse.birt.data.engine.api.timefunction.TimeMember;
@@ -37,6 +38,7 @@ import org.eclipse.birt.data.engine.olap.data.api.cube.IDimension;
import org.eclipse.birt.data.engine.olap.data.impl.AggregationDefinition;
import org.eclipse.birt.data.engine.olap.data.impl.AggregationFunctionDefinition;
import org.eclipse.birt.data.engine.olap.data.impl.DimColumn;
+import org.eclipse.birt.data.engine.olap.data.impl.aggregation.function.AbstractMDX;
import org.eclipse.birt.data.engine.olap.data.impl.aggregation.function.TimeFunctionFactory;
import org.eclipse.birt.data.engine.olap.data.impl.aggregation.function.TimeMemberUtil;
import org.eclipse.birt.data.engine.olap.data.impl.dimension.Member;
@@ -195,11 +197,15 @@ public class AggregationCalculator
periodsFunction = TimeFunctionFactory.createTrailingFunction(
toDatelevelType,function.getBaseTimePeriod( ).countOfUnit() );
}
+ ( (AbstractMDX) periodsFunction ).setReferenceDate( (ReferenceDate) function.getReferenceDate( ) );
+
if( function.getRelativeTimePeriod( ) != null )
{
paralevelType = toLevelType( function.getRelativeTimePeriod( ).getType( ) );
IParallelPeriod parallelPeriod = TimeFunctionFactory.createParallelPeriodFunction(paralevelType,
function.getRelativeTimePeriod( ).countOfUnit());
+ ( (AbstractMDX) parallelPeriod ).setReferenceDate( (ReferenceDate) function.getReferenceDate( ) );
+
periodsFunction = new PeriodsToDateWithParallel( parallelPeriod,
periodsFunction );
}
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 31592fe..39a92ae 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
@@ -13,6 +13,7 @@ import org.eclipse.birt.data.engine.api.aggregation.Accumulator;
import org.eclipse.birt.data.engine.api.aggregation.AggregationManager;
import org.eclipse.birt.data.engine.api.aggregation.IAggrFunction;
import org.eclipse.birt.data.engine.api.timefunction.ITimeFunction;
+import org.eclipse.birt.data.engine.api.timefunction.ReferenceDate;
import org.eclipse.birt.data.engine.api.timefunction.TimePeriodType;
import org.eclipse.birt.data.engine.api.timefunction.IParallelPeriod;
import org.eclipse.birt.data.engine.api.timefunction.IPeriodsFunction;
@@ -31,6 +32,8 @@ import org.eclipse.birt.data.engine.olap.data.api.cube.IDimension;
import org.eclipse.birt.data.engine.olap.data.impl.AggregationDefinition;
import org.eclipse.birt.data.engine.olap.data.impl.AggregationFunctionDefinition;
import org.eclipse.birt.data.engine.olap.data.impl.DimColumn;
+import org.eclipse.birt.data.engine.olap.data.impl.aggregation.function.AbstractMDX;
+import org.eclipse.birt.data.engine.olap.data.impl.aggregation.function.MonthToDateFunction;
import org.eclipse.birt.data.engine.olap.data.impl.aggregation.function.TimeFunctionFactory;
import org.eclipse.birt.data.engine.olap.data.impl.aggregation.function.TimeMemberUtil;
import org.eclipse.birt.data.engine.olap.data.impl.dimension.Member;
@@ -284,11 +287,14 @@ public class TimeFunctionCalculator
periodsFunction[i] = TimeFunctionFactory.createTrailingFunction(
toDatelevelType,function.getBaseTimePeriod( ).countOfUnit() );
}
+ ( (AbstractMDX) periodsFunction[i] ).setReferenceDate( (ReferenceDate) function.getReferenceDate( ) );
+
if( function.getRelativeTimePeriod( ) != null )
{
paralevelType = toLevelType( function.getRelativeTimePeriod( ).getType( ) );
IParallelPeriod parallelPeriod = TimeFunctionFactory.createParallelPeriodFunction(paralevelType,
function.getRelativeTimePeriod( ).countOfUnit());
+ ( (AbstractMDX) parallelPeriod ).setReferenceDate( (ReferenceDate) function.getReferenceDate( ) );
periodsFunction[i] = new PeriodsToDateWithParallel( parallelPeriod,
periodsFunction[i] );
}
@@ -985,7 +991,9 @@ class PeriodsToDateWithParallel implements IPeriodsFunction
*/
public List<TimeMember> getResult(TimeMember member)
{
- return periodsToDateFunc.getResult( parallelFunc.getResult( member ) );
+ TimeMember timeMember = parallelFunc.getResult( member );
+ ((AbstractMDX)periodsToDateFunc).setReferenceDate( ((AbstractMDX)parallelFunc).getReferenceDate( ));
+ return periodsToDateFunc.getResult( timeMember );
}
public String getToolTip(TimeMember member)
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 506d94e..f2e4e66 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
@@ -1,6 +1,9 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
+import java.util.List;
+
+import org.eclipse.birt.data.engine.api.timefunction.ReferenceDate;
import org.eclipse.birt.data.engine.api.timefunction.TimeMember;
import com.ibm.icu.util.Calendar;
@@ -24,6 +27,7 @@ abstract public class AbstractMDX
protected boolean isCurrent = false;
+ private ReferenceDate referenceDate = null;
/**
* translate the TimeMember.values to Calendar return the base
* level("year","month","day"...)
@@ -37,8 +41,7 @@ abstract public class AbstractMDX
int[] values )
{
String type = "";
- int year_woy = 1;
- int year = 1;
+ int dayOfWeek = 1;
for ( int i = 0; i < values.length; i++ )
{
if ( levelTypes[i].equals( TimeMember.TIME_LEVEL_TYPE_YEAR ) )
@@ -63,15 +66,22 @@ abstract public class AbstractMDX
else if ( levelTypes[i].equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH ) )
{
- year_woy = cal.get( Calendar.YEAR_WOY );
- year = cal.get( Calendar.YEAR );
- // year_woy < year, means last week of previous year
- // for example. 2011/1/1, the year_woy is 2010
- if ( year_woy < year )
+ if ( referenceDate != null && referenceDate.getDate( ) != null)
+ {
+ dayOfWeek = referenceDate.getDate( ).getDay( );
+ cal.set( Calendar.DAY_OF_WEEK, dayOfWeek + 1);
+ }
+ else
{
- cal.add( Calendar.DAY_OF_WEEK, 7 );
+ int year_woy = cal.get( Calendar.YEAR_WOY );
+ int year = cal.get( Calendar.YEAR );
+ if ( year_woy < year )
+ {
+ cal.add( Calendar.DAY_OF_WEEK, 7 );
+ }
+ cal.set( Calendar.DAY_OF_WEEK, 1 );
}
- cal.set( Calendar.DAY_OF_WEEK, 1 );
+
cal.set( Calendar.WEEK_OF_MONTH, values[i] );
type = WEEK;
@@ -79,13 +89,21 @@ abstract public class AbstractMDX
else if ( levelTypes[i].equals( TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR ) )
{
- year_woy = cal.get( Calendar.YEAR_WOY );
- year = cal.get( Calendar.YEAR );
- if ( year_woy < year )
+ if ( referenceDate != null && referenceDate.getDate( ) != null)
{
- cal.add( Calendar.DAY_OF_WEEK, 7 );
+ dayOfWeek = referenceDate.getDate( ).getDay( );
+ cal.set( Calendar.DAY_OF_WEEK, dayOfWeek + 1 );
+ }
+ else
+ {
+ int year_woy = cal.get( Calendar.YEAR_WOY );
+ int year = cal.get( Calendar.YEAR );
+ if ( year_woy < year )
+ {
+ cal.add( Calendar.DAY_OF_WEEK, 7 );
+ }
+ cal.set( Calendar.DAY_OF_WEEK, 1 );
}
- cal.set( Calendar.DAY_OF_WEEK, 1 );
cal.set( Calendar.WEEK_OF_YEAR, values[i] );
type = WEEK;
@@ -111,7 +129,8 @@ abstract public class AbstractMDX
type = DAY;
}
}
-
+
+ this.referenceDate = new ReferenceDate( cal.getTime( ) );
return type;
}
@@ -172,8 +191,154 @@ abstract public class AbstractMDX
return tmp;
}
+ protected void retrieveWeek(List<TimeMember> list, Calendar cal, String[] levels, String type)
+ {
+ int endWeek = cal.get( Calendar.WEEK_OF_YEAR );
+ int startWeek = 1;
+ int startMonth = 1;
+ Calendar startCal = (Calendar) cal.clone( );
+
+ if ( type.equals( "yearToDate" ) )
+ {
+ startCal.set( Calendar.MONTH, 0 );
+ startCal.set( Calendar.DAY_OF_MONTH, 1 );
+ // week of year > 1, this week should also be added
+ if ( startCal.get( Calendar.WEEK_OF_YEAR ) > 1 )
+ {
+ int[] newValues = getValueFromCal( startCal, levels );
+ TimeMember newMember = new TimeMember( newValues, levels );
+ list.add( newMember );
+ startCal.add( Calendar.WEEK_OF_YEAR, 1 );
+ }
+ startWeek = 1;
+ }
+ else if ( type.equals( "quarterToDate" ) )
+ {
+ int quarter = cal.get( Calendar.MONTH ) / 3 + 1;
+ startMonth = quarter * 3 - 2;
+ startCal.set( Calendar.MONTH, startMonth - 1 );
+ startCal.set( Calendar.DAY_OF_MONTH, 1 );
+ startWeek = startCal.get( Calendar.WEEK_OF_YEAR );
+ }
+ else if ( type.equals( "monthToDate" ) )
+ {
+ startMonth = cal.get( Calendar.MONTH );
+ startCal.set( Calendar.MONTH, startMonth );
+ startCal.set( Calendar.DAY_OF_MONTH, 1 );
+ startWeek = startCal.get( Calendar.WEEK_OF_YEAR );
+ }
+
+ TimeMember newMember = null;
+ for ( int i = startWeek; i <= endWeek; i++ )
+ {
+ int[] newValues = getValueFromCal( startCal, levels );
+ newMember = new TimeMember( newValues, levels );
+ list.add( newMember );
+ if ( i != startWeek && isAddExtraWeek( type, startCal ) )
+ {
+ addExtraWeek( list, startCal, newMember, levels );
+ }
+
+ startCal.add( Calendar.WEEK_OF_YEAR, 1 );
+ startCal.set( Calendar.DAY_OF_WEEK, 1 );
+ }
+
+ }
+
+
+ /**
+ * If the week across month,quarter,year, this week will be divided into 2
+ * parts, for example, 2011.11month,week of month 5, this week will be
+ * divided into 2011,11,week of month 5 and 2011,12,week of month 0.
+ * So when we do year to date(level week), when visit the 2011.11month,week of month
+ * 5, we should also add the extra week, 2011,12,week of month 0
+ */
+ protected void addExtraWeek(List<TimeMember> timeMemberList, Calendar cal, TimeMember srcMember, String[] levels)
+ {
+ int weekStart = 1;
+ int week = 1;
+ int weekEnd = 1;
+ int[] newValues = null;
+ TimeMember newMember = null;
+ int dayOfWeek = cal.get( Calendar.DAY_OF_WEEK );
+ week = cal.get( Calendar.WEEK_OF_MONTH );
+ cal.set( Calendar.DAY_OF_WEEK, 1 );
+ weekStart = cal.get( Calendar.WEEK_OF_MONTH );
+
+ // if the weekofmonth in a week is not the same, this week must across month,
+ // may need add extra week.
+ if ( weekStart != week )
+ {
+ newValues = getValueFromCal( cal, levels );
+ newMember = new TimeMember( newValues, levels );
+
+ }
+ else
+ {
+ cal.set( Calendar.DAY_OF_WEEK, 7 );
+ weekEnd = cal.get( Calendar.WEEK_OF_MONTH );
+ if ( weekEnd != week )
+ {
+ newValues = getValueFromCal( cal, levels );
+ newMember = new TimeMember( newValues, levels );
+ }
+ }
+ if ( newMember != null && !newMember.equals( srcMember ) )
+ {
+ timeMemberList.add( newMember );
+ }
+ cal.set( Calendar.DAY_OF_WEEK, dayOfWeek );
+
+ }
+
+ private boolean isAddExtraWeek(String type, Calendar cal)
+ {
+ int dayOfWeek = cal.get( Calendar.DAY_OF_WEEK );
+ if ( type.equals( "monthToDate" ) )
+ {
+ return false;
+ }
+
+ else if ( type.equals( "quarterToDate" ) )
+ {
+ cal.set( Calendar.DAY_OF_WEEK, 7 );
+ int quarterEnd = cal.get( Calendar.MONTH ) / 3 + 1;
+ cal.set( Calendar.DAY_OF_WEEK, 1 );
+ int quarterStart = cal.get( Calendar.MONTH ) / 3 + 1;
+ if ( quarterEnd != quarterStart )
+ {
+ return false;
+ }
+ }
+
+ else if ( type.equals( "yearToDate" ) )
+ {
+ cal.set( Calendar.DAY_OF_WEEK, 7 );
+ int yearEnd = cal.get( Calendar.YEAR );
+ cal.set( Calendar.DAY_OF_WEEK, 1 );
+ int yearStart = cal.get( Calendar.YEAR );
+ if ( yearStart != yearEnd )
+ {
+ return false;
+ }
+ }
+ cal.set( Calendar.DAY_OF_WEEK, dayOfWeek );
+ return true;
+ }
+
+
public void setIsCurrent( boolean isCurrent )
{
this.isCurrent = isCurrent;
}
+
+ public void setReferenceDate( ReferenceDate referenceDate)
+ {
+ this.referenceDate = referenceDate;
+ }
+
+ public ReferenceDate getReferenceDate( )
+ {
+ return this.referenceDate ;
+ }
}
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 90c75b4..9c4f1b5 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
@@ -38,6 +38,21 @@ public class MonthToDateFunction extends AbstractMDX
TimeMemberUtil.getDefaultLocale( ) );
cal.clear( );
String baseType = translateToCal( cal, levelTypes, values );
+
+ if ( isCurrent )
+ {
+ int month = cal.get( Calendar.MONTH );
+ while ( true )
+ {
+ if ( cal.get( Calendar.MONTH ) != month )
+ {
+ cal.add( Calendar.DAY_OF_YEAR, -1 );
+ break;
+ }
+ cal.add( Calendar.DAY_OF_YEAR, 1 );
+ }
+
+ }
int[] tmp;
if ( baseType.equals( MONTH ) )
{
@@ -45,30 +60,7 @@ public class MonthToDateFunction extends AbstractMDX
}
else if ( baseType.equals( WEEK ) )
{
- int weekOfMonth = cal.get( Calendar.WEEK_OF_MONTH );
- int month = cal.get( Calendar.MONTH );
- int year = cal.get( Calendar.YEAR );
- for ( int i = 1; i <= weekOfMonth; i++ )
- {
- cal.set( Calendar.YEAR, year );
- cal.set( Calendar.MONTH, month );
- cal.set( Calendar.WEEK_OF_MONTH, i );
- tmp = getValueFromCal( cal, levelTypes );
- TimeMember timeMember = new TimeMember( tmp, levelTypes );
- timeMembers.add( timeMember );
- }
- if( isCurrent )
- {
- int currentMonth = cal.get( Calendar.MONTH );
- cal.add( Calendar.WEEK_OF_MONTH, 1 );
- while( currentMonth == cal.get( Calendar.MONTH ))
- {
- int[] newValues = getValueFromCal( cal, levelTypes );
- TimeMember newMember = new TimeMember( newValues, levelTypes );
- timeMembers.add( newMember );
- cal.add( Calendar.WEEK_OF_MONTH, 1 );
- }
- }
+ retrieveWeek( timeMembers, cal, levelTypes, "monthToDate" );
}
else if ( baseType.equals( DAY ) )
{
@@ -80,21 +72,9 @@ public class MonthToDateFunction extends AbstractMDX
TimeMember timeMember = new TimeMember( tmp, levelTypes );
timeMembers.add( timeMember );
}
- if( isCurrent )
- {
- int currentMonth = cal.get( Calendar.MONTH );
- cal.add( Calendar.DAY_OF_MONTH, 1 );
- while( currentMonth == cal.get( Calendar.MONTH ))
- {
- int[] newValues = getValueFromCal( cal, levelTypes );
- TimeMember newMember = new TimeMember( newValues, levelTypes );
- timeMembers.add( newMember );
- cal.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/PreviousNPeriodsFunction.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/PreviousNPeriodsFunction.java
index a4742af..890dc2c 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,6 +1,7 @@
package org.eclipse.birt.data.engine.olap.data.impl.aggregation.function;
import org.eclipse.birt.data.engine.api.timefunction.IParallelPeriod;
+import org.eclipse.birt.data.engine.api.timefunction.ReferenceDate;
import org.eclipse.birt.data.engine.api.timefunction.TimeMember;
import com.ibm.icu.util.Calendar;
@@ -54,6 +55,7 @@ public class PreviousNPeriodsFunction extends AbstractMDX implements IParallelPe
else if ( levelName.equals( TimeMember.TIME_LEVEL_TYPE_DAY_OF_WEEK ) )
cal.add( Calendar.DAY_OF_WEEK, offset );
+ setReferenceDate( new ReferenceDate( cal.getTime( ) ));
int[] newValues = getValueFromCal( cal, levels );
TimeMember newMember = new TimeMember( newValues, levels );
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 440ff1a..83fbe60 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
@@ -21,6 +21,21 @@ public class QuarterToDateFunction extends AbstractMDX implements IPeriodsFuncti
TimeMemberUtil.getDefaultLocale( ) );
cal.clear();
String calculateUnit = this.translateToCal( cal, levels, values ) ;
+ if ( isCurrent )
+ {
+ int quarter = cal.get( Calendar.MONTH ) / 3 + 1;
+ while ( true )
+ {
+ if ( cal.get( Calendar.MONTH ) / 3 + 1 != quarter )
+ {
+ cal.add( Calendar.DAY_OF_YEAR, -1 );
+ break;
+ }
+
+ cal.add( Calendar.DAY_OF_YEAR, 1 );
+ }
+ }
+
List<TimeMember> list = new ArrayList<TimeMember>( );
if ( calculateUnit.equals( QUARTER ) )
@@ -42,49 +57,10 @@ public class QuarterToDateFunction extends AbstractMDX implements IPeriodsFuncti
list.add( newMember );
}
- if( isCurrent )
- {
- int currentQuarter = cal.get( Calendar.MONTH ) / 3 + 1;
- cal.add( Calendar.MONTH, 1 );
- while( currentQuarter == cal.get( Calendar.MONTH ) / 3 + 1)
- {
- int[] newValues = getValueFromCal( cal, levels );
- newMember = new TimeMember( newValues, levels );
- list.add( newMember );
- cal.add( Calendar.MONTH, 1 );
- }
- }
}
else if ( calculateUnit.equals( WEEK ) )
{
- int weekOfYear = cal.get( Calendar.WEEK_OF_YEAR );
- int quarter = cal.get( Calendar.MONTH ) / 3 + 1;
- int startMonth = quarter * 3 - 2;
-
- Calendar startCal = (Calendar)cal.clone( );
- startCal.set( Calendar.MONTH, startMonth-1 );
- startCal.set( Calendar.DAY_OF_MONTH, 1 );
- int starWeek = startCal.get( Calendar.WEEK_OF_YEAR );
- TimeMember newMember = null;
- for ( int i = starWeek; i <= weekOfYear; i++ )
- {
- cal.set (Calendar.WEEK_OF_YEAR,i);
- int[] newValues = getValueFromCal( cal, levels );
- newMember = new TimeMember( newValues, levels );
- list.add( newMember );
- }
- if( isCurrent )
- {
- int currentQuarter = cal.get( Calendar.MONTH ) / 3 + 1;
- cal.add( Calendar.WEEK_OF_YEAR, 1 );
- while( currentQuarter == cal.get( Calendar.MONTH ) / 3 + 1)
- {
- int[] newValues = getValueFromCal( cal, levels );
- newMember = new TimeMember( newValues, levels );
- list.add( newMember );
- cal.add( Calendar.WEEK_OF_YEAR, 1 );
- }
- }
+ retrieveWeek( list, cal, levels, "quarterToDate" );
}
else if ( calculateUnit.equals( DAY ) )
{
@@ -103,18 +79,6 @@ public class QuarterToDateFunction extends AbstractMDX implements IPeriodsFuncti
newMember = new TimeMember( newValues, levels );
list.add( newMember );
}
- if( isCurrent )
- {
- int currentQuarter = cal.get( Calendar.MONTH ) / 3 + 1;
- cal.add( Calendar.DAY_OF_YEAR, 1 );
- while( currentQuarter == cal.get( Calendar.MONTH ) / 3 + 1)
- {
- int[] newValues = getValueFromCal( cal, levels );
- newMember = new TimeMember( newValues, levels );
- list.add( newMember );
- cal.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/TrailingFunction.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/TrailingFunction.java
index 26232a7..9c2f43b 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
@@ -142,11 +142,11 @@ public class TrailingFunction extends AbstractMDX implements IPeriodsFunction
cal1.add( Calendar.DAY_OF_WEEK, 7 );
}
dayOfWeek = cal1.get( Calendar.DAY_OF_WEEK );
- if ( dayOfWeek > 1 )
+ if ( dayOfWeek == 1 )
{
- cal1.add( Calendar.DAY_OF_WEEK, 1 - dayOfWeek );
+ cal1.add( Calendar.WEEK_OF_YEAR, -Math.abs( offset ) / offset );
}
- cal1.add( Calendar.WEEK_OF_YEAR, -Math.abs( offset ) / offset );
+
}
else if ( calculateUnit.equals( MONTH ) )
{
@@ -189,6 +189,10 @@ public class TrailingFunction extends AbstractMDX implements IPeriodsFunction
fillDateTmp = getValueFromCal( cal2, levelTypes );
timeMember = new TimeMember( fillDateTmp, levelTypes );
timeMembers.add( timeMember );
+ if ( calculateUnit.equals( WEEK ) )
+ {
+ this.addExtraWeek( timeMembers, cal2, timeMember, levelTypes );
+ }
cal2Value = getValueFromCal( cal2, levelTypes );
}
diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/WeekToDateFunciton.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/WeekToDateFunciton.java
index 320bc95..0d1aafd 100644
--- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/WeekToDateFunciton.java
+++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/olap/data/impl/aggregation/function/WeekToDateFunciton.java
@@ -35,6 +35,16 @@ public class WeekToDateFunciton extends AbstractMDX implements IPeriodsFunction
cal.clear( );
String baseType = translateToCal( cal, levelTypes, values );
+ if ( isCurrent )
+ {
+ int weekDay = cal.get( Calendar.DAY_OF_WEEK );
+ while ( weekDay < 7 )
+ {
+ cal.add( Calendar.DAY_OF_YEAR, 1 );
+ weekDay = cal.get( Calendar.DAY_OF_WEEK );
+ }
+ }
+
if ( baseType.equals( WEEK ) )
{
timeMembers.add( member );
@@ -54,18 +64,6 @@ public class WeekToDateFunciton extends AbstractMDX implements IPeriodsFunction
TimeMember timeMember = new TimeMember( tmp, levelTypes );
timeMembers.add( timeMember );
}
-
- if ( isCurrent )
- {
- for ( int i = weekday + 1; i <= 7; i++ )
- {
- newCal.setTimeInMillis( cal.getTimeInMillis( )
- + ( i - weekday ) * dayTimeInMills );
- tmp = getValueFromCal( newCal, levelTypes );
- TimeMember timeMember = new TimeMember( tmp, levelTypes );
- timeMembers.add( 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 6e1a558..65a69d9 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
@@ -20,6 +20,12 @@ public class YearToDateFunction extends AbstractMDX implements IPeriodsFunction
TimeMemberUtil.getDefaultLocale( ) );
cal.clear( );
String calculateUnit = this.translateToCal( cal, levels, values ) ;
+ if ( isCurrent )
+ {
+ cal.set( Calendar.MONTH, 11 );
+ cal.set( Calendar.DAY_OF_MONTH, 31 );
+ }
+
List<TimeMember> list = new ArrayList<TimeMember>( );
if ( calculateUnit.equals( YEAR ) )
@@ -33,71 +39,29 @@ public class YearToDateFunction extends AbstractMDX implements IPeriodsFunction
TimeMember newMember = null;
for ( int i = 1; i <= quarter; i++ )
{
+ cal.set( Calendar.DAY_OF_MONTH, 1 );
cal.set( Calendar.MONTH, (i-1)*3 );
int[] newValues = getValueFromCal( cal, levels );
newMember = new TimeMember( newValues, levels );
list.add( newMember );
}
- if( isCurrent )
- {
- int year = cal.get( Calendar.YEAR );
- cal.add( Calendar.MONTH, 3 );
- while( year == cal.get( Calendar.YEAR ))
- {
- int[] newValues = getValueFromCal( cal, levels );
- newMember = new TimeMember( newValues, levels );
- list.add( newMember );
- cal.add( Calendar.MONTH, 3 );
- }
- }
}
else if ( calculateUnit.equals( MONTH ) )
{
int month = cal.get( Calendar.MONTH )+1;
TimeMember newMember = null;
- for( int i=1; i<=month ; i++)
+ for ( int i = 1; i <= month; i++ )
{
- cal.set( Calendar.MONTH, i-1 );
- int[] newValues = getValueFromCal( cal,levels);
- newMember = new TimeMember(newValues,levels);
+ cal.set( Calendar.DAY_OF_MONTH, 1 );
+ cal.set( Calendar.MONTH, i - 1 );
+ int[] newValues = getValueFromCal( cal, levels );
+ newMember = new TimeMember( newValues, levels );
list.add( newMember );
}
- if( isCurrent )
- {
- int year = cal.get( Calendar.YEAR );
- cal.add( Calendar.MONTH, 1 );
- while( year == cal.get( Calendar.YEAR ))
- {
- int[] newValues = getValueFromCal( cal, levels );
- newMember = new TimeMember( newValues, levels );
- list.add( newMember );
- cal.add( Calendar.MONTH, 1 );
- }
- }
}
else if ( calculateUnit.equals( WEEK ) )
{
- int weekOfYear = cal.get( Calendar.WEEK_OF_YEAR );
- TimeMember newMember = null;
- for ( int i = 1; i <= weekOfYear; i++ )
- {
- cal.set (Calendar.WEEK_OF_YEAR,i);
- int[] newValues = getValueFromCal( cal, levels );
- newMember = new TimeMember( newValues, levels );
- list.add( newMember );
- }
- if( isCurrent )
- {
- int year = cal.get( Calendar.YEAR );
- cal.add( Calendar.WEEK_OF_YEAR, 1 );
- while( year == cal.get( Calendar.YEAR ))
- {
- int[] newValues = getValueFromCal( cal, levels );
- newMember = new TimeMember( newValues, levels );
- list.add( newMember );
- cal.add( Calendar.WEEK_OF_YEAR, 1 );
- }
- }
+ retrieveWeek(list, cal, levels, "yearToDate");
}
else if ( calculateUnit.equals( DAY ) )
{
@@ -110,18 +74,6 @@ public class YearToDateFunction extends AbstractMDX implements IPeriodsFunction
newMember = new TimeMember( newValues, levels );
list.add( newMember );
}
- if( isCurrent )
- {
- int year = cal.get( Calendar.YEAR );
- cal.add( Calendar.DAY_OF_YEAR, 1 );
- while( year == cal.get( Calendar.YEAR ))
- {
- int[] newValues = getValueFromCal( cal, levels );
- newMember = new TimeMember( newValues, levels );
- list.add( newMember );
- cal.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/i18n/Messages.properties b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/Messages.properties
index fd66f44..6445d5c 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/Messages.properties
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/Messages.properties
@@ -84,7 +84,7 @@ timeFunction.QUARTER_TO_DATE_LAST_YEAR.name = Quarter to Date Last Year
timeFunction.QUARTER_TO_DATE_LAST_YEAR.description = Calculate the specified metric for same quarter in previous N year
timeFunction.CURRENT_YEAR.name = Current Year
timeFunction.CURRENT_YEAR.description = Calculate the specified metric for current year
-timeFunction.WEEK_TO_DATE.name = Week To Date
+timeFunction.WEEK_TO_DATE.name = Week to Date
timeFunction.WEEK_TO_DATE.description = Calculate the specified metric for same week
timeFunction.CURRENT_PERIOD_FROM_N_PERIOD_AGO.name = Current Period from N Periods Ago
timeFunction.CURRENT_PERIOD_FROM_N_PERIOD_AGO.description = Calculate the specified metric for current period from N period ago