← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22012: SmsSchedulerTasks execution

 

------------------------------------------------------------
revno: 22012
committer: Zubair Asghar<zubair@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-02-19 15:24:05 +0100
message:
  SmsSchedulerTasks execution
modified:
  dhis-2/dhis-services/dhis-service-administration/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/resources/struts.xml
  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-administration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2016-02-17 10:10:29 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2016-02-19 14:24:05 +0000
@@ -91,7 +91,7 @@
   <bean id="resourceTable15MinTask" class="org.hisp.dhis.resourcetable.scheduling.ResourceTableTask" scope="prototype" />
   
   <bean id="abstractScheduledMessageTask"
-		class="org.hisp.dhis.sms.scheduling.SendScheduledMessageTask" scope="prototype">
+		class="org.hisp.dhis.sms.scheduling.SendScheduledMessageTask">
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="outboundSmsService"
@@ -102,21 +102,21 @@
 		<property name="jdbcTemplate" ref="jdbcTemplate" />
 	</bean>
 
-	<bean id="sendMessageScheduledTask"
+	<bean id="sendScheduledMessageTask"
 		class="org.hisp.dhis.sms.scheduling.SendScheduledMessageTask"
 		parent="abstractScheduledMessageTask" scope="prototype">
 		<property name="sendingMessage" value="true" />
 		<property name="sendNow" value="false"/>
 	</bean>
 
-	<bean id="scheduleMessageTask"
+	<bean id="smsSchedulerTask"
 		class="org.hisp.dhis.sms.scheduling.SendScheduledMessageTask"
 		parent="abstractScheduledMessageTask" scope="prototype">
 		<property name="sendingMessage" value="false" />
 		<property name="sendNow" value="false"/>
 	</bean>
 	
-	<bean id="sendMessageScheduledTaskNow"
+	<bean id="sendScheduledMessageTaskNow"
 		class="org.hisp.dhis.sms.scheduling.SendScheduledMessageTask"
 		parent="abstractScheduledMessageTask" scope="prototype">
 		<property name="sendingMessage" value="false" />

=== 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	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java	2016-02-19 14:24:05 +0000
@@ -167,4 +167,15 @@
         
         return scheduledTasks;
     }
+
+    @Override
+    public void executeTask( String taskKey )
+    {
+        Runnable task = tasks.get( taskKey );
+        
+        if (task != null)
+        {
+            scheduler.executeTask( task );
+        }
+    }
 }

=== 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	2016-02-17 10:10:29 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java	2016-02-19 14:24:05 +0000
@@ -47,6 +47,7 @@
     String TASK_DATA_SYNCH = "dataSynchTask";
     String TASK_SMS_SCHEDULER = "smsSchedulerTask";
     String TASK_SEND_SCHEDULED_SMS = "sendScheduledMessageTask";
+    String TASK_SEND_SCHEDULED_SMS_NOW = "sendScheduledMessageTaskNow";
     
     /**
      * Schedules all tasks.
@@ -54,6 +55,11 @@
     void scheduleTasks();
     
     /**
+     * Execute the Task.
+     */
+    void executeTask(String taskKey);
+    
+    /**
      * Schedules the given tasks. The task map will replace the currently scheduled
      * 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	2016-02-17 10:10:29 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2016-02-19 14:24:05 +0000
@@ -179,8 +179,9 @@
         <entry key="analyticsLast3YearsTask" value-ref="analyticsLast3YearsTask" />
         <entry key="monitoringLastDayTask" value-ref="monitoringLastDayTask" />
         <entry key="dataSynchTask" value-ref="dataSynchTask" />
-        <entry key="smsSchedulerTask" value-ref="scheduleMessageTask" />    
-        <entry key="sendScheduledMessageTask" value-ref="sendMessageScheduledTask" />  
+        <entry key="smsSchedulerTask" value-ref="smsSchedulerTask" />    
+        <entry key="sendScheduledMessageTask" value-ref="sendScheduledMessageTask" />  
+        <entry key="sendScheduledMessageTaskNow" value-ref="sendScheduledMessageTaskNow" />  
       </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	2016-02-17 10:10:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java	2016-02-19 14:24:05 +0000
@@ -94,12 +94,26 @@
     // Input
     // -------------------------------------------------------------------------
 
+    private boolean executeNow;
+    
+    public void setExecuteNow( boolean executeNow )
+    {
+        this.executeNow = executeNow;
+    }
+
     private boolean schedule;
 
     public void setSchedule( boolean schedule )
     {
         this.schedule = schedule;
     }
+    
+    private String taskKey;
+
+    public void setTaskKey( String taskKey )
+    {
+        this.taskKey = taskKey;
+    }
 
     private String resourceTableStrategy;
 
@@ -228,6 +242,13 @@
     @Override
     public String execute()
     {
+        if ( executeNow )
+        {       
+            schedulingManager.executeTask( taskKey );
+            
+            return SUCCESS;
+        }
+        
         if ( schedule )
         {
             if ( ScheduledTaskStatus.RUNNING.equals( schedulingManager.getTaskStatus() ) )

=== 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	2016-02-17 10:10:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2016-02-19 14:24:05 +0000
@@ -294,6 +294,7 @@
 last_3_years_daily=Last 3 years daily
 all_daily=All daily
 every_mid_night=Every night at 12
+rightNow= Right Now
 execute_now=Execute Now
 all_every_15_min=All every 15 minutes
 resource_table_task_strategy=Resource tables task strategy

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2015-12-17 13:36:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2016-02-19 14:24:05 +0000
@@ -511,6 +511,15 @@
       <param name="schedule">true</param>
       <param name="requiredAuthorities">F_SCHEDULING_ADMIN</param>
     </action>
+    
+     <action name="executeTask" class="org.hisp.dhis.dataadmin.action.scheduling.ScheduleTasksAction">
+      <result name="success" type="redirect">viewScheduledTasks.action</result>
+      <param name="page">/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm</param>
+      <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
+      <param name="javascripts">javascript/scheduling.js</param>
+      <param name="executeNow">true</param>
+      <param name="requiredAuthorities">F_SCHEDULING_ADMIN</param>
+    </action>
 
     <!-- OptionSet -->
 

=== 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	2016-02-17 10:10:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm	2016-02-19 14:24:05 +0000
@@ -80,10 +80,11 @@
 <select id="smsSchedulerStrategy" name="smsSchedulerStrategy" class="scheduling">
     <option value="disabled">$i18n.getString( "disabled" )</option>
     <option value="everyMidNight"#if ( $smsSchedulerStrategy && $smsSchedulerStrategy == "everyMidNight" ) selected="selected"#end>$i18n.getString( "every_mid_night" )</option>
+    
 </select>
+<input type="button" style="width:140px" onclick="window.location.href='executeTask.action?taskKey=sendScheduledMessageTaskNow'" value="$i18n.getString( 'Run Now' )"/>
 </div>
 
-
 <!-- Submit -->
 
 <div class="setting">