← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17125: Fixed bug - Sending scheduled message is wrong time which was set in Schedule automated message ...

 

------------------------------------------------------------
revno: 17125
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-10-15 21:21:42 +0700
message:
  Fixed bug - Sending scheduled message is wrong time which was set in  Schedule automated message reminder.
modified:
  dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/SendScheduledMessageTask.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackingEventMessage.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-eventreporting/src/main/java/org/hisp/dhis/scheduling/SendScheduledMessageTask.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/SendScheduledMessageTask.java	2014-05-16 08:12:25 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/SendScheduledMessageTask.java	2014-10-15 14:21:42 +0000
@@ -30,8 +30,11 @@
 
 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.Date;
 import java.util.List;
+
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramStageInstanceService;
 import org.hisp.dhis.program.SchedulingProgramObject;
@@ -143,9 +146,7 @@
 
             scheduleProgramStageInstanceMessage();
             scheduleProgramInstanceMessage();
-
-            sendMessage();
-
+            
             clock.logTime( "Preparing reminder messages completed" );
             notifier.notify( taskId, INFO, "Preparing reminder messages completed", true );
         }
@@ -255,6 +256,7 @@
         {
             for ( OutboundSms outboundSms : outboundSmsList )
             {
+                outboundSms.setDate( new Date() );
                 outboundSms.setStatus( OutboundSmsStatus.SENT );
                 smsSender.sendMessage( outboundSms, null );
             }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2014-10-07 15:18:38 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2014-10-15 14:21:42 +0000
@@ -261,54 +261,57 @@
 
         Collection<SchedulingProgramObject> schedulingProgramObjects = new HashSet<>();
         
-        
-        while ( rs.next() )
+        if ( rs.getRow() > 0 )
         {
-            String message = rs.getString( "templatemessage" );
-  
-            int programInstanceId = rs.getInt( "programinstanceid" ) ;
-            
-            List<String> attributeUids = reminderService.getAttributeUids( message );
-            SqlRowSet attributeValueRow = jdbcTemplate
-                .queryForRowSet( "select tea.uid ,teav.value from trackedentityattributevalue teav "
-                    + " INNER JOIN trackedentityattribute tea on tea.trackedentityattributeid=teav.trackedentityattributeid "
-                    + " INNER JOIN programinstance ps on teav.trackedentityinstanceid=ps.trackedentityinstanceid "
-                    + " INNER JOIN programstageinstance psi on ps.programinstanceid=psi.programinstanceid "
-                    + " where tea.uid in ( " + TextUtils.getQuotedCommaDelimitedString( attributeUids ) + ") "
-                    + " and ps.programinstanceid=" + programInstanceId );
-            while ( attributeValueRow.next() )
+            while ( rs.next() )
             {
-                String uid = attributeValueRow.getString( "uid" );
-                String value = attributeValueRow.getString( "value" );
-                String key = "\\{(" + TrackedEntityInstanceReminder.ATTRIBUTE + ")=(" + uid + ")\\}";
-                message = message.replaceAll( key, value );
+                String message = rs.getString( "templatemessage" );
+
+                int programInstanceId = rs.getInt( "programinstanceid" );
+
+                List<String> attributeUids = reminderService.getAttributeUids( message );
+                SqlRowSet attributeValueRow = jdbcTemplate
+                    .queryForRowSet( "select tea.uid ,teav.value from trackedentityattributevalue teav "
+                        + " INNER JOIN trackedentityattribute tea on tea.trackedentityattributeid=teav.trackedentityattributeid "
+                        + " INNER JOIN programinstance ps on teav.trackedentityinstanceid=ps.trackedentityinstanceid "
+                        + " INNER JOIN programstageinstance psi on ps.programinstanceid=psi.programinstanceid "
+                        + " where tea.uid in ( " + TextUtils.getQuotedCommaDelimitedString( attributeUids ) + ") "
+                        + " and ps.programinstanceid=" + programInstanceId );
+                while ( attributeValueRow.next() )
+                {
+                    String uid = attributeValueRow.getString( "uid" );
+                    String value = attributeValueRow.getString( "value" );
+                    String key = "\\{(" + TrackedEntityInstanceReminder.ATTRIBUTE + ")=(" + uid + ")\\}";
+                    message = message.replaceAll( key, value );
+                }
+
+                String organisationunitName = rs.getString( "orgunitName" );
+                String programName = rs.getString( "programName" );
+                String incidentDate = rs.getString( "dateofincident" ).split( " " )[0];
+                String daysSinceIncidentDate = rs.getString( "days_since_incident_date" );
+                String erollmentDate = rs.getString( "enrollmentdate" ).split( " " )[0];
+                String daysSinceEnrollementDate = rs.getString( "days_since_erollment_date" );
+
+                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_PROGRAM_NAME, programName );
+                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_ORGUNIT_NAME,
+                    organisationunitName );
+                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_INCIDENT_DATE, incidentDate );
+                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_ENROLLMENT_DATE,
+                    erollmentDate );
+                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_ENROLLMENT_DATE,
+                    daysSinceEnrollementDate );
+                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_INCIDENT_DATE,
+                    daysSinceIncidentDate );
+
+                SchedulingProgramObject schedulingProgramObject = new SchedulingProgramObject();
+                schedulingProgramObject.setProgramInstanceId( programInstanceId );
+                schedulingProgramObject.setPhoneNumber( rs.getString( "phonenumber" ) );
+                schedulingProgramObject.setMessage( message );
+
+                schedulingProgramObjects.add( schedulingProgramObject );
             }
