summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpshi2011-11-24 01:53:39 (EST)
committer mwu2011-11-24 01:53:39 (EST)
commit0faa1b1d413d21c592bcd9c8bb42725870b12e2e (patch)
treeaf07e6ed97af9cf8afdae68dd4bba8276909fa46
parent571038c7543030939b6cdb94eb2b04e46b6b1550 (diff)
downloadorg.eclipse.birt-0faa1b1d413d21c592bcd9c8bb42725870b12e2e.zip
org.eclipse.birt-0faa1b1d413d21c592bcd9c8bb42725870b12e2e.tar.gz
org.eclipse.birt-0faa1b1d413d21c592bcd9c8bb42725870b12e2e.tar.bz2
support week to date last year, update unit test
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/BaseTimeFunction.java7
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/IBuildInBaseTimeFunction.java1
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionHandle.java6
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java16
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/Messages.properties2
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/ResourceConstants.java2
-rw-r--r--data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/ModelAdapter.java7
-rw-r--r--data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java4
8 files changed, 38 insertions, 7 deletions
diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/BaseTimeFunction.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/BaseTimeFunction.java
index f6e5827..aebeb93 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/BaseTimeFunction.java
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/BaseTimeFunction.java
@@ -106,6 +106,13 @@ public class BaseTimeFunction implements ITimeFunction
Message.getMessage( ResourceConstants.TIMEFUNCITON_N1 ),
true ) );
}
+ else if ( this.name.equals( IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR ) )
+ {
+ arguments.add( new ArgumentInfo( IArgumentInfo.N_PERIOD1,
+ Message.getMessage( ResourceConstants.TIMEFUNCITON_N1_DISPLAYNAME ),
+ Message.getMessage( ResourceConstants.TIMEFUNCITON_N1 ),
+ true ) );
+ }
else
if( this.name.equals( IBuildInBaseTimeFunction.MONTH_TO_DATE_LAST_YEAR ) )
{
diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/IBuildInBaseTimeFunction.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/IBuildInBaseTimeFunction.java
index d37350f..5662ab8 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/IBuildInBaseTimeFunction.java
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/IBuildInBaseTimeFunction.java
@@ -29,6 +29,7 @@ public interface IBuildInBaseTimeFunction
public static final String PREVIOUS_MONTH = "PREVIOUS MONTH";
public static final String PREVIOUS_QUARTER = "PREVIOUS QUARTER";
public static final String PREVIOUS_YEAR = "PREVIOUS YEAR";
+ public static final String WEEK_TO_DATE_LAST_YEAR = "WEEK TO DATE LAST YEAR";
public static final String MONTH_TO_DATE_LAST_YEAR = "MONTH TO DATE LAST YEAR";
public static final String QUARTER_TO_DATE_LAST_YEAR = "QUARTER TO DATE LAST YEAR";
public static final String PREVIOUS_WEEK_TO_DATE = "PREVIOUS WEEK TO DATE";
diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionHandle.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionHandle.java
index 1e32725..3f52830 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionHandle.java
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionHandle.java
@@ -160,6 +160,12 @@ public class TimeFunctionHandle
local ),
Message.getMessage( ResourceConstants.TIMEFUNCITON_PREVIOUS_YEAR_TO_DATE_DES,
local ) ) );
+ baseTimeFunctionMap.put( IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR,
+ new BaseTimeFunction( IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR,
+ Message.getMessage( ResourceConstants.TIMEFUNCITON_WEEK_TO_DATE_LAST_YEAR,
+ local ),
+ Message.getMessage( ResourceConstants.TIMEFUNCITON_WEEK_TO_DATE_LAST_YEAR_DES,
+ local ) ) );
baseTimeFunctionMap.put( IBuildInBaseTimeFunction.MONTH_TO_DATE_LAST_YEAR,
new BaseTimeFunction( IBuildInBaseTimeFunction.MONTH_TO_DATE_LAST_YEAR,
Message.getMessage( ResourceConstants.TIMEFUNCITON_MONTH_TO_DATE_LAST_YEAR,
diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java
index 2d642f6..4492491 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/timeFunction/TimeFunctionManager.java
@@ -149,12 +149,12 @@ public class TimeFunctionManager
periodType.add( IArgumentInfo.Period_Type.DAY );
}
// for WTD, only support static reference date
- if ( timeLevelsInXtab.isEmpty()
- && (timeType.contains( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_WEEK_OF_YEAR )
- || timeType.contains( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_YEAR )))
+ if ( timeLevelsInXtab.isEmpty( )
+ && ( timeType.contains( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_WEEK_OF_YEAR ) ) )
{
availableFunctions.add( handle.getFunction( IBuildInBaseTimeFunction.WEEK_TO_DATE ) );
availableFunctions.add( handle.getFunction( IBuildInBaseTimeFunction.PREVIOUS_WEEK_TO_DATE ) );
+ availableFunctions.add( handle.getFunction( IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR) );
periodType.add( IArgumentInfo.Period_Type.WEEK );
}
@@ -278,6 +278,10 @@ public class TimeFunctionManager
{
return handle.getFunction( IBuildInBaseTimeFunction.MONTH_TO_DATE_LAST_YEAR );
}
+ else if ( IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR.equals( name ) )
+ {
+ return handle.getFunction( IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR );
+ }
else if ( IBuildInBaseTimeFunction.QUARTER_TO_DATE_LAST_YEAR.equals( name ) )
{
return handle.getFunction( IBuildInBaseTimeFunction.QUARTER_TO_DATE_LAST_YEAR );
@@ -373,14 +377,14 @@ public class TimeFunctionManager
DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_YEAR
};
}
- if ( IBuildInBaseTimeFunction.WEEK_TO_DATE.equals( calculationType )
- || IBuildInBaseTimeFunction.PREVIOUS_WEEK_TO_DATE.equals( calculationType ))
+ if ( IBuildInBaseTimeFunction.WEEK_TO_DATE.equals( calculationType )
+ || IBuildInBaseTimeFunction.PREVIOUS_WEEK_TO_DATE.equals( calculationType )
+ || IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR.equals( calculationType ) )
{
return new String[]{
DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_WEEK_OF_YEAR
};
}
-
if( IBuildInBaseTimeFunction.CURRENT_PERIOD_FROM_N_PERIOD_AGO.equals( calculationType ) )
{
Iterator iter = handle.calculationArgumentsIterator( );
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 3727b6d..516c2ad 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
@@ -76,6 +76,8 @@ timeFunction.MONTH_TO_DATE.name = Month to Date
timeFunction.MONTH_TO_DATE.description = Calculate the specified metric for same month
timeFunction.PREVIOUS_YEAR_TO_DATE.name = Previous Year to Date
timeFunction.PREVIOUS_YEAR_TO_DATE.description = Calculate the specified metric for same year in previous N year
+timeFunction.WEEK_TO_DATE_LAST_YEAR.name = Week to Date Last Year
+timeFunction.WEEK_TO_DATE_LAST_YEAR.description = Calculate the specified metric for same week in previous N year
timeFunction.MONTH_TO_DATE_LAST_YEAR.name = Month to Date Last Year
timeFunction.MONTH_TO_DATE_LAST_YEAR.description = Calculate the specified metric for same month in previous N year
timeFunction.QUARTER_TO_DATE_LAST_YEAR.name = Quarter to Date Last Year
diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/ResourceConstants.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/ResourceConstants.java
index 33f0681..abd5eda 100644
--- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/ResourceConstants.java
+++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/i18n/ResourceConstants.java
@@ -78,6 +78,8 @@ public class ResourceConstants
public final static String TIMEFUNCITON_MONTH_TO_DATE_DES = "timeFunction.MONTH_TO_DATE.description";
public final static String TIMEFUNCITON_PREVIOUS_YEAR_TO_DATE = "timeFunction.PREVIOUS_YEAR_TO_DATE.name";
public final static String TIMEFUNCITON_PREVIOUS_YEAR_TO_DATE_DES ="timeFunction.PREVIOUS_YEAR_TO_DATE.description";
+ public final static String TIMEFUNCITON_WEEK_TO_DATE_LAST_YEAR = "timeFunction.WEEK_TO_DATE_LAST_YEAR.name";
+ public final static String TIMEFUNCITON_WEEK_TO_DATE_LAST_YEAR_DES = "timeFunction.WEEK_TO_DATE_LAST_YEAR.description";
public final static String TIMEFUNCITON_MONTH_TO_DATE_LAST_YEAR = "timeFunction.MONTH_TO_DATE_LAST_YEAR.name";
public final static String TIMEFUNCITON_MONTH_TO_DATE_LAST_YEAR_DES = "timeFunction.MONTH_TO_DATE_LAST_YEAR.description";
public final static String TIMEFUNCITON_QUARTER_TO_DATE_LAST_YEAR = "timeFunction.QUARTER_TO_DATE_LAST_YEAR.name";
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 3c24207..7043f43 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
@@ -531,6 +531,10 @@ public class ModelAdapter implements IModelAdapter
{
baseTimePeriod = new TimePeriod( 0, TimePeriodType.WEEK );
}
+ else if ( IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR.equals( calculateType ) )
+ {
+ baseTimePeriod = new TimePeriod( 0, TimePeriodType.WEEK );
+ }
else if ( IBuildInBaseTimeFunction.MONTH_TO_DATE_LAST_YEAR.equals( calculateType ) )
{
baseTimePeriod = new TimePeriod( 0, TimePeriodType.MONTH );
@@ -633,7 +637,8 @@ public class ModelAdapter implements IModelAdapter
String calculateType = periodHandle.getCalculationType( );
TimePeriod relativeTimePeriod = null;
- if ( IBuildInBaseTimeFunction.MONTH_TO_DATE_LAST_YEAR.equals( calculateType )
+ if ( IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR.equals( calculateType )
+ || IBuildInBaseTimeFunction.MONTH_TO_DATE_LAST_YEAR.equals( calculateType )
|| IBuildInBaseTimeFunction.QUARTER_TO_DATE_LAST_YEAR.equals( calculateType ) )
{
Iterator iter = periodHandle.calculationArgumentsIterator( );
diff --git a/data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java b/data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java
index 4068c4f..e01042d 100644
--- a/data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java
+++ b/data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java
@@ -270,6 +270,10 @@ public class TimeFunctionManagerTest extends TestCase
timeTypes = TimeFunctionManager.getTimeType( computedHandle );
assertTrue( timeTypes[0].equals( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_YEAR ) );
+ computedHandle.setCalculationType( IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR );
+ timeTypes = TimeFunctionManager.getTimeType( computedHandle );
+ assertTrue( timeTypes[0].equals( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_WEEK_OF_YEAR ) );
+
computedHandle.setCalculationType( IBuildInBaseTimeFunction.MONTH_TO_DATE_LAST_YEAR );
timeTypes = TimeFunctionManager.getTimeType( computedHandle );
assertTrue( timeTypes[0].equals( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_MONTH ) );