← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17583: Data import, displaying translated error messages in import summary

 

------------------------------------------------------------
revno: 17583
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-11-25 17:39:09 +0100
message:
  Data import, displaying translated error messages in import summary
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/DefaultI18nManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
  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/webapp/dhis-web-importexport/importSummary.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-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nManager.java	2014-07-24 16:46:51 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nManager.java	2014-11-25 16:39:09 +0000
@@ -42,6 +42,8 @@
 {
     String ID = I18nManager.class.getName();
 
+    I18n getI18n();
+    
     I18n getI18n( Locale locale );
 
     I18n getI18n( Class<?> clazz );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/DefaultI18nManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/DefaultI18nManager.java	2014-07-24 16:46:51 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/DefaultI18nManager.java	2014-11-25 16:39:09 +0000
@@ -68,6 +68,14 @@
     // -------------------------------------------------------------------------
 
     @Override
+    public I18n getI18n()
+    {
+        Locale locale = getCurrentLocale();
+        
+        return new I18n( getGlobalResourceBundle( locale ), null );
+    }
+
+    @Override
     public I18n getI18n( Locale locale )
     {
         return new I18n( getGlobalResourceBundle( locale ), null );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties	2014-11-25 12:35:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties	2014-11-25 16:39:09 +0000
@@ -193,6 +193,7 @@
 unsupported_browser=Please upgrade your browser. Internet Explorer version 8 and earlier is not supported.
 data_element_or_type_null_or_empty=Data element or type not defined
 value_length_greater_than_max_length=Value is greater than max length
+comment_length_greater_than_max_length=Comment is greater than max length
 value_not_numeric=Value is not numeric
 value_not_unit_interval=Value is not a unit interval
 value_not_percentage=Value is not a percentage

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2014-11-10 14:05:42 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2014-11-25 16:39:09 +0000
@@ -74,6 +74,8 @@
 import org.hisp.dhis.dxf2.metadata.ImportOptions;
 import org.hisp.dhis.dxf2.pdfform.PdfDataEntryFormUtil;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.importexport.ImportStrategy;
 import org.hisp.dhis.jdbc.batchhandler.DataValueBatchHandler;
 import org.hisp.dhis.node.types.CollectionNode;
@@ -103,14 +105,13 @@
 {
     private static final Log log = LogFactory.getLog( DefaultDataValueSetService.class );
 
+    private static final String ERROR_SEP = ": ";
     private static final String ERROR_INVALID_DATA_SET = "Invalid data set: ";
-
     private static final String ERROR_INVALID_PERIOD = "Invalid period: ";
-
     private static final String ERROR_INVALID_ORG_UNIT = "Invalid org unit: ";
-
     private static final String ERROR_OBJECT_NEEDED_TO_COMPLETE = "Must be provided to complete data set";
-
+    private static final String ERROR_INSIGNIFICANT_ZERO = "Value is zero and not significant";
+    
     @Autowired
     private IdentifiableObjectManager identifiableObjectManager;
 
@@ -137,6 +138,9 @@
 
     @Autowired
     private DataValueSetStore dataValueSetStore;
+    
+    @Autowired
+    private I18nManager i18nManager;
 
     @Autowired
     private Notifier notifier;
@@ -558,6 +562,8 @@
         notifier.clear( id ).notify( id, "Process started" );
 
         ImportSummary summary = new ImportSummary();
+        
+        I18n i18n = i18nManager.getI18n();
 
         importOptions = importOptions != null ? importOptions : ImportOptions.getDefaultImportOptions();
 
@@ -685,7 +691,7 @@
 
             if ( valueValid != null )
             {
-                summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), valueValid ) );
+                summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), i18n.getString( valueValid ) + ERROR_SEP + dataValue.getValue() ) );
                 continue;
             }
 
@@ -693,7 +699,7 @@
 
             if ( commentValid != null )
             {
-                summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), commentValid ) );
+                summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), i18n.getString( commentValid ) ) );
                 continue;
             }
 
@@ -728,13 +734,11 @@
             internalValue.setComment( trimToNull( dataValue.getComment() ) );
             internalValue.setFollowup( dataValue.getFollowup() );
 
-            String valid = ValidationUtils.dataValueIsValid( internalValue.getValue(), dataElement );
-
             boolean zeroInsignificant = ValidationUtils.dataValueIsZeroAndInsignificant( internalValue.getValue(), dataElement );
             
-            if ( valid != null || zeroInsignificant )
+            if ( zeroInsignificant )
             {
-                summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), internalValue.getValue() ) );
+                summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), ERROR_INSIGNIFICANT_ZERO ) );
                 continue;
             }
             

=== 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	2014-09-24 14:48:25 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java	2014-11-25 16:39:09 +0000
@@ -362,7 +362,7 @@
      * if invalid, possible values are:
      * </p>
      * <ul>
-     * <li>comment_too_long</li>
+     * <li>comment_length_greater_than_max_length</li>
      * </ul>
      * 
      * @param comment the comment.
@@ -377,7 +377,7 @@
         
         if ( comment.length() > VALUE_MAX_LENGTH )
         {
-            return "comment_too_long";
+            return "comment_length_greater_than_max_length";
         }
         
         return null;

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importSummary.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importSummary.vm	2012-04-30 20:10:16 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importSummary.vm	2014-11-25 16:39:09 +0000
@@ -8,23 +8,23 @@
 <h4>$i18n.getString( "import_count" )</h4>
 #if( $summary.dataValueCount )
 <table>
-<col width="110">
-<col width="110">
+<col width="120">
+<col width="260">
 <tr>
 	<th>$i18n.getString( "type" )</th>
-	<th style="text-align:center">$i18n.getString( "count" )</th>
+	<th>$i18n.getString( "count" )</th>
 </tr>
 <tr>
 	<td>$i18n.getString( "imported" )</td>
-	<td style="text-align:center">${summary.dataValueCount.imported}</td>
+	<td>${summary.dataValueCount.imported}</td>
 </tr>
 <tr>
 	<td>$i18n.getString( "updated" )</td>
-	<td style="text-align:center">${summary.dataValueCount.updated}</td>
+	<td>${summary.dataValueCount.updated}</td>
 </tr>
 <tr>
 	<td>$i18n.getString( "ignored" )</td>
-	<td style="text-align:center">${summary.dataValueCount.ignored}</td>
+	<td>${summary.dataValueCount.ignored}</td>
 </tr>
 </table>
 #else
@@ -34,8 +34,8 @@
 <h4>$i18n.getString( "conflicts" )</h4>
 #if( $summary.conflicts.size() > 0 )
 <table>
-<col width="110">
-<col width="110">
+<col width="120">
+<col width="260">
 <tr>
 	<th>$i18n.getString( "element" )</th>
 	<th>$i18n.getString( "description" )</th>