/**
 * 
 */
package org.yacos.core.article;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.yacos.core.users.User;

/**
 * @author christiancorsano
 *
 */
@Entity
@IdClass(PreferencePK.class)
public class Preference implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * Id mandatory in every entity.
	 */
	@Id
	@ManyToOne(targetEntity=User.class)
	@JoinColumn(name="pcmember_id",nullable=false)
	private User pcMember;
	
	@Id
	@ManyToOne(targetEntity=Article.class)
	@JoinColumn(name="article_id",nullable=false)
	private Article article;
	
	private String preference;
		
	/**
	 * @return the pcMember
	 */
	@ManyToOne(targetEntity=User.class)
	@JoinColumn(name="pcmember_id",nullable=false)
	public User getPcMember() {
		return pcMember;
	}
	/**
	 * @param pcMember the pcMember to set
	 */
	@ManyToOne(targetEntity=User.class)
	@JoinColumn(name="pcmember_id",nullable=false)
	public void setPcMember(User pcMember) {
		this.pcMember = pcMember;
	}
	/**
	 * @return the article
	 */
	@ManyToOne(targetEntity=Article.class)
	@JoinColumn(name="article_id",nullable=false)
	public Article getArticle() {
		return article;
	}
	/**
	 * @param article the article to set
	 */
	@ManyToOne(targetEntity=Article.class)
	@JoinColumn(name="article_id",nullable=false)
	public void setArticle(Article article) {
		this.article = article;
	}
	public String getPreference() {
		return preference;
	}
	public void setPreference(String preference) {
		this.preference = preference;
	}
	
	public PreferencePK getId(){
		PreferencePK id = new PreferencePK();
		id.article = this.article;
		id.pcMember = this.pcMember;
		return id;
	}
}


