← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15719: Analytics, setting min earliest date for tables to year 1800 and max latest to 2100.

 

------------------------------------------------------------
revno: 15719
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-06-17 13:09:06 +0200
message:
  Analytics, setting min earliest date for tables to year 1800 and max latest to 2100.
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.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-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java	2014-05-04 12:21:18 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java	2014-06-17 11:09:06 +0000
@@ -68,6 +68,9 @@
     public static final String PREFIX_ORGUNITLEVEL = "uidlevel";
     public static final String PREFIX_INDEX = "in_";
     
+    private static Date MIN_EARLIEST_DATE = new Cal().set( 1800, 1, 1 ).time();
+    private static Date MAX_LATEST_DATE = new Cal().set( 2100, 1, 1 ).time();
+    
     @Autowired
     protected OrganisationUnitService organisationUnitService;
     
@@ -124,7 +127,12 @@
             earliest = getEarliestData();
         }
         
-        return getTables( earliest, getLatestData() );
+        Date latest = getLatestData();
+        
+        earliest = earliest.before( MIN_EARLIEST_DATE ) ? MIN_EARLIEST_DATE : earliest;
+        latest = latest.after( MAX_LATEST_DATE ) ? MAX_LATEST_DATE : latest;
+        
+        return getTables( earliest, latest );
     }
 
     @Transactional