dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30025
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15226: use PERIOD_TYPE_MAP instead of creating new instances in PeriodType.getPeriodTypeFromIsoString
------------------------------------------------------------
revno: 15226
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-05-12 14:33:49 +0200
message:
use PERIOD_TYPE_MAP instead of creating new instances in PeriodType.getPeriodTypeFromIsoString
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2014-04-29 04:43:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2014-05-12 12:33:49 +0000
@@ -273,47 +273,47 @@
{
if ( isoPeriod.matches( "\\b\\d{4}\\b" ) )
{
- return new YearlyPeriodType();
+ return PERIOD_TYPE_MAP.get( YearlyPeriodType.NAME );
}
if ( isoPeriod.matches( "\\b\\d{4}[-]?\\d{2}\\b" ) )
{
- return new MonthlyPeriodType();
+ return PERIOD_TYPE_MAP.get( MonthlyPeriodType.NAME );
}
if ( isoPeriod.matches( "\\b\\d{4}W\\d[\\d]?\\b" ) )
{
- return new WeeklyPeriodType();
+ return PERIOD_TYPE_MAP.get( WeeklyPeriodType.NAME );
}
if ( isoPeriod.matches( "\\b\\d{8}\\b" ) )
{
- return new DailyPeriodType();
+ return PERIOD_TYPE_MAP.get( DailyPeriodType.NAME );
}
if ( isoPeriod.matches( "\\b\\d{4}Q\\d\\b" ) )
{
- return new QuarterlyPeriodType();
+ return PERIOD_TYPE_MAP.get( QuarterlyPeriodType.NAME );
}
if ( isoPeriod.matches( "\\b\\d{4}S\\d\\b" ) )
{
- return new SixMonthlyPeriodType();
+ return PERIOD_TYPE_MAP.get( SixMonthlyPeriodType.NAME );
}
if ( isoPeriod.matches( "\\b\\d{4}AprilS\\d\\b" ) )
{
- return new SixMonthlyAprilPeriodType();
+ return PERIOD_TYPE_MAP.get( SixMonthlyAprilPeriodType.NAME );
}
if ( isoPeriod.matches( "\\b\\d{6}B\\b" ) )
{
- return new BiMonthlyPeriodType();
+ return PERIOD_TYPE_MAP.get( BiMonthlyPeriodType.NAME );
}
if ( isoPeriod.matches( "\\b\\d{4}April\\b" ) )
{
- return new FinancialAprilPeriodType();
+ return PERIOD_TYPE_MAP.get( FinancialAprilPeriodType.NAME );
}
if ( isoPeriod.matches( "\\b\\d{4}July\\b" ) )
{
- return new FinancialJulyPeriodType();
+ return PERIOD_TYPE_MAP.get( FinancialJulyPeriodType.NAME );
}
if ( isoPeriod.matches( "\\b\\d{4}Oct\\b" ) )
{
- return new FinancialOctoberPeriodType();
+ return PERIOD_TYPE_MAP.get( FinancialOctoberPeriodType.NAME );
}
return null;