package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.CascadeType.ALL;
import static javax.persistence.FetchType.LAZY;

@Getter
@Setter
@Entity
@Table(name = "HeadAnggaran_T")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class HeadAnggaran extends BaseTransaction {

	@Caption(value = "Kode Head Anggaran")
	@Column(name = "KdHeadAnggaran", length = 50)
	private String kdHeadAnggaran;

	@Caption(value = "Tahun")
	@Column(name = "Tahun")
	private Integer tahun;

	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "headAnggaran")
	@Caption(value = "Kegiatan Anggaran")
	private Set<KegiatanAnggaran> kegiatanAnggaran = new HashSet<>();

	@ManyToOne
	@JoinColumn(name = "ObjectKemenLembFk")
	@Caption(value = "Kemen/Lemb")
	private KemenLemb kemenLemb;

	@Column(name = "ObjectKemenLembFk", insertable = false, updatable = false, nullable = false)
	private Integer kemenLembId;

	@ManyToOne
	@JoinColumn(name = "ObjectUnitOrganisasiFk")
	@Caption(value = "Unit Organisasi")
	private UnitOrg unitOrganisasi;

	@Column(name = "ObjectUnitOrganisasiFk", insertable = false, updatable = false, nullable = false)
	private Integer unitOrganisasiId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectRuanganFk")
	@Caption(value = "Object Ruangan")
	private Ruangan ruangan;

	@Column(name = "ObjectRuanganFk", insertable = false, updatable = false, nullable = false)
	private Integer ruanganId;

	@ManyToOne
	@JoinColumn(name = "ObjectProgramFk")
	@Caption(value = "Program")
	private Program program;

	@Column(name = "ObjectProgramFk", insertable = false, updatable = false, nullable = false)
	private Integer programId;

	@ManyToOne
	@JoinColumn(name = "ObjectUnitKerjaFk")
	@Caption(value = "Object Unit Kerja")
	private UnitKerja unitKerja;

	@Column(name = "ObjectUnitKerjaFk", insertable = false, updatable = false)
	private Integer unitKerjaId;

}
