← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11266: Data value import, validation of comments

 

------------------------------------------------------------
revno: 11266
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-06-26 14:31:29 +0200
message:
  Data value import, validation of comments
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties


--
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/dataanalysis/DataAnalysisStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java	2012-07-25 13:18:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java	2013-06-26 12:31:29 +0000
@@ -51,7 +51,7 @@
      * @param dataElement the DataElement.
      * @param categoryOptionCombo the DataElementCategoryOptionCombo.
      * @param organisationUnit the OrganisationUnit.
-     * @return the standard deviation.
+     * @return a mapping between organisation unit identifier and its standard deviation.
      */
     Map<Integer, Double> getStandardDeviation( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, Set<Integer> organisationUnits );
     
@@ -62,10 +62,20 @@
      * @param dataElement the DataElement.
      * @param categoryOptionCombo the DataElementCategoryOptionCombo.
      * @param organisationUnit the OrganisationUnit.
-     * @return the average.
+     * @return a mapping between organisation unit identifier and its average data value.
      */
     Map<Integer, Double> getAverage( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, Set<Integer> organisationUnits );
     
+    /**
+     * Generates a collection of data value violations of min-max predefined values.
+     * 
+     * @param dataElements the data elements.
+     * @param categoryOptionCombos the category option combos.
+     * @param periods the periods.
+     * @param organisationUnits the organisation units.
+     * @param limit the max limit of violations to return.
+     * @return a collection of data value violations.
+     */
     Collection<DeflatedDataValue> getMinMaxViolations( Collection<DataElement> dataElements, Collection<DataElementCategoryOptionCombo> categoryOptionCombos,
         Collection<Period> periods, Collection<OrganisationUnit> organisationUnits, int limit );
     

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2013-06-23 18:19:54 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2013-06-26 12:31:29 +0000
@@ -374,6 +374,14 @@
                 summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), valueValid ) );
                 continue;
             }
+            
+            String commentValid = ValidationUtils.commentIsValid( dataValue.getComment() );
+            
+            if ( commentValid != null )
+            {
+                summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), commentValid ) );
+                continue;
+            }
 
             if ( periodMap.containsKey( dataValue.getPeriod() ) )
             {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml	2012-11-07 08:12:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml	2013-06-26 12:31:29 +0000
@@ -13,7 +13,7 @@
       <key-many-to-one name="optionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" column="categoryoptioncomboid" foreign-key="fk_datavalue_categoryoptioncomboid" />
     </composite-id>
 
-    <property name="value" />
+    <property name="value" length="255" />
 
     <property name="storedBy" column="storedby" length="100" />
 

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java	2013-05-17 06:44:41 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java	2013-06-26 12:31:29 +0000
@@ -217,7 +217,6 @@
      * values are:
      * <p/>
      * <ul>
-     * <li>value_null_or_empty</li>
      * <li>data_element_or_type_null_or_empty</li>
      * <li>value_length_greater_than_max_length</li>
      * <li>value_not_numeric</li>
@@ -280,4 +279,30 @@
 
         return null;
     }
+    
+    /**
+     * Checks if the given comment is valid. Returns null if valid and a string
+     * if invalid, possible values are:
+     * </p>
+     * <ul>
+     * <li>comment_too_long</li>
+     * </ul>
+     * 
+     * @param comment the comment.
+     * @return null if the comment is valid, a string if not.
+     */
+    public static String commentIsValid( String comment )
+    {
+        if ( comment == null || comment.trim().isEmpty() )
+        {
+            return null;
+        }
+        
+        if ( comment.length() > 360 )
+        {
+            return "comment_too_long";
+        }
+        
+        return null;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2013-05-30 11:20:45 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2013-06-26 12:31:29 +0000
@@ -316,4 +316,12 @@
 dxf2=DXF2
 metadata_import=Meta-Data Import
 metadata_export=Meta-Data Export
-gml_import=GML Import
\ No newline at end of file
+gml_import=GML Import
+data_element_or_type_null_or_empty=Data element or type is null or empty
+value_length_greater_than_max_length=Value is greater than max length
+value_not_numeric=Value is not numeric
+value_not_integer=Value is not a valid integer
+value_not_positive_integer=Value is not a valid positive integer
+value_not_negative_integer=Value is not a valid negative integer
+value_is_zero_and_not_zero_significant=Value is zero and not zero-significant
+comment_too_long=Comment is too long
\ No newline at end of file