package com.bookbase.app.model.entity;

import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.PrimaryKey;

import java.util.Calendar;

@Entity(tableName = "Book")
public class Book {

    //, foreignKeys = @ForeignKey(entity = Author.class, parentColumns = "authorId", childColumns = "author", onDelete = CASCADE)

    @PrimaryKey(autoGenerate = true)
    private int bookId;
    private String title;
    private int author;
    private String description;
    private Genre genre;
    private String coverImage;
    private String isbn;
    private int rating;
    private String review;
    private boolean isRead;
    private Calendar purchaseDate;
    private double purchasePrice;
    private boolean isOwned;

    // Default constructor for Room database.
    public Book(){
        
    }

    @Ignore
    public Book(String title, int author){
        this.title = title;
        this.author = author;
        this.isRead = false;
        this.rating = 0;
        this.author = author;
        this.description = "";
        this.isbn = "";
        this.genre = new Genre("");
        this.review = "";

    }

    @Ignore
    public Book(String title, int author, String description, Genre genre){
        this.title = title;
        this.author = author;
        this.isRead = false;
        this.rating = 0;
        this.author = author;
        this.description = "";
        this.isbn = "";
        this.genre = new Genre("");
        this.review = "";

    }


    public Book(int bookId, boolean isRead, int rating, int author, String description,
                Genre genre, String isbn, String title, String review, String coverImage,
                Calendar purchaseDate, double purchasePrice, boolean isOwned) {
        this.bookId = bookId;
        this.isRead = isRead;
        this.rating = rating;
        this.author = author;
        this.description = description;
        this.genre = genre;
        this.isbn = isbn;
        this.title = title;
        this.review = review;
        this.coverImage = coverImage;
        this.purchaseDate = purchaseDate;
        this.purchasePrice = purchasePrice;
        this.isOwned = isOwned;
    }

    public int getBookId(){ return bookId; }
    public boolean getIsRead(){ return isRead; }
    public int getRating(){ return rating; }
    public int getAuthor(){ return author; }
    public String getDescription(){ return description; }
    public Genre getGenre() { return genre; }
    public String getIsbn(){ return isbn; }
    public String getTitle(){ return title; }
    public String getReview() { return review; }
    public Calendar getPurchaseDate() { return purchaseDate; }
    public double getPurchasePrice() { return purchasePrice; }
    public String getCoverImage() { return coverImage; }
    public boolean getIsOwned() { return isOwned; }

    public void setBookId(int bookId){ this.bookId = bookId; }
    public void setIsRead(boolean isRead){ this.isRead = isRead; }
    public void setRating(int rating){ this.rating = rating; }
    public void setAuthor(int author){ this.author = author; }
    public void setDescription(String description){ this.description = description; }
    public void setGenre(Genre genre) { this.genre = genre; }
    public void setIsbn(String isbn){ this.isbn = isbn; }
    public void setTitle(String title){ this.title = title; }
    public void setReview(String review){ this.review = review; }
    public void setPurchaseDate(Calendar date){ this.purchaseDate = date; }
    public void setPurchasePrice(double price){ this.purchasePrice = price; }
    public void setCoverImage(String imageDirectory) { this.coverImage = imageDirectory; }
    public void setIsOwned(boolean isOwned) { this.isOwned = isOwned; }

}

@@ -171,16 +171,85 @@
 maryKey;
+%0Aimport android.os.Bundle;%0A%0Aimport com.bookbase.app.utils.Converters;
 %0A%0Aimport
@@ -3875,10 +3875,721 @@
 ned; %7D%0A%0A
+    public Bundle bundleBook()%7B%0A        Bundle bundle = new Bundle();%0A        bundle.putInt(%22bookId%22, bookId);%0A        bundle.putString(%22title%22, title);%0A        bundle.putInt(%22author%22, author);%0A        //bundle.putInt(%22genre%22, genre) //TODO: Need to fix so can bundle Genre val.%0A        bundle.putString(%22coverImage%22, coverImage);%0A        bundle.putString(%22isbn%22, isbn);%0A        bundle.putInt(%22rating%22, rating);%0A        bundle.putString(%22review%22, review);%0A        bundle.putBoolean(%22isRead%22, isRead);%0A        bundle.putString(%22purchaseDate%22, Converters.calendarToString(purchaseDate));%0A        bundle.putDouble(%22price%22, purchasePrice);%0A        bundle.putBoolean(%22owned%22, isOwned);%0A        return bundle;%0A    %7D%0A%0A
 %7D%0A

Add bundleBook method