Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added queries to async system

  • Loading branch information...
commit 6504a170ae82f688f4301a924c26a578c9ea0b7b 1 parent 300087c
greenrobot authored
3  DaoCore/src/de/greenrobot/dao/AsyncOperation.java
View
@@ -31,7 +31,8 @@
InsertOrReplace, InsertOrReplaceInTxIterable, InsertOrReplaceInTxArray, //
Update, UpdateInTxIterable, UpdateInTxArray, //
Delete, DeleteInTxIterable, DeleteInTxArray, //
- TransactionRunnable, TransactionCallable
+ TransactionRunnable, TransactionCallable, //
+ QueryList, QueryUnique
}
public static final int FLAG_MERGE_TX = 1;
6 DaoCore/src/de/greenrobot/dao/AsyncOperationExecutor.java
View
@@ -200,7 +200,7 @@ private void executeOperationAndPostCompleted(AsyncOperation operation) {
postOperationCompleted(operation);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
private void executeOperation(AsyncOperation operation) {
operation.timeStarted = System.currentTimeMillis();
try {
@@ -246,6 +246,10 @@ private void executeOperation(AsyncOperation operation) {
break;
case TransactionCallable:
executeTransactionCallable(operation);
+ case QueryList:
+ operation.result = ((Query) operation.parameter).list();
+ case QueryUnique:
+ operation.result = ((Query) operation.parameter).unique();
default:
throw new DaoException("Unsupported operation: " + operation.type);
}
20 DaoCore/src/de/greenrobot/dao/AsyncSession.java
View
@@ -192,6 +192,26 @@ public AsyncOperation callInTx(Callable<?> callable, int flags) {
return enqueueDatabaseOperation(OperationType.TransactionCallable, callable, flags);
}
+ /** Asynchronous version of {@link Query#list()}. */
+ public AsyncOperation queryList(Query<?> query) {
+ return queryList(query, 0);
+ }
+
+ /** Asynchronous version of {@link Query#list()}. */
+ public AsyncOperation queryList(Query<?> query, int flags) {
+ return enqueueDatabaseOperation(OperationType.QueryList, query, flags);
+ }
+
+ /** Asynchronous version of {@link Query#unique()}. */
+ public AsyncOperation queryUnique(Query<?> query) {
+ return queryUnique(query, 0);
+ }
+
+ /** Asynchronous version of {@link Query#unique()}. */
+ public AsyncOperation queryUnique(Query<?> query, int flags) {
+ return enqueueDatabaseOperation(OperationType.QueryUnique, query, flags);
+ }
+
private AsyncOperation enqueueDatabaseOperation(OperationType type, Object param, int flags) {
AsyncOperation operation = new AsyncOperation(type, session.getDatabase(), param, flags);
executor.enqueue(operation);
Please sign in to comment.
Something went wrong with that request. Please try again.