// Path: smssync/src/main/java/org/addhen/smssync/data/exception/WebServiceNotFoundException.java
// public class WebServiceNotFoundException extends Exception {
// 
//     /**
//      * Default exception
//      */
//     public WebServiceNotFoundException() {
//         super();
//     }
// 
//     /**
//      * Initialize the exception with a custom message
//      *
//      * @param message The message be shown when the exception is thrown
//      */
//     public WebServiceNotFoundException(final String message) {
//         super(message);
//     }
// 
//     /**
//      * Initialize the exception with a custom message and the cause of the exception
//      *
//      * @param message The message to be shown when the exception is thrown
//      * @param cause   The cause of the exception
//      */
//     public WebServiceNotFoundException(final String message, final Throwable cause) {
//         super(message, cause);
//     }
// 
//     /**
//      * Initialize the exception with a the cause of the exception
//      *
//      * @param cause The cause of the exception
//      */
//     public WebServiceNotFoundException(final Throwable cause) {
//         super(cause);
//     }
// }


import static nl.qbusict.cupboard.CupboardFactory.cupboard;
import org.addhen.smssync.data.entity.SyncUrl;
import org.addhen.smssync.data.exception.WebServiceNotFoundException;
import android.content.Context;
import android.support.annotation.NonNull;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import rx.Observable;
/*
 * Copyright (c) 2010 - 2015 Ushahidi Inc
 * All rights reserved
 * Contact: team@ushahidi.com
 * Website: http://www.ushahidi.com
 * GNU Lesser General Public License Usage
 * This file may be used under the terms of the GNU Lesser
 * General Public License version 3 as published by the Free Software
 * Foundation and appearing in the file LICENSE.LGPL included in the
 * packaging of this file. Please review the following information to
 * ensure the GNU Lesser General Public License version 3 requirements
 * will be met: http://www.gnu.org/licenses/lgpl.html.
 *  
 * If you have questions regarding the use of this file, please contact
 * Ushahidi developers at team@ushahidi.com.
 */

package org.addhen.smssync.data.database;







/**
 * @author Ushahidi Team <team@ushahidi.com>
 */
@Singleton
public class WebServiceDatabaseHelper extends BaseDatabaseHelper {

    /**
     * Default constructor
     *
     * @param context The calling context. Cannot be a null value
     */
    @Inject
    public WebServiceDatabaseHelper(@NonNull Context context) {
        super(context);
    }

    /**
     * Gets webServices by it's status
     *
     * @param status The status to use to query for the webService
     * @return An Observable that emits a {@link SyncUrl}
     */
    public Observable<List<SyncUrl>> getByStatus(final SyncUrl.Status status) {
        return Observable.create((subscriber) -> {
            final List<SyncUrl> syncUrlEntity = get(status);
            if (syncUrlEntity != null) {
                subscriber.onNext(syncUrlEntity);
                subscriber.onCompleted();
            } else {
// Path: smssync/src/main/java/org/addhen/smssync/data/exception/WebServiceNotFoundException.java
// public class WebServiceNotFoundException extends Exception {
// 
//     /**
//      * Default exception
//      */
//     public WebServiceNotFoundException() {
//         super();
//     }
// 
//     /**
//      * Initialize the exception with a custom message
//      *
//      * @param message The message be shown when the exception is thrown
//      */
//     public WebServiceNotFoundException(final String message) {
//         super(message);
//     }
// 
//     /**
//      * Initialize the exception with a custom message and the cause of the exception
//      *
//      * @param message The message to be shown when the exception is thrown
//      * @param cause   The cause of the exception
//      */
//     public WebServiceNotFoundException(final String message, final Throwable cause) {
//         super(message, cause);
//     }
// 
//     /**
//      * Initialize the exception with a the cause of the exception
//      *
//      * @param cause The cause of the exception
//      */
//     public WebServiceNotFoundException(final Throwable cause) {
//         super(cause);
//     }
// }


// Path: smssync/src/main/java/org/addhen/smssync/data/database/WebServiceDatabaseHelper.java
import static nl.qbusict.cupboard.CupboardFactory.cupboard;
import org.addhen.smssync.data.entity.SyncUrl;
import org.addhen.smssync.data.exception.WebServiceNotFoundException;
import android.content.Context;
import android.support.annotation.NonNull;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import rx.Observable;

/*
 * Copyright (c) 2010 - 2015 Ushahidi Inc
 * All rights reserved
 * Contact: team@ushahidi.com
 * Website: http://www.ushahidi.com
 * GNU Lesser General Public License Usage
 * This file may be used under the terms of the GNU Lesser
 * General Public License version 3 as published by the Free Software
 * Foundation and appearing in the file LICENSE.LGPL included in the
 * packaging of this file. Please review the following information to
 * ensure the GNU Lesser General Public License version 3 requirements
 * will be met: http://www.gnu.org/licenses/lgpl.html.
 *  
 * If you have questions regarding the use of this file, please contact
 * Ushahidi developers at team@ushahidi.com.
 */

package org.addhen.smssync.data.database;







/**
 * @author Ushahidi Team <team@ushahidi.com>
 */
@Singleton
public class WebServiceDatabaseHelper extends BaseDatabaseHelper {

    /**
     * Default constructor
     *
     * @param context The calling context. Cannot be a null value
     */
    @Inject
    public WebServiceDatabaseHelper(@NonNull Context context) {
        super(context);
    }

    /**
     * Gets webServices by it's status
     *
     * @param status The status to use to query for the webService
     * @return An Observable that emits a {@link SyncUrl}
     */
    public Observable<List<SyncUrl>> getByStatus(final SyncUrl.Status status) {
        return Observable.create((subscriber) -> {
            final List<SyncUrl> syncUrlEntity = get(status);
            if (syncUrlEntity != null) {
                subscriber.onNext(syncUrlEntity);
                subscriber.onCompleted();
            } else {
                subscriber.onError(new WebServiceNotFoundException());