← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20390: Fixed bug - Exception thrown when to run Schedule Automated Message function.

 

------------------------------------------------------------
revno: 20390
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-28 12:06:45 -0700
message:
  Fixed bug - Exception thrown when to run Schedule Automated Message function.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminder.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramReminder.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramReminder.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/caseaggregation/CaseAggregationCondition.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java	2015-09-28 19:06:45 +0000
@@ -82,7 +82,7 @@
     
     public static String FORMULA_VISIT = "visit";
     
-    public static String OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE = "dateOfIncident";
+    public static String OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE = "incidentDate";
 
     public static String OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE = "enrollmentDate";
 
@@ -117,14 +117,14 @@
         + OBJECT_TRACKED_ENTITY_ATTRIBUTE + "|" + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT
         + "([a-zA-Z0-9@#\\- ]+[" + SEPARATOR_ID + "[a-zA-Z0-9]*]*)" + "\\]";
 
-    // Date dataElement - currentDate/dateOfIncident/executionDate/enrollmentDate
+    // Date dataElement - currentDate/incidentDate/executionDate/enrollmentDate
     public static final String minusDataelementRegExp1 = MINUS_OPERATOR + "{1}\\s*\\(\\s*\\["
         + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([0-9]+)+" + SEPARATOR_ID + "([0-9]+)+" + SEPARATOR_ID
         + "([0-9]+)+\\]\\s*(,)\\s*" + "(" + CURRENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE + "|"
         + OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_REPORT_DATE
         + ")\\s*\\)\\s*(>=|<=|!=|>|<|=){1}\\s*([0-9]+){1}";
 
-    // currentDate/dateOfIncident/executionDate/enrollmentDate - Date dataElement
+    // currentDate/incidentDate/executionDate/enrollmentDate - Date dataElement
     public static final String minusDataelementRegExp2 = MINUS_OPERATOR + "{1}\\s*\\(\\s*(" + CURRENT_DATE + "|"
         + OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE + "|"
         + OBJECT_PROGRAM_PROPERTY_REPORT_DATE + ")\\s*(,)\\s*\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT
@@ -137,13 +137,13 @@
         + "[0-9]+)+\\])\\s*(,)\\s*(\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([0-9]+"
         + SEPARATOR_ID + "[0-9]+" + SEPARATOR_ID + "[0-9]+)+\\])\\s*\\)\\s*(>=|<=|!=|>|<|=){1}\\s*([0-9]+)";
 
-    // currentDate/ dateOfIncident/executionDate/enrollmentDate - Date attribute
+    // currentDate/ incidentDate/executionDate/enrollmentDate - Date attribute
     public static final String minusAttributeRegExp1 = MINUS_OPERATOR + "{1}\\s*\\(\\s*(" + CURRENT_DATE + "|"
         + OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE + "|"
         + OBJECT_PROGRAM_PROPERTY_REPORT_DATE + ")\\s*(,)\\s*\\[" + OBJECT_TRACKED_ENTITY_ATTRIBUTE + SEPARATOR_OBJECT
         + "([0-9]+)+\\]\\s*\\)\\s(>=|<=|!=|>|<|=){1}\\s*([0-9]+){1}";
 
-    // Date attribute - currentDate/ dateOfIncident/executionDate/enrollmentDate
+    // Date attribute - currentDate/ incidentDate/executionDate/enrollmentDate
     public static final String minusAttributeRegExp2 = MINUS_OPERATOR + "{1}\\s*\\(\\s*\\["
         + OBJECT_TRACKED_ENTITY_ATTRIBUTE + SEPARATOR_OBJECT + "([0-9]+)+\\]\\s*(,)\\s*(" + CURRENT_DATE + "|"
         + OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE + "|"

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2015-09-10 10:49:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2015-09-28 19:06:45 +0000
@@ -159,10 +159,10 @@
      * @param programInstance the program instance.
      * @param programStage the program stage.
      * @param enrollmentDate the enrollment date.
-     * @param dateOfIncident the date of incident.
+     * @param incidentDate the date of incident.
      * @param organisationUnit the organisation unit where the event took place.
      * @return ProgramStageInstance a ProgramStageInstance object.
      */
     ProgramStageInstance createProgramStageInstance( ProgramInstance programInstance, ProgramStage programStage,
-        Date enrollmentDate, Date dateOfIncident, OrganisationUnit organisationUnit );
+        Date enrollmentDate, Date incidentDate, OrganisationUnit organisationUnit );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminder.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminder.java	2015-08-06 17:12:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminder.java	2015-09-28 19:06:45 +0000
@@ -60,7 +60,7 @@
 
     public static final String ENROLLEMENT_DATE_TO_COMPARE = "enrollmentdate";
 
-    public static final String INCIDENT_DATE_TO_COMPARE = "dateofincident";
+    public static final String INCIDENT_DATE_TO_COMPARE = "incidentdate";
 
     public static final String TEMPLATE_MESSSAGE_PROGRAM_NAME = "{program-name}";
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java	2015-09-25 10:35:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java	2015-09-28 19:06:45 +0000
@@ -73,7 +73,7 @@
 
     private static final String TAG_CLOSE = "/>";
 
-    private static final String PROGRAM_INCIDENT_DATE = "dateOfIncident";
+    private static final String PROGRAM_INCIDENT_DATE = "incidentDate";
 
     private static final String PROGRAM_ENROLLMENT_DATE = "enrollmentDate";
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2015-09-24 08:32:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2015-09-28 19:06:45 +0000
@@ -428,7 +428,7 @@
 
             String organisationunitName = rs.getString( "orgunitName" );
             String programName = rs.getString( "programName" );
-            String incidentDate = rs.getString( "dateofincident" ).split( " " )[0];
+            String incidentDate = rs.getString( "incidentdate" ).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" );
@@ -458,9 +458,9 @@
     private String sendMessageToTrackedEntityInstanceSql( String dateToCompare )
     {
         return "SELECT pi.programinstanceid, pav.value as phonenumber, prm.templatemessage, "
-            + "         org.name as orgunitName, " + "         pg.name as programName, pi.dateofincident , "
+            + "         org.name as orgunitName, " + "         pg.name as programName, pi.incidentDate, "
             + "         pi.enrollmentdate,(DATE(now()) - DATE(pi.enrollmentdate) ) as days_since_erollment_date, "
-            + "         (DATE(now()) - DATE(pi.dateofincident) ) as days_since_incident_date "
+            + "         (DATE(now()) - DATE(pi.incidentDate) ) as days_since_incident_date "
             + "       FROM trackedentityinstance p INNER JOIN programinstance pi "
             + "              ON p.trackedentityinstanceid=pi.trackedentityinstanceid INNER JOIN program pg "
             + "              ON pg.programid=pi.programid INNER JOIN organisationunit org "
@@ -479,8 +479,8 @@
     private String sendMessageToOrgunitRegisteredSql( String dateToCompare )
     {
         return "SELECT pi.programinstanceid, org.phonenumber, prm.templatemessage, org.name as orgunitName, "
-            + "   pg.name as programName, pi.dateofincident, pi.enrollmentdate,(DATE(now()) - DATE(pi.enrollmentdate) ) as days_since_erollment_date, "
-            + "       (DATE(now()) - DATE(pi.dateofincident) ) as days_since_incident_date "
+            + "   pg.name as programName, pi.incidentDate, pi.enrollmentdate,(DATE(now()) - DATE(pi.enrollmentdate) ) as days_since_erollment_date, "
+            + "       (DATE(now()) - DATE(pi.incidentDate) ) as days_since_incident_date "
             + "    FROM trackedentityinstance p INNER JOIN programinstance pi "
             + "           ON p.trackedentityinstanceid=pi.trackedentityinstanceid INNER JOIN program pg "
             + "           ON pg.programid=pi.programid INNER JOIN organisationunit org "
@@ -495,9 +495,9 @@
 
     private String sendMessageToUsersSql( String dateToCompare )
     {
-        return "SELECT pi.programinstanceid, uif.phonenumber, prm.templatemessage, org.name as orgunitName, pg.name as programName, pi.dateofincident ,"
+        return "SELECT pi.programinstanceid, uif.phonenumber, prm.templatemessage, org.name as orgunitName, pg.name as programName, pi.incidentDate ,"
             + "pi.enrollmentdate,(DATE(now()) - DATE(pi.enrollmentdate) ) as days_since_erollment_date, "
-            + "(DATE(now()) - DATE(pi.dateofincident) ) as days_since_incident_date "
+            + "(DATE(now()) - DATE(pi.incidentDate) ) as days_since_incident_date "
             + "FROM trackedentityinstance p INNER JOIN programinstance pi "
             + "    ON p.trackedentityinstanceid=pi.trackedentityinstanceid INNER JOIN program pg "
             + "    ON pg.programid=pi.programid INNER JOIN organisationunit org "
@@ -521,8 +521,8 @@
     private String sendMessageToUserGroupsSql( String dateToCompare )
     {
         return "select pi.programinstanceid, uif.phonenumber,prm.templatemessage, org.name as orgunitName ,"
-            + " pg.name as programName, pi.dateofincident, pi.enrollmentdate, (DATE(now()) - DATE(pi.enrollmentdate) ) as days_since_erollment_date, "
-            + "(DATE(now()) - DATE(pi.dateofincident) ) as days_since_incident_date "
+            + " pg.name as programName, pi.incidentDate, pi.enrollmentdate, (DATE(now()) - DATE(pi.enrollmentdate) ) as days_since_erollment_date, "
+            + "(DATE(now()) - DATE(pi.incidentDate) ) as days_since_incident_date "
             + "  from trackedentityinstance p INNER JOIN programinstance pi " + "       ON p.trackedentityinstanceid=pi.trackedentityinstanceid "
             + "   INNER JOIN program pg " + "       ON pg.programid=pi.programid "
             + "   INNER JOIN organisationunit org " + "       ON org.organisationunitid = p.organisationunitid "

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java	2015-09-18 10:16:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java	2015-09-28 19:06:45 +0000
@@ -327,6 +327,8 @@
 
         updateProgramExpressionUid();
         
+        updatePropertiesChangeInCaseAggregate();
+        
         // TODO fix
         // executeSql( "DROP TABLE programstage_programindicators" );
     }
@@ -395,6 +397,42 @@
         }
     }
     
+    private void updatePropertiesChangeInCaseAggregate()
+    {
+        StatementHolder holder = statementManager.getHolder();
+        try
+        {
+            Statement statement = holder.getStatement();
+            ResultSet resultSet = statement
+                .executeQuery( "SELECT caseaggregationconditionid, aggregationExpression FROM caseaggregationcondition where LOWER(aggregationExpression) like '%dateofincident%'" );
+
+            while ( resultSet.next() )
+            {
+                String id = resultSet.getString( "caseaggregationconditionid" );
+                String expression = resultSet.getString( "aggregationExpression" );
+
+                expression = expression.replaceAll( "dateOfIncident", "incidentDate" );
+                expression = expression.replaceAll( "dateofincident", "incidentDate" );
+                expression = expression.replaceAll( "'", "''" );
+                
+                executeSql( "UPDATE caseaggregationcondition SET aggregationExpression='" + expression
+                    + "'  WHERE caseaggregationconditionid=" + id );
+                
+                System.out.println("\n\n ---  " + "UPDATE caseaggregationcondition SET aggregationExpression='" + expression
+                    + "'  WHERE caseaggregationconditionid=" + id + "\n\n ");
+            }
+        }
+        catch ( Exception ex )
+        {
+            log.debug( ex );
+        }
+        finally
+        {
+            holder.close();
+        }
+    }
+  
+    
     private void updateProgramInstanceStatus()
     {
         // Set active status for events

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramReminder.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramReminder.vm	2015-06-10 08:33:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addProgramReminder.vm	2015-09-28 19:06:45 +0000
@@ -52,7 +52,7 @@
 			<td>
 				<select id='datesToCompare' name='datesToCompare'/>
 					<option value="enrollmentdate">$i18n.getString( "enrollment_date" )</option>
-					<option value="dateofincident">$i18n.getString( "incident_date" )</option>
+					<option value="incidentDate">$i18n.getString( "incident_date" )</option>
 				</select>
 			</td>
 		</tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js	2015-09-09 20:18:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/program.js	2015-09-28 19:06:45 +0000
@@ -73,8 +73,8 @@
     var dataEntryMethod = ( json.program.dataEntryMethod == 'true') ? i18n_yes : i18n_no;
     setInnerHTML('dataEntryMethodField', dataEntryMethod);
 
-    setInnerHTML('dateOfEnrollmentDescriptionField', json.program.dateOfEnrollmentDescription);
-    setInnerHTML('dateOfIncidentDescriptionField', json.program.dateOfIncidentDescription);
+    setInnerHTML('enrollmentDateLabelField', json.program.enrollmentDateLabel);
+    setInnerHTML('incidentDateLabelField', json.program.incidentDateLabel);
     setInnerHTML('programStageCountField', json.program.programStageCount);
     setInnerHTML('noAttributesField', json.program.noAttributes);
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm	2015-09-09 20:18:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm	2015-09-28 19:06:45 +0000
@@ -48,7 +48,7 @@
           data-can-manage="$security.canManage( $program )"
           data-can-update="$security.canUpdate( $program )"
           data-can-defined-program-entry-form="#if($program.type!=3)true#{else}false#end"
-          data-can-manage-template-message="#if($program.programType.value=="without_registration")true#{else}false#end"
+          data-can-manage-template-message="#if($program.programType.value=="with_registration")true#{else}false#end"
 		  data-can-manage-program-rule="#if( $auth.hasAccess( "dhis-web-maintenance-program", "programRule" ) ) true #{else}false#end"
           data-can-delete="$security.canDelete( $program )"
           data-can-manage-form="#if( $auth.hasAccess( "dhis-web-maintenance-program", "programIndicator" ) && $program.programType.value=="with_registration")true#{else}false#end">
@@ -77,8 +77,8 @@
 				<p><label class="bold">$i18n.getString( "skip_to_generate_overdue_events" ):</label><br><span id="ignoreOverdueEventsField"></span></p>
 				<p><label class="bold">$i18n.getString( "only_enroll_once" ):</label><br><span id="onlyEnrollOnceField"></span></p>
 				<p><label class="bold">$i18n.getString( "show_incident_date" ):</label><br><span id="displayIncidentDate"></span></p>                              
-				<p><label class="bold">$i18n.getString( "date_of_incident_description" ):</label><br><span id="dateOfIncidentDescriptionField"></span></p>                              
-				<p><label class="bold">$i18n.getString( "date_of_enrollment_description" ):</label><br><span id="dateOfEnrollmentDescriptionField"></span></p>                          
+				<p><label class="bold">$i18n.getString( "date_of_incident_description" ):</label><br><span id="incidentDateLabelField"></span></p>                              
+				<p><label class="bold">$i18n.getString( "date_of_enrollment_description" ):</label><br><span id="enrollmentDateLabelField"></span></p>                          
 				<p><label class="bold">$i18n.getString( "number_of_attributes" ):</label><br><span id="noAttributesField"></span></p>
 				<p><label class="bold">$i18n.getString( "id" ):</label><br><span id="idField"></span></p>
 			</div>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramReminder.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramReminder.vm	2015-06-10 08:33:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramReminder.vm	2015-09-28 19:06:45 +0000
@@ -84,7 +84,7 @@
 			<td>
 				<select id='datesToCompare' name='datesToCompare' #if($!reminder.whenToSend==3) disabled #end />
 					<option value="enrollmentdate" #if($!reminder.dateToCompare=='enrollmentdate') selected #end>$i18n.getString( "enrollment_date" )</option>
-					<option value="dateofincident" #if($!reminder.dateToCompare=='dateofincident') selected #end>$i18n.getString( "incident_date" )</option>
+					<option value="incidentDate" #if($!reminder.dateToCompare=='incidentDate') selected #end>$i18n.getString( "incident_date" )</option>
 				</select>
 			</td>
 		</tr>