/** * Execute store operation * <p> * <b>NOTE: this is a sync operation, proceed with a caution as it may include SQLite instruction<b/> * </p> * * @throws {@link ApolloException} in case of any errors */ public final T execute() throws ApolloException { checkIfExecuted(); try { return perform(); } catch (Exception e) { throw new ApolloException("Failed to perform store operation", e); } }
@Nonnull @Override public GraphQLStoreOperation<Boolean> clearAll() { return GraphQLStoreOperation.emptyOperation(Boolean.FALSE); }
@Override public void run() { try { Log.v(TAG,"Thread:[" + Thread.currentThread().getId() +"]: Updating store with the optimistic update for [" + request.operation +"]"); store.write(request.operation, data).execute(); } catch (Exception e) { Log.e(TAG, "Thread:[" + Thread.currentThread().getId() +"]: failed to update store with optimistic update for: [" + request.operation +"]"); } } });
@Override public void run() { T result; try { result = perform(); } catch (Exception e) { notifyFailure(new ApolloException("Failed to perform store operation", e)); return; } notifySuccess(result); } });
/** * Schedules operation to be executed in dispatcher * * @param callback to be notified about operation result */ public void enqueue(@Nullable final Callback<T> callback) { checkIfExecuted(); this.callback.set(callback); dispatcher.execute(new Runnable() { @Override public void run() { T result; try { result = perform(); } catch (Exception e) { notifyFailure(new ApolloException("Failed to perform store operation", e)); return; } notifySuccess(result); } }); }
private void updateListPostsQueryCache() { List<ListPostsQuery.ListPost> items = new ArrayList<>(); items.addAll(allPosts.values()); ListPostsQuery.Data data = new ListPostsQuery.Data(items); ClientFactory.getInstance(display.getApplicationContext()).getStore() .write(listPostsQuery, data).enqueue(null); }
private Set<String> rollbackOptimisticUpdates(final InterceptorRequest request) { try { return mApolloStore.rollbackOptimisticUpdates(request.uniqueId).execute(); } catch (Exception e) { logger.e(e, "failed to rollback operation optimistic updates, for: %s", request.operation); return Collections.emptySet(); } }
@Override public void run() { T result; try { result = perform(); } catch (Exception e) { notifyFailure(new ApolloException("Failed to perform store operation", e)); return; } notifySuccess(result); } });
/** * Schedules operation to be executed in dispatcher * * @param callback to be notified about operation result */ public void enqueue(@Nullable final Callback<T> callback) { checkIfExecuted(); this.callback.set(callback); dispatcher.execute(new Runnable() { @Override public void run() { T result; try { result = perform(); } catch (Exception e) { notifyFailure(new ApolloException("Failed to perform store operation", e)); return; } notifySuccess(result); } }); }
@Nonnull @Override public GraphQLStoreOperation<Boolean> clearAll() { return GraphQLStoreOperation.emptyOperation(Boolean.FALSE); }
private Set<String> rollbackOptimisticUpdates(final InterceptorRequest request) { try { return mApolloStore.rollbackOptimisticUpdates(request.uniqueId).execute(); } catch (Exception e) { logger.e(e, "failed to rollback operation optimistic updates, for: %s", request.operation); return Collections.emptySet(); } }
/** * Execute store operation * <p> * <b>NOTE: this is a sync operation, proceed with a caution as it may include SQLite instruction<b/> * </p> * * @throws {@link ApolloException} in case of any errors */ public final T execute() throws ApolloException { checkIfExecuted(); try { return perform(); } catch (Exception e) { throw new ApolloException("Failed to perform store operation", e); } }
@Nonnull @Override public <D extends Operation.Data, T, V extends Operation.Variables> GraphQLStoreOperation<T> read( @Nonnull Operation<D, T, V> operation) { return GraphQLStoreOperation.emptyOperation(null); }
@Override public void run() { try { mApolloStore.rollbackOptimisticUpdatesAndPublish(request.uniqueId).execute(); } catch (Exception e) { logger.e(e, "failed to rollback operation optimistic updates, for: %s", request.operation); } } });
@Nonnull @Override public GraphQLStoreOperation<Boolean> rollbackOptimisticUpdatesAndPublish(@Nonnull UUID mutationId) { return GraphQLStoreOperation.emptyOperation(Boolean.FALSE); }
@Override public void run() { try { mApolloStore.rollbackOptimisticUpdatesAndPublish(request.uniqueId).execute(); } catch (Exception e) { logger.e(e, "failed to rollback operation optimistic updates, for: %s", request.operation); } } });
@Nonnull @Override public GraphQLStoreOperation<Boolean> rollbackOptimisticUpdatesAndPublish(@Nonnull UUID mutationId) { return GraphQLStoreOperation.emptyOperation(Boolean.FALSE); }
@Override public void run() { try { if (request.optimisticUpdates.isPresent()) { Operation.Data optimisticUpdates = request.optimisticUpdates.get(); mApolloStore.writeOptimisticUpdatesAndPublish(request.operation, optimisticUpdates, request.uniqueId) .execute(); } } catch (Exception e) { logger.e(e, "failed to write operation optimistic updates, for: %s", request.operation); } } });
@Nonnull @Override public <D extends Operation.Data, T, V extends Operation.Variables> GraphQLStoreOperation<Boolean> writeAndPublish( @Nonnull Operation<D, T, V> operation, @Nonnull D operationData) { return GraphQLStoreOperation.emptyOperation(Boolean.FALSE); }
@Override public void run() { try { if (request.optimisticUpdates.isPresent()) { Operation.Data optimisticUpdates = request.optimisticUpdates.get(); mApolloStore.writeOptimisticUpdatesAndPublish(request.operation, optimisticUpdates, request.uniqueId) .execute(); } } catch (Exception e) { logger.e(e, "failed to write operation optimistic updates, for: %s", request.operation); } } });