← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16985: Fixed bug - The atttribute values in the template messages are wrong.

 

------------------------------------------------------------
revno: 16985
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-10-07 22:18:38 +0700
message:
  Fixed bug - The atttribute values in the template messages are wrong.
modified:
  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/HibernateProgramStageInstanceStore.java


--
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-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-09-24 14:26:12 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2014-10-07 15:18:38 +0000
@@ -260,19 +260,22 @@
         SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );
 
         Collection<SchedulingProgramObject> schedulingProgramObjects = new HashSet<>();
-
+        
+        
         while ( rs.next() )
         {
-             String message = rs.getString( "templatemessage" );
-
+            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 ) + ") " );
-
+                    + " where tea.uid in ( " + TextUtils.getQuotedCommaDelimitedString( attributeUids ) + ") "
+                    + " and ps.programinstanceid=" + programInstanceId );
             while ( attributeValueRow.next() )
             {
                 String uid = attributeValueRow.getString( "uid" );
@@ -299,7 +302,7 @@
                 daysSinceIncidentDate );
             
             SchedulingProgramObject schedulingProgramObject = new SchedulingProgramObject();
-            schedulingProgramObject.setProgramInstanceId( rs.getInt( "programinstanceid" ) );
+            schedulingProgramObject.setProgramInstanceId( programInstanceId );
             schedulingProgramObject.setPhoneNumber( rs.getString( "phonenumber" ) );
             schedulingProgramObject.setMessage( message );
 

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2014-09-23 15:47:39 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2014-10-07 15:18:38 +0000
@@ -139,12 +139,14 @@
             String message = rs.getString( "templatemessage" );
             
             List<String> attributeUids = reminderService.getAttributeUids( message );
+            int programstageinstanceid = rs.getInt( "programstageinstanceid" );
             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 ) + ") " );
+                    + " where tea.uid in ( " + TextUtils.getQuotedCommaDelimitedString( attributeUids ) + ")  "
+                    + " and psi.programstageinstanceid=" + programstageinstanceid );
 
             while ( attributeValueRow.next() )
             {
@@ -168,7 +170,7 @@
             
 
             SchedulingProgramObject schedulingProgramObject = new SchedulingProgramObject();
-            schedulingProgramObject.setProgramStageInstanceId( rs.getInt( "programstageinstanceid" ) );
+            schedulingProgramObject.setProgramStageInstanceId( programstageinstanceid );
             schedulingProgramObject.setPhoneNumber( rs.getString( "phonenumber" ) );
             schedulingProgramObject.setMessage( message );