dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35296
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18118: Analytics tables. Fixed clean tables function.
------------------------------------------------------------
revno: 18118
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-01-23 18:23:01 +0100
message:
Analytics tables. Fixed clean tables function.
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
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
--
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 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java 2015-01-23 17:23:01 +0000
@@ -47,7 +47,7 @@
public static final String EVENT_ANALYTICS_TABLE_NAME = "analytics_event";
/**
- * Returns analytics tables which yearly partitions.
+ * Returns analytics tables which are yearly partitions.
*
* @param earliest the start date for the first year to generate table partitions.
* @param latest the end date for the last year to generate table partitions.
@@ -55,6 +55,11 @@
List<AnalyticsTable> getTables( Date earliest );
/**
+ * Returns all potential analytics tables which are yearly partitions.
+ */
+ List<AnalyticsTable> getAllTables();
+
+ /**
* Checks if the database content is in valid state for analytics table generation.
* Returns null if valid, a descriptive string if invalid.
*/
=== 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 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java 2015-01-23 17:23:01 +0000
@@ -123,10 +123,20 @@
{
log.info( "Get tables using earliest: " + earliest );
+ return getTables( getDataYears( earliest ) );
+ }
+
+ @Override
+ @Transactional
+ public List<AnalyticsTable> getAllTables()
+ {
+ return getTables( ListUtils.getClosedOpenList( 1500, 2100 ) );
+ }
+
+ private List<AnalyticsTable> getTables( List<Integer> dataYears )
+ {
List<AnalyticsTable> tables = new ArrayList<>();
- List<Integer> dataYears = getDataYears( earliest );
-
Collections.sort( dataYears );
String baseName = getTableName();
=== 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 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java 2015-01-23 17:23:01 +0000
@@ -157,7 +157,7 @@
@Override
public void dropTables()
{
- List<AnalyticsTable> tables = tableManager.getTables( null );
+ List<AnalyticsTable> tables = tableManager.getAllTables();
for ( AnalyticsTable table : tables )
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java 2015-01-23 17:23:01 +0000
@@ -57,6 +57,12 @@
}
@Override
+ public List<AnalyticsTable> getAllTables()
+ {
+ return getTables( null );
+ }
+
+ @Override
public String validState()
{
return null;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java 2015-01-23 17:23:01 +0000
@@ -48,6 +48,7 @@
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.system.util.DateUtils;
+import org.hisp.dhis.system.util.ListUtils;
import org.hisp.dhis.system.util.MathUtils;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.springframework.beans.factory.annotation.Autowired;
@@ -73,10 +74,20 @@
{
log.info( "Get tables using earliest: " + earliest );
+ return getTables( getDataYears( earliest ) );
+ }
+
+ @Override
+ @Transactional
+ public List<AnalyticsTable> getAllTables()
+ {
+ return getTables( ListUtils.getClosedOpenList( 1500, 2100 ) );
+ }
+
+ private List<AnalyticsTable> getTables( List<Integer> dataYears )
+ {
List<AnalyticsTable> tables = new ArrayList<>();
- List<Integer> dataYears = getDataYears( earliest );
-
Collections.sort( dataYears );
String baseName = getTableName();
@@ -100,7 +111,7 @@
return tables;
}
-
+
@Override
public String validState()
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java 2015-01-23 17:23:01 +0000
@@ -56,6 +56,12 @@
}
@Override
+ public List<AnalyticsTable> getAllTables()
+ {
+ return getTables( null );
+ }
+
+ @Override
public String validState()
{
return null;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java 2015-01-23 17:23:01 +0000
@@ -57,7 +57,7 @@
public static Period getPeriod( Integer year )
{
- DateTime time = new DateTime( year, 1, 1, 0, 0 );
+ DateTime time = new DateTime( year, 1, 1, 1, 1 );
return PERIODTYPE.createPeriod( time.toDate() );
}
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListUtils.java 2015-01-23 17:23:01 +0000
@@ -290,4 +290,24 @@
return union;
}
+
+ /**
+ * Returns a contiguous list of Integers starting on and including a, ending
+ * on and excluding b.
+ *
+ * @param a start, inclusive.
+ * @param b end, exclusive.
+ * @return a list of Integers.
+ */
+ public static List<Integer> getClosedOpenList( int a, int b )
+ {
+ List<Integer> list = new ArrayList<Integer>();
+
+ for ( int i = a; i < b; i++ )
+ {
+ list.add( i );
+ }
+
+ return list;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java 2015-01-23 17:23:01 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.datamart.DataMartManager;
import org.hisp.dhis.maintenance.MaintenanceService;
+import org.hisp.dhis.resourcetable.ResourceTableService;
import org.hisp.dhis.user.CurrentUserService;
import com.opensymphony.xwork2.Action;
@@ -63,10 +64,20 @@
@Resource(name="org.hisp.dhis.analytics.CompletenessTargetTableService")
private AnalyticsTableService completenessTargetTableService;
+
+ @Resource(name="org.hisp.dhis.analytics.OrgUnitTargetTableService")
+ private AnalyticsTableService orgUnitTargetTableService;
@Resource(name="org.hisp.dhis.analytics.EventAnalyticsTableService")
private AnalyticsTableService eventAnalyticsTableService;
+ private ResourceTableService resourceTableService;
+
+ public void setResourceTableService( ResourceTableService resourceTableService )
+ {
+ this.resourceTableService = resourceTableService;
+ }
+
private MaintenanceService maintenanceService;
public void setMaintenanceService( MaintenanceService maintenanceService )
@@ -181,10 +192,14 @@
if ( clearAnalytics )
{
+ resourceTableService.dropAllSqlViews();
analyticsTableService.dropTables();
completenessTableService.dropTables();
completenessTargetTableService.dropTables();
+ orgUnitTargetTableService.dropTables();
eventAnalyticsTableService.dropTables();
+
+ log.info( "'" + username + "': Cleared analytics tables" );
}
if ( clearDataMart )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2014-12-04 06:39:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2015-01-23 17:23:01 +0000
@@ -8,6 +8,7 @@
<bean id="org.hisp.dhis.dataadmin.action.maintenance.PerformMaintenanceAction"
class="org.hisp.dhis.dataadmin.action.maintenance.PerformMaintenanceAction"
scope="prototype">
+ <property name="resourceTableService" ref="org.hisp.dhis.resourcetable.ResourceTableService" />
<property name="maintenanceService" ref="org.hisp.dhis.maintenance.MaintenanceService" />
<property name="completenessService" ref="compulsoryDataCompletenessService" />
<property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />