dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37925
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19369: Added simple method to retrieve ISO8601 duration string from period types
------------------------------------------------------------
revno: 19369
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-06-11 20:52:58 +0100
message:
Added simple method to retrieve ISO8601 duration string from period types
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryComboMap.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.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/dataelement/CategoryComboMap.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryComboMap.java 2015-03-23 09:24:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryComboMap.java 2015-06-11 19:52:58 +0000
@@ -162,4 +162,9 @@
return key;
}
+
+ public String toString()
+ {
+ return "CatComboMap: catcombo=" + categoryCombo.getName() + " map:" + ccMap.toString();
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java 2015-04-08 22:57:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java 2015-06-11 19:52:58 +0000
@@ -42,6 +42,8 @@
extends CalendarPeriodType
{
private static final String ISO_FORMAT = "yyyyMMB";
+
+ private static final String ISO8601_DURATION = "P2M";
/**
* The name of the BiMonthlyPeriodType, which is "BiMonthly".
@@ -176,4 +178,9 @@
return cal.toIso( dateTimeUnit ).toJdkDate();
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java 2015-06-11 19:52:58 +0000
@@ -50,6 +50,8 @@
private static final long serialVersionUID = 5371766471215556241L;
public static final String ISO_FORMAT = "yyyyMMdd";
+
+ private static final String ISO8601_DURATION = "P1D";
/**
* The name of the DailyPeriodType, which is "Daily".
@@ -164,6 +166,12 @@
{
return ISO_FORMAT;
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
@Override
public Date getRewindedDate( Date date, Integer rewindedPeriods )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java 2015-06-11 19:52:58 +0000
@@ -44,6 +44,8 @@
private static final long serialVersionUID = 8790198046182231889L;
private static final String ISO_FORMAT = "yyyyApril";
+
+ private static final String ISO8601_DURATION = "P1Y";
public static final String NAME = "FinancialApril";
@@ -70,4 +72,10 @@
{
return ISO_FORMAT;
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java 2015-06-11 19:52:58 +0000
@@ -44,6 +44,8 @@
private static final long serialVersionUID = 5190072405972068226L;
private static final String ISO_FORMAT = "yyyyJuly";
+
+ private static final String ISO8601_DURATION = "P1Y";
public static final String NAME = "FinancialJuly";
@@ -70,4 +72,10 @@
{
return ISO_FORMAT;
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java 2015-06-11 19:52:58 +0000
@@ -44,6 +44,8 @@
private static final long serialVersionUID = -1623576547899897811L;
private static final String ISO_FORMAT = "yyyyOct";
+
+ private static final String ISO8601_DURATION = "P1Y";
public static final String NAME = "FinancialOct";
@@ -70,4 +72,10 @@
{
return ISO_FORMAT;
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2015-06-11 19:52:58 +0000
@@ -52,6 +52,8 @@
private static final long serialVersionUID = -6920058214699654387L;
private static final String ISO_FORMAT = "yyyyMM";
+
+ private static final String ISO8601_DURATION = "P1M";
/**
* The name of the MonthlyPeriodType, which is "Monthly".
@@ -171,6 +173,12 @@
}
@Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
+
+ @Override
public Date getRewindedDate( Date date, Integer rewindedPeriods )
{
Calendar cal = getCalendar();
=== 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 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2015-06-11 19:52:58 +0000
@@ -315,6 +315,8 @@
{
return toIsoPeriod( dateTimeUnit, dateTimeUnit );
}
+
+ public abstract String getIso8601Duration();
public abstract Period createPeriod( DateTimeUnit dateTimeUnit, org.hisp.dhis.calendar.Calendar calendar );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2015-04-08 22:57:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2015-06-11 19:52:58 +0000
@@ -52,6 +52,8 @@
private static final long serialVersionUID = -5973809094923012052L;
private static final String ISO_FORMAT = "yyyyQn";
+
+ private static final String ISO8601_DURATION = "P1Q";
/**
* The name of the QuarterlyPeriodType, which is "Quarterly".
@@ -195,6 +197,12 @@
{
return ISO_FORMAT;
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
public enum Quarter
{
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java 2015-05-26 21:09:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java 2015-06-11 19:52:58 +0000
@@ -48,6 +48,8 @@
private static final String ISO_FORMAT = "yyyyAprilSn";
+ private static final String ISO8601_DURATION = "P6M";
+
private static final int BASE_MONTH = DateTimeConstants.APRIL;
/**
@@ -104,4 +106,10 @@
{
return ISO_FORMAT;
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java 2015-05-26 21:09:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java 2015-06-11 19:52:58 +0000
@@ -49,6 +49,8 @@
private static final String ISO_FORMAT = "yyyySn";
+ private static final String ISO8601_DURATION = "P6M";
+
private static final int BASE_MONTH = DateTimeConstants.JANUARY;
/**
@@ -105,4 +107,10 @@
{
return ISO_FORMAT;
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java 2015-06-11 19:52:58 +0000
@@ -55,6 +55,8 @@
* The name of the TwoYearlyPeriodType, which is "TwoYearly".
*/
public static final String NAME = "TwoYearly";
+
+ private static final String ISO8601_DURATION = "P2Y";
public static final int FREQUENCY_ORDER = 730;
@@ -214,6 +216,12 @@
{
return null; // TODO
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
@Override
public Date getRewindedDate( Date date, Integer rewindedPeriods )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java 2015-06-11 19:52:58 +0000
@@ -56,6 +56,8 @@
private static final String ISO_FORMAT = "yyyyWn";
+ private static final String ISO8601_DURATION = "P7D";
+
/**
* The name of the WeeklyPeriodType, which is "Weekly".
*/
@@ -187,6 +189,12 @@
{
return ISO_FORMAT;
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
@Override
public Date getRewindedDate( Date date, Integer rewindedPeriods )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java 2015-06-11 19:52:58 +0000
@@ -52,6 +52,8 @@
private static final long serialVersionUID = 3893035414025085437L;
private static final String ISO_FORMAT = "yyyy";
+
+ private static final String ISO8601_DURATION = "P1Y";
/**
* The name of the YearlyPeriodType, which is "Yearly".
@@ -188,6 +190,12 @@
{
return ISO_FORMAT;
}
+
+ @Override
+ public String getIso8601Duration() {
+ return ISO8601_DURATION;
+ }
+
@Override
public Date getRewindedDate( Date date, Integer rewindedPeriods )