← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12718: Scheduling of data monitoring task

 

------------------------------------------------------------
revno: 12718
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-16 13:58:17 +0200
message:
  Scheduling of data monitoring task
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
  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/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/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-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2013-10-15 17:46:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2013-10-16 11:58:17 +0000
@@ -438,7 +438,9 @@
     <property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
   </bean>
   
-  <bean id="monitoringTask" class="org.hisp.dhis.validation.scheduling.MonitoringTask" />
+  <!-- Scheduled task for data monitoring -->
+  
+  <bean id="monitoringLastDayTask" class="org.hisp.dhis.validation.scheduling.MonitoringTask" />
 
   <bean id="org.hisp.dhis.dataelement.DataElementCategoryService" class="org.hisp.dhis.dataelement.DefaultDataElementCategoryService">
     <property name="dataElementCategoryStore" ref="org.hisp.dhis.dataelement.DataElementCategoryStore" />

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java	2013-10-16 11:58:17 +0000
@@ -68,6 +68,8 @@
     {
         this.tasks = tasks;
     }
+    
+    // TODO Avoid map, use bean identifier directly and get bean from context
 
     // -------------------------------------------------------------------------
     // SchedulingManager implementation

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java	2013-10-16 11:58:17 +0000
@@ -41,6 +41,7 @@
     final String TASK_DATAMART_FROM_6_TO_12_MONTS = "dataMartFrom6To12MonthsTask";
     final String TASK_ANALYTICS_ALL = "analyticsAllTask";
     final String TASK_ANALYTICS_LAST_3_YEARS = "analyticsLast3YearsTask";
+    final String TASK_MONITORING_LAST_DAY = "monitoringLastDayTask";
         
     /**
      * Schedule all tasks.

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2013-09-30 19:54:38 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2013-10-16 11:58:17 +0000
@@ -166,6 +166,7 @@
         <entry key="dataMartFrom6To12MonthsTask" value-ref="dataMartFrom6To12MonthsTask" />
         <entry key="analyticsAllTask" value-ref="analyticsAllTask" />
         <entry key="analyticsLast3YearsTask" value-ref="analyticsLast3YearsTask" />
+        <entry key="monitoringLastDayTask" value-ref="monitoringLastDayTask" />
       </map>
     </property>
   </bean>

=== 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	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java	2013-10-16 11:58:17 +0000
@@ -34,6 +34,7 @@
 import static org.hisp.dhis.scheduling.SchedulingManager.TASK_DATAMART_LAST_12_MONTHS;
 import static org.hisp.dhis.scheduling.SchedulingManager.TASK_DATAMART_LAST_6_MONTHS;
 import static org.hisp.dhis.scheduling.SchedulingManager.TASK_RESOURCE_TABLE;
+import static org.hisp.dhis.scheduling.SchedulingManager.TASK_MONITORING_LAST_DAY;
 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;
@@ -48,6 +49,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -68,6 +71,8 @@
     private static final String STRATEGY_ALL_DAILY = "allDaily";
     private static final String STRATEGY_LAST_3_YEARS_DAILY = "last3YearsDaily";
     
+    private static final Log log = LogFactory.getLog( ScheduleTasksAction.class );
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -163,6 +168,18 @@
     {
         this.dataMartStrategy = dataMartStrategy;
     }
+    
+    private String monitoringStrategy;
+
+    public String getMonitoringStrategy()
+    {
+        return monitoringStrategy;
+    }
+
+    public void setMonitoringStrategy( String monitoringStrategy )
+    {
+        this.monitoringStrategy = monitoringStrategy;
+    }
 
     // -------------------------------------------------------------------------
     // Output
@@ -195,7 +212,7 @@
 
     @SuppressWarnings("unchecked")
     public String execute()
-    {
+    {        
         if ( schedule )
         {
             systemSettingManager.saveSystemSetting( KEY_SCHEDULED_PERIOD_TYPES, (HashSet<String>) scheduledPeriodTypes );
@@ -248,6 +265,18 @@
                     cronKeyMap.putValue( CRON_DAILY_0AM_EXCEPT_SUNDAY, TASK_DATAMART_LAST_6_MONTHS );
                     cronKeyMap.putValue( CRON_WEEKLY_SUNDAY_0AM, TASK_DATAMART_FROM_6_TO_12_MONTS );
                 }
+
+                // -------------------------------------------------------------
+                // Monitoring
+                // -------------------------------------------------------------
+                
+                if ( STRATEGY_ALL_DAILY.equals( monitoringStrategy ) )
+                {
+                    cronKeyMap.putValue( CRON_DAILY_0AM_EXCEPT_SUNDAY, TASK_MONITORING_LAST_DAY );
+                    cronKeyMap.putValue( CRON_WEEKLY_SUNDAY_0AM, TASK_MONITORING_LAST_DAY );
+                    
+                    System.out.println("11");
+                }
                 
                 schedulingManager.scheduleTasks( cronKeyMap );
             }
@@ -289,7 +318,17 @@
             else if ( keys.contains( TASK_DATAMART_LAST_6_MONTHS ) )
             {
                 dataMartStrategy = STRATEGY_LAST_6_DAILY_6_TO_12_WEEKLY;
-            }            
+            }
+
+            // -------------------------------------------------------------
+            // Monitoring
+            // -------------------------------------------------------------
+            
+            if ( keys.contains( TASK_MONITORING_LAST_DAY ) )
+            {
+                monitoringStrategy = STRATEGY_ALL_DAILY;
+                System.out.println("22");
+            }
         }
         
         scheduledPeriodTypes = (Set<String>) systemSettingManager.getSystemSetting( KEY_SCHEDULED_PERIOD_TYPES, DEFAULT_SCHEDULED_PERIOD_TYPES );
@@ -297,8 +336,12 @@
         
         status = schedulingManager.getTaskStatus();        
         running = STATUS_RUNNING.equals( status );
+        
         levels = organisationUnitService.getOrganisationUnitLevels();
 
+        log.info( "Status: " + status );
+        log.info( "Running: " + running );
+        
         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	2013-10-08 13:19:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2013-10-16 11:58:17 +0000
@@ -325,8 +325,6 @@
 data_element_category_option_combo=Data element category option combinations
 update_category_option_combos=Update category option combinations
 date_period_structure=Date period structure
-
-#-- The locale management page ------------------------------------------------------#
 locale=Locale
 locale_management=Locale Management
 create_new_locale=Create New Locale
@@ -336,4 +334,6 @@
 language=Language
 country=Country
 locale_language_no_translation=Please select a language
-locale_country_no_translation=Please select a country
\ No newline at end of file
+locale_country_no_translation=Please select a country
+data_monitoring=Data monitoring
+data_monitoring_strategy=Data monitoring strategy
\ 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/viewScheduledTasks.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm	2013-03-06 10:51:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm	2013-10-16 11:58:17 +0000
@@ -69,6 +69,19 @@
 </select>
 </div>
 
+<!-- Monitoring -->
+
+<div class="settingHeader">$i18n.getString( "data_monitoring" )</div>
+
+<div class="settingLabel">$i18n.getString( "data_monitoring_strategy" )</div>
+
+<div class="setting">
+<select id="monitoringStrategy" name="monitoringStrategy" class="scheduling">
+    <option value="never">$i18n.getString( "never" )</option>
+    <option value="allDaily"#if( $monitoringStrategy && $monitoringStrategy == "allDaily" ) selected="selected"#end>$i18n.getString( "all_daily" )</option>
+</select>
+</div>
+
 <div class="setting">
 	<input type="button" style="width:140px" onclick="submitSchedulingForm()"
 	#if ( $running )