1

I want to perform update and delete operation in a single applyEdits() call from my android application, my code is as below:

Thread.sleep(300);
layer.applyEdits(null, deletes, updates, new CallbackListener<FeatureEditResult[][]>() {
...
});

I am able to perform the desired operation only before applying a certain sleep interval, if not, the deletes array gets passed as empty, and therefore, the delete and update operations does not take place in a single transaction.

Please provide your inputs.

6
  • Cross-posted as stackoverflow.com/q/43522614/820534
    – PolyGeo
    Commented Apr 20, 2017 at 20:23
  • 1
    I don't understand why there is a downvote on a valid question? Would the voter mind to explain it, please?
    – Ali_Waris
    Commented Apr 24, 2017 at 7:43
  • Cross-posts have a tendency to attract downvotes. Please do not cross-post. meta.stackexchange.com/a/64069/215590
    – PolyGeo
    Commented Apr 24, 2017 at 8:49
  • @PolyGeo Downvoting at SO seems okay as it is less relevant there, I agree. But why downvoting here at GIS?
    – Ali_Waris
    Commented Apr 24, 2017 at 9:21
  • I know that I have never removed a downvote when asked about it. That may or may not be the same for a downvoter on this cross-post. The paramount thing with voting on SE is that it is anonymous.
    – PolyGeo
    Commented Apr 24, 2017 at 10:09

1 Answer 1

2
+25

What if you call deleteFeaturesAsync() and then updateFeaturesAsync() when you get the callback? Does it have to be in the same operation? Two asynchronous calls may work better.

I'm a little rusty on Android/Java, but maybe something like (I cannot test right now):

public ListenableFuture<Feature>deletesFuture = layer.deleteFeaturesAsync(deletes);

// add done listener
deletesFuture.addDoneListener(new Runnable() {
   @Override
   public void run() {
    try {
     // now try doing the updates
     public LisenableFuture<Feature>updatesFuture = layer.updateFeaturesAsync(updates) // updates is a global var

     // add yet another event listener on the update features if you want
     updatesFuture.addDoneListener(new Runnable() {
       @Override
       public void run() {
        try {
         // do stuff when updates have been added
        } catch (Exception e) {
         Log.e(getResources().getString(R.string.app_name), "updating features failed: " + e.getMessage());
        }
       }
      }
     } catch (Exception e) {
      Log.e(getResources().getString(R.string.app_name), "deleting features failed: " + e.getMessage());
     }
    }
   }

If you haven't done so already, you should check out the ArcGIS Runtime Samples for Android on GitHub.

9
  • Thanks for the answer, but performing two different operations is not what I need to do. Because if somehow, the delete call succeeds and the update call fails, then I am down with data loss which is unacceptable. :( The whole idea is to perform applyEdits in a single transaction.
    – Ali_Waris
    Commented Apr 25, 2017 at 2:52
  • Moreover, the samples that I read tells about either 'adds' or 'deletes' or 'updates'. None of them talks about performing these operations in one go.
    – Ali_Waris
    Commented Apr 25, 2017 at 2:54
  • 1
    What if you just send a POST request to the ArcGIS REST API? Just convert the features to JSON and make the call manually? It will not return back features, but at least you can do them all in the same applyEdits call. From what I saw, the Android SDK doesn't support an applyEdits method.
    – crmackey
    Commented Apr 26, 2017 at 3:52
  • That's the last option I kept with me; using ArcGIS REST API directly. However, can you please explain with references, your statement : "Android SDK doesn't support an applyEdits method." ?
    – Ali_Waris
    Commented Apr 26, 2017 at 6:24
  • The only documentation I can provide is the FeatureTable API Reference. I have not actually used the Quartz release (100.0) of the SDK, I have only used the 10.2.7 release for Android and I do not remember seeing an applyEdits there either. Both versions only have separate add, update, and delete methods. The iOS SDK is the same way.
    – crmackey
    Commented Apr 26, 2017 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.