// Path: rest-server/src/main/java/com/readlearncode/dukesbookshop/restserver/domain/Author.java
// @XmlRootElement
// public class Author implements Serializable {
// 
//     private String id;
//     private String firstName;
//     private String lastName;
//     private String blogURL;
// 
//     public Author() {
//     }
// 
//     public Author(String id, String firstName, String lastName) {
//         this.id = id;
//         this.firstName = firstName;
//         this.lastName = lastName;
//     }
// 
//     public Author(String id, String firstName, String lastName, String blogURL) {
//         this(id, firstName, lastName);
//         this.blogURL = blogURL;
//     }
// 
// 
//     @Produces(MediaType.APPLICATION_JSON)
//     public String getId() {
//         return id;
//     }
// 
//     @GET
//     @Path("/firstName")
//     @Produces(MediaType.APPLICATION_JSON)
//     public String getFirstName() {
//         return firstName;
//     }
// 
//     @GET
//     @Path("/lastName")
//     @Produces(MediaType.APPLICATION_JSON)
//     public String getLastName() {
//         return lastName;
//     }
// 
//     @GET
//     @Path("/blog")
//     @Produces(MediaType.APPLICATION_JSON)
//     public String getBlogURL() {
//         return blogURL;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public void setFirstName(String firstName) {
//         this.firstName = firstName;
//     }
// 
//     public void setLastName(String lastName) {
//         this.lastName = lastName;
//     }
// 
//     public void setBlogURL(String blogURL) {
//         this.blogURL = blogURL;
//     }
// 
// 
// }
// 
// Path: rest-server/src/main/java/com/readlearncode/dukesbookshop/restserver/domain/BookBuilder.java
// public class BookBuilder {
//     private String id;
//     private String title;
//     private String description;
//     private Float price;
//     private Date published;
//     private ArrayList<Author> authors = new ArrayList<>();
//     private String imageFileName;
//     private String link;
// 
//     public BookBuilder setId(String id) {
//         this.id = id;
//         return this;
//     }
// 
//     public BookBuilder setTitle(String title) {
//         this.title = title;
//         return this;
//     }
// 
//     public BookBuilder setDescription(String description) {
//         this.description = description;
//         return this;
//     }
// 
//     public BookBuilder setPrice(Float price) {
//         this.price = price;
//         return this;
//     }
// 
//     public BookBuilder setPublished(Date published) {
//         this.published = published;
//         return this;
//     }
// 
//     public BookBuilder setAuthors(ArrayList<Author> authors) {
//         this.authors.addAll(authors);
//         return this;
//     }
// 
//     public BookBuilder addAuthor(Author author) {
//         this.authors.add(author);
//         return this;
//     }
// 
//     public BookBuilder setImageFileName(String imageFileName) {
//         this.imageFileName = imageFileName;
//         return this;
//     }
// 
//     public BookBuilder setLink(String link) {
//         this.link = link;
//         return this;
//     }
// 
//     public Book createBook() {
//         return new Book(id, title, description, price, published, authors, imageFileName, link);
//     }
// }


import com.readlearncode.dukesbookshop.restserver.domain.Author;
import com.readlearncode.dukesbookshop.restserver.domain.BookBuilder;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
package com.readlearncode.dukesbookshop.restserver.infrastructure;



/**
 * Source code github.com/readlearncode
 *
 * @author Alex Theedom www.readlearncode.com
 * @version 1.0
 */
@Singleton
@Startup
public class BootstrapData {

    private static final String API_URL = "http://localhost:8081/rest-server";
    private static final String IMAGE_LOCATION = "/images/covers/";

    @EJB
    private BookRepository bookRepository;

    @EJB
    private AuthorRepository authorRepository;

    @PostConstruct
    public void populateRepositories() {

        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");

        // Create the authors
// Path: rest-server/src/main/java/com/readlearncode/dukesbookshop/restserver/domain/Author.java
// @XmlRootElement
// public class Author implements Serializable {
// 
//     private String id;
//     private String firstName;
//     private String lastName;
//     private String blogURL;
// 
//     public Author() {
//     }
// 
//     public Author(String id, String firstName, String lastName) {
//         this.id = id;
//         this.firstName = firstName;
//         this.lastName = lastName;
//     }
// 
//     public Author(String id, String firstName, String lastName, String blogURL) {
//         this(id, firstName, lastName);
//         this.blogURL = blogURL;
//     }
// 
// 
//     @Produces(MediaType.APPLICATION_JSON)
//     public String getId() {
//         return id;
//     }
// 
//     @GET
//     @Path("/firstName")
//     @Produces(MediaType.APPLICATION_JSON)
//     public String getFirstName() {
//         return firstName;
//     }
// 
//     @GET
//     @Path("/lastName")
//     @Produces(MediaType.APPLICATION_JSON)
//     public String getLastName() {
//         return lastName;
//     }
// 
//     @GET
//     @Path("/blog")
//     @Produces(MediaType.APPLICATION_JSON)
//     public String getBlogURL() {
//         return blogURL;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public void setFirstName(String firstName) {
//         this.firstName = firstName;
//     }
// 
//     public void setLastName(String lastName) {
//         this.lastName = lastName;
//     }
// 
//     public void setBlogURL(String blogURL) {
//         this.blogURL = blogURL;
//     }
// 
// 
// }
// 
// Path: rest-server/src/main/java/com/readlearncode/dukesbookshop/restserver/domain/BookBuilder.java
// public class BookBuilder {
//     private String id;
//     private String title;
//     private String description;
//     private Float price;
//     private Date published;
//     private ArrayList<Author> authors = new ArrayList<>();
//     private String imageFileName;
//     private String link;
// 
//     public BookBuilder setId(String id) {
//         this.id = id;
//         return this;
//     }
// 
//     public BookBuilder setTitle(String title) {
//         this.title = title;
//         return this;
//     }
// 
//     public BookBuilder setDescription(String description) {
//         this.description = description;
//         return this;
//     }
// 
//     public BookBuilder setPrice(Float price) {
//         this.price = price;
//         return this;
//     }
// 
//     public BookBuilder setPublished(Date published) {
//         this.published = published;
//         return this;
//     }
// 
//     public BookBuilder setAuthors(ArrayList<Author> authors) {
//         this.authors.addAll(authors);
//         return this;
//     }
// 
//     public BookBuilder addAuthor(Author author) {
//         this.authors.add(author);
//         return this;
//     }
// 
//     public BookBuilder setImageFileName(String imageFileName) {
//         this.imageFileName = imageFileName;
//         return this;
//     }
// 
//     public BookBuilder setLink(String link) {
//         this.link = link;
//         return this;
//     }
// 
//     public Book createBook() {
//         return new Book(id, title, description, price, published, authors, imageFileName, link);
//     }
// }


// Path: rest-server/src/main/java/com/readlearncode/dukesbookshop/restserver/infrastructure/BootstrapData.java
import com.readlearncode.dukesbookshop.restserver.domain.Author;
import com.readlearncode.dukesbookshop.restserver.domain.BookBuilder;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

package com.readlearncode.dukesbookshop.restserver.infrastructure;



/**
 * Source code github.com/readlearncode
 *
 * @author Alex Theedom www.readlearncode.com
 * @version 1.0
 */
@Singleton
@Startup
public class BootstrapData {

    private static final String API_URL = "http://localhost:8081/rest-server";
    private static final String IMAGE_LOCATION = "/images/covers/";

    @EJB
    private BookRepository bookRepository;

    @EJB
    private AuthorRepository authorRepository;

    @PostConstruct
    public void populateRepositories() {

        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");

        // Create the authors
        Author meek = authorRepository.saveAuthor(new Author("1", "Captain S. P.", "Meek", "http://www.gutenberg.org"));