package org.yacos.core.forum;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.yacos.core.article.Article;
import org.yacos.core.users.User;

@Entity
public class Message implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8960098137182930392L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	private String message;
	private String title;
	
	@Temporal(TemporalType.DATE)
	private Date dateMessage;
	
	@ManyToOne(targetEntity=Article.class)
	@JoinColumn(name="article_id",nullable=false)
	private Article article;
	
	@ManyToOne(targetEntity=User.class)
	@JoinColumn(name="user_id",nullable=false)
	private User user;
	
	public Message() {}
	
	public Message(Integer id, String message, String title, Article article, User user) {
		this.id = id;
		this.message = message;
		this.title = title;
		this.dateMessage = new Date();
		this.article = article;
		this.user = user;
	}
	
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Integer getId() {
		return id;
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getMessage() {
		return message;
	}
	
	public void setMessage(String message) {
		this.message = message;
	}
	
	@Temporal(TemporalType.DATE)
	public Date getDateMessage() {
		return dateMessage;
	}
	
	@Temporal(TemporalType.DATE)
	public void setDateMessage(Date dateMessage) {
		this.dateMessage = dateMessage;
	}
	
	@ManyToOne(targetEntity=Article.class)
	@JoinColumn(name="article_id",nullable=false)
	public Article getArticle() {
		return article;
	}
	
	@ManyToOne(targetEntity=Article.class)
	@JoinColumn(name="article_id",nullable=false)
	public void setArticle(Article article) {
		this.article = article;
	}
	
	@ManyToOne(targetEntity=User.class)
	@JoinColumn(name="user_id",nullable=false)
	public User getUser() {
		return user;
	}
	
	@ManyToOne(targetEntity=User.class)
	@JoinColumn(name="user_id",nullable=false)
	public void setUser(User user) {
		this.user = user;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
}
