package com.peetz.library.entity;

import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@NamedQueries({
    @NamedQuery(name="Article.findAll", query="SELECT a from ArticleEntity as a")
})

@Entity
@Table(name="ARTICLE")
public class ArticleEntity {
	private Long id;
	
	private String title;
	
	private Collection<ArticleEntity> relatedArticles = new ArrayList<ArticleEntity>();
	
	private Collection<ArticleEntity> originArticles = new ArrayList<ArticleEntity>();
	
	private FileEntity file;
	
	private MagazineEntity magazine;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Long getId() { return id; }
	
	@SuppressWarnings("unused")
	private void setId(Long id) { this.id = id; }

	@Column
	public String getTitle() {
		return title;
	}

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

	@ManyToMany
	public Collection<ArticleEntity> getRelatedArticles() {
		return relatedArticles;
	}

	public void setRelatedArticles(Collection<ArticleEntity> relatedArticles) {
		this.relatedArticles = relatedArticles;
	}

	@ManyToMany
	public Collection<ArticleEntity> getOriginArticles() {
		return originArticles;
	}

	public void setOriginArticles(Collection<ArticleEntity> originArticles) {
		this.originArticles = originArticles;
	}

	@ManyToOne
	public FileEntity getFile() {
		return file;
	}

	public void setFile(FileEntity file) {
		this.file = file;
	}

	@ManyToOne
	public MagazineEntity getMagazine() {
		return magazine;
	}

	public void setMagazine(MagazineEntity magazine) {
		this.magazine = magazine;
	}
}