-
-            String organisationunitName = rs.getString( "orgunitName" );
-            String programName = rs.getString( "programName" );
-            String incidentDate = rs.getString( "dateofincident" ).split( " " )[0];
-            String daysSinceIncidentDate = rs.getString( "days_since_incident_date" );
-            String erollmentDate = rs.getString( "enrollmentdate" ).split( " " )[0];
-            String daysSinceEnrollementDate = rs.getString( "days_since_erollment_date" );
-
-            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_PROGRAM_NAME, programName );
-            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_ORGUNIT_NAME,
-                organisationunitName );
-            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_INCIDENT_DATE, incidentDate );
-            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_ENROLLMENT_DATE, erollmentDate );
-            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_ENROLLMENT_DATE,
-                daysSinceEnrollementDate );
-            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_INCIDENT_DATE,
-                daysSinceIncidentDate );
-            
-            SchedulingProgramObject schedulingProgramObject = new SchedulingProgramObject();
-            schedulingProgramObject.setProgramInstanceId( programInstanceId );
-            schedulingProgramObject.setPhoneNumber( rs.getString( "phonenumber" ) );
-            schedulingProgramObject.setMessage( message );
-
-            schedulingProgramObjects.add( schedulingProgramObject );
         }
-
+        
         return schedulingProgramObjects;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm	2014-07-08 05:38:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm	2014-10-15 14:21:42 +0000
@@ -84,7 +84,7 @@
 					<td>$format.formatDateTime($!sms.date)</td>
 					<td>$programStageInstance.programStage.displayName</td>
 					<td>$sms.sender</td>
-					<td>$i18n.getString('message')</td>
+					<td>$i18n.getString('sms')</td>
 					<td #if( $sms.status=='ERROR') style="color:red" #end >$sms.status</td>
 					<td>$sms.message</td>
 					<td>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackingEventMessage.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackingEventMessage.vm	2014-07-08 05:47:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackingEventMessage.vm	2014-10-15 14:21:42 +0000
@@ -37,7 +37,7 @@
 				<td>$format.formatDateTime($!sms.date)</td>
 				<td>$encoder.htmlEncode($programStageInstance.programStage.displayName)</td>
 				<td>$encoder.htmlEncode($sms.sender)</td>
-				<td>$i18n.getString('message')</td>
+				<td>$i18n.getString('sms')</td>
 				<td #if( $sms.status=='ERROR') style="color:red" #end >$sms.status</td>
 				<td>$encoder.htmlEncode($sms.message)</td>
 				<td>