← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8982: [mobile] fix program validation

 

------------------------------------------------------------
revno: 8982
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Tue 2012-11-13 11:26:49 +0700
message:
  [mobile] fix program validation
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/programStageForm.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-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java	2012-11-08 13:33:53 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java	2012-11-13 04:26:49 +0000
@@ -41,6 +41,7 @@
 import org.hisp.dhis.api.mobile.model.ActivityValue;
 import org.hisp.dhis.api.mobile.model.DataElement;
 import org.hisp.dhis.api.mobile.model.DataValue;
+import org.hisp.dhis.program.ProgramExpressionService;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.i18n.I18nFormat;
@@ -63,10 +64,9 @@
 import org.hisp.dhis.program.ProgramValidationResult;
 import org.hisp.dhis.program.ProgramValidationService;
 import org.hisp.dhis.util.ContextUtils;
-
 import com.opensymphony.xwork2.Action;
 import com.opensymphony.xwork2.ActionContext;
-//import org.hisp.dhis.api.mobile.model.ProgramStage;
+
 
 public class SaveProgramStageFormAction
     implements Action
@@ -204,7 +204,19 @@
     {
         this.programStageSectionService = programStageSectionService;
     }
+    
+    private ProgramExpressionService programExpressionService;
+    
+    public ProgramExpressionService getProgramExpressionService()
+    {
+        return programExpressionService;
+    }
 
+    public void setProgramExpressionService( ProgramExpressionService programExpressionService )
+    {
+        this.programExpressionService = programExpressionService;
+    }
+        
     // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------
@@ -357,7 +369,7 @@
         this.patient = patient;
     }
 
-    private Map<Integer, String> leftsideFormulaMap;
+    private Map<Integer, String> leftsideFormulaMap = new HashMap<Integer, String>();;
 
     public Map<Integer, String> getLeftsideFormulaMap()
     {
@@ -369,7 +381,7 @@
         this.leftsideFormulaMap = leftsideFormulaMap;
     }
 
-    private Map<Integer, String> rightsideFormulaMap;
+    private Map<Integer, String> rightsideFormulaMap = new HashMap<Integer, String>();;
 
     public Map<Integer, String> getRightsideFormulaMap()
     {
@@ -565,6 +577,7 @@
         ProgramStageInstance programStageInstance )
     {
         programValidationResults = new ArrayList<ProgramValidationResult>();
+        
         if ( validations != null )
         {
             for ( ProgramValidation validation : validations )
@@ -575,8 +588,19 @@
                 if ( validationResult != null )
                 {
                     programValidationResults.add( validationResult );
+                    
+                    leftsideFormulaMap.put(
+                        validationResult.getProgramValidation().getId(),
+                        programExpressionService.getExpressionDescription( validationResult.getProgramValidation()
+                            .getLeftSide().getExpression() ) );
+                    
+                    rightsideFormulaMap.put(
+                        validationResult.getProgramValidation().getId(),
+                        programExpressionService.getExpressionDescription( validationResult.getProgramValidation()
+                            .getRightSide().getExpression() ) );
                 }
             }
         }
+        
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2012-10-29 03:48:40 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2012-11-13 04:26:49 +0000
@@ -210,6 +210,7 @@
 		<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="programValidationService" ref="org.hisp.dhis.program.ProgramValidationService" />
 		<property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService"/>
+		<property name="programExpressionService" ref="org.hisp.dhis.program.ProgramExpressionService" />
 
 	</bean>
 

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/programStageForm.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/programStageForm.vm	2012-11-07 12:55:09 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/programStageForm.vm	2012-11-13 04:26:49 +0000
@@ -15,8 +15,11 @@
 	<h3 style="text-align: left; background-color: #990000; color: white;">$i18n.getString("warnings_and_errors")</h3>
 	<p style="text-align: left;">
 		#if ($typeViolationsSize > 0)$typeViolationsSize $i18n.getString("type_violation_errors"). <br /> #end
-		#foreach($programValidation in $programValidationResults)
-			$programValidation.programValidation.description . <br/>
+		#foreach($result in $programValidationResults)
+			#set ( $id = $result.programValidation.id )
+			#set ( $leftFormula = $leftsideFormulaMap.get( $id ) )
+			#set ( $rightFormula = $rightsideFormulaMap.get( $id ) )
+			$!encoder.htmlEncode( $leftFormula ) $encoder.htmlEncode( $result.programValidation.operator.mathematicalOperator ) $!encoder.htmlEncode( $rightFormula ) <br/>
 		#end
 		#if ($programViolationsSize > 0 && $typeViolationsSize == 0) <a href="showPatientProgramList.action?patientId=${patientId}">$i18n.getString("save_any_way")</a> #end	
 	</p>