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.CascadeType.ALL;
import static javax.persistence.FetchType.LAZY;

@Getter
@Setter
@Entity
@Table(name = "DraftSurat_T")
public class DraftSurat extends BaseTransaction {

	@ManyToOne
	@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 = "Judul")
	@Caption(value = "judul")
	private String judul;

	@Column(name = "verbalKonsep")
	@Caption(value = "verbal Konsep")
	private String verbalKonsep;

	@Column(name = "lembarCatatan")
	@Caption(value = "Lembar Catatan")
	private String lembarCatatan;

	@ManyToOne
	@JoinColumn(name = "ObjectJenisSuratFk")
	@Caption(value = "JenisSurat")
	private JenisSurat jenisSurat;

	@Column(name = "ObjectJenisSuratFk", insertable = false, updatable = false)
	private Integer jenisSuratId;

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

	@JsonManagedReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "draftSurat")
	private Set<DraftSuratRuangan> draftSuratRuangan = new HashSet<>();

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

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

}
