// Path: app/src/main/java/com/photoviewer/data/repository/PhotoEntityDataSource.java
// public class PhotoEntityDataSource implements PhotoRepository {
// 
//     private DatabasePhotoEntityStore mDatabasePhotoEntityStore;
//     private ServerPhotoEntityStore mServerPhotoEntityStore;
// 
//     @Inject
//     public PhotoEntityDataSource(DatabasePhotoEntityStore databasePhotoEntityStore, ServerPhotoEntityStore serverPhotoEntityStore) {
//         mDatabasePhotoEntityStore = databasePhotoEntityStore;
//         mServerPhotoEntityStore = serverPhotoEntityStore;
//     }
// 
//     @Override
//     public Observable<List<PhotoEntity>> photos() {
//         return Observable.create(new Observable.OnSubscribe<List<PhotoEntity>>() {
//             @Override
//             public void call(Subscriber<? super List<PhotoEntity>> subscriber) {
//                 queryDatabaseForAll(subscriber);
//             }
//         });
//     }
// 
//     @Override
//     public Observable<List<PhotoEntity>> searchPhotosByTitle(String title) {
//         return mDatabasePhotoEntityStore.queryForTitle(title);
//     }
// 
//     @Override
//     public Observable<PhotoEntity> photo(int photoId) {
//         return mDatabasePhotoEntityStore.queryForId(photoId);
//     }
// 
//     private void queryDatabaseForAll(final Subscriber<? super List<PhotoEntity>> subscriber) {
//         mDatabasePhotoEntityStore.queryForAll().subscribe(new Observer<List<PhotoEntity>>() {
//             @Override
//             public void onCompleted() {
// 
//             }
// 
//             @Override
//             public void onError(Throwable e) {
//                 subscriber.onError(e);
//                 fetchServerForAll(subscriber);
//             }
// 
//             @Override
//             public void onNext(List<PhotoEntity> photoEntities) {
//                 if (photoEntities.size() != 0) {
//                     subscriber.onNext(photoEntities);
//                     subscriber.onCompleted();
//                 } else {
//                     fetchServerForAll(subscriber);
//                 }
//             }
//         });
//     }
// 
//     private void fetchServerForAll(Subscriber<? super List<PhotoEntity>> subscriber) {
//         mServerPhotoEntityStore.photoEntityList().subscribe(new Observer<List<PhotoEntity>>() {
//             @Override
//             public void onCompleted() {
//                 subscriber.onCompleted();
//             }
// 
//             @Override
//             public void onError(Throwable e) {
//                 subscriber.onError(e);
//             }
// 
//             @Override
//             public void onNext(List<PhotoEntity> photoEntities) {
//                 subscriber.onNext(photoEntities);
//                 mDatabasePhotoEntityStore.
//                         saveAll(photoEntities).
//                         subscribe();
//             }
//         });
//     }
// }
// 
// Path: app/src/main/java/com/photoviewer/domain/Photo.java
// @Accessors(prefix = "m")
// public class Photo {
// 
//     @Getter
//     @Setter
//     private int mId;
// 
//     @Getter
//     @Setter
//     private String mTitle;
// 
//     @Getter
//     @Setter
//     private String mUrl;
// 
//     @Getter
//     @Setter
//     private String mThumbnailUrl;
// }
// 
// Path: app/src/main/java/com/photoviewer/domain/mapper/photo/PhotoEntityToPhoto.java
// public class PhotoEntityToPhoto extends BaseLayerDataTransformer<PhotoEntity, Photo> {
//     @Override
//     public Photo transform(PhotoEntity from) {
//         Photo transformed = new Photo();
// 
//         transformed.setId(from.getId());
//         transformed.setTitle(from.getTitle());
//         transformed.setUrl(from.getUrl());
//         transformed.setThumbnailUrl(from.getThumbnailUrl());
// 
//         return transformed;
//     }
// }
// 
// Path: app/src/main/java/com/photoviewer/presentation/di/modules/RxModule.java
// @Module(library = true, complete = false) public class RxModule {
// 
//   public static final String COMPUTATION = "computation";
//   public static final String IO = "io";
//   public static final String MAIN_THREAD = "main_thread";
// 
//   @Provides @Singleton @Named(IO) Scheduler provideIoScheduler() {
//     return Schedulers.io();
//   }
// 
//   @Provides @Singleton @Named(MAIN_THREAD) Scheduler provideMainScheduler() {
//     return AndroidSchedulers.mainThread();
//   }
// 
//   @Provides @Singleton @Named(COMPUTATION) Scheduler provideComputationScheduler() {
//     return Schedulers.computation();
//   }
// }


import com.photoviewer.data.repository.PhotoEntityDataSource;
import com.photoviewer.domain.Photo;
import com.photoviewer.domain.mapper.photo.PhotoEntityToPhoto;
import com.photoviewer.presentation.di.modules.RxModule;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import lombok.Setter;
import lombok.experimental.Accessors;
import rx.Observable;
import rx.Scheduler;
package com.photoviewer.domain.usecases;




@Accessors(prefix = "m") public class SearchByTitle extends UseCase<List<Photo>> {

  @Setter private String mSearchedTitle;
  private PhotoEntityDataSource mPhotoEntityDataSource;
  private final PhotoEntityToPhoto photoTransformer;

  @Inject public SearchByTitle(@Named(RxModule.COMPUTATION) Scheduler executionScheduler,
      @Named(RxModule.MAIN_THREAD) Scheduler observingScheduler,
      PhotoEntityDataSource photoEntityDataSource) {
    super(executionScheduler, observingScheduler);
    mPhotoEntityDataSource = photoEntityDataSource;
    photoTransformer = new PhotoEntityToPhoto();
  }

// Path: app/src/main/java/com/photoviewer/data/repository/PhotoEntityDataSource.java
// public class PhotoEntityDataSource implements PhotoRepository {
// 
//     private DatabasePhotoEntityStore mDatabasePhotoEntityStore;
//     private ServerPhotoEntityStore mServerPhotoEntityStore;
// 
//     @Inject
//     public PhotoEntityDataSource(DatabasePhotoEntityStore databasePhotoEntityStore, ServerPhotoEntityStore serverPhotoEntityStore) {
//         mDatabasePhotoEntityStore = databasePhotoEntityStore;
//         mServerPhotoEntityStore = serverPhotoEntityStore;
//     }
// 
//     @Override
//     public Observable<List<PhotoEntity>> photos() {
//         return Observable.create(new Observable.OnSubscribe<List<PhotoEntity>>() {
//             @Override
//             public void call(Subscriber<? super List<PhotoEntity>> subscriber) {
//                 queryDatabaseForAll(subscriber);
//             }
//         });
//     }
// 
//     @Override
//     public Observable<List<PhotoEntity>> searchPhotosByTitle(String title) {
//         return mDatabasePhotoEntityStore.queryForTitle(title);
//     }
// 
//     @Override
//     public Observable<PhotoEntity> photo(int photoId) {
//         return mDatabasePhotoEntityStore.queryForId(photoId);
//     }
// 
//     private void queryDatabaseForAll(final Subscriber<? super List<PhotoEntity>> subscriber) {
//         mDatabasePhotoEntityStore.queryForAll().subscribe(new Observer<List<PhotoEntity>>() {
//             @Override
//             public void onCompleted() {
// 
//             }
// 
//             @Override
//             public void onError(Throwable e) {
//                 subscriber.onError(e);
//                 fetchServerForAll(subscriber);
//             }
// 
//             @Override
//             public void onNext(List<PhotoEntity> photoEntities) {
//                 if (photoEntities.size() != 0) {
//                     subscriber.onNext(photoEntities);
//                     subscriber.onCompleted();
//                 } else {
//                     fetchServerForAll(subscriber);
//                 }
//             }
//         });
//     }
// 
//     private void fetchServerForAll(Subscriber<? super List<PhotoEntity>> subscriber) {
//         mServerPhotoEntityStore.photoEntityList().subscribe(new Observer<List<PhotoEntity>>() {
//             @Override
//             public void onCompleted() {
//                 subscriber.onCompleted();
//             }
// 
//             @Override
//             public void onError(Throwable e) {
//                 subscriber.onError(e);
//             }
// 
//             @Override
//             public void onNext(List<PhotoEntity> photoEntities) {
//                 subscriber.onNext(photoEntities);
//                 mDatabasePhotoEntityStore.
//                         saveAll(photoEntities).
//                         subscribe();
//             }
//         });
//     }
// }
// 
// Path: app/src/main/java/com/photoviewer/domain/Photo.java
// @Accessors(prefix = "m")
// public class Photo {
// 
//     @Getter
//     @Setter
//     private int mId;
// 
//     @Getter
//     @Setter
//     private String mTitle;
// 
//     @Getter
//     @Setter
//     private String mUrl;
// 
//     @Getter
//     @Setter
//     private String mThumbnailUrl;
// }
// 
// Path: app/src/main/java/com/photoviewer/domain/mapper/photo/PhotoEntityToPhoto.java
// public class PhotoEntityToPhoto extends BaseLayerDataTransformer<PhotoEntity, Photo> {
//     @Override
//     public Photo transform(PhotoEntity from) {
//         Photo transformed = new Photo();
// 
//         transformed.setId(from.getId());
//         transformed.setTitle(from.getTitle());
//         transformed.setUrl(from.getUrl());
//         transformed.setThumbnailUrl(from.getThumbnailUrl());
// 
//         return transformed;
//     }
// }
// 
// Path: app/src/main/java/com/photoviewer/presentation/di/modules/RxModule.java
// @Module(library = true, complete = false) public class RxModule {
// 
//   public static final String COMPUTATION = "computation";
//   public static final String IO = "io";
//   public static final String MAIN_THREAD = "main_thread";
// 
//   @Provides @Singleton @Named(IO) Scheduler provideIoScheduler() {
//     return Schedulers.io();
//   }
// 
//   @Provides @Singleton @Named(MAIN_THREAD) Scheduler provideMainScheduler() {
//     return AndroidSchedulers.mainThread();
//   }
// 
//   @Provides @Singleton @Named(COMPUTATION) Scheduler provideComputationScheduler() {
//     return Schedulers.computation();
//   }
// }


// Path: app/src/main/java/com/photoviewer/domain/usecases/SearchByTitle.java
import com.photoviewer.data.repository.PhotoEntityDataSource;
import com.photoviewer.domain.Photo;
import com.photoviewer.domain.mapper.photo.PhotoEntityToPhoto;
import com.photoviewer.presentation.di.modules.RxModule;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
import lombok.Setter;
import lombok.experimental.Accessors;
import rx.Observable;
import rx.Scheduler;

package com.photoviewer.domain.usecases;




@Accessors(prefix = "m") public class SearchByTitle extends UseCase<List<Photo>> {

  @Setter private String mSearchedTitle;
  private PhotoEntityDataSource mPhotoEntityDataSource;
  private final PhotoEntityToPhoto photoTransformer;

  @Inject public SearchByTitle(@Named(RxModule.COMPUTATION) Scheduler executionScheduler,
      @Named(RxModule.MAIN_THREAD) Scheduler observingScheduler,
      PhotoEntityDataSource photoEntityDataSource) {
    super(executionScheduler, observingScheduler);
    mPhotoEntityDataSource = photoEntityDataSource;
    photoTransformer = new PhotoEntityToPhoto();
  }

  @Override protected Observable<List<Photo>> call() {