← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19588: add UI for updating orgUnit paths (data admin -> maintenance)

 

------------------------------------------------------------
revno: 19588
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-07-08 15:51:00 +0700
message:
  add UI for updating orgUnit paths (data admin -> maintenance)
modified:
  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-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-03-03 16:18:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java	2015-07-08 08:51:00 +0000
@@ -28,8 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import javax.annotation.Resource;
-
+import com.opensymphony.xwork2.Action;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.aggregation.AggregatedDataValueService;
@@ -38,46 +37,47 @@
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.datamart.DataMartManager;
 import org.hisp.dhis.maintenance.MaintenanceService;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.resourcetable.ResourceTableService;
 import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.beans.factory.annotation.Autowired;
 
-import com.opensymphony.xwork2.Action;
+import javax.annotation.Resource;
 
 /**
  * @author Lars Helge Overland
- * @version $Id$
  */
 public class PerformMaintenanceAction
     implements Action
 {
     private static final Log log = LogFactory.getLog( PerformMaintenanceAction.class );
-    
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
 
-    @Resource(name="org.hisp.dhis.analytics.AnalyticsTableService")
+    @Resource( name = "org.hisp.dhis.analytics.AnalyticsTableService" )
     private AnalyticsTableService analyticsTableService;
 
-    @Resource(name="org.hisp.dhis.analytics.CompletenessTableService")
+    @Resource( name = "org.hisp.dhis.analytics.CompletenessTableService" )
     private AnalyticsTableService completenessTableService;
-    
-    @Resource(name="org.hisp.dhis.analytics.CompletenessTargetTableService")
+
+    @Resource( name = "org.hisp.dhis.analytics.CompletenessTargetTableService" )
     private AnalyticsTableService completenessTargetTableService;
 
-    @Resource(name="org.hisp.dhis.analytics.OrgUnitTargetTableService")
+    @Resource( name = "org.hisp.dhis.analytics.OrgUnitTargetTableService" )
     private AnalyticsTableService orgUnitTargetTableService;
-    
-    @Resource(name="org.hisp.dhis.analytics.EventAnalyticsTableService")
+
+    @Resource( name = "org.hisp.dhis.analytics.EventAnalyticsTableService" )
     private AnalyticsTableService eventAnalyticsTableService;
-    
+
     private MaintenanceService maintenanceService;
 
     public void setMaintenanceService( MaintenanceService maintenanceService )
     {
         this.maintenanceService = maintenanceService;
     }
-    
+
     private DataSetCompletenessService completenessService;
 
     public void setCompletenessService( DataSetCompletenessService completenessService )
@@ -86,12 +86,12 @@
     }
 
     private AggregatedDataValueService aggregatedDataValueService;
-    
+
     public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService )
     {
         this.aggregatedDataValueService = aggregatedDataValueService;
     }
-        
+
     private DataMartManager dataMartManager;
 
     public void setDataMartManager( DataMartManager dataMartManager )
@@ -105,7 +105,7 @@
     {
         this.currentUserService = currentUserService;
     }
-    
+
     private DataElementCategoryService categoryService;
 
     public void setCategoryService( DataElementCategoryService categoryService )
@@ -120,12 +120,15 @@
         this.resourceTableService = resourceTableService;
     }
 
+    @Autowired
+    private OrganisationUnitService organisationUnitService;
+
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
-    
+
     private boolean clearAnalytics;
-    
+
     public void setClearAnalytics( boolean clearAnalytics )
     {
         this.clearAnalytics = clearAnalytics;
@@ -139,7 +142,7 @@
     }
 
     public boolean dataMartIndex;
-    
+
     public void setDataMartIndex( boolean dataMartIndex )
     {
         this.dataMartIndex = dataMartIndex;
@@ -151,23 +154,23 @@
     {
         this.zeroValues = zeroValues;
     }
-    
+
     private boolean dataSetCompleteness;
 
     public void setDataSetCompleteness( boolean dataSetCompleteness )
     {
         this.dataSetCompleteness = dataSetCompleteness;
     }
-    
+
     private boolean prunePeriods;
 
     public void setPrunePeriods( boolean prunePeriods )
     {
         this.prunePeriods = prunePeriods;
     }
-    
+
     private boolean removeExpiredInvitations;
-    
+
     public void setRemoveExpiredInvitations( boolean removeExpiredInvitations )
     {
         this.removeExpiredInvitations = removeExpiredInvitations;
@@ -181,12 +184,12 @@
     }
 
     private boolean createSqlViews;
-    
+
     public void setCreateSqlViews( boolean createSqlViews )
     {
         this.createSqlViews = createSqlViews;
     }
-    
+
     private boolean updateCategoryOptionCombos;
 
     public void setUpdateCategoryOptionCombos( boolean updateCategoryOptionCombos )
@@ -194,16 +197,23 @@
         this.updateCategoryOptionCombos = updateCategoryOptionCombos;
     }
 
+    private boolean updateOrganisationUnitPaths;
+
+    public void setUpdateOrganisationUnitPaths( boolean updateOrganisationUnitPaths )
+    {
+        this.updateOrganisationUnitPaths = updateOrganisationUnitPaths;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
-    
+
     @Override
     public String execute()
         throws Exception
     {
         String username = currentUserService.getCurrentUsername();
-        
+
         if ( clearAnalytics )
         {
             resourceTableService.dropAllSqlViews();
@@ -212,85 +222,92 @@
             completenessTargetTableService.dropTables();
             orgUnitTargetTableService.dropTables();
             eventAnalyticsTableService.dropTables();
-            
+
             log.info( "'" + username + "': Cleared analytics tables" );
         }
-        
+
         if ( clearDataMart )
         {
             aggregatedDataValueService.dropDataMart();
             aggregatedDataValueService.createDataMart();
-            
+
             log.info( "'" + username + "': Cleared data mart" );
         }
-        
+
         if ( dataMartIndex )
         {
             dataMartManager.dropDataValueIndex();
             dataMartManager.dropIndicatorValueIndex();
             dataMartManager.dropOrgUnitDataValueIndex();
             dataMartManager.dropOrgUnitIndicatorValueIndex();
-            
+
             dataMartManager.createDataValueIndex();
             dataMartManager.createIndicatorValueIndex();
             dataMartManager.createOrgUnitDataValueIndex();
             dataMartManager.createOrgUnitIndicatorValueIndex();
-            
+
             completenessService.dropIndex();
             completenessService.createIndex();
-            
+
             log.info( "'" + username + "': Rebuilt data mart indexes" );
         }
-        
+
         if ( zeroValues )
         {
             maintenanceService.deleteZeroDataValues();
-            
+
             log.info( "Cleared zero values" );
         }
-        
+
         if ( dataSetCompleteness )
         {
             completenessService.deleteDataSetCompleteness();
-            
+
             log.info( "'" + username + "': Cleared data completeness" );
         }
-        
+
         if ( prunePeriods )
         {
             maintenanceService.prunePeriods();
-            
+
             log.info( "'" + username + "': Pruned periods" );
         }
-        
+
         if ( removeExpiredInvitations )
         {
             maintenanceService.removeExpiredInvitations();
-            
+
             log.info( "'" + username + "': Removed expired invitations" );
         }
 
         if ( dropSqlViews )
         {
             resourceTableService.dropAllSqlViews();
-            
+
             log.info( "'" + username + "': Dropped SQL views" );
         }
-        
+
         if ( createSqlViews )
         {
             resourceTableService.createAllSqlViews();
-            
+
             log.info( "'" + username + "': Created SQL views" );
         }
-        
+
         if ( updateCategoryOptionCombos )
         {
             categoryService.updateAllOptionCombos();
-            
+
             log.info( "'" + username + "': Updated category option combos" );
         }
-        
+
+        if ( updateOrganisationUnitPaths )
+        {
+            organisationUnitService.forceUpdatePaths();
+
+            log.info( "'" + username + "': Updated organisation unit paths" );
+        }
+
         return SUCCESS;
     }
 }

=== 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	2015-05-08 20:26:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2015-07-08 08:51:00 +0000
@@ -346,6 +346,7 @@
 period_structure=Period structure
 data_element_category_option_combo=Data element category option combinations
 update_category_option_combos=Update category option combinations
+update_organisation_unit_paths=Update organisation unit paths
 date_period_structure=Date period structure
 locale=Locale
 locale_management=Locale Management

=== 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	2015-02-20 14:53:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/maintenance.js	2015-07-08 08:51:00 +0000
@@ -1,45 +1,44 @@
-
-function performMaintenance()
-{
-    var clearAnalytics = $( "#clearAnalytics" ).is( ":checked" );
-    var clearDataMart = $( "#clearDataMart" ).is( ":checked" );
-    var dataMartIndex = $( "#dataMartIndex" ).is( ":checked" );
-    var zeroValues = $( "#zeroValues" ).is( ":checked" );
-    var dataSetCompleteness = $( "#dataSetCompleteness" ).is( ":checked" );
-    var prunePeriods = $( "#prunePeriods" ).is( ":checked" );
-    var removeExpiredInvitations = $( "#removeExpiredInvitations" ).is( ":checked" );
-    var dropSqlViews = $( "#dropSqlViews" ).is( ":checked" );
-    var createSqlViews = $( "#createSqlViews" ).is( ":checked" );
-    var updateCategoryOptionCombos = $( "#updateCategoryOptionCombos" ).is( ":checked" );
-    
-    if ( clearAnalytics || clearDataMart || dataMartIndex || zeroValues || dataSetCompleteness || 
-    	prunePeriods || removeExpiredInvitations || dropSqlViews || createSqlViews || updateCategoryOptionCombos )
-    {
-        setHeaderWaitMessage( i18n_performing_maintenance );
-        
-        var params = "clearAnalytics=" + clearAnalytics + 
-        	"&clearDataMart=" + clearDataMart + 
-            "&dataMartIndex=" + dataMartIndex +
-            "&zeroValues=" + zeroValues +
-            "&dataSetCompleteness=" + dataSetCompleteness +
-            "&prunePeriods=" + prunePeriods +
-            "&removeExpiredInvitations=" + removeExpiredInvitations +
-            "&dropSqlViews=" + dropSqlViews +
-            "&createSqlViews=" + createSqlViews +
-            "&updateCategoryOptionCombos=" + updateCategoryOptionCombos;
-        
-		$.ajax({
-			   type: "POST",
-			   url: "performMaintenance.action",
-			   data: params,
-			   dataType: "xml",
-			   success: function(result){
-				   setHeaderDelayMessage( i18n_maintenance_performed );
-			   }
-			});
-    }
-    else
-    {
-    	setHeaderDelayMessage( i18n_select_options );
-    }
+function performMaintenance() {
+  var clearAnalytics = $("#clearAnalytics").is(":checked");
+  var clearDataMart = $("#clearDataMart").is(":checked");
+  var dataMartIndex = $("#dataMartIndex").is(":checked");
+  var zeroValues = $("#zeroValues").is(":checked");
+  var dataSetCompleteness = $("#dataSetCompleteness").is(":checked");
+  var prunePeriods = $("#prunePeriods").is(":checked");
+  var removeExpiredInvitations = $("#removeExpiredInvitations").is(":checked");
+  var dropSqlViews = $("#dropSqlViews").is(":checked");
+  var createSqlViews = $("#createSqlViews").is(":checked");
+  var updateCategoryOptionCombos = $("#updateCategoryOptionCombos").is(":checked");
+  var updateOrganisationUnitPaths = $("#updateOrganisationUnitPaths").is(":checked");
+
+  if( clearAnalytics || clearDataMart || dataMartIndex || zeroValues || dataSetCompleteness ||
+    prunePeriods || removeExpiredInvitations || dropSqlViews || createSqlViews || updateCategoryOptionCombos || updateOrganisationUnitPaths ) {
+
+    setHeaderWaitMessage(i18n_performing_maintenance);
+
+    var params = "clearAnalytics=" + clearAnalytics +
+      "&clearDataMart=" + clearDataMart +
+      "&dataMartIndex=" + dataMartIndex +
+      "&zeroValues=" + zeroValues +
+      "&dataSetCompleteness=" + dataSetCompleteness +
+      "&prunePeriods=" + prunePeriods +
+      "&removeExpiredInvitations=" + removeExpiredInvitations +
+      "&dropSqlViews=" + dropSqlViews +
+      "&createSqlViews=" + createSqlViews +
+      "&updateCategoryOptionCombos=" + updateCategoryOptionCombos +
+      "&updateOrganisationUnitPaths=" + updateOrganisationUnitPaths;
+
+    $.ajax({
+      type: "POST",
+      url: "performMaintenance.action",
+      data: params,
+      dataType: "xml",
+      success: function(result) {
+        setHeaderDelayMessage(i18n_maintenance_performed);
+      }
+    });
+  }
+  else {
+    setHeaderDelayMessage(i18n_select_options);
+  }
 }
\ 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/maintenanceForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/maintenanceForm.vm	2015-02-20 14:53:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/maintenanceForm.vm	2015-07-08 08:51:00 +0000
@@ -57,6 +57,11 @@
 </p>
 
 <p>
+    <input type="checkbox" id="updateOrganisationUnitPaths"/>
+    <label for="updateOrganisationUnitPaths">$i18n.getString( "update_organisation_unit_paths" )</label>
+</p>
+
+<p>
 	<input type="button" value="$i18n.getString( 'perform_maintenance' )" onclick="performMaintenance()" style="width:170px"/>
 </p>