← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16317: Scheduling, added last success time info for analytics and resource tables

 

------------------------------------------------------------
revno: 16317
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-08-05 12:57:11 +0200
message:
  Scheduling, added last success time info for analytics and resource tables
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/AnalyticsTableTask.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/synch/DefaultSynchronizationManager.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.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-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2014-07-10 10:27:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2014-08-05 10:57:11 +0000
@@ -98,6 +98,9 @@
     final String KEY_CUSTOM_LOGIN_PAGE_LOGO = "keyCustomLoginPageLogo";
     final String KEY_CUSTOM_TOP_MENU_LOGO = "keyCustomTopMenuLogo";
     final String KEY_ANALYTICS_MAINTENANCE_MODE = "keyAnalyticsMaintenanceMode";
+    final String KEY_LAST_SUCCESSFUL_DATA_SYNC = "keyLastSuccessfulDataSynch";
+    final String KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE = "keyLastSuccessfulAnalyticsTablesUpdate";
+    final String KEY_LAST_SUCCESSFUL_RESOURCE_TABLES_UPDATE = "keyLastSuccessfulResourceTablesUpdate";
 
     final String DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY = "lastMonth";
     final String DEFAULT_FLAG = "dhis2";

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java	2014-08-05 10:57:11 +0000
@@ -28,9 +28,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_LAST_SUCCESSFUL_RESOURCE_TABLES_UPDATE;
+
+import java.util.Date;
+
 import org.hisp.dhis.message.MessageService;
 import org.hisp.dhis.resourcetable.ResourceTableService;
 import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.system.notification.NotificationLevel;
 import org.hisp.dhis.system.notification.Notifier;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -50,6 +55,9 @@
     @Autowired
     private MessageService messageService;
 
+    @Autowired
+    private SystemSettingManager systemSettingManager;
+    
     private TaskId taskId;
 
     public void setTaskId( TaskId taskId )
@@ -64,6 +72,8 @@
     @Override
     public void run()
     {
+        final Date startTime = new Date();
+        
         notifier.notify( taskId, "Generating resource tables" );
         
         try
@@ -80,6 +90,8 @@
             
             throw ex;
         }
+
+        systemSettingManager.saveSystemSetting( KEY_LAST_SUCCESSFUL_RESOURCE_TABLES_UPDATE, startTime );
     }    
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/AnalyticsTableTask.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/AnalyticsTableTask.java	2014-07-10 12:07:18 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/AnalyticsTableTask.java	2014-08-05 10:57:11 +0000
@@ -30,12 +30,16 @@
 
 import static org.hisp.dhis.system.notification.NotificationLevel.ERROR;
 import static org.hisp.dhis.system.notification.NotificationLevel.INFO;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE;
+
+import java.util.Date;
 
 import javax.annotation.Resource;
 
 import org.hisp.dhis.analytics.AnalyticsTableService;
 import org.hisp.dhis.message.MessageService;
 import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.setting.SystemSettingManager;
 import org.hisp.dhis.system.notification.Notifier;
 import org.hisp.dhis.system.util.DebugUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -67,6 +71,9 @@
     @Autowired
     private MessageService messageService;
 
+    @Autowired
+    private SystemSettingManager systemSettingManager;
+    
     private Integer lastYears;
 
     public void setLastYears( Integer lastYears )
@@ -109,6 +116,8 @@
     @Override
     public void run()
     {
+        final Date startTime = new Date();
+        
         notifier.clear( taskId ).notify( taskId, "Analytics table update process started" );
 
         try
@@ -155,5 +164,7 @@
             
             throw ex;
         }
+        
+        systemSettingManager.saveSystemSetting( KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE, startTime );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/synch/DefaultSynchronizationManager.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/synch/DefaultSynchronizationManager.java	2014-07-25 08:41:20 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/synch/DefaultSynchronizationManager.java	2014-08-05 10:57:11 +0000
@@ -29,6 +29,7 @@
  */
 
 import static org.apache.commons.lang.StringUtils.trimToNull;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_LAST_SUCCESSFUL_DATA_SYNC;
 
 import java.io.IOException;
 import java.util.Calendar;
