/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cookery_db.database;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 *
 * @author nick
 */
@Entity
@Table(name = "RECIPE")
@NamedQueries({@NamedQuery(name = "Recipe.findAll", query = "SELECT r FROM Recipe r"), @NamedQuery(name = "Recipe.findByRecipeid", query = "SELECT r FROM Recipe r WHERE r.recipeid = :recipeid"), @NamedQuery(name = "Recipe.findByName", query = "SELECT r FROM Recipe r WHERE r.name = :name"), @NamedQuery(name = "Recipe.findBySource", query = "SELECT r FROM Recipe r WHERE r.source = :source"), @NamedQuery(name = "Recipe.findByDifficulty", query = "SELECT r FROM Recipe r WHERE r.difficulty = :difficulty"), @NamedQuery(name = "Recipe.findByTemperature", query = "SELECT r FROM Recipe r WHERE r.temperature = :temperature"), @NamedQuery(name = "Recipe.findByAuthor", query = "SELECT r FROM Recipe r WHERE r.author = :author")})
public class Recipe implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "RECIPEID")
    private Integer recipeid;
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @Column(name = "SOURCE")
    private String source;
    @Basic(optional = false)
    @Column(name = "DIFFICULTY")
    private int difficulty;
    @Column(name = "TEMPERATURE")
    private Double temperature;
    @Basic(optional = false)
    @Lob
    @Column(name = "STEPS")
    private String steps;
    @Column(name = "AUTHOR")
    private String author;
    @JoinColumn(name = "CATEGORY", referencedColumnName = "CATEGORYID")
    @ManyToOne(optional = false)
    private Category category;
    @JoinColumn(name = "COOKMETHOD", referencedColumnName = "COOKMETHODID")
    @ManyToOne
    private CookMethod cookmethod;
    @JoinColumn(name = "KEYINGREDIENT", referencedColumnName = "INGREDIENTID")
    @ManyToOne(optional = false)
    private Ingredient keyingredient;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "recipe1")
    private Collection<RecipeIngredient> recipeIngredientCollection;

    public Recipe()
    {
    }

    public Recipe(Integer recipeid)
    {
        this.recipeid = recipeid;
    }

    public Recipe(Integer recipeid, String name, int difficulty, String steps)
    {
        this.recipeid = recipeid;
        this.name = name;
        this.difficulty = difficulty;
        this.steps = steps;
    }

    public Integer getRecipeid()
    {
        return recipeid;
    }

    public void setRecipeid(Integer recipeid)
    {
        this.recipeid = recipeid;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getSource()
    {
        return source;
    }

    public void setSource(String source)
    {
        this.source = source;
    }

    public int getDifficulty()
    {
        return difficulty;
    }

    public void setDifficulty(int difficulty)
    {
        this.difficulty = difficulty;
    }

    public Double getTemperature()
    {
        return temperature;
    }

    public void setTemperature(Double temperature)
    {
        this.temperature = temperature;
    }

    public String getSteps()
    {
        return steps;
    }

    public void setSteps(String steps)
    {
        this.steps = steps;
    }

    public String getAuthor()
    {
        return author;
    }

    public void setAuthor(String author)
    {
        this.author = author;
    }

    public Category getCategory()
    {
        return category;
    }

    public void setCategory(Category category)
    {
        this.category = category;
    }

    public CookMethod getCookmethod()
    {
        return cookmethod;
    }

    public void setCookmethod(CookMethod cookmethod)
    {
        this.cookmethod = cookmethod;
    }

    public Ingredient getKeyingredient()
    {
        return keyingredient;
    }

    public void setKeyingredient(Ingredient keyingredient)
    {
        this.keyingredient = keyingredient;
    }

    public Collection<RecipeIngredient> getRecipeIngredientCollection()
    {
        return recipeIngredientCollection;
    }

    public void setRecipeIngredientCollection(Collection<RecipeIngredient> recipeIngredientCollection)
    {
        this.recipeIngredientCollection = recipeIngredientCollection;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (recipeid != null ? recipeid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Recipe))
        {
            return false;
        }
        Recipe other = (Recipe) object;
        if ((this.recipeid == null && other.recipeid != null) || (this.recipeid != null && !this.recipeid.equals(other.recipeid)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "cookery_db.database.Recipe[recipeid=" + recipeid + "]";
    }

}
