=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java 2014-08-05 11:19:29 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java 2014-08-24 17:53:31 +0000 @@ -77,6 +77,11 @@ * Required. Must be unique together with startDate. */ private Date endDate; + + /** + * Transient string holding the ISO representation of the period. + */ + private transient String isoPeriod; // ------------------------------------------------------------------------- // Constructors @@ -93,6 +98,7 @@ this.startDate = period.getStartDate(); this.endDate = period.getEndDate(); this.name = period.getName(); + this.isoPeriod = period.getIsoDate(); } protected Period( PeriodType periodType, Date startDate, Date endDate ) @@ -102,6 +108,14 @@ this.endDate = endDate; } + protected Period( PeriodType periodType, Date startDate, Date endDate, String isoPeriod ) + { + this.periodType = periodType; + this.startDate = startDate; + this.endDate = endDate; + this.isoPeriod = isoPeriod; + } + // ------------------------------------------------------------------------- // Logic // ------------------------------------------------------------------------- @@ -131,13 +145,13 @@ } /** - * Returns an ISO8601 formatted string version of the period + * Returns an ISO8601 formatted string version of the period. * * @return the period string */ public String getIsoDate() { - return periodType.getIsoDate( this ); + return isoPeriod != null ? isoPeriod : periodType.getIsoDate( this ); } /** === 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-08-24 17:10:16 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2014-08-24 17:53:31 +0000 @@ -29,6 +29,7 @@ */ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; + import org.hisp.dhis.calendar.CalendarService; import org.hisp.dhis.calendar.DateInterval; import org.hisp.dhis.calendar.DateUnit; @@ -37,6 +38,7 @@ import org.hisp.dhis.calendar.PeriodTypeParser; import org.hisp.dhis.calendar.impl.Iso8601Calendar; import org.hisp.dhis.common.DxfNamespaces; +import org.hisp.dhis.common.Timer; import java.io.Serializable; import java.util.ArrayList; @@ -241,8 +243,10 @@ * @return the valid Period based on the given date */ public Period createPeriod( Date date, org.hisp.dhis.calendar.Calendar calendar ) - { - return createPeriod( calendar.fromIso( DateUnit.fromJdkDate( date ) ), calendar ); + { + DateUnit unit = DateUnit.fromJdkDate( date ); + + return createPeriod( calendar.fromIso( unit ), calendar ); } public Period toIsoPeriod( DateUnit start, DateUnit end ) @@ -254,7 +258,10 @@ protected Period toIsoPeriod( DateUnit start, DateUnit end, org.hisp.dhis.calendar.Calendar calendar ) { - return new Period( this, calendar.toIso( start ).toJdkDate(), calendar.toIso( end ).toJdkDate() ); + DateUnit from = calendar.toIso( start ); + DateUnit to = calendar.toIso( end ); + + return new Period( this, from.toJdkDate(), to.toJdkDate(), getIsoDate( from ) ); } public Period toIsoPeriod( DateUnit dateUnit ) @@ -424,7 +431,7 @@ final DateUnit from = cal.toIso( dateInterval.getFrom() ); final DateUnit to = cal.toIso( dateInterval.getTo() ); - return new Period( this, from.toJdkDate(), to.toJdkDate() ); + return new Period( this, from.toJdkDate(), to.toJdkDate(), getIsoDate( from ) ); } /** @@ -437,7 +444,7 @@ { return getIsoDate( createLocalDateUnitInstance( period.getStartDate() ) ); } - + /** * Returns an iso8601 formatted string representation of the dataUnit * === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java 2014-08-24 15:24:33 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java 2014-08-24 17:53:31 +0000 @@ -41,6 +41,7 @@ import org.amplecode.staxwax.factory.XMLFactory; import org.hisp.dhis.calendar.Calendar; +import org.hisp.dhis.common.Timer; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dxf2.datavalue.DataValue; @@ -142,7 +143,7 @@ DataValue dataValue = dataValueSet.getDataValueInstance(); String periodType = rowSet.getString( "ptname" ); - Date startDate = rowSet.getDate( "pestart" ); + Date startDate = rowSet.getDate( "pestart" ); Period isoPeriod = PeriodType.getPeriodTypeByName( periodType ).createPeriod( startDate, calendar ); dataValue.setDataElement( rowSet.getString( "deuid" ) );