package com.jasamedika.medifirst2000.entities;

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

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.FetchType.LAZY;

@Getter
@Setter
@Entity
@Table(name = "Disposisi_T")
public class Disposisi extends BaseTransaction {

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectDokumenFk")
	@NotNull(message = "Object Dokumen Harus Diisi")
	@Caption(value = "Object Dokumen")
	private Dokumen dokumen;

	@Column(name = "ObjectDokumenFk", insertable = false, updatable = false)
	private Integer ObjectDokumenId;

	@Column(name = "NoSurat")
	@Caption(value = "noSurat")
	private String noSurat;

	@Column(name = "hal")
	@Caption(value = "hal")
	private String hal;

	@ManyToOne
	@JoinColumn(name = "ObjectJabatanDisampaikanFk")
	@Caption(value = "Disampaikan")
	private Jabatan jabatanDisampaikan;

	@Column(name = "ObjectJabatanDisampaikanFk", insertable = false, updatable = false)
	private Integer jabatanDisampaikanId;

	@ManyToOne
	@JoinColumn(name = "ObjectPegawaiDisampaikanFk")
	@Caption(value = "Disampaikan")
	private Pegawai pegawaiDisampaikan;

	@Column(name = "ObjectJabatanDisampaikanFk", insertable = false, updatable = false)
	private Integer pegawaiDisampaikanId;

	@ManyToOne
	@JoinColumn(name = "ObjectJabatanAsalSuratFk")
	@Caption(value = "Asal Surat")
	private Jabatan jabatanAsalSurat;

	@Column(name = "ObjectJabatanDisampaikanFk", insertable = false, updatable = false)
	private Integer jabatanAsalSuratId;

	@ManyToOne
	@JoinColumn(name = "ObjectPegawaiAsalSuratFk")
	@Caption(value = "Pegawai Disampaikan")
	private Pegawai pegawaiAsalSurat;

	@Column(name = "ObjectPegawaiAsalSuratFk", insertable = false, updatable = false)
	private Integer pegawaiAsalSuratId;

	@ManyToOne
	@JoinColumn(name = "ObjectSifatSuratFk")
	@Caption(value = "Pegawai Disampaikan")
	private SifatSurat sifatSurat;

	@Column(name = "ObjectSifatSuratFk", insertable = false, updatable = false)
	private Integer sifatSuratId;

	@Column(name = "IsiSurat")
	@Caption(value = "isiSurat")
	private String isiSurat;

	@JsonManagedReference
	@OneToMany(cascade = CascadeType.ALL, fetch = LAZY, mappedBy = "disposisi")
	private Set<DisposisiJabatan> disposisiJabatan = new HashSet<>();

	@JsonManagedReference
	@OneToMany(cascade = CascadeType.ALL, fetch = LAZY, mappedBy = "disposisi")
	private Set<DisposisiTanggapan> disposisiTanggapan = new HashSet<>();

	@Column(name = "tanggal")
	@Caption(value = "Tanggal")
	private Date tanggal;

}
