package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
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 = "LimbahB3Masuk_T")
public class LimbahB3Masuk extends BaseTransaction {

	@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectJenisLimbahB3MasukFk")
	@NotNull(message = "Jenis Limbah tidak boleh kosong")
	@Caption(value = "jenis Limbah")
	private JenisLimbahB3Masuk jenisLimbahB3Masuk;

	@Column(name = "ObjectJenisLimbahB3MasukFk", insertable = false, updatable = false, nullable = false)
	private Integer jenisLimbahB3MasukId;

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

	@Column(name = "BeratSampahMedis")
	@Caption(value = "Berat Sampah Medis")
	private Double beratSampahMedis;

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

	@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectRuanganFk")
	@Caption(value = "Pelayanan")
	private Ruangan ruangan;

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

	@JsonManagedReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "limbahB3Masuk")
	@Caption(value = "mapPegawaiLimbah")
	private Set<MapPegawaiLimbah> mapPegawaiLimbah = new HashSet<>();

	@Column(name = "MaksimalPenyimpanan")
	@Caption(value = "Maksimal Penyimpanan")
	private Integer maksimalPenyimpanan;

	@Column(name = "QtyKeluar")
	@Caption(value = "qty Keluar")
	private Double qtyKeluar;

}