package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
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.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 = "IpsrsPemeliharaan_T")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class IpsrsPemeliharaan extends BaseTransaction {

	@ManyToOne(fetch = LAZY)
	@Caption(value = "Ipsrs Maintenance")
	@JoinColumn(name = "ObjectIpsrsMaintenanceFk")
	private IpsrsMaintenance ipsrsMaintenance;

	@Column(name = "ObjectIpsrsMaintenanceFk", columnDefinition = "CHAR(32)", insertable = false, updatable = false)
	private String ipsrsMaintenanceId;

	@Caption(value = "Jadwal Pemeliharaan")
	@Column(name = "JadwalPemeliharaan")
	private Date jadwalPemeliharaan;

	@Caption(value = "Alert Pemeliharaan")
	@Column(name = "AlertPemeliharaan")
	private Date alertPemeliharaan;

	@Caption(value = "Status Pemeliharaan")
	@Column(name = "StatusPemeliharaan")
	private String statusPemeliharaan;

	@JsonBackReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "ipsrsPemeliharaan")
	private Set<IpsrsTeknisiPemeliharaan> ipsrsTeknisiPemeliharaan = new HashSet<>();

}
