package com.jasamedika.medifirst2000.entities;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.jasamedika.medifirst2000.base.BaseMaster;
import com.jasamedika.medifirst2000.helper.Caption;

//
/**
 * 
 * @author Syamsu
 */

//@Entity
//@Table(name = "ObjekModulAplikasi_S_Sample")
//@JsonSerialize
//@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class ObjekModulAplikasiS extends BaseMaster {

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "public.objekmodulaplikasi_m_id_seq")
	@javax.persistence.SequenceGenerator(name = "public.objekmodulaplikasi_m_id_seq", sequenceName = "public.objekmodulaplikasi_m_id_seq", allocationSize = 1)
	@Column(name = "id")
	protected Integer id;

	public Integer getId() {

		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@NotNull(message = "Kd Objek  Modul Aplikasi tidak boleh kosong")
	@Column(name = "KdObjekModulAplikasi", nullable = false, length = 6)
	@Caption(value = "Kode Modul Aplikasi")
	private String kdObjekModulAplikasi;

	public String getKdObjekModulAplikasi() {
		return kdObjekModulAplikasi;
	}

	public void setKdObjekModulAplikasi(String kdObjekModulAplikasi) {
		this.kdObjekModulAplikasi = kdObjekModulAplikasi;
	}

	@Column(name = "KdObjekModulAplikasiHead")
	@Caption(value = "Kode Objek Modul Aplikasi Head")
	private String kdObjekModulAplikasiHead;

	public String getKdObjekModulAplikasiHead() {
		return kdObjekModulAplikasiHead;
	}

	public void setKdObjekModulAplikasiHead(String kdObjekModulAplikasiHead) {
		this.kdObjekModulAplikasiHead = kdObjekModulAplikasiHead;
	}

	@NotNull(message = "Objek Modul Aplikasi tidak boleh kosong")
	@Column(name = "ObjekModulAplikasi", nullable = false, length = 50)
	@Caption(value = "Objek Modul Aplikasi")
	private String objekModulAplikasi;

	public String getObjekModulAplikasi() {
		return objekModulAplikasi;
	}

	public void setObjekModulAplikasi(String objekModulAplikasi) {
		this.objekModulAplikasi = objekModulAplikasi;
	}

	@Column(name = "KdModulAplikasi", nullable = false, length = 2)
	@Caption(value = "Kode Modul Aplikasi")
	private String kdModulAplikasi;

	public String getKdModulAplikasi() {
		return kdModulAplikasi;
	}

	public void setKdModulAplikasi(String kdModulAplikasi) {
		this.kdModulAplikasi = kdModulAplikasi;
	}

	@NotNull(message = "Fungsi tidak boleh kosong")
	@Column(name = "Fungsi", nullable = false, length = 500)
	@Caption(value = "Fungsi")
	private String fungsi;

	public void setFungsi(String fungsi) {
		this.fungsi = fungsi;
	}

	public String getFungsi() {
		return this.fungsi;
	}

	@NotNull(message = "Keterangan tidak boleh kosong")
	@Column(name = "Keterangan", nullable = false, length = 500)
	@Caption(value = "Keterangan")
	private String keterangan;

	public void setKeterangan(String keterangan) {
		this.keterangan = keterangan;
	}

	public String getKeterangan() {
		return this.keterangan;
	}

	@Column(name = "AlamatUrlFormObjekModulAplikasi")
	private String alamatUrlFormObjekModulAplikasi;

	public String getAlamatUrlFormObjekModulAplikasi() {
		return alamatUrlFormObjekModulAplikasi;
	}

	public void setAlamatUrlFormObjekModulAplikasi(String alamatUrlFormObjekModulAplikasi) {
		this.alamatUrlFormObjekModulAplikasi = alamatUrlFormObjekModulAplikasi;
	}

	@Column(name = "ObjekModulNoUrut")
	private int objekModulNoUrut;

	public int getObjekModulNoUrut() {
		return objekModulNoUrut;
	}

	public void setObjekModulNoUrut(int objekModulNoUrut) {
		this.objekModulNoUrut = objekModulNoUrut;
	}

	/////////////////////
	/// Foreign Keys
	//////////////////

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "kdModulAplikasi", referencedColumnName = "kdModulAplikasi", insertable = false, updatable = false)
	@JsonIgnore
	private ModulAplikasiS modulAplikasiS;

	public ModulAplikasiS getModulAplikasiS() {
		return modulAplikasiS;
	}

	public void setModulAplikasiS(ModulAplikasiS modulAplikasiS) {
		this.modulAplikasiS = modulAplikasiS;
	}

	/////////////////////
	// Link Back Keys
	////////////////////


	@NotFound(action = NotFoundAction.IGNORE)
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true, targetEntity = ObjekModulAplikasiS.class)	
	@JoinColumn(name="kdObjekModulAplikasiHead", referencedColumnName="kdObjekModulAplikasi")	
	private Set<ObjekModulAplikasiS> children = new HashSet<>();

	public Set<ObjekModulAplikasiS> getChildren() {
		return children;
	}

	public void setChildren(Set<ObjekModulAplikasiS> children) {
		this.children = children;
	}

}
