dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21969
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10518: Improve Schedule automated message reminder function.
------------------------------------------------------------
revno: 10518
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-04-11 13:26:56 +0700
message:
Improve Schedule automated message reminder function.
removed:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/TaskCategory.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleSendMessageTasksAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.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/scheduling/TaskCategory.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/TaskCategory.java 2013-03-29 04:26:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/TaskCategory.java 2013-04-11 06:26:56 +0000
@@ -37,5 +37,6 @@
DATAVALUE_IMPORT,
METADATA_IMPORT,
METADATA_EXPORT,
- AGGREGATE_QUERY_BUILDER
+ AGGREGATE_QUERY_BUILDER,
+ SENDING_REMINDER_MESSAGE
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java 2013-04-02 15:14:17 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java 2013-04-11 06:26:56 +0000
@@ -47,7 +47,7 @@
/**
* @author Chau Thu Tran
*
- * @version RunCaseAggregateConditionTask.java 9:52:10 AM Oct 10, 2012 $
+ * @version CaseAggregateConditionTask.java 9:52:10 AM Oct 10, 2012 $
*/
public class CaseAggregateConditionTask
implements Runnable
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java 2013-04-10 08:45:43 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/SendScheduledMessageTask.java 2013-04-11 06:26:56 +0000
@@ -28,6 +28,7 @@
package org.hisp.dhis.patient.scheduling;
import static org.hisp.dhis.sms.outbound.OutboundSms.DHIS_SYSTEM_SENDER;
+import static org.hisp.dhis.system.notification.NotificationLevel.INFO;
import java.util.Collection;
import java.util.List;
@@ -35,10 +36,14 @@
import org.hisp.dhis.program.ProgramInstanceService;
import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.program.SchedulingProgramObject;
+import org.hisp.dhis.scheduling.TaskId;
import org.hisp.dhis.sms.SmsServiceException;
import org.hisp.dhis.sms.outbound.OutboundSms;
import org.hisp.dhis.sms.outbound.OutboundSmsService;
import org.hisp.dhis.sms.outbound.OutboundSmsStatus;
+import org.hisp.dhis.system.notification.Notifier;
+import org.hisp.dhis.system.util.Clock;
+import org.hisp.dhis.system.util.SystemUtils;
import org.springframework.jdbc.core.JdbcTemplate;
/**
@@ -77,10 +82,17 @@
this.jdbcTemplate = jdbcTemplate;
}
+ private Notifier notifier;
+
+ public void setNotifier( Notifier notifier )
+ {
+ this.notifier = notifier;
+ }
+
// -------------------------------------------------------------------------
// Params
// -------------------------------------------------------------------------
-
+
private Boolean sendingMessage;
public void setSendingMessage( Boolean sendingMessage )
@@ -88,6 +100,13 @@
this.sendingMessage = sendingMessage;
}
+ private TaskId taskId;
+
+ public void setTaskId( TaskId taskId )
+ {
+ this.taskId = taskId;
+ }
+
// -------------------------------------------------------------------------
// Runnable implementation
// -------------------------------------------------------------------------
@@ -95,15 +114,35 @@
@Override
public void run()
{
+ final int cpuCores = SystemUtils.getCpuCores();
+
+ Clock clock = new Clock().startClock().logTime(
+ "Aggregate process started, number of CPU cores: " + cpuCores + ", " + SystemUtils.getMemoryString() );
+
if ( sendingMessage )
{
+ clock.logTime( "Start to send messages in outbound" );
+ notifier.notify( taskId, INFO, "Start to send messages in outbound", true );
+
sendMessage();
+
+ clock.logTime( "Sending messages in outbound completed" );
+ notifier.notify( taskId, INFO, "Sending messages in outbound completed", true );
}
else
{
+ clock.logTime( "Start to prepare reminder messages" );
+ notifier.clear( taskId ).notify( taskId, "Start to prepare reminder messages" );
+
scheduleProgramStageInstanceMessage();
scheduleProgramInstanceMessage();
+
+ sendMessage();
+
+ clock.logTime( "Preparing reminder messages completed" );
+ notifier.notify( taskId, INFO, "Preparing reminder messages completed", true );
}
+
}
// -------------------------------------------------------------------------
@@ -112,9 +151,11 @@
private void scheduleProgramStageInstanceMessage()
{
+ notifier.notify( taskId, "Start to prepare reminder messages for events" );
+
Collection<SchedulingProgramObject> schedulingProgramObjects = programStageInstanceService
.getSendMesssageEvents();
-
+
for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
{
String message = schedulingProgramObject.getMessage();
@@ -125,24 +166,36 @@
outboundSms.setSender( DHIS_SYSTEM_SENDER );
outboundSmsService.saveOutboundSms( outboundSms );
+ String sortOrderSql = "SELECT max(sort_order) "
+ + "FROM programstageinstance_outboundsms where programstageinstanceid="
+ + schedulingProgramObject.getProgramStageInstanceId();
+ int sortOrder = jdbcTemplate.queryForInt( sortOrderSql ) + 1;
+
String sql = "INSERT INTO programstageinstance_outboundsms"
+ "( programstageinstanceid, outboundsmsid, sort_order) VALUES " + "("
+ schedulingProgramObject.getProgramStageInstanceId() + ", " + outboundSms.getId() + ","
- + (System.currentTimeMillis() / 1000) + ") ";
+ + sortOrder + ") ";
jdbcTemplate.execute( sql );
+
+ notifier.notify( taskId, "Reminder messages for event of " + outboundSms.getRecipients()
+ + " is created " );
}
catch ( SmsServiceException e )
{
message = e.getMessage();
}
}
+
+ notifier.notify( taskId, INFO, "Preparing reminder messages for events completed", true );
}
-
+
private void scheduleProgramInstanceMessage()
{
- Collection<SchedulingProgramObject> schedulingProgramObjects = programInstanceService.getSendMesssageEvents();
-
+ notifier.notify( taskId, "Start to prepare reminder messages for enrollements" );
+
+ Collection<SchedulingProgramObject> schedulingProgramObjects = programInstanceService.getSendMesssageEvents();
+
for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
{
String message = schedulingProgramObject.getMessage();
@@ -152,18 +205,28 @@
outboundSms.setSender( DHIS_SYSTEM_SENDER );
outboundSmsService.saveOutboundSms( outboundSms );
+ String sortOrderSql = "select max(sort_order) "
+ + "from programinstance_outboundsms where programinstanceid="
+ + schedulingProgramObject.getProgramInstanceId();
+ int sortOrder = jdbcTemplate.queryForInt( sortOrderSql ) + 1;
+
String sql = "INSERT INTO programinstance_outboundsms"
+ "( programinstanceid, outboundsmsid, sort_order) VALUES " + "("
- + schedulingProgramObject.getProgramInstanceId() + ", " + outboundSms.getId() + ","
- + (System.currentTimeMillis() / 1000) + ") ";
+ + schedulingProgramObject.getProgramInstanceId() + ", " + outboundSms.getId() + "," + sortOrder + ") ";
jdbcTemplate.execute( sql );
+
+ notifier.notify( taskId, "Reminder messages for enrollement of " + outboundSms.getRecipients()
+ + " is created " );
}
catch ( SmsServiceException e )
{
message = e.getMessage();
}
}
+
+ notifier.notify( taskId, INFO, "Preparing reminder messages for enrollement completed", true );
+
}
private void sendMessage()
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2013-04-11 03:23:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2013-04-11 06:26:56 +0000
@@ -179,41 +179,6 @@
return rs != null ? rs.intValue() : 0;
}
- // @SuppressWarnings( "unchecked" )
- // public Collection<ProgramInstance> getUnenrollment( Program program,
- // Collection<Integer> orgunitIds,
- // Date startDate, Date endDate )
- // {
- // return getCriteria( Restrictions.eq( "program", program ),
- // Restrictions.ge( "enrollmentDate", startDate ),
- // Restrictions.le( "enrollmentDate", endDate ) ).createAlias( "patient",
- // "patient" )
- // .createAlias( "programStageInstances", "programStageInstance" )
- // .createAlias( "patient.organisationUnit", "organisationUnit" )
- // .add( Restrictions.in( "organisationUnit.id", orgunitIds ) ).add(
- // Restrictions.eq( "completed", true ) )
- // .add( Restrictions.eq( "programStageInstance.completed", false )
- // ).list();
- // }
- //
- // public int countUnenrollment( Program program, Collection<Integer>
- // orgunitIds, Date startDate, Date endDate )
- // {
- // Number rs = (Number) getCriteria( Restrictions.eq( "program", program ),
- // Restrictions.ge( "endDate", startDate ), Restrictions.le( "endDate",
- // endDate ) )
- // .createAlias( "patient", "patient" ).createAlias(
- // "programStageInstances", "programStageInstance" )
- // .createAlias( "patient.organisationUnit", "organisationUnit" )
- // .add( Restrictions.in( "organisationUnit.id", orgunitIds ) ).add(
- // Restrictions.eq( "completed", true ) )
- // .add( Restrictions.eq( "programStageInstance.completed", false ) )
- // .setProjection( Projections.projectionList().add(
- // Projections.countDistinct( "id" ) ) ).uniqueResult();
- //
- // return rs != null ? rs.intValue() : 0;
- // }
-
public int countByStatus( Integer status, Program program, Collection<Integer> orgunitIds, Date startDate,
Date endDate )
{
@@ -275,7 +240,6 @@
String message = "";
for ( int i = 1; i <= cols; i++ )
{
-
message = rs.getString( "templatemessage" );
String patientName = rs.getString( "firstName" );
String organisationunitName = rs.getString( "orgunitName" );
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-04-10 08:45:43 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-04-11 06:26:56 +0000
@@ -399,13 +399,12 @@
+ " ON prm.programstageid = ps.programstageid "
+ "WHERE pi.status="
+ ProgramInstance.STATUS_ACTIVE
- + " "
+ " and p.phonenumber is not NULL and p.phonenumber != '' "
+ " and prm.templatemessage is not NULL and prm.templatemessage != '' "
+ " and pg.type=1 and prm.daysallowedsendmessage is not null "
+ " and psi.executiondate is null "
+ " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage ";
-
+
SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );
int cols = rs.getMetaData().getColumnCount();
@@ -417,7 +416,6 @@
String message = "";
for ( int i = 1; i <= cols; i++ )
{
-
message = rs.getString( "templatemessage" );
String patientName = rs.getString( "firstName" );
String organisationunitName = rs.getString( "orgunitName" );
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-10 08:45:43 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-11 06:26:56 +0000
@@ -447,8 +447,9 @@
class="org.hisp.dhis.patient.scheduling.SendScheduledMessageTask">
<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="outboundSmsService" ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
- <property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+ <property name="notifier" ref="notifier" />
+ <property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
<bean id="sendMessageScheduled"
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java 2013-04-10 09:48:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ExecuteSendMessageAction.java 1970-01-01 00:00:00 +0000
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2004-2009, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.patient.action.schedule;
-
-import static org.hisp.dhis.sms.outbound.OutboundSms.DHIS_SYSTEM_SENDER;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramInstanceService;
-import org.hisp.dhis.program.ProgramStageInstance;
-import org.hisp.dhis.program.ProgramStageInstanceService;
-import org.hisp.dhis.program.SchedulingProgramObject;
-import org.hisp.dhis.sms.SmsServiceException;
-import org.hisp.dhis.sms.outbound.OutboundSms;
-import org.hisp.dhis.sms.outbound.OutboundSmsService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- *
- * @version ExecuteSendMessageAction.java 9:14:46 AM Sep 17, 2012 $
- */
-public class ExecuteSendMessageAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private ProgramStageInstanceService programStageInstanceService;
-
- public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
- {
- this.programStageInstanceService = programStageInstanceService;
- }
-
- private ProgramInstanceService programInstanceService;
-
- public void setProgramInstanceService( ProgramInstanceService programInstanceService )
- {
- this.programInstanceService = programInstanceService;
- }
-
- private OutboundSmsService outboundSmsService;
-
- public void setOutboundSmsService( OutboundSmsService outboundSmsService )
- {
- this.outboundSmsService = outboundSmsService;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- @Override
- public String execute()
- {
- // ---------------------------------------------------------------------
- // Send program-instance messages
- // ---------------------------------------------------------------------
-
- Collection<SchedulingProgramObject> schedulingProgramObjects = programInstanceService.getSendMesssageEvents();
-
- for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
- {
- String message = schedulingProgramObject.getMessage();
- try
- {
- OutboundSms outboundSms = new OutboundSms( message, schedulingProgramObject.getPhoneNumber() );
- outboundSms.setSender( DHIS_SYSTEM_SENDER );
- outboundSmsService.sendMessage( outboundSms, null );
-
- ProgramInstance programInstance = programInstanceService.getProgramInstance( schedulingProgramObject.getProgramInstanceId() );
- List<OutboundSms> messages = programInstance.getOutboundSms();
- if( messages == null )
- {
- messages = new ArrayList<OutboundSms>();
- }
- messages.add( outboundSms );
- programInstance.setOutboundSms( messages );
- programInstanceService.updateProgramInstance( programInstance );
- }
- catch ( SmsServiceException e )
- {
- message = e.getMessage();
- }
- }
-
- // ---------------------------------------------------------------------
- // Send program-stage-instance messages
- // ---------------------------------------------------------------------
-
- schedulingProgramObjects = programStageInstanceService.getSendMesssageEvents();
-
- for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
- {
- String message = schedulingProgramObject.getMessage();
-
- String phoneNumber = schedulingProgramObject.getPhoneNumber();
-
- try
- {
- OutboundSms outboundSms = new OutboundSms( message, phoneNumber );
- outboundSms.setSender( DHIS_SYSTEM_SENDER );
- outboundSmsService.sendMessage( outboundSms, null );
-
- ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( schedulingProgramObject.getProgramStageInstanceId() );
- List<OutboundSms> messages = programStageInstance.getOutboundSms();
- if( messages == null )
- {
- messages = new ArrayList<OutboundSms>();
- }
- messages.add( outboundSms );
- programStageInstance.setOutboundSms( messages );
- programStageInstanceService.updateProgramStageInstance( programStageInstance );
- }
- catch ( SmsServiceException e )
- {
- message = e.getMessage();
- }
- }
-
- return SUCCESS;
- }
-
-}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleSendMessageTasksAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleSendMessageTasksAction.java 2012-09-25 06:44:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleSendMessageTasksAction.java 2013-04-11 06:26:56 +0000
@@ -36,8 +36,13 @@
import java.util.Map;
import org.hisp.dhis.patient.scheduling.ProgramSchedulingManager;
+import org.hisp.dhis.patient.scheduling.SendScheduledMessageTask;
+import org.hisp.dhis.scheduling.TaskCategory;
+import org.hisp.dhis.scheduling.TaskId;
import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.system.notification.Notifier;
import org.hisp.dhis.system.scheduling.Scheduler;
+import org.hisp.dhis.user.CurrentUserService;
import com.opensymphony.xwork2.Action;
@@ -67,6 +72,27 @@
this.schedulingManager = schedulingManager;
}
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
+ private SendScheduledMessageTask sendMessageScheduled;
+
+ public void setSendMessageScheduled( SendScheduledMessageTask sendMessageScheduled )
+ {
+ this.sendMessageScheduled = sendMessageScheduled;
+ }
+
+ private Notifier notifier;
+
+ public void setNotifier( Notifier notifier )
+ {
+ this.notifier = notifier;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -78,13 +104,6 @@
this.execute = execute;
}
- private boolean schedule;
-
- public void setSchedule( boolean schedule )
- {
- this.schedule = schedule;
- }
-
private String timeSendingMessage;
public void setTimeSendingMessage( String timeSendingMessage )
@@ -116,13 +135,17 @@
public String execute()
{
+ TaskId taskId = new TaskId( TaskCategory.SENDING_REMINDER_MESSAGE, currentUserService.getCurrentUser() );
+ notifier.clear( taskId );
+ sendMessageScheduled.setTaskId( taskId );
+
systemSettingManager.saveSystemSetting( KEY_TIME_FOR_SENDING_MESSAGE, timeSendingMessage );
-
+
if ( execute )
{
schedulingManager.executeTasks();
}
- else if ( schedule )
+ else
{
if ( Scheduler.STATUS_RUNNING.equals( schedulingManager.getTaskStatus() ) )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-10 09:48:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-11 06:26:56 +0000
@@ -1039,17 +1039,9 @@
<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
<property name="schedulingManager"
ref="org.hisp.dhis.patient.scheduling.ProgramSchedulingManager" />
- </bean>
-
- <bean id="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction"
- class="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction"
- scope="prototype">
- <property name="programStageInstanceService"
- ref="org.hisp.dhis.program.ProgramStageInstanceService" />
- <property name="programInstanceService"
- ref="org.hisp.dhis.program.ProgramInstanceService" />
- <property name="outboundSmsService"
- ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
+ <property name="notifier" ref="notifier" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ <property name="sendMessageScheduled" ref="sendMessageScheduled" />
</bean>
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2013-04-05 07:46:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2013-04-11 06:26:56 +0000
@@ -1066,14 +1066,6 @@
<param name="requiredAuthorities">F_SCHEDULING_SEND_MESSAGE</param>
</action>
- <action name="executeSendMessage"
- class="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction">
- <result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonResponseSuccess.vm
- </result>
- <param name="requiredAuthorities">F_SCHEDULING_SEND_MESSAGE</param>
- </action>
-
<action name="viewScheduledCaseAggCondTasks"
class="org.hisp.dhis.patient.action.schedule.GetScheduleAggQueryBuilderParamsAction">
<result name="success" type="velocity">/main.vm</result>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js 2013-04-02 05:15:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js 2013-04-11 06:26:56 +0000
@@ -7,8 +7,6 @@
{
$.post( 'scheduleTasks.action',{
execute:false,
- schedule: true,
- gateWayId: getFieldValue("gatewayId"),
timeSendingMessage: getFieldValue("timeSendingMessage")
}, function( json ){
var status = json.scheduleTasks.status;
@@ -30,16 +28,23 @@
function executeTasks()
{
var ok = confirm( i18n_execute_tasks_confirmation );
- setWaitMessage( i18n_executing );
if ( ok )
{
- $.post( 'executeSendMessage.action',{}
- , function( json ){
- setMessage(i18n_execute_success);
+ $.post( 'scheduleTasks.action',{
+ execute:true,
+ timeSendingMessage: getFieldValue("timeSendingMessage")
+ }, function( json ){
+ pingMessageNotificationsTimeout();
});
}
}
+function pingMessageNotificationsTimeout()
+{
+ pingNotifications( 'SENDING_REMINDER_MESSAGE', 'notificationTable' );
+ setTimeout( "pingMessageNotificationsTimeout()", 200 );
+}
+
// -----------------------------------------------------------------------
// Schedule Automated Aggregate
// -----------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm 2012-11-02 15:59:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm 2013-04-11 06:26:56 +0000
@@ -1,4 +1,5 @@
<h3>$i18n.getString('schedule_automated_message_reminder_form') #openHelp( "schedule_sending_message" )</h3>
+
<form id='scheduleMessageForm' name='scheduleMessageForm' method="post">
<table>
<tbody>
@@ -26,7 +27,12 @@
</tbody>
</table>
<span id="info">$i18n.getString( "scheduling_is" ) $!i18n.getString( $!status )</span>
- <span id='message'></span>
+
+ <table id="notificationTable" class="notificationTable" style="display:none">
+ <col width="120">
+ <col width="380">
+ </table>
+
</form>
<script>