dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22233
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10658: Impl function for dropping all analytics tables
------------------------------------------------------------
revno: 10658
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-04-22 10:10:07 +0200
message:
Impl function for dropping all analytics tables
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableService.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-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/org/hisp/dhis/dataadmin/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/maintenance.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/maintenanceForm.vm
--
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/AnalyticsTableService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableService.java 2013-03-05 22:03:40 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableService.java 2013-04-22 08:10:07 +0000
@@ -38,4 +38,9 @@
* @param taskId the TaskId.
*/
void update( boolean last3Years, TaskId id );
+
+ /**
+ * Drops analytics and and temporary analytics tables between 1900 and 2100.
+ */
+ void dropTables();
}
=== 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-03-24 18:40:42 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java 2013-04-22 08:10:07 +0000
@@ -55,8 +55,6 @@
public static final String PREFIX_ORGUNITLEVEL = "uidlevel";
public static final String PREFIX_INDEX = "in_";
- private static final String TABLE_TEMP_SUFFIX = "_temp";
-
@Autowired
protected OrganisationUnitService organisationUnitService;
=== 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-04-03 17:22:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java 2013-04-22 08:10:07 +0000
@@ -93,7 +93,7 @@
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 = PartitionUtils.getTempTableNames( earliest, latest, tableName );
clock.logTime( "Partition tables: " + tables + ", earliest: " + earliest + ", latest: " + latest + ", last 3 years: " + last3YearsOnly );
@@ -135,6 +135,20 @@
notifier.notify( taskId, "Table update done" );
}
+ public void dropTables()
+ {
+ List<String> tempTables = PartitionUtils.getTempTableNames(
+ new Cal().set( 1900, 1, 1 ).time(), new Cal().set( 2100, 1, 1 ).time(), tableManager.getTableName() );
+
+ for ( String tempTable : tempTables )
+ {
+ String realTable = tempTable.replaceFirst( AnalyticsTableManager.TABLE_TEMP_SUFFIX, "" );
+
+ tableManager.dropTable( tempTable );
+ tableManager.dropTable( realTable );
+ }
+ }
+
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
@@ -251,14 +265,6 @@
}
}
- protected void dropTables( List<String> tables )
- {
- for ( String table : tables )
- {
- tableManager.dropTable( table );
- }
- }
-
private int getProcessNo()
{
int cores = SystemUtils.getCpuCores();
=== 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 2013-01-23 11:54:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java 2013-04-22 08:10:07 +0000
@@ -27,10 +27,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import javax.annotation.Resource;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.aggregation.AggregatedDataValueService;
import org.hisp.dhis.aggregation.AggregatedOrgUnitDataValueService;
+import org.hisp.dhis.analytics.AnalyticsTableService;
import org.hisp.dhis.common.DeleteNotAllowedException;
import org.hisp.dhis.completeness.DataSetCompletenessService;
import org.hisp.dhis.datamart.DataMartManager;
@@ -53,6 +56,15 @@
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
+
+ @Resource(name="org.hisp.dhis.analytics.AnalyticsTableService")
+ private AnalyticsTableService analyticsTableService;
+
+ @Resource(name="org.hisp.dhis.analytics.CompletenessTableService")
+ private AnalyticsTableService completenessTableService;
+
+ @Resource(name="org.hisp.dhis.analytics.CompletenessTargetTableService")
+ private AnalyticsTableService completenessTargetTableService;
private MaintenanceService maintenanceService;
@@ -107,6 +119,13 @@
// Input
// -------------------------------------------------------------------------
+ private boolean clearAnalytics;
+
+ public void setClearAnalytics( boolean clearAnalytics )
+ {
+ this.clearAnalytics = clearAnalytics;
+ }
+
private boolean clearDataMart;
public void setClearDataMart( boolean clearDataMart )
@@ -149,6 +168,13 @@
public String execute()
throws Exception
{
+ if ( clearAnalytics )
+ {
+ analyticsTableService.dropTables();
+ completenessTableService.dropTables();
+ completenessTargetTableService.dropTables();
+ }
+
if ( clearDataMart )
{
aggregatedDataValueService.deleteAggregatedDataValues();
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2013-03-04 20:41:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2013-04-22 08:10:07 +0000
@@ -318,4 +318,5 @@
removing_min_max_values=Removing min-max values
generating_min_max_values=Generating min-max values
done=Done
-period_structure=Period structure
\ No newline at end of file
+period_structure=Period structure
+clear_analytics_tables=Clear analytics tables
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/maintenance.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/maintenance.js 2012-02-24 08:44:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/maintenance.js 2013-04-22 08:10:07 +0000
@@ -1,17 +1,19 @@
function performMaintenance()
{
+ var clearAnalytics = document.getElementById( "clearAnalytics" ).checked;
var clearDataMart = document.getElementById( "clearDataMart" ).checked;
var dataMartIndex = document.getElementById( "dataMartIndex" ).checked;
var zeroValues = document.getElementById( "zeroValues" ).checked;
var dataSetCompleteness = document.getElementById( "dataSetCompleteness" ).checked;
var prunePeriods = document.getElementById( "prunePeriods" ).checked;
- if ( clearDataMart || dataMartIndex || zeroValues || dataSetCompleteness || prunePeriods )
+ if ( clearAnalytics || clearDataMart || dataMartIndex || zeroValues || dataSetCompleteness || prunePeriods )
{
setWaitMessage( i18n_performing_maintenance );
- var params = "clearDataMart=" + clearDataMart +
+ var params = "clearAnalytics=" + clearAnalytics +
+ "&clearDataMart=" + clearDataMart +
"&dataMartIndex=" + dataMartIndex +
"&zeroValues=" + zeroValues +
"&dataSetCompleteness=" + dataSetCompleteness +
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/maintenanceForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/maintenanceForm.vm 2012-07-30 16:39:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/maintenanceForm.vm 2013-04-22 08:10:07 +0000
@@ -13,6 +13,11 @@
<h3>$i18n.getString( "maintenance" ) #openHelp( "maintenance" )</h3>
<p>
+ <input type="checkbox" id="clearAnalytics"/>
+ <label for="clearAnalytics">$i18n.getString( "clear_analytics_tables" )</label>
+</p>
+
+<p>
<input type="checkbox" id="clearDataMart"/>
<label for="clearDataMart">$i18n.getString( "clear_data_mart" )</label>
</p>