package org.gdgcd.demo;

import org.gdgcd.demo.domain.Book;
import org.gdgcd.demo.service.BookMeta;
import org.gdgcd.demo.service.BookMetaEnvelope;
import org.gdgcd.demo.service.BookService;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

public class SearchEngine {

    @Inject
    BookService bookService;

    public Observable<Book> search(String query)


    public Observable<BookMetaEnvelope> search1(String query) {
        return bookService.getBooks(query);
    }

    public static Book buildBook(BookMeta bookMeta) {
        Book book = new Book();
        book.title = bookMeta.getTitle();
        book.imageUrl = bookMeta.getImage();
        book.description = bookMeta.getDescription();
        return book;
    }
}

@@ -185,16 +185,40 @@
 rvice;%0A%0A
+import java.util.List;%0A%0A
 import j
@@ -407,16 +407,556 @@
 g query)
+ %7B%0A        return bookService.getBooks(query).flatMap(new Func1%3CBookMetaEnvelope, Observable%3CBookMeta%3E%3E() %7B%0A            @Override%0A            public Observable%3CBookMeta%3E call(BookMetaEnvelope bookMetaEnvelope) %7B%0A                final List%3CBookMeta%3E books = bookMetaEnvelope.getBooks();%0A                return Observable.from(books);%0A%0A            %7D%0A        %7D).map(new Func1%3CBookMeta, Book%3E() %7B%0A            @Override%0A            public Book call(BookMeta bookMeta) %7B%0A                return buildBook(bookMeta);%0A            %7D%0A        %7D);%0A    %7D
 %0A%0A%0A    p

bring search back