← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9613: Added method PeriodService.getPeriod(String isoPeriod). Fixed issue with analytics table service.

 

------------------------------------------------------------
revno: 9613
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-01-25 18:38:21 +0200
message:
  Added method PeriodService.getPeriod(String isoPeriod). Fixed issue with analytics table service.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.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/PeriodService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java	2012-09-23 14:24:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java	2013-01-25 16:38:21 +0000
@@ -71,6 +71,14 @@
     Period getPeriod( int id );
 
     /**
+     * Gets the Period with the given ISO period identifier.
+     * 
+     * @param isoPeriod the ISO period identifier.
+     * @return the Period with the given ISO period identifier.
+     */
+    Period getPeriod( String isoPeriod );
+    
+    /**
      * Returns a Period.
      * 
      * @param startDate the start date of the Period.

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java	2013-01-25 10:33:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java	2013-01-25 16:38:21 +0000
@@ -84,7 +84,7 @@
         final Date latest = tableManager.getLatestData();
         final String tableName = tableManager.getTableName();
         final List<String> tables = PartitionUtils.getTempTableNames( earliest, latest, tableName );        
-        clock.logTime( "Checked data timespan and got tables: " + tables );
+        clock.logTime( "Got partition tables: " + tables + ", earliest: " + earliest + ", latest: " + latest );
         
         //dropTables( tables );
         

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2013-01-25 10:33:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2013-01-25 16:38:21 +0000
@@ -211,7 +211,7 @@
 
     public Date getLatestData()
     {
-        final String sql = "select max(pe.startdate) from datavalue dv " +
+        final String sql = "select max(pe.enddate) from datavalue dv " +
             "join period pe on dv.periodid=pe.periodid";
         
         return jdbcTemplate.queryForObject( sql, Date.class );

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java	2013-01-25 10:33:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTableManager.java	2013-01-25 16:38:21 +0000
@@ -160,7 +160,7 @@
 
     public Date getLatestData()
     {
-        final String sql = "select max(pe.startdate) from completedatasetregistration cdr " +
+        final String sql = "select max(pe.enddate) from completedatasetregistration cdr " +
             "join period pe on cdr.periodid=pe.periodid";
         
         return jdbcTemplate.queryForObject( sql, Date.class );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java	2012-12-13 12:48:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java	2013-01-25 16:38:21 +0000
@@ -83,6 +83,18 @@
     {
         return periodStore.get( id );
     }
+    
+    public Period getPeriod( String isoPeriod )
+    {
+        Period period = PeriodType.getPeriodFromIsoString( isoPeriod );
+        
+        if ( period != null )
+        {        
+            period = periodStore.getPeriod( period.getStartDate(), period.getEndDate(), period.getPeriodType() );
+        }
+        
+        return period;
+    }
 
     public Period getPeriod( Date startDate, Date endDate, PeriodType periodType )
     {