# HG changeset patch
# User Antonio Moreno <antonio.moreno@openbravo.com>
# Date 1456342079 -3600
#      Wed Feb 24 20:27:59 2016 +0100
# Node ID 37e248619d212bb91cddf392f5982b1a6f8d4997
# Parent  7c388d2db6de8db8919323a1f6e1355e084e406c
Fixed issue 32331. Prevent early update to the Import Entry record:
Before this change, if a request to the DataSynchronizationProcess contained more than one record, the Import Entry record was updated after the first one instead of being updated after the last one.

diff -r 7c388d2db6de -r 37e248619d21 src/org/openbravo/mobile/core/process/DataSynchronizationProcess.java
--- a/src/org/openbravo/mobile/core/process/DataSynchronizationProcess.java	Wed Feb 24 09:39:45 2016 +0100
+++ b/src/org/openbravo/mobile/core/process/DataSynchronizationProcess.java	Wed Feb 24 20:27:59 2016 +0100
@@ -234,10 +234,6 @@
         try {
           result = saveRecord(jsonRecord);
 
-          if (importEntryId != null) {
-            setImportEntryProcessed();
-          }
-
           if (!result.get(JsonConstants.RESPONSE_STATUS).equals(
               JsonConstants.RPCREQUEST_STATUS_SUCCESS)) {
             log.error(this.getClass().getName() + ": There was an error importing record: "
@@ -296,7 +292,7 @@
         }
       }
 
-      if (jsonarray.length() == 0 && importEntryId != null) {
+      if (importEntryId != null && !isImportEntryInError()) {
         setImportEntryProcessed();
 
         try {
@@ -334,6 +330,10 @@
     return jsonResponse;
   }
 
+  private boolean isImportEntryInError() {
+    return importEntryManager.isImportEntryError(importEntryId);
+  }
+
   protected void setImportEntryProcessed() {
     importEntryManager.setImportEntryProcessed(importEntryId);
   }
