package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.jasamedika.medifirst2000.base.BaseTransaction;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
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 = "ItJadwalPerawatan_T")
public class ItJadwalPerawatan extends BaseTransaction {

	@Column(name = "tanggal")
	private Date tanggal;

	@Column(name = "TglJadwal")
	private Date tglJadwal;

	@Column(name = "TglPelaksanaan")
	private Date tglPelaksanaan;

	@Column(name = "Keluhan")
	private String keterangan;

	@Column(name = "StatusPengerjaan", length = 50)
	private String statusPengerjaan;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectStrukOrderFk")
	private StrukOrder strukOrder;

	@Column(name = "ObjectStrukOrderFk", insertable = false, updatable = false, nullable = false)
	private String strukOrderId;

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

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

	@JsonBackReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "itJadwalPerawatan")
	private Set<ItJadwalPerawatanTeknisi> itJadwalPerawatanTeknisi = new HashSet<>();

	@JsonBackReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "itJadwalPerawatan")
	private Set<ItJadwalPerawatanItem> itJadwalPerawatanItem = new HashSet<>();

}
