From 2f239945846c85298ad956e98a31bf47603b3e23 Mon Sep 17 00:00:00 2001
From: 4lfant <4lfant@gmail.com>
Date: Mon, 21 Oct 2019 23:55:35 +0300
Subject: [PATCH] Offline
---
build.gradle | 10 +-
src/com/backendless/DataStoreFactory.java | 1211 ++---
src/com/backendless/IDataStore.java | 377 +-
src/com/backendless/Persistence.java | 51 +-
.../persistence/DataQueryBuilder.java | 23 +
.../persistence/MapDrivenDataStore.java | 118 +-
.../offline/AndroidTransactionStorage.java | 73 +
.../persistence/offline/CallbackManager.java | 84 +
.../offline/ConnectivityManager.java | 51 +
.../offline/DataRetrievalPolicy.java | 7 +
.../persistence/offline/DatabaseHelper.java | 125 +
.../persistence/offline/DatabaseManager.java | 21 +
.../offline/LocalStorageManager.java | 250 +
.../offline/LocalStoragePolicy.java | 7 +
.../offline/OfflineAwareCallback.java | 11 +
.../offline/PendingOperationEnum.java | 7 +
.../offline/SQLiteDatabaseManager.java | 181 +
.../offline/SyncCompletionCallback.java | 8 +
.../persistence/offline/SyncError.java | 11 +
.../persistence/offline/SyncFailure.java | 16 +
.../persistence/offline/SyncManager.java | 280 ++
.../persistence/offline/SyncStatusReport.java | 11 +
.../persistence/offline/SyncSuccess.java | 16 +
.../persistence/offline/Transaction.java | 49 +
.../offline/TransactionManager.java | 44 +
.../offline/TransactionStorage.java | 12 +
.../offline/TransactionStorageFactory.java | 46 +
.../AndroidBackendlessQueryVisitor.java | 396 ++
.../offline/visitor/bcknd/DateUtil.java | 29 +
.../offline/visitor/bcknd/UnitConvertor.java | 47 +
.../offline/visitor/bcknd/Units.java | 18 +
.../offline/visitor/gen/BackendlessQuery.g4 | 309 ++
.../visitor/gen/BackendlessQuery.interp | 179 +
.../visitor/gen/BackendlessQuery.tokens | 89 +
.../gen/BackendlessQueryBaseListener.java | 879 ++++
.../gen/BackendlessQueryBaseVisitor.java | 504 ++
.../visitor/gen/BackendlessQueryLexer.interp | 244 +
.../visitor/gen/BackendlessQueryLexer.java | 322 ++
.../visitor/gen/BackendlessQueryLexer.tokens | 89 +
.../visitor/gen/BackendlessQueryListener.java | 794 ++++
.../visitor/gen/BackendlessQueryParser.java | 4073 +++++++++++++++++
.../visitor/gen/BackendlessQueryVisitor.java | 475 ++
.../visitor/res/AggregateFunction.java | 16 +
.../visitor/res/AggregateOperator.java | 20 +
.../visitor/res/CombinedCondition.java | 18 +
.../visitor/res/ComparisonCondition.java | 18 +
.../offline/visitor/res/Condition.java | 4 +
.../offline/visitor/res/Expression.java | 18 +
.../visitor/res/ExpressionOperator.java | 20 +
.../offline/visitor/res/Field.java | 22 +
.../offline/visitor/res/LikeCondition.java | 19 +
.../offline/visitor/res/NotCondition.java | 14 +
.../offline/visitor/res/NullCondition.java | 16 +
.../offline/visitor/res/Operator.java | 25 +
.../offline/visitor/res/QueryPart.java | 4 +
.../offline/visitor/res/SelectQuery.java | 53 +
.../offline/visitor/res/SortField.java | 19 +
.../offline/visitor/res/Table.java | 14 +
.../offline/visitor/res/Value.java | 14 +
59 files changed, 11122 insertions(+), 739 deletions(-)
create mode 100644 src/com/backendless/persistence/offline/AndroidTransactionStorage.java
create mode 100644 src/com/backendless/persistence/offline/CallbackManager.java
create mode 100644 src/com/backendless/persistence/offline/ConnectivityManager.java
create mode 100644 src/com/backendless/persistence/offline/DataRetrievalPolicy.java
create mode 100644 src/com/backendless/persistence/offline/DatabaseHelper.java
create mode 100644 src/com/backendless/persistence/offline/DatabaseManager.java
create mode 100644 src/com/backendless/persistence/offline/LocalStorageManager.java
create mode 100644 src/com/backendless/persistence/offline/LocalStoragePolicy.java
create mode 100644 src/com/backendless/persistence/offline/OfflineAwareCallback.java
create mode 100644 src/com/backendless/persistence/offline/PendingOperationEnum.java
create mode 100644 src/com/backendless/persistence/offline/SQLiteDatabaseManager.java
create mode 100644 src/com/backendless/persistence/offline/SyncCompletionCallback.java
create mode 100644 src/com/backendless/persistence/offline/SyncError.java
create mode 100644 src/com/backendless/persistence/offline/SyncFailure.java
create mode 100644 src/com/backendless/persistence/offline/SyncManager.java
create mode 100644 src/com/backendless/persistence/offline/SyncStatusReport.java
create mode 100644 src/com/backendless/persistence/offline/SyncSuccess.java
create mode 100644 src/com/backendless/persistence/offline/Transaction.java
create mode 100644 src/com/backendless/persistence/offline/TransactionManager.java
create mode 100644 src/com/backendless/persistence/offline/TransactionStorage.java
create mode 100644 src/com/backendless/persistence/offline/TransactionStorageFactory.java
create mode 100644 src/com/backendless/persistence/offline/visitor/AndroidBackendlessQueryVisitor.java
create mode 100644 src/com/backendless/persistence/offline/visitor/bcknd/DateUtil.java
create mode 100644 src/com/backendless/persistence/offline/visitor/bcknd/UnitConvertor.java
create mode 100644 src/com/backendless/persistence/offline/visitor/bcknd/Units.java
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.g4
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.interp
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.tokens
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryBaseListener.java
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryBaseVisitor.java
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.interp
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.java
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.tokens
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryListener.java
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryParser.java
create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryVisitor.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/AggregateFunction.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/AggregateOperator.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/CombinedCondition.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/ComparisonCondition.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/Condition.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/Expression.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/ExpressionOperator.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/Field.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/LikeCondition.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/NotCondition.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/NullCondition.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/Operator.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/QueryPart.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/SelectQuery.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/SortField.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/Table.java
create mode 100644 src/com/backendless/persistence/offline/visitor/res/Value.java
diff --git a/build.gradle b/build.gradle
index a856af25f..4c2c906b1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -70,7 +70,9 @@ uploadArchives {
pom.whenConfigured {
p -> p.dependencies = p.dependencies.findAll {
- dep -> ( dep.artifactId != "commons" && dep.artifactId != "weborbclient" )
+ dep -> ( dep.artifactId != "commons" &&
+ dep.artifactId != "weborbclient" &&
+ dep.artifactId != "antlr4-runtime" )
}
}
@@ -181,7 +183,8 @@ def libsToPackage() {
def artifactsToPackage =
[
["com.backendless", "commons"],
- ["weborb", "weborbclient"]
+ ["weborb", "weborbclient"],
+ ["org.antlr", "antlr4-runtime"]
]
def libsToPackage = ["mediaLib.jar"]
@@ -263,10 +266,13 @@ dependencies {
}
compileOnly( group: "weborb", name: "weborbclient", version: "5.1.0.212", changing: true)
+ compileOnly( group: 'org.antlr', name: 'antlr4-runtime', version: '4.7.2', changing: true)
+
compileOnly ('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
+
}
apply plugin: 'java'
diff --git a/src/com/backendless/DataStoreFactory.java b/src/com/backendless/DataStoreFactory.java
index 6f5270b84..e4c8cc646 100644
--- a/src/com/backendless/DataStoreFactory.java
+++ b/src/com/backendless/DataStoreFactory.java
@@ -1,554 +1,659 @@
-/*
- * ********************************************************************************************************************
- *
- * BACKENDLESS.COM CONFIDENTIAL
- *
- * ********************************************************************************************************************
- *
- * Copyright 2(Integer)null12 BACKENDLESS.COM. All Rights Reserved.
- *
- * NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers,
- * if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
- * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
- * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
- * unless prior written permission is obtained from Backendless.com.
- *
- * ********************************************************************************************************************
- */
-
-package com.backendless;
-
-import com.backendless.async.callback.AsyncCallback;
-import com.backendless.exceptions.BackendlessException;
-import com.backendless.persistence.BackendlessSerializer;
-import com.backendless.persistence.DataQueryBuilder;
-import com.backendless.persistence.LoadRelationsQueryBuilder;
-import com.backendless.rt.data.EventHandler;
-import com.backendless.rt.data.EventHandlerFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-class DataStoreFactory
-{
- private static final List emptyRelations = new ArrayList();
- private final static EventHandlerFactory eventHandlerFactory = new EventHandlerFactory();
-
- protected static IDataStore createDataStore( final Class entityClass )
- {
-
- return new IDataStore()
- {
- private EventHandler eventHandler = eventHandlerFactory.of( entityClass );
-
- @Override
- public List create( List objects ) throws BackendlessException
- {
- return Backendless.Persistence.create( objects );
- }
-
- @Override
- public void create( List objects, AsyncCallback> responder ) throws BackendlessException
- {
- Backendless.Persistence.create( objects, responder );
- }
-
- @Override
- public E save( final E entity ) throws BackendlessException
- {
- return Backendless.Persistence.save( entity );
- }
-
- @Override
- public void save( final E entity, final AsyncCallback responder )
- {
- Backendless.Persistence.save( entity, responder );
- }
-
- @Override
- public Long remove( final E entity ) throws BackendlessException
- {
- return Backendless.Persistence.remove( entity );
- }
-
- @Override
- public void remove( final E entity, final AsyncCallback responder )
- {
- Backendless.Persistence.remove( entity, responder );
- }
-
- @Override
- public int remove( final String whereClause ) throws BackendlessException
- {
- return Backendless.Persistence.remove( BackendlessSerializer.getSimpleName( entityClass ), whereClause );
- }
-
- @Override
- public void remove( final String whereClause, AsyncCallback responder ) throws BackendlessException
- {
- Backendless.Persistence.remove( BackendlessSerializer.getSimpleName( entityClass ), whereClause, responder );
- }
-
- @Override
- public int update( final String whereClause, Map changes ) throws BackendlessException
- {
- return Backendless.Persistence.update( BackendlessSerializer.getSimpleName( entityClass ), whereClause, changes );
- }
-
- @Override
- public void update( final String whereClause, Map changes, AsyncCallback responder ) throws BackendlessException
- {
- Backendless.Persistence.update( BackendlessSerializer.getSimpleName( entityClass ), whereClause, changes, responder );
- }
-
- @Override
- public E findFirst() throws BackendlessException
- {
- return Backendless.Persistence.first( entityClass );
- }
-
- @Override
- public E findFirst( Integer relationsDepth ) throws BackendlessException
- {
- return findFirst( emptyRelations, relationsDepth );
- }
-
- @Override
- public E findFirst( List relations ) throws BackendlessException
- {
- return findFirst( relations, (Integer)null );
- }
-
- private E findFirst( List relations, Integer relationsDepth ) throws BackendlessException
- {
- return Backendless.Persistence.first( entityClass, relations, relationsDepth );
- }
-
- @Override
- public int getObjectCount()
- {
- return Backendless.Persistence.getObjectCount( entityClass );
- }
-
- @Override
- public int getObjectCount( DataQueryBuilder dataQueryBuilder )
- {
- return Backendless.Persistence.getObjectCount( entityClass, dataQueryBuilder );
- }
-
- public void findFirst( final AsyncCallback responder )
- {
- Backendless.Persistence.first( entityClass, responder );
- }
-
- @Override
- public void findFirst( Integer relationsDepth, final AsyncCallback responder )
- {
- findFirst( emptyRelations, relationsDepth, responder );
- }
-
- @Override
- public void findFirst( List relations, AsyncCallback responder )
- {
- findFirst( relations, (Integer)null, responder );
- }
-
- private void findFirst( List relations, Integer relationsDepth, final AsyncCallback responder )
- {
- Backendless.Persistence.first( entityClass, relations, relationsDepth, responder );
- }
-
- @Override
- public E findLast() throws BackendlessException
- {
- return Backendless.Persistence.last( entityClass );
- }
-
- @Override
- public E findLast( Integer relationsDepth ) throws BackendlessException
- {
- return findLast( emptyRelations, relationsDepth );
- }
-
- @Override
- public E findLast( List relations ) throws BackendlessException
- {
- return findLast( relations, (Integer)null );
- }
-
- private E findLast( List relations, Integer relationsDepth ) throws BackendlessException
- {
- return Backendless.Persistence.last( entityClass, relations, relationsDepth );
- }
-
- @Override
- public void findLast( final AsyncCallback responder )
- {
- Backendless.Persistence.last( entityClass, responder );
- }
-
- @Override
- public void findLast( Integer relationsDepth, final AsyncCallback responder )
- {
- findLast( emptyRelations, relationsDepth, responder );
- }
-
- @Override
- public void findLast( List relations, AsyncCallback responder )
- {
- findLast( relations, (Integer)null, responder );
- }
-
- private void findLast( List relations, Integer relationsDepth, final AsyncCallback responder )
- {
- Backendless.Persistence.last( entityClass, relations, relationsDepth, responder );
- }
-
- @Override
- public List find() throws BackendlessException
- {
- return Backendless.Persistence.find( entityClass, DataQueryBuilder.create() );
- }
-
- @Override
- public List find( DataQueryBuilder dataQueryBuilder ) throws BackendlessException
- {
- return Backendless.Persistence.find( entityClass, dataQueryBuilder );
- }
-
- @Override
- public void find( AsyncCallback> responder )
- {
- Backendless.Persistence.find( entityClass, DataQueryBuilder.create(), responder );
- }
-
- @Override
- public void find( DataQueryBuilder dataQueryBuilder, AsyncCallback> responder )
- {
- Backendless.Persistence.find( entityClass, dataQueryBuilder, responder );
- }
-
- @Override
- public E findById( String objectId ) throws BackendlessException
- {
- return findById( objectId, emptyRelations );
- }
-
- @Override
- public E findById( String objectId, List relations ) throws BackendlessException
- {
- return Backendless.Persistence.findById( entityClass, objectId, relations );
- }
-
- @Override
- public E findById( String objectId, Integer relationsDepth ) throws BackendlessException
- {
- return Backendless.Persistence.findById( entityClass, objectId, emptyRelations, relationsDepth );
- }
-
- @Override
- public E findById( String objectId, List relations, Integer relationsDepth ) throws BackendlessException
- {
- return Backendless.Persistence.findById( entityClass, objectId, relations, relationsDepth );
- }
-
- @Override
- public E findById( E entity )
- {
- return findById( entity, emptyRelations );
- }
-
- @Override
- public E findById( E entity, List relations )
- {
- return findById( entity, relations, (Integer)null );
- }
-
- @Override
- public E findById( E entity, Integer relationsDepth )
- {
- return findById( entity, emptyRelations, relationsDepth );
- }
-
- @Override
- public E findById( E entity, List relations, Integer relationsDepth )
- {
- return Backendless.Data.findById( entity, relations, relationsDepth );
- }
-
- @Override
- public void findById( String objectId, AsyncCallback responder )
- {
- findById( objectId, emptyRelations, responder );
- }
-
- @Override
- public void findById( String objectId, List relations, AsyncCallback responder )
- {
- Backendless.Persistence.findById( entityClass, objectId, relations, responder );
- }
-
- @Override
- public void findById( String objectId, Integer relationsDepth, AsyncCallback responder )
- {
- findById( objectId, emptyRelations, relationsDepth, responder );
- }
-
- @Override
- public void findById( String objectId, List relations, Integer relationsDepth, AsyncCallback responder )
- {
- Backendless.Persistence.findById( entityClass, objectId, relations, relationsDepth, responder );
- }
-
- @Override
- public void findById( E entity, AsyncCallback responder )
- {
- findById( entity, emptyRelations, responder );
- }
-
- @Override
- public void findById( E entity, List relations, AsyncCallback responder )
- {
- findById( entity, relations, (Integer)null, responder );
- }
-
- @Override
- public void findById( E entity, Integer relationsDepth, AsyncCallback responder )
- {
- findById( entity, emptyRelations, relationsDepth, responder );
- }
-
- @Override
- public void findById( E entity, List relations, Integer relationsDepth, AsyncCallback responder )
- {
- Backendless.Data.findById( entity, relations, relationsDepth, responder );
- }
-
- @Override
- public E findById( String id, DataQueryBuilder queryBuilder ) throws BackendlessException
- {
- return Backendless.Persistence.findById( entityClass, id, queryBuilder );
- }
-
- @Override
- public E findById( E entity, DataQueryBuilder queryBuilder ) throws BackendlessException
- {
- return Backendless.Persistence.findById( entity, queryBuilder );
- }
-
- @Override
- public void findById( String id, DataQueryBuilder queryBuilder, AsyncCallback responder )
- {
- Backendless.Persistence.findById( entityClass, id, queryBuilder, responder );
- }
-
- @Override
- public void findById( E entity, DataQueryBuilder queryBuilder, AsyncCallback responder )
- {
- Backendless.Persistence.findById( entity, queryBuilder, responder );
- }
-
- @Override
- public List loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder )
- {
- String typeName = BackendlessSerializer.getSimpleName( entityClass );
- return Backendless.Persistence.loadRelations( typeName, objectId, queryBuilder, queryBuilder.getRelationType() );
- }
-
- @Override
- public void loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder, AsyncCallback> responder )
- {
- String typeName = BackendlessSerializer.getSimpleName( entityClass );
- Backendless.Persistence.loadRelations( typeName, objectId, queryBuilder, queryBuilder.getRelationType(), responder );
- }
-
- @Override
- public void getObjectCount( AsyncCallback responder )
- {
- Backendless.Persistence.getObjectCount( entityClass, responder );
- }
-
- @Override
- public void getObjectCount( DataQueryBuilder dataQueryBuilder, AsyncCallback responder )
- {
- Backendless.Persistence.getObjectCount( entityClass, dataQueryBuilder, responder );
- }
-
- @Override
- public int addRelation( E parent, String relationColumnName, Collection children )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
- Collection childObjectIds = new ArrayList<>();
- for( R child : children )
- {
- String childObjectId = Persistence.getEntityId( child );
- childObjectIds.add( childObjectId );
- }
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
- return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args );
- }
-
- @Override
- public void addRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
- Collection childObjectIds = new ArrayList<>();
- for( R child : children )
- {
- String childObjectId = Persistence.getEntityId( child );
- childObjectIds.add( childObjectId );
- }
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
- Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback );
- }
-
- @Override
- public int addRelation( E parent, String relationColumnName, String whereClause )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
- return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args );
- }
-
- @Override
- public void addRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
- Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback );
- }
-
- @Override
- public int setRelation( E parent, String relationColumnName, Collection children )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
- Collection childObjectIds = new ArrayList<>();
- for( R child : children )
- {
- String childObjectId = Persistence.getEntityId( child );
- childObjectIds.add( childObjectId );
- }
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
- return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args );
- }
-
- @Override
- public void setRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
- Collection childObjectIds = new ArrayList<>();
- for( R child : children )
- {
- String childObjectId = Persistence.getEntityId( child );
- childObjectIds.add( childObjectId );
- }
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
- Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args, callback );
- }
-
- @Override
- public int setRelation( E parent, String relationColumnName, String whereClause )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
- return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args );
- }
-
- @Override
- public void setRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
- Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback );
- }
-
- @Override
- public int deleteRelation( E parent, String relationColumnName, Collection children )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
- Collection childObjectIds = new ArrayList<>();
- for( R child : children )
- {
- String childObjectId = Persistence.getEntityId( child );
- childObjectIds.add( childObjectId );
- }
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
- return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args );
- }
-
- @Override
- public void deleteRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
- Collection childObjectIds = new ArrayList<>();
- for( R child : children )
- {
- String childObjectId = Persistence.getEntityId( child );
- childObjectIds.add( childObjectId );
- }
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
- Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args, callback );
- }
-
- @Override
- public int deleteRelation( E parent, String relationColumnName, String whereClause )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
- return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args );
- }
-
- @Override
- public void deleteRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback )
- {
- String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
-
- String parentObjectId = Persistence.getEntityId( parent );
-
- Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
- Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args, callback );
- }
-
- @Override
- public EventHandler rt()
- {
- return eventHandler;
- }
- };
- }
+/*
+ * ********************************************************************************************************************
+ *
+ * BACKENDLESS.COM CONFIDENTIAL
+ *
+ * ********************************************************************************************************************
+ *
+ * Copyright 2(Integer)null12 BACKENDLESS.COM. All Rights Reserved.
+ *
+ * NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers,
+ * if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
+ * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
+ * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
+ * unless prior written permission is obtained from Backendless.com.
+ *
+ * ********************************************************************************************************************
+ */
+
+package com.backendless;
+
+import com.backendless.async.callback.AsyncCallback;
+import com.backendless.exceptions.BackendlessException;
+import com.backendless.persistence.BackendlessSerializer;
+import com.backendless.persistence.DataQueryBuilder;
+import com.backendless.persistence.LoadRelationsQueryBuilder;
+import com.backendless.persistence.offline.LocalStorageManager;
+import com.backendless.persistence.offline.OfflineAwareCallback;
+import com.backendless.persistence.offline.SyncCompletionCallback;
+import com.backendless.persistence.offline.SyncManager;
+import com.backendless.persistence.offline.TransactionManager;
+import com.backendless.rt.data.EventHandler;
+import com.backendless.rt.data.EventHandlerFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import static com.backendless.persistence.BackendlessSerializer.serializeToMap;
+
+class DataStoreFactory
+{
+ private static final List emptyRelations = new ArrayList();
+ private static final EventHandlerFactory eventHandlerFactory = new EventHandlerFactory();
+ private static final TransactionManager transactionManager = TransactionManager.getInstance();
+ private static final SyncManager syncManager = SyncManager.getInstance();
+
+ protected static IDataStore createDataStore( final Class entityClass )
+ {
+
+ return new IDataStore()
+ {
+ private EventHandler eventHandler = eventHandlerFactory.of( entityClass );
+ private final LocalStorageManager storageManager = new LocalStorageManager(
+ BackendlessSerializer.getSimpleName( entityClass ));
+
+ @Override
+ public List create( List objects ) throws BackendlessException
+ {
+ return Backendless.Persistence.create( objects );
+ }
+
+ @Override
+ public void create( List objects, AsyncCallback> responder ) throws BackendlessException
+ {
+ Backendless.Persistence.create( objects, responder );
+ }
+
+ @Override
+ public E save( final E entity ) throws BackendlessException
+ {
+ return Backendless.Persistence.save( entity );
+ }
+
+ @Override
+ public void save( final E entity, final AsyncCallback responder )
+ {
+ Backendless.Persistence.save( entity, responder );
+ }
+
+ @Override
+ public Long remove( final E entity ) throws BackendlessException
+ {
+ return Backendless.Persistence.remove( entity );
+ }
+
+ @Override
+ public void remove( final E entity, final AsyncCallback responder )
+ {
+ Backendless.Persistence.remove( entity, responder );
+ }
+
+ @Override
+ public int remove( final String whereClause ) throws BackendlessException
+ {
+ return Backendless.Persistence.remove( BackendlessSerializer.getSimpleName( entityClass ), whereClause );
+ }
+
+ @Override
+ public void remove( final String whereClause, AsyncCallback responder ) throws BackendlessException
+ {
+ Backendless.Persistence.remove( BackendlessSerializer.getSimpleName( entityClass ), whereClause, responder );
+ }
+
+ @Override
+ public int update( final String whereClause, Map changes ) throws BackendlessException
+ {
+ return Backendless.Persistence.update( BackendlessSerializer.getSimpleName( entityClass ), whereClause, changes );
+ }
+
+ @Override
+ public void update( final String whereClause, Map changes, AsyncCallback responder ) throws BackendlessException
+ {
+ Backendless.Persistence.update( BackendlessSerializer.getSimpleName( entityClass ), whereClause, changes, responder );
+ }
+
+ @Override
+ public E findFirst() throws BackendlessException
+ {
+ return Backendless.Persistence.first( entityClass );
+ }
+
+ @Override
+ public E findFirst( Integer relationsDepth ) throws BackendlessException
+ {
+ return findFirst( emptyRelations, relationsDepth );
+ }
+
+ @Override
+ public E findFirst( List relations ) throws BackendlessException
+ {
+ return findFirst( relations, (Integer)null );
+ }
+
+ private E findFirst( List relations, Integer relationsDepth ) throws BackendlessException
+ {
+ return Backendless.Persistence.first( entityClass, relations, relationsDepth );
+ }
+
+ @Override
+ public int getObjectCount()
+ {
+ return Backendless.Persistence.getObjectCount( entityClass );
+ }
+
+ @Override
+ public int getObjectCount( DataQueryBuilder dataQueryBuilder )
+ {
+ return Backendless.Persistence.getObjectCount( entityClass, dataQueryBuilder );
+ }
+
+ public void findFirst( final AsyncCallback responder )
+ {
+ Backendless.Persistence.first( entityClass, responder );
+ }
+
+ @Override
+ public void findFirst( Integer relationsDepth, final AsyncCallback responder )
+ {
+ findFirst( emptyRelations, relationsDepth, responder );
+ }
+
+ @Override
+ public void findFirst( List relations, AsyncCallback responder )
+ {
+ findFirst( relations, (Integer)null, responder );
+ }
+
+ private void findFirst( List relations, Integer relationsDepth, final AsyncCallback responder )
+ {
+ Backendless.Persistence.first( entityClass, relations, relationsDepth, responder );
+ }
+
+ @Override
+ public E findLast() throws BackendlessException
+ {
+ return Backendless.Persistence.last( entityClass );
+ }
+
+ @Override
+ public E findLast( Integer relationsDepth ) throws BackendlessException
+ {
+ return findLast( emptyRelations, relationsDepth );
+ }
+
+ @Override
+ public E findLast( List relations ) throws BackendlessException
+ {
+ return findLast( relations, (Integer)null );
+ }
+
+ private E findLast( List relations, Integer relationsDepth ) throws BackendlessException
+ {
+ return Backendless.Persistence.last( entityClass, relations, relationsDepth );
+ }
+
+ @Override
+ public void findLast( final AsyncCallback responder )
+ {
+ Backendless.Persistence.last( entityClass, responder );
+ }
+
+ @Override
+ public void findLast( Integer relationsDepth, final AsyncCallback responder )
+ {
+ findLast( emptyRelations, relationsDepth, responder );
+ }
+
+ @Override
+ public void findLast( List relations, AsyncCallback responder )
+ {
+ findLast( relations, (Integer)null, responder );
+ }
+
+ private void findLast( List relations, Integer relationsDepth, final AsyncCallback responder )
+ {
+ Backendless.Persistence.last( entityClass, relations, relationsDepth, responder );
+ }
+
+ @Override
+ public List find() throws BackendlessException
+ {
+ return find(DataQueryBuilder.create() );
+ }
+
+ @Override
+ public List find( DataQueryBuilder dataQueryBuilder ) throws BackendlessException
+ {
+ if (!storageManager.shouldRetrieveOnline(dataQueryBuilder))
+ return storageManager.find(entityClass, dataQueryBuilder);
+
+ List result = Backendless.Persistence.find( entityClass, dataQueryBuilder );
+ storageManager.store(result, dataQueryBuilder);
+ return result;
+ }
+
+ @Override
+ public void find( AsyncCallback> responder )
+ {
+ find(DataQueryBuilder.create(), responder );
+ }
+
+ @Override
+ public void find( DataQueryBuilder dataQueryBuilder, AsyncCallback> responder )
+ {
+ if (!storageManager.shouldRetrieveOnline(dataQueryBuilder)) {
+ storageManager.find(entityClass, dataQueryBuilder, responder);
+ return;
+ }
+
+ AsyncCallback> storeCallback = storageManager.getStoreCallback(dataQueryBuilder, responder);
+
+ Backendless.Persistence.find( entityClass, dataQueryBuilder, storeCallback );
+ }
+
+ @Override
+ public E findById( String objectId ) throws BackendlessException
+ {
+ return findById( objectId, emptyRelations );
+ }
+
+ @Override
+ public E findById( String objectId, List relations ) throws BackendlessException
+ {
+ return Backendless.Persistence.findById( entityClass, objectId, relations );
+ }
+
+ @Override
+ public E findById( String objectId, Integer relationsDepth ) throws BackendlessException
+ {
+ return Backendless.Persistence.findById( entityClass, objectId, emptyRelations, relationsDepth );
+ }
+
+ @Override
+ public E findById( String objectId, List relations, Integer relationsDepth ) throws BackendlessException
+ {
+ return Backendless.Persistence.findById( entityClass, objectId, relations, relationsDepth );
+ }
+
+ @Override
+ public E findById( E entity )
+ {
+ return findById( entity, emptyRelations );
+ }
+
+ @Override
+ public E findById( E entity, List relations )
+ {
+ return findById( entity, relations, (Integer)null );
+ }
+
+ @Override
+ public E findById( E entity, Integer relationsDepth )
+ {
+ return findById( entity, emptyRelations, relationsDepth );
+ }
+
+ @Override
+ public E findById( E entity, List relations, Integer relationsDepth )
+ {
+ return Backendless.Data.findById( entity, relations, relationsDepth );
+ }
+
+ @Override
+ public void findById( String objectId, AsyncCallback responder )
+ {
+ findById( objectId, emptyRelations, responder );
+ }
+
+ @Override
+ public void findById( String objectId, List relations, AsyncCallback responder )
+ {
+ Backendless.Persistence.findById( entityClass, objectId, relations, responder );
+ }
+
+ @Override
+ public void findById( String objectId, Integer relationsDepth, AsyncCallback responder )
+ {
+ findById( objectId, emptyRelations, relationsDepth, responder );
+ }
+
+ @Override
+ public void findById( String objectId, List relations, Integer relationsDepth, AsyncCallback responder )
+ {
+ Backendless.Persistence.findById( entityClass, objectId, relations, relationsDepth, responder );
+ }
+
+ @Override
+ public void findById( E entity, AsyncCallback responder )
+ {
+ findById( entity, emptyRelations, responder );
+ }
+
+ @Override
+ public void findById( E entity, List relations, AsyncCallback responder )
+ {
+ findById( entity, relations, (Integer)null, responder );
+ }
+
+ @Override
+ public void findById( E entity, Integer relationsDepth, AsyncCallback responder )
+ {
+ findById( entity, emptyRelations, relationsDepth, responder );
+ }
+
+ @Override
+ public void findById( E entity, List relations, Integer relationsDepth, AsyncCallback responder )
+ {
+ Backendless.Data.findById( entity, relations, relationsDepth, responder );
+ }
+
+ @Override
+ public E findById( String id, DataQueryBuilder queryBuilder ) throws BackendlessException
+ {
+ return Backendless.Persistence.findById( entityClass, id, queryBuilder );
+ }
+
+ @Override
+ public E findById( E entity, DataQueryBuilder queryBuilder ) throws BackendlessException
+ {
+ return Backendless.Persistence.findById( entity, queryBuilder );
+ }
+
+ @Override
+ public void findById( String id, DataQueryBuilder queryBuilder, AsyncCallback responder )
+ {
+ Backendless.Persistence.findById( entityClass, id, queryBuilder, responder );
+ }
+
+ @Override
+ public void findById( E entity, DataQueryBuilder queryBuilder, AsyncCallback responder )
+ {
+ Backendless.Persistence.findById( entity, queryBuilder, responder );
+ }
+
+ @Override
+ public List loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder )
+ {
+ String typeName = BackendlessSerializer.getSimpleName( entityClass );
+ return Backendless.Persistence.loadRelations( typeName, objectId, queryBuilder, queryBuilder.getRelationType() );
+ }
+
+ @Override
+ public void loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder, AsyncCallback> responder )
+ {
+ String typeName = BackendlessSerializer.getSimpleName( entityClass );
+ Backendless.Persistence.loadRelations( typeName, objectId, queryBuilder, queryBuilder.getRelationType(), responder );
+ }
+
+ @Override
+ public void getObjectCount( AsyncCallback responder )
+ {
+ Backendless.Persistence.getObjectCount( entityClass, responder );
+ }
+
+ @Override
+ public void getObjectCount( DataQueryBuilder dataQueryBuilder, AsyncCallback responder )
+ {
+ Backendless.Persistence.getObjectCount( entityClass, dataQueryBuilder, responder );
+ }
+
+ @Override
+ public int addRelation( E parent, String relationColumnName, Collection children )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+ Collection childObjectIds = new ArrayList<>();
+ for( R child : children )
+ {
+ String childObjectId = Persistence.getEntityId( child );
+ childObjectIds.add( childObjectId );
+ }
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
+ return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args );
+ }
+
+ @Override
+ public void addRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+ Collection childObjectIds = new ArrayList<>();
+ for( R child : children )
+ {
+ String childObjectId = Persistence.getEntityId( child );
+ childObjectIds.add( childObjectId );
+ }
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
+ Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback );
+ }
+
+ @Override
+ public int addRelation( E parent, String relationColumnName, String whereClause )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
+ return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args );
+ }
+
+ @Override
+ public void addRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
+ Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback );
+ }
+
+ @Override
+ public int setRelation( E parent, String relationColumnName, Collection children )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+ Collection childObjectIds = new ArrayList<>();
+ for( R child : children )
+ {
+ String childObjectId = Persistence.getEntityId( child );
+ childObjectIds.add( childObjectId );
+ }
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
+ return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args );
+ }
+
+ @Override
+ public void setRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+ Collection childObjectIds = new ArrayList<>();
+ for( R child : children )
+ {
+ String childObjectId = Persistence.getEntityId( child );
+ childObjectIds.add( childObjectId );
+ }
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
+ Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args, callback );
+ }
+
+ @Override
+ public int setRelation( E parent, String relationColumnName, String whereClause )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
+ return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args );
+ }
+
+ @Override
+ public void setRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
+ Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback );
+ }
+
+ @Override
+ public int deleteRelation( E parent, String relationColumnName, Collection children )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+ Collection childObjectIds = new ArrayList<>();
+ for( R child : children )
+ {
+ String childObjectId = Persistence.getEntityId( child );
+ childObjectIds.add( childObjectId );
+ }
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
+ return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args );
+ }
+
+ @Override
+ public void deleteRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+ Collection childObjectIds = new ArrayList<>();
+ for( R child : children )
+ {
+ String childObjectId = Persistence.getEntityId( child );
+ childObjectIds.add( childObjectId );
+ }
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds };
+ Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args, callback );
+ }
+
+ @Override
+ public int deleteRelation( E parent, String relationColumnName, String whereClause )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
+ return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args );
+ }
+
+ @Override
+ public void deleteRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback )
+ {
+ String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() );
+
+ String parentObjectId = Persistence.getEntityId( parent );
+
+ Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause };
+ Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args, callback );
+ }
+
+ @Override
+ public EventHandler rt()
+ {
+ return eventHandler;
+ }
+
+ /*
+ TODO: OFFLINE SECTION
+ */
+
+ @Override
+ public void initLocalDatabase(String whereClause, AsyncCallback responder) {
+ storageManager.initDatabase(whereClause, responder);
+ }
+
+ @Override
+ public void clearLocalDatabase() {
+ storageManager.clearLocalDatabase();
+ }
+
+ @Override
+ public void saveEventually(E entity) {
+ saveEventually(entity, null);
+ }
+
+ @Override
+ public void saveEventually(E entity, OfflineAwareCallback responder) {
+ int blLocalId = storageManager.save(entity, responder);
+ Map serializedEntity = serializeToMap( entity );
+ serializedEntity.put("blLocalId", blLocalId);
+
+ Object[] args = new Object[] {
+ BackendlessSerializer.getSimpleName( entity.getClass() ),
+ serializedEntity};
+
+ transactionManager.scheduleOperation("save", args, entityClass.getName(), responder);
+ }
+
+ @Override
+ public void removeEventually(E entity) {
+ removeEventually(entity, null);
+ }
+
+ @Override
+ public void removeEventually(E entity, OfflineAwareCallback responder) {
+ final Map serializedEntity = serializeToMap( entity );
+
+ Object[] args = new Object[] {
+ BackendlessSerializer.getSimpleName( entity.getClass() ),
+ serializedEntity };
+
+ transactionManager.scheduleOperation("remove", args, entityClass.getName(), responder);
+ }
+
+ @Override
+ public void onSave(AsyncCallback responder) {
+ transactionManager.onSave(BackendlessSerializer.getSimpleName( entityClass ), responder);
+
+ }
+
+ @Override
+ public void onRemove(AsyncCallback responder) {
+ transactionManager.onRemove(BackendlessSerializer.getSimpleName( entityClass ), responder);
+
+ }
+
+ @Override
+ public void enableAutoSync() {
+ syncManager.enableAutoSync(BackendlessSerializer.getSimpleName( entityClass ));
+ }
+
+ @Override
+ public void disableAutoSync() {
+ syncManager.disableAutoSync(BackendlessSerializer.getSimpleName( entityClass ));
+ }
+
+ @Override
+ public boolean isAutoSyncEnabled() {
+ return syncManager.isAutoSyncEnabled(BackendlessSerializer.getSimpleName( entityClass ));
+ }
+
+ @Override
+ public void startOfflineSync(SyncCompletionCallback callback) {
+ syncManager.startSemiAutoSynchronization(BackendlessSerializer.getSimpleName( entityClass ), callback);
+ }
+
+
+ };
+ }
}
\ No newline at end of file
diff --git a/src/com/backendless/IDataStore.java b/src/com/backendless/IDataStore.java
index 75a3be8d8..e1b2fa18f 100644
--- a/src/com/backendless/IDataStore.java
+++ b/src/com/backendless/IDataStore.java
@@ -1,175 +1,202 @@
-/*
- * ********************************************************************************************************************
- *
- * BACKENDLESS.COM CONFIDENTIAL
- *
- * ********************************************************************************************************************
- *
- * Copyright 2012 BACKENDLESS.COM. All Rights Reserved.
- *
- * NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers,
- * if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
- * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
- * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
- * unless prior written permission is obtained from Backendless.com.
- *
- * ********************************************************************************************************************
- */
-
-package com.backendless;
-
-import com.backendless.async.callback.AsyncCallback;
-import com.backendless.exceptions.BackendlessException;
-import com.backendless.persistence.DataQueryBuilder;
-import com.backendless.persistence.LoadRelationsQueryBuilder;
-import com.backendless.rt.data.EventHandler;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-public interface IDataStore
-{
- List create( List objects ) throws BackendlessException;
-
- void create( List objects, AsyncCallback> responder ) throws BackendlessException;
-
- E save( E entity ) throws BackendlessException;
-
- void save( E entity, AsyncCallback responder );
-
- Long remove( E entity ) throws BackendlessException;
-
- void remove( E entity, AsyncCallback responder );
-
- int remove( String whereClause ) throws BackendlessException;
-
- void remove( String whereClause, AsyncCallback responder ) throws BackendlessException;
-
- int update( String whereClause, Map changes ) throws BackendlessException;
-
- void update( String whereClause, Map changes, AsyncCallback responder ) throws BackendlessException;
-
- E findFirst() throws BackendlessException;
-
- E findFirst( Integer relationsDepth ) throws BackendlessException;
-
- E findFirst( List relations ) throws BackendlessException;
-
- void findFirst( AsyncCallback responder );
-
- void findFirst( Integer relationsDepth, AsyncCallback responder );
-
- void findFirst( List relations, AsyncCallback responder );
-
- E findLast() throws BackendlessException;
-
- E findLast( Integer relationsDepth ) throws BackendlessException;
-
- E findLast( List relations ) throws BackendlessException;
-
- void findLast( AsyncCallback responder );
-
- void findLast( Integer relationsDepth, AsyncCallback responder );
-
- void findLast( List relations, AsyncCallback responder );
-
- List find() throws BackendlessException;
-
- List find( DataQueryBuilder dataQueryBuilder ) throws BackendlessException;
-
- void find( AsyncCallback> responder );
-
- void find( DataQueryBuilder dataQueryBuilder, AsyncCallback> responder );
-
- E findById( String id ) throws BackendlessException;
-
- E findById( String id, List relations ) throws BackendlessException;
-
- E findById( String id, Integer relationsDepth ) throws BackendlessException;
-
- E findById( String id, List relations, Integer relationsDepth ) throws BackendlessException;
-
- E findById( String id, DataQueryBuilder queryBuilder ) throws BackendlessException;
-
- E findById( E entity ) throws BackendlessException;
-
- E findById( E entity, List relations ) throws BackendlessException;
-
- E findById( E entity, Integer relationsDepth ) throws BackendlessException;
-
- E findById( E entity, List relations, Integer relationsDepth ) throws BackendlessException;
-
- E findById( E entity, DataQueryBuilder queryBuilder ) throws BackendlessException;
-
- int getObjectCount();
-
- int getObjectCount( DataQueryBuilder dataQueryBuilder );
-
- void findById( String id, AsyncCallback responder );
-
- void findById( String id, List relations, AsyncCallback responder );
-
- void findById( String id, Integer relationsDepth, AsyncCallback responder );
-
- void findById( String id, List relations, Integer relationsDepth, AsyncCallback responder );
-
- void findById( String id, DataQueryBuilder queryBuilder, AsyncCallback responder );
-
- void findById( E entity, AsyncCallback responder );
-
- void findById( E entity, List relations, AsyncCallback responder );
-
- void findById( E entity, Integer relationsDepth, AsyncCallback responder );
-
- void findById( E entity, List relations, Integer relationsDepth, AsyncCallback responder );
-
- void findById( E entity, DataQueryBuilder queryBuilder, AsyncCallback responder );
-
- /**
- * @see com.backendless.persistence.LoadRelationsQueryBuilder
- *
- * @param objectId parentObjectId
- * @param child relation type
- */
- List loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder );
-
- /**
- * @see com.backendless.persistence.LoadRelationsQueryBuilder
- *
- * @param objectId parentObjectId
- * @param child relation type
- * @param responder asynchronous callback
- */
- void loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder, AsyncCallback> responder );
-
- void getObjectCount( AsyncCallback responder );
-
- void getObjectCount( DataQueryBuilder dataQueryBuilder, AsyncCallback responder );
-
- int addRelation( E parent, String relationColumnName, Collection children );
-
- void addRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback );
-
- int addRelation( E parent, String relationColumnName, String whereClause );
-
- void addRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback );
-
- int setRelation( E parent, String relationColumnName, Collection children );
-
- void setRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback );
-
- int setRelation( E parent, String relationColumnName, String whereClause );
-
- void setRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback );
-
- int deleteRelation( E parent, String relationColumnName, Collection children );
-
- void deleteRelation( E parent, String relationColumnName, Collection children, AsyncCallback