예제 #1
0
  public void addBook(Book book) {
    if (book == null) {
      return;
    }

    ru.ncedu.entity.Author author =
        (book.getAuthor() == null) ? null : LibraryService.getAuthorById(book.getAuthor().getId());
    LibraryService.addBook(
        new ru.ncedu.entity.Book(book.name, book.description, book.genre, book.year, author));
  }
예제 #2
0
 public void addAuthor(Author author) {
   if (author == null) {
     return;
   }
   LibraryService.addAuthor(
       new ru.ncedu.entity.Author(author.firstName, author.lastName, author.age));
 }
예제 #3
0
  public List<Book> getAllBooks() {
    List<ru.ncedu.entity.Book> books = LibraryService.getAllBooks();

    List<Book> resultList = new ArrayList<Book>(books.size());
    for (ru.ncedu.entity.Book book : books) {
      resultList.add(new Book(book));
    }

    return resultList;
  }
예제 #4
0
  public List<Author> getAllAuthors() {
    List<ru.ncedu.entity.Author> authors = LibraryService.getAllAuthors();

    List<Author> resultList = new ArrayList<Author>(authors.size());
    for (ru.ncedu.entity.Author author : authors) {
      resultList.add(
          new Author(author.getId(), author.getFirstName(), author.getLastName(), author.getAge()));
    }

    return resultList;
  }