← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17014: properly report import, updated, deleted data-values in AbstractEventService

 

------------------------------------------------------------
revno: 17014
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-10-09 14:03:34 +0700
message:
  properly report import,updated,deleted data-values in AbstractEventService
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java


--
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/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java	2014-10-09 06:53:32 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java	2014-10-09 07:03:34 +0000
@@ -308,8 +308,7 @@
                         {
                             if ( !CodeGenerator.isValidCode( event.getEvent() ) )
                             {
-                                return new ImportSummary( ImportStatus.ERROR,
-                                    "Event.event did not point to a valid event" );
+                                return new ImportSummary( ImportStatus.ERROR, "Event.event did not point to a valid event" );
                             }
                         }
                     }
@@ -520,7 +519,7 @@
                 TrackedEntityDataValue existingDataValue = existingDataValues.get( value.getDataElement() );
 
                 saveDataValue( programStageInstance, event.getStoredBy(), dataElement, value.getValue(),
-                    value.getProvidedElsewhere(), existingDataValue );
+                    value.getProvidedElsewhere(), existingDataValue, null );
             }
         }
 
@@ -744,7 +743,7 @@
     }
 
     private void saveDataValue( ProgramStageInstance programStageInstance, String storedBy, DataElement dataElement,
-        String value, Boolean providedElsewhere, TrackedEntityDataValue dataValue )
+        String value, Boolean providedElsewhere, TrackedEntityDataValue dataValue, ImportSummary importSummary )
     {
         if ( value != null && value.trim().length() == 0 )
         {
@@ -760,6 +759,11 @@
                 dataValue.setProvidedElsewhere( providedElsewhere );
 
                 dataValueService.saveTrackedEntityDataValue( dataValue );
+
+                if ( importSummary != null )
+                {
+                    importSummary.getDataValueCount().incrementImported();
+                }
             }
             else
             {
@@ -769,11 +773,21 @@
                 dataValue.setProvidedElsewhere( providedElsewhere );
 
                 dataValueService.updateTrackedEntityDataValue( dataValue );
+
+                if ( importSummary != null )
+                {
+                    importSummary.getDataValueCount().incrementUpdated();
+                }
             }
         }
         else if ( dataValue != null )
         {
             dataValueService.deleteTrackedEntityDataValue( dataValue );
+
+            if ( importSummary != null )
+            {
+                importSummary.getDataValueCount().incrementDeleted();
+            }
         }
     }
 
@@ -892,10 +906,8 @@
                         TrackedEntityDataValue existingDataValue = dataElementValueMap.get( dataValue.getDataElement() );
 
                         saveDataValue( programStageInstance, dataValueStoredBy, dataElement, dataValue.getValue(),
-                            dataValue.getProvidedElsewhere(), existingDataValue );
+                            dataValue.getProvidedElsewhere(), existingDataValue, importSummary );
                     }
-
-                    importSummary.getDataValueCount().incrementImported();
                 }
             }
             else