summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpshi2011-11-20 22:09:37 (EST)
committer mwu2011-11-20 22:09:37 (EST)
commit7cfa0245d04ef46ac84f964f3dd77f69463d4e8a (patch)
tree53b31e7739f0b9cf8aae700e4776969c79e96ff2
parent4652c4a0a24970f8dad61eeff4e48b93fa2434dc (diff)
downloadorg.eclipse.birt-7cfa0245d04ef46ac84f964f3dd77f69463d4e8a.zip
org.eclipse.birt-7cfa0245d04ef46ac84f964f3dd77f69463d4e8a.tar.gz
org.eclipse.birt-7cfa0245d04ef46ac84f964f3dd77f69463d4e8a.tar.bz2
support trailing 120 days in data adapter, update the unit test
-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.java9
-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.java4
-rw-r--r--data/org.eclipse.birt.report.data.adapter/test/org/eclipse/birt/report/data/adapter/internal/script/TimeFunctionManagerTest.java8
7 files changed, 28 insertions, 4 deletions
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 db117dc..a6fe185 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
@@ -18,6 +18,7 @@ public interface IBuildInBaseTimeFunction
public static final String TRAILING_30_DAYS = "TRAILING 30 DAYS";
public static final String TRAILING_60_DAYS = "TRAILING 60 DAYS";
public static final String TRAILING_90_DAYS = "TRAILING 90 DAYS";
+ public static final String TRAILING_120_DAYS = "TRAILING 120 DAYS";
public static final String TRAILING_12_MONTHS = "TRAILING 12 MONTHS";
public static final String YEAR_TO_DATE = "YEAR TO DATE";
public static final String QUARTER_TO_DATE = "QUARTER 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 bf8468a..789fcc4 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
@@ -118,6 +118,12 @@ public class TimeFunctionHandle
local ),
Message.getMessage( ResourceConstants.TIMEFUNCITON_TRAILING_90_DAYS_DES,
local ) ) );
+ baseTimeFunctionMap.put( IBuildInBaseTimeFunction.TRAILING_120_DAYS,
+ new BaseTimeFunction( IBuildInBaseTimeFunction.TRAILING_120_DAYS,
+ Message.getMessage( ResourceConstants.TIMEFUNCITON_TRAILING_120_DAYS,
+ local ),
+ Message.getMessage( ResourceConstants.TIMEFUNCITON_TRAILING_120_DAYS_DES,
+ local ) ) );
baseTimeFunctionMap.put( IBuildInBaseTimeFunction.TRAILING_12_MONTHS,
new BaseTimeFunction( IBuildInBaseTimeFunction.TRAILING_12_MONTHS,
Message.getMessage( ResourceConstants.TIMEFUNCITON_TRAILING_12_MONTHS,
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 e0c3143..ec03cdf 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
@@ -125,7 +125,7 @@ public class TimeFunctionManager
availableFunctions.add( handle.getFunction( IBuildInBaseTimeFunction.TRAILING_30_DAYS ) );
availableFunctions.add( handle.getFunction( IBuildInBaseTimeFunction.TRAILING_60_DAYS ) );
availableFunctions.add( handle.getFunction( IBuildInBaseTimeFunction.TRAILING_90_DAYS ) );
-
+ availableFunctions.add( handle.getFunction( IBuildInBaseTimeFunction.TRAILING_120_DAYS ) );
periodType.add( IArgumentInfo.Period_Type.DAY );
}
// for WTD, only support static reference date
@@ -223,6 +223,10 @@ public class TimeFunctionManager
{
return handle.getFunction( IBuildInBaseTimeFunction.TRAILING_90_DAYS );
}
+ else if ( IBuildInBaseTimeFunction.TRAILING_120_DAYS.equals( name ) )
+ {
+ return handle.getFunction( IBuildInBaseTimeFunction.TRAILING_120_DAYS );
+ }
else if ( IBuildInBaseTimeFunction.TRAILING_12_MONTHS.equals( name ) )
{
return handle.getFunction( IBuildInBaseTimeFunction.TRAILING_12_MONTHS );
@@ -335,7 +339,8 @@ public class TimeFunctionManager
}
if ( IBuildInBaseTimeFunction.TRAILING_30_DAYS.equals( calculationType )
|| IBuildInBaseTimeFunction.TRAILING_60_DAYS.equals( calculationType )
- || IBuildInBaseTimeFunction.TRAILING_90_DAYS.equals( calculationType ) )
+ || IBuildInBaseTimeFunction.TRAILING_90_DAYS.equals( calculationType )
+ || IBuildInBaseTimeFunction.TRAILING_120_DAYS.equals( calculationType ) )
{
return new String[]{
DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_YEAR
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 06e04a8..5eb2b7f 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
@@ -61,7 +61,9 @@ timeFunction.TRAILING_30_DAYS.description = Calculate the specified metric for l
timeFunction.TRAILING_60_DAYS.name = Trailing 60 Days
timeFunction.TRAILING_60_DAYS.description = Calculate the specified metric for last 60 days
timeFunction.TRAILING_90_DAYS.name = Trailing 90 Days
+timeFunction.TRAILING_120_DAYS.name = Trailing 120 Days
timeFunction.TRAILING_90_DAYS.description = Calculate the specified metric for last 90 days
+timeFunction.TRAILING_120_DAYS.description = Calculate the specified metric for last 120 days
timeFunction.TRAILING_12_MONTHS.name = Trailing 12 Months
timeFunction.TRAILING_12_MONTHS.description = Calculate the specified metric for last 12 months
timeFunction.YEAR_TO_DATE.name = Year to Date
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 c0987fc..11f67c6 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
@@ -63,7 +63,9 @@ public class ResourceConstants
public final static String TIMEFUNCITON_TRAILING_60_DAYS ="timeFunction.TRAILING_60_DAYS.name";
public final static String TIMEFUNCITON_TRAILING_60_DAYS_DES = "timeFunction.TRAILING_60_DAYS.description";
public final static String TIMEFUNCITON_TRAILING_90_DAYS = "timeFunction.TRAILING_90_DAYS.name";
+ public final static String TIMEFUNCITON_TRAILING_120_DAYS = "timeFunction.TRAILING_120_DAYS.name";
public final static String TIMEFUNCITON_TRAILING_90_DAYS_DES ="timeFunction.TRAILING_90_DAYS.description";
+ public final static String TIMEFUNCITON_TRAILING_120_DAYS_DES ="timeFunction.TRAILING_120_DAYS.description";
public final static String TIMEFUNCITON_TRAILING_12_MONTHS = "timeFunction.TRAILING_12_MONTHS.name";
public final static String TIMEFUNCITON_TRAILING_12_MONTHS_DES ="timeFunction.TRAILING_12_MONTHS.description";
public final static String TIMEFUNCITON_YEAR_TO_DATE = "timeFunction.YEAR_TO_DATE.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 b0da96a..bb71c3c 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
@@ -503,6 +503,10 @@ public class ModelAdapter implements IModelAdapter
{
baseTimePeriod = new TimePeriod( -90, TimePeriodType.DAY );
}
+ else if ( IBuildInBaseTimeFunction.TRAILING_120_DAYS.equals( calculateType ) )
+ {
+ baseTimePeriod = new TimePeriod( -120, TimePeriodType.DAY );
+ }
else if ( IBuildInBaseTimeFunction.TRAILING_12_MONTHS.equals( calculateType ) )
{
baseTimePeriod = new TimePeriod( -12, TimePeriodType.MONTH );
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 225eec5..8786b91 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
@@ -138,9 +138,9 @@ public class TimeFunctionManagerTest extends TestCase
levelsInxTab.add( "year" );
levelsInxTab.add( "quarter" );
List<ITimeFunction> function1 = TimeFunctionManager.getCalculationTypes( cube1.getDimension( "TimeDimension" ),levelsInxTab, true );
- assertTrue( function1.size( ) ==22 );
+ assertTrue( function1.size( ) ==23 );
- ITimeFunction function = function1.get( 18 );
+ ITimeFunction function = function1.get( 19 );
assertTrue( function.getName( ).equals( "CURRENT PERIOD FROM N PERIODS AGO" ));
List<IArgumentInfo> arguments = function.getArguments( );
@@ -228,6 +228,10 @@ public class TimeFunctionManagerTest extends TestCase
timeTypes = TimeFunctionManager.getTimeType( computedHandle );
assertTrue( timeTypes[0].equals( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_YEAR ) );
+ computedHandle.setCalculationType( IBuildInBaseTimeFunction.TRAILING_120_DAYS );
+ timeTypes = TimeFunctionManager.getTimeType( computedHandle );
+ assertTrue( timeTypes[0].equals( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_DAY_OF_YEAR ) );
+
computedHandle.setCalculationType( IBuildInBaseTimeFunction.TRAILING_12_MONTHS );
timeTypes = TimeFunctionManager.getTimeType( computedHandle );
assertTrue( timeTypes[0].equals( DesignChoiceConstants.DATE_TIME_LEVEL_TYPE_MONTH ) );