// Path: RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/sql/observables/operators/NotifyOfUpdate.java
// public class NotifyOfUpdate<ModelType> extends DBFlowBaseCompletable<ModelType> implements HasUpstreamCompletableSource {
// 
//     private final Completable mSource;
//     private final String mQuery;
// 
//     public NotifyOfUpdate(Completable source, String query, Class<ModelType> clazz) {
//         super(clazz);
//         mSource = source;
//         mQuery = query;
//     }
// 
//     @Override
//     public CompletableSource source() {
//         return mSource;
//     }
// 
//     @Override
//     protected void subscribeActual(CompletableObserver observer) {
//         mSource.subscribe(new CompletableObservable(observer, mQuery, getPrimaryModelClass()));
//         super.subscribeActual(observer);
//     }
// 
//     @Override
//     public void run() {
//         if(mQuery.toLowerCase().contains("delete ")){
//             SqlUtils.notifyModelChanged(getPrimaryModelClass(), BaseModel.Action.DELETE, null);
//         } else if(mQuery.toLowerCase().contains("update ")){
//             SqlUtils.notifyModelChanged(getPrimaryModelClass(), BaseModel.Action.UPDATE, null);
//         }
//     }
// 
//     private class CompletableObservable implements CompletableObserver, Disposable {
// 
//         private final CompletableObserver mActual;
//         private final String mQuery;
//         private final Class mModelClazz;
//         private boolean mIsDisposed = false;
// 
//         public CompletableObservable(CompletableObserver observer, String query, Class modelClazz) {
//             mActual = observer;
//             mQuery = query;
//             mModelClazz = modelClazz;
//         }
// 
//         @Override
//         public void onSubscribe(Disposable d) {
//             mActual.onSubscribe(this);
//         }
// 
//         @Override
//         public void onError(Throwable e) {
//             mActual.onError(e);
//         }
// 
//         @Override
//         public void onComplete() {
//             if(mQuery.toLowerCase().contains("delete ")){
//                 SqlUtils.notifyModelChanged(mModelClazz, BaseModel.Action.DELETE, null);
//             } else if(mQuery.toLowerCase().contains("update ")){
//                 SqlUtils.notifyModelChanged(mModelClazz, BaseModel.Action.UPDATE, null);
//             }
// 
//             mActual.onComplete();
//         }
// 
//         @Override
//         public void dispose() {
//             mIsDisposed = true;
//         }
// 
//         @Override
//         public boolean isDisposed() {
//             return mIsDisposed;
//         }
//     }
// }


import android.support.annotation.Nullable;
import com.raizlabs.android.dbflow.sql.language.BaseQueriable;
import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
import au.com.roadhouse.rxdbflow.rx2.sql.observables.operators.NotifyOfUpdate;
import io.reactivex.Completable;
package au.com.roadhouse.rxdbflow.rx2.sql.observables;





/**
 * Given an RxSQLite query, executes a statement without a result.
 */
public class DBFlowExecuteCompletable<TModel> extends DBFlowBaseCompletable<TModel>  {

    private final BaseQueriable mBaseQueriable;
    private final DatabaseWrapper mDatabaseWrapper;

    /**
     * Creates a new Observable which executes a sql statement against a table
     * @param clazz The model class representing the table to execute against
     * @param modelQueriable The query to execute
     * @param databaseWrapper The database in which the target table resides
     */
    public DBFlowExecuteCompletable(Class<TModel> clazz, BaseQueriable modelQueriable, @Nullable DatabaseWrapper databaseWrapper) {
        super(clazz);
        mBaseQueriable = modelQueriable;
        mDatabaseWrapper = databaseWrapper;
    }


    public Completable notifyOfUpdates(){
// Path: RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/sql/observables/operators/NotifyOfUpdate.java
// public class NotifyOfUpdate<ModelType> extends DBFlowBaseCompletable<ModelType> implements HasUpstreamCompletableSource {
// 
//     private final Completable mSource;
//     private final String mQuery;
// 
//     public NotifyOfUpdate(Completable source, String query, Class<ModelType> clazz) {
//         super(clazz);
//         mSource = source;
//         mQuery = query;
//     }
// 
//     @Override
//     public CompletableSource source() {
//         return mSource;
//     }
// 
//     @Override
//     protected void subscribeActual(CompletableObserver observer) {
//         mSource.subscribe(new CompletableObservable(observer, mQuery, getPrimaryModelClass()));
//         super.subscribeActual(observer);
//     }
// 
//     @Override
//     public void run() {
//         if(mQuery.toLowerCase().contains("delete ")){
//             SqlUtils.notifyModelChanged(getPrimaryModelClass(), BaseModel.Action.DELETE, null);
//         } else if(mQuery.toLowerCase().contains("update ")){
//             SqlUtils.notifyModelChanged(getPrimaryModelClass(), BaseModel.Action.UPDATE, null);
//         }
//     }
// 
//     private class CompletableObservable implements CompletableObserver, Disposable {
// 
//         private final CompletableObserver mActual;
//         private final String mQuery;
//         private final Class mModelClazz;
//         private boolean mIsDisposed = false;
// 
//         public CompletableObservable(CompletableObserver observer, String query, Class modelClazz) {
//             mActual = observer;
//             mQuery = query;
//             mModelClazz = modelClazz;
//         }
// 
//         @Override
//         public void onSubscribe(Disposable d) {
//             mActual.onSubscribe(this);
//         }
// 
//         @Override
//         public void onError(Throwable e) {
//             mActual.onError(e);
//         }
// 
//         @Override
//         public void onComplete() {
//             if(mQuery.toLowerCase().contains("delete ")){
//                 SqlUtils.notifyModelChanged(mModelClazz, BaseModel.Action.DELETE, null);
//             } else if(mQuery.toLowerCase().contains("update ")){
//                 SqlUtils.notifyModelChanged(mModelClazz, BaseModel.Action.UPDATE, null);
//             }
// 
//             mActual.onComplete();
//         }
// 
//         @Override
//         public void dispose() {
//             mIsDisposed = true;
//         }
// 
//         @Override
//         public boolean isDisposed() {
//             return mIsDisposed;
//         }
//     }
// }


// Path: RxDbFlow-Rx2/src/main/java/au/com/roadhouse/rxdbflow/rx2/sql/observables/DBFlowExecuteCompletable.java
import android.support.annotation.Nullable;
import com.raizlabs.android.dbflow.sql.language.BaseQueriable;
import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;
import au.com.roadhouse.rxdbflow.rx2.sql.observables.operators.NotifyOfUpdate;
import io.reactivex.Completable;

package au.com.roadhouse.rxdbflow.rx2.sql.observables;





/**
 * Given an RxSQLite query, executes a statement without a result.
 */
public class DBFlowExecuteCompletable<TModel> extends DBFlowBaseCompletable<TModel>  {

    private final BaseQueriable mBaseQueriable;
    private final DatabaseWrapper mDatabaseWrapper;

    /**
     * Creates a new Observable which executes a sql statement against a table
     * @param clazz The model class representing the table to execute against
     * @param modelQueriable The query to execute
     * @param databaseWrapper The database in which the target table resides
     */
    public DBFlowExecuteCompletable(Class<TModel> clazz, BaseQueriable modelQueriable, @Nullable DatabaseWrapper databaseWrapper) {
        super(clazz);
        mBaseQueriable = modelQueriable;
        mDatabaseWrapper = databaseWrapper;
    }


    public Completable notifyOfUpdates(){
        return new NotifyOfUpdate<>(this, mBaseQueriable.getQuery(), getPrimaryModelClass());