← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5623: (mobile) validation for data entry, wip..

 

------------------------------------------------------------
revno: 5623
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-27 13:16:47 +0100
message:
  (mobile) validation for data entry, wip..
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetOverviewAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties
  dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntryOverview.vm
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntrySection.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/dataentry/action/GetDataSetOverviewAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetOverviewAction.java	2011-12-27 10:32:41 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetOverviewAction.java	2011-12-27 12:16:47 +0000
@@ -39,7 +39,9 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.user.CurrentUserService;
 
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @author mortenoh
@@ -169,6 +171,13 @@
         this.markComplete = markComplete;
     }
 
+    private List<String> validationRuleViolations = new ArrayList<String>();
+
+    public List<String> getValidationRuleViolations()
+    {
+        return validationRuleViolations;
+    }
+
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -210,6 +219,8 @@
             }
         }
 
+        validationRuleViolations = formUtils.getValidationRuleViolations( organisationUnit, dataSet, period );
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java	2011-12-27 11:13:41 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java	2011-12-27 12:16:47 +0000
@@ -28,6 +28,7 @@
 package org.hisp.dhis.light.dataentry.action;
 
 import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementOperand;
 import org.hisp.dhis.dataset.DataSet;
@@ -40,10 +41,7 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author mortenoh
@@ -135,6 +133,11 @@
         this.sectionId = sectionId;
     }
 
+    public Integer getSectionId()
+    {
+        return sectionId;
+    }
+
     private DataSet dataSet;
 
     public DataSet getDataSet()
@@ -233,6 +236,7 @@
         {
             name = "Default";
             dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
+            Collections.sort( dataElements, new IdentifiableObjectNameComparator() );
         }
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java	2011-12-27 12:16:47 +0000
@@ -27,23 +27,15 @@
 
 package org.hisp.dhis.light.dataentry.action;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionContext;
 import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataset.CompleteDataSetRegistration;
-import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.dataset.*;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.datavalue.DeflatedDataValue;
@@ -56,8 +48,8 @@
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.util.ContextUtils;
 
-import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionContext;
+import javax.servlet.http.HttpServletRequest;
+import java.util.*;
 
 /**
  * @author mortenoh
@@ -184,6 +176,18 @@
         return dataSetId;
     }
 
+    private Integer sectionId;
+
+    public void setSectionId( Integer sectionId )
+    {
+        this.sectionId = sectionId;
+    }
+
+    public Integer getSectionId()
+    {
+        return sectionId;
+    }
+
     private DataSet dataSet;
 
     public DataSet getDataSet()
@@ -243,6 +247,20 @@
         return validated;
     }
 
+    private String name;
+
+    public String getName()
+    {
+        return name;
+    }
+
+    private List<DataElement> dataElements = new ArrayList<DataElement>();
+
+    public List<DataElement> getDataElements()
+    {
+        return dataElements;
+    }
+
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -303,7 +321,7 @@
                         if ( !valueIsEmpty && !FormUtils.isBoolean( value ) )
                         {
                             correctType = false;
-                            typeViolations.put( key, value + " " + i18n.getString( "is_invalid_boolean" ) );
+                            typeViolations.put( key, "\"" + value + "\"" + " " + i18n.getString( "is_invalid_boolean" ) );
                         }
                     }
                     else if ( type.equals( DataElement.VALUE_TYPE_DATE ) )
@@ -311,7 +329,7 @@
                         if ( !FormUtils.isDate( value ) )
                         {
                             correctType = false;
-                            typeViolations.put( key, value + " " + i18n.getString( "is_invalid_date" ) );
+                            typeViolations.put( key, "\"" + value + "\"" + " " + i18n.getString( "is_invalid_date" ) );
                         }
                     }
                     else if ( type.equals( DataElement.VALUE_TYPE_INT )
@@ -320,7 +338,7 @@
                         if ( !FormUtils.isNumber( value ) )
                         {
                             correctType = false;
-                            typeViolations.put( key, value + " " + i18n.getString( "is_invalid_number" ) );
+                            typeViolations.put( key, "\"" + value + "\"" + " " + i18n.getString( "is_invalid_number" ) );
                         }
                     }
                     else if ( type.equals( DataElement.VALUE_TYPE_INT )
@@ -329,7 +347,7 @@
                         if ( !FormUtils.isInteger( value ) )
                         {
                             correctType = false;
-                            typeViolations.put( key, value + " " + i18n.getString( "is_invalid_integer" ) );
+                            typeViolations.put( key, "\"" + value + "\"" + " " + i18n.getString( "is_invalid_integer" ) );
                         }
                     }
                     else if ( type.equals( DataElement.VALUE_TYPE_INT )
@@ -338,7 +356,7 @@
                         if ( !FormUtils.isPositiveInteger( value ) )
                         {
                             correctType = false;
-                            typeViolations.put( key, value + " " + i18n.getString( "is_invalid_positive_integer" ) );
+                            typeViolations.put( key, "\"" + value + "\"" + " " + i18n.getString( "is_invalid_positive_integer" ) );
                         }
                     }
                     else if ( type.equals( DataElement.VALUE_TYPE_INT )
@@ -347,7 +365,7 @@
                         if ( !FormUtils.isNegativeInteger( value ) )
                         {
                             correctType = false;
-                            typeViolations.put( key, value + " " + i18n.getString( "is_invalid_negative_integer" ) );
+                            typeViolations.put( key, "\"" + value + "\"" + " " + i18n.getString( "is_invalid_negative_integer" ) );
                         }
                     }
                 }
@@ -412,6 +430,26 @@
             needsValidation = true;
         }
 
+        if ( sectionId != null )
+        {
+            for ( Section section : dataSet.getSections() )
+            {
+                if ( section.getId() == sectionId )
+                {
+                    name = section.getName();
+                    dataElements = section.getDataElements();
+
+                    break;
+                }
+            }
+        }
+        else
+        {
+            name = "Default";
+            dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
+            Collections.sort( dataElements, new IdentifiableObjectNameComparator() );
+        }
+
         dataValues = formUtils.getDataValueMap( organisationUnit, dataSet, period );
 
         validationViolations = formUtils.getValidationViolations( organisationUnit, dataSet, period );

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2011-12-27 11:13:41 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2011-12-27 12:16:47 +0000
@@ -9,6 +9,7 @@
 dashboard_reports=Dashboard reports
 dashboard_charts=Dashboard charts
 dashboard_documents=Dashboard documents
+data_entry=Data Entry
 data_entry_overview=Data Entry Overview
 logout=Logout
 desktop_version=Desktop version

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2011-12-27 11:13:41 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2011-12-27 12:16:47 +0000
@@ -42,7 +42,7 @@
     <action name="saveSectionForm" class="org.hisp.dhis.light.dataentry.action.SaveSectionFormAction">
       <result name="success" type="redirect">/mobile/dataEntry.action?organisationUnitId=${organisationUnitId}&amp;dataSetId=${dataSetId}&amp;periodId=${periodId}</result>
       <result name="error" type="velocity">/dhis-web-light/main.vm</result>
-      <param name="page">/dhis-web-light/dataEntry.vm</param>
+      <param name="page">/dhis-web-light/dataEntrySection.vm</param>
       <param name="requiredAuthorities">F_DATAVALUE_ADD,F_DATAVALUE_UPDATE,F_DATAVALUE_DELETE</param>
     </action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntryOverview.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntryOverview.vm	2011-12-27 11:13:41 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntryOverview.vm	2011-12-27 12:16:47 +0000
@@ -7,6 +7,17 @@
 
 <h2>$encoder.htmlEncode( $dataSetName )</h2>
 
+#if( $validationRuleViolations.size() > 0 )
+<div class="header-box" align="center">
+    <h3 style="text-align: left; background-color: #990000; color: white;">$i18n.getString("validation_rule_violations")</h3>
+    <p style="text-align: left;">
+        #foreach( $validationRuleViolation in $validationRuleViolations )
+            $validationRuleViolation <br />
+        #end
+    </p>
+</div>
+#end
+
 <p>
     <ul>
     #if( $dataSet.sections.size() > 0 )

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntrySection.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntrySection.vm	2011-12-27 11:18:41 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntrySection.vm	2011-12-27 12:16:47 +0000
@@ -9,17 +9,13 @@
 
 <h2>$encoder.htmlEncode( $dataSetName )</h2>
 
-#set( $validationRuleViolationsSize = $validationRuleViolations.size() )
 #set( $validationViolationsSize = $validationViolations.size() )
 #set( $typeViolationsSize = $typeViolations.size() )
 
-#if( $validationRuleViolationsSize > 0 || $validationViolationsSize > 0 || $typeViolationsSize > 0 )
+#if( $validationViolationsSize > 0 || $typeViolationsSize > 0 )
 <div class="header-box" align="center">
 	<h3 style="text-align: left; background-color: #990000; color: white;">$i18n.getString("warnings_and_errors")</h3>
 	<p style="text-align: left;">
-		#if( $validationRuleViolationsSize > 0 )
-			$validationRuleViolationsSize $i18n.getString("validation_rule_violation_warnings"). <br />
-		#end
 		#if( $validationViolationsSize > 0 )
 			$validationViolationsSize $i18n.getString("minmax_violation_warnings"). <br />
 		#end
@@ -30,22 +26,12 @@
 </div>
 #end
 
-#if( $validationRuleViolationsSize > 0 )
-<div class="header-box" align="center">
-	<h3 style="text-align: left; background-color: #990000; color: white;">$i18n.getString("validation_rule_violations")</h3>
-	<p style="text-align: left;">
-	#foreach( $validationRuleViolation in $validationRuleViolations )
-		$validationRuleViolation <br />
-	#end
-	</p>
-</div>
-#end
-
 <form action="saveSectionForm.action" method="POST">
 
 <input type="hidden" id="organisationUnitId" name="organisationUnitId" value="$organisationUnitId" />
 <input type="hidden" id="dataSetId" name="dataSetId" value="$dataSetId" />
 <input type="hidden" id="periodId" name="periodId" value="$periodId" />
+<input type="hidden" id="sectionId" name="sectionId" value="$sectionId" />
 <input type="hidden" id="validated" name="validated" value="#if($validated)true#{else}false#end" />
 
 #macro( createSection $sectionName $dataElements )