package info.bukova.isspst.data;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;

@MappedSuperclass
@Indexed
public abstract class BaseData implements OwnedDataModel {
	
	@Id
	@Column(name="ID")
    @GeneratedValue
	private int id;
	@Column(name="CREATED")
	private Date created;
	@Column(name="MODIFIED")
	private Date modified;
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="OWNED_BY_ID")
	@IndexedEmbedded
	private User ownedBy;
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="MODIFIED_BY_ID")
	@IndexedEmbedded
	private User modifiedBy;
	@Transient
	private boolean valid;

	@Override
	public void setId(int id) {
		this.id = id;
	}

	@Override
	public int getId() {
		return this.id;
	}

	@Override
	public void setCreated(Date created) {
		this.created = created;
	}

	@Override
	public Date getCreated() {
		return this.created;
	}

	@Override
	public void setModified(Date modified) {
		this.modified = modified;
	}

	@Override
	public Date getModified() {
		return this.modified;
	}

	@Override
	public boolean isValid() {
		return this.valid;
	}

	@Override
	public void setValid(boolean valid) {
		this.valid = valid;
	}

	@Override
	public void setOwnedBy(User user) {
		this.ownedBy = user;
	}

	@Override
	public User getOwnedBy() {
		return this.ownedBy;
	}

	@Override
	public void setModifiedBy(User user) {
		this.modifiedBy = user;
	}

	@Override
	public User getModifiedBy() {
		return this.modifiedBy;
	}

}