@@ -70,8 +71,6 @@
 {
     private static final Log log = LogFactory.getLog( DefaultSynchronizationManager.class );
     
-    private static final String KEY_LAST_SUCCESSFUL_SYNC = "keyLastSuccessfulSynch";
-    
     private static final String PING_PATH = "/api/system/ping";
     private static final String HEADER_AUTHORIZATION = "Authorization";
     
@@ -227,7 +226,7 @@
     
     public Date getLastSynchSuccess()
     {
-        return (Date) systemSettingManager.getSystemSetting( KEY_LAST_SUCCESSFUL_SYNC );
+        return (Date) systemSettingManager.getSystemSetting( KEY_LAST_SUCCESSFUL_DATA_SYNC );
     }
     
     // -------------------------------------------------------------------------
@@ -242,7 +241,7 @@
     {
         Date fallback = new Cal().subtract( Calendar.DAY_OF_YEAR, 3 ).time();
         
-        return (Date) systemSettingManager.getSystemSetting( KEY_LAST_SUCCESSFUL_SYNC, fallback );
+        return (Date) systemSettingManager.getSystemSetting( KEY_LAST_SUCCESSFUL_DATA_SYNC, fallback );
     }
 
     /**
@@ -250,7 +249,7 @@
      */
     private void setLastSynchSuccess( Date time )
     {
-        systemSettingManager.saveSystemSetting( KEY_LAST_SUCCESSFUL_SYNC, time );
+        systemSettingManager.saveSystemSetting( KEY_LAST_SUCCESSFUL_DATA_SYNC, time );
     }
 
     /**

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java	2014-07-25 08:41:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java	2014-08-05 10:57:11 +0000
@@ -37,7 +37,7 @@
 import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_ORGUNITGROUPSET_AGG_LEVEL;
 import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULED_PERIOD_TYPES;
 import static org.hisp.dhis.setting.SystemSettingManager.KEY_ORGUNITGROUPSET_AGG_LEVEL;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_PERIOD_TYPES;
+import static org.hisp.dhis.setting.SystemSettingManager.*;
 import static org.hisp.dhis.system.scheduling.Scheduler.CRON_DAILY_0AM;
 import static org.hisp.dhis.system.scheduling.Scheduler.CRON_EVERY_MIN;
 import static org.hisp.dhis.system.scheduling.Scheduler.STATUS_RUNNING;
@@ -210,13 +210,27 @@
         return levels;
     }
     
+    private Date lastResourceTableSuccess;
+
+    public Date getLastResourceTableSuccess()
+    {
+        return lastResourceTableSuccess;
+    }
+    
+    private Date lastAnalyticsTableSuccess;
+
+    public Date getLastAnalyticsTableSuccess()
+    {
+        return lastAnalyticsTableSuccess;
+    }
+    
     private Date lastDataSyncSuccess;
     
     public Date getLastDataSyncSuccess()
     {
         return lastDataSyncSuccess;
     }
-
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -350,6 +364,9 @@
         running = STATUS_RUNNING.equals( status );
         
         levels = organisationUnitService.getOrganisationUnitLevels();
+        
+        lastResourceTableSuccess = (Date) systemSettingManager.getSystemSetting( KEY_LAST_SUCCESSFUL_RESOURCE_TABLES_UPDATE );
+        lastAnalyticsTableSuccess = (Date) systemSettingManager.getSystemSetting( KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE );
         lastDataSyncSuccess = synchronizationManager.getLastSynchSuccess();
 
         log.info( "Status: " + status );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm	2014-07-26 23:08:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm	2014-08-05 10:57:11 +0000
@@ -11,6 +11,8 @@
 
 <div class="settingLabel settingIndent">$i18n.getString( "resource_table_task_strategy" )</div>
 
+<div class="settingLabel settingIndent tipText">$i18n.getString( "last_success" ): $!format.formatDateTime( $lastResourceTableSuccess )</div>
+
 <div class="setting settingIndent">
 <select id="resourceTableStrategy" name="resourceTableStrategy" class="scheduling">
 	<option value="disabled">$i18n.getString( "disabled" )</option>
@@ -24,6 +26,8 @@
 
 <div class="settingLabel settingIndent">$i18n.getString( "analytics_tables_task_strategy" )</div>
 
+<div class="settingLabel settingIndent tipText">$i18n.getString( "last_success" ): $!format.formatDateTime( $lastAnalyticsTableSuccess )</div>
+
 <div class="setting settingIndent">
 <select id="analyticsStrategy" name="analyticsStrategy" class="scheduling">
     <option value="disabled">$i18n.getString( "disabled" )</option>