package uk.org.adamretter.webexample.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import static javax.persistence.GenerationType.SEQUENCE;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author aretter
 */

@Entity
@Table(name="conference", schema="public")
public class Conference implements java.io.Serializable {
    
    private Integer id;
    private String name;
    private Date date;
    private Short duration;
    private String settlement;
    private String url;
    private String description;
    private Set<Category> categories = new HashSet<Category>(0);
    
    private Date timestamp;
    
 
    public Conference() {    
    }

    public Conference(String name, Date date, Short duration, String settlement, String url, String description, Date timestamp) {
        this.name = name;
        this.date = date;
        this.duration = duration;
        this.settlement = settlement;
        this.url = url;
        this.description = description;
        this.timestamp = timestamp;
    }

    public Conference(String name, Date date, Short duration, String settlement, String url, String description, Set<Category> categories, Date timestamp) {
        this.name = name;
        this.date = date;
        this.duration = duration;
        this.settlement = settlement;
        this.url = url;
        this.description = description;
        this.categories = categories;
        this.timestamp = timestamp;
    }

    @Id
    @SequenceGenerator(name="generator", sequenceName="conference_id_seq")
    @GeneratedValue(strategy=SEQUENCE, generator="generator")
    @Column(name="id", unique=true, nullable=false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
    
    @Column(name="name", nullable=false, length=50)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    @Temporal(TemporalType.DATE)
    @Column(name="conference_date", nullable=false, length=13)
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }
    
    @Column(name="duration", nullable=false)
    public Short getDuration() {
        return duration;
    }

    public void setDuration(Short duration) {
        this.duration = duration;
    }
    
    @Column(name="settlement", nullable=false, length=50)
    public String getSettlement() {
        return settlement;
    }

    public void setSettlement(String settlement) {
        this.settlement = settlement;
    }
    
    @Column(name="url", nullable=false, length=255)
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
    
     @Column(name="description", nullable=false, length=1024)
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
    
    @ManyToMany(fetch=FetchType.LAZY)
    @JoinTable(
        name="conference_categories",
        joinColumns=@JoinColumn(name="conference_id"),
        inverseJoinColumns=@JoinColumn(name="category_id")
    )
    public Set<Category> getCategories() {
        return categories;
    }

    public void setCategories(Set<Category> categories) {
        this.categories = categories;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="timestamp", nullable=false, length=29)
    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    
    
}