← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17681: Data import. Better user feedback. Check for non-existing category option combos.

 

------------------------------------------------------------
revno: 17681
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-12-08 23:01:08 +0200
message:
  Data import. Better user feedback. Check for non-existing category option combos.
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.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-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-12-07 13:56:05 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2014-12-08 21:01:08 +0000
@@ -105,12 +105,10 @@
 {
     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;
@@ -689,30 +687,42 @@
             totalCount++;
 
             DataElement dataElement = dataElementMap.get( trimToNull( dataValue.getDataElement() ) );
-            DataElementCategoryOptionCombo categoryOptionCombo = categoryOptionComboMap.get( trimToNull( dataValue.getCategoryOptionCombo() ) );
             Period period = outerPeriod != null ? outerPeriod : PeriodType.getPeriodFromIsoString( trimToNull( dataValue.getPeriod() ) );
             OrganisationUnit orgUnit = outerOrgUnit != null ? outerOrgUnit : orgUnitMap.get( trimToNull( dataValue.getOrgUnit() ) );
+            DataElementCategoryOptionCombo categoryOptionCombo = categoryOptionComboMap.get( trimToNull( dataValue.getCategoryOptionCombo() ) );
             DataElementCategoryOptionCombo attrOptionCombo = outerAttrOptionCombo != null ? outerAttrOptionCombo : 
                 categoryOptionComboMap.get( trimToNull( dataValue.getAttributeOptionCombo() ) );
 
             if ( dataElement == null )
             {
-                summary.getConflicts().add( new ImportConflict( DataElement.class.getSimpleName(), dataValue.getDataElement() ) );
+                summary.getConflicts().add( new ImportConflict( dataValue.getDataElement(), "Data element not found or not acccessible" ) );
                 continue;
             }
 
             if ( period == null )
             {
-                summary.getConflicts().add( new ImportConflict( Period.class.getSimpleName(), dataValue.getPeriod() ) );
+                summary.getConflicts().add( new ImportConflict( dataValue.getPeriod(), "Period not valid" ) );
                 continue;
             }
 
             if ( orgUnit == null )
             {
-                summary.getConflicts().add( new ImportConflict( OrganisationUnit.class.getSimpleName(), dataValue.getOrgUnit() ) );
+                summary.getConflicts().add( new ImportConflict( dataValue.getOrgUnit(), "Organisation unit not found or not acccessible" ) );
                 continue;
             }
 
+            if ( categoryOptionCombo == null && trimToNull( dataValue.getCategoryOptionCombo() ) != null )
+            {
+                summary.getConflicts().add( new ImportConflict( dataValue.getCategoryOptionCombo(), "Category option combo not found or not accessible" ) );
+                continue;
+            }
+            
+            if ( attrOptionCombo == null && trimToNull( dataValue.getAttributeOptionCombo() ) != null )
+            {
+                summary.getConflicts().add( new ImportConflict( dataValue.getAttributeOptionCombo(), "Attribute option combo not found or not accessible" ) );
+                continue;
+            }
+            
             if ( categoryOptionCombo == null )
             {
                 categoryOptionCombo = fallbackCategoryOptionCombo;
@@ -732,7 +742,7 @@
 
             if ( valueValid != null )
             {
-                summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), i18n.getString( valueValid ) + ERROR_SEP + dataValue.getValue() ) );
+                summary.getConflicts().add( new ImportConflict( dataValue.getValue(), i18n.getString( valueValid ) ) );
                 continue;
             }
 
@@ -740,7 +750,7 @@
 
             if ( commentValid != null )
             {
-                summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), i18n.getString( commentValid ) ) );
+                summary.getConflicts().add( new ImportConflict( "Comment", i18n.getString( commentValid ) ) );
                 continue;
             }
 
@@ -779,7 +789,7 @@
             
             if ( zeroInsignificant )
             {
-                summary.getConflicts().add( new ImportConflict( DataValue.class.getSimpleName(), ERROR_INSIGNIFICANT_ZERO ) );
+                summary.getConflicts().add( new ImportConflict( internalValue.getValue(), "Value is zero and not significant" ) );
                 continue;
             }
             

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm	2014-12-07 13:56:05 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm	2014-12-08 21:01:08 +0000
@@ -88,4 +88,4 @@
 </table>
 </div>
 
-<div id="importSummaryDiv" class="page formSection" style="display:none; width:400px; padding-bottom:20px;"></div>
+<div id="importSummaryDiv" class="page formSection" style="display:none; width:500px; padding-bottom:20px;"></div>