dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24014
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11718: Centralized code
------------------------------------------------------------
revno: 11718
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-08-20 16:15:42 +0200
message:
Centralized code
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java
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/DefaultAnalyticsTableService.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/AnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java 2013-05-07 08:37:33 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java 2013-08-20 14:15:42 +0000
@@ -44,6 +44,11 @@
public static final String COMPLETENESS_TARGET_TABLE_NAME = "completenesstarget";
/**
+ * Returns table names.
+ */
+ List<String> getTables( boolean last3YearsOnly );
+
+ /**
* Checks if the database content is in valid state for analytics table generation.
*/
boolean validState();
=== 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 2013-05-24 14:48:40 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java 2013-08-20 14:15:42 +0000
@@ -28,6 +28,8 @@
*/
import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Future;
@@ -42,6 +44,7 @@
import org.hisp.dhis.jdbc.StatementBuilder;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Cal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -81,6 +84,17 @@
// Implementation
// -------------------------------------------------------------------------
+ public List<String> getTables( boolean last3YearsOnly )
+ {
+ Date threeYrsAgo = new Cal().subtract( Calendar.YEAR, 2 ).set( 1, 1 ).time();
+ Date earliest = last3YearsOnly ? threeYrsAgo : getEarliestData();
+ Date latest = getLatestData();
+ String tableName = getTableName();
+ List<String> tables = PartitionUtils.getTempTableNames( earliest, latest, tableName );
+
+ return tables;
+ }
+
public String getTempTableName()
{
return getTableName() + TABLE_TEMP_SUFFIX;
=== 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-05-07 08:37:33 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java 2013-08-20 14:15:42 +0000
@@ -28,9 +28,7 @@
*/
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Collection;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -92,13 +90,9 @@
return;
}
- final Date threeYrsAgo = new Cal().subtract( Calendar.YEAR, 2 ).set( 1, 1 ).time();
- final Date earliest = last3YearsOnly ? threeYrsAgo : tableManager.getEarliestData();
- final Date latest = tableManager.getLatestData();
- final String tableName = tableManager.getTableName();
- final List<String> tables = PartitionUtils.getTempTableNames( earliest, latest, tableName );
+ final List<String> tables = tableManager.getTables( last3YearsOnly );
- clock.logTime( "Partition tables: " + tables + ", earliest: " + earliest + ", latest: " + latest + ", last 3 years: " + last3YearsOnly );
+ clock.logTime( "Partition tables: " + tables + ", last 3 years: " + last3YearsOnly );
notifier.notify( taskId, "Creating analytics tables" );