package com.jasamedika.medifirst2000.entities;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.helper.Caption;

@Entity
@Table(name = "IpsrsPerbaikan_T")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class IpsrsPerbaikan extends BaseTransaction{

	@Caption(value = "No Order")
	@Column(name = "NoOrder", nullable = true)
	private String noOrder;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Caption(value = "Tanggal Pesan")
	@NotNull(message="Tanggal Pesan tidak boleh kosong")
	@Column(name = "TanggalPesan", nullable = false)
	private Date tglPesan;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ObjectRegistrasiAsetFk")
	@Caption(value = "Registrasi Aset")
	private RegistrasiAset registrasiAset;
	
	@Column(name = "ObjectRegistrasiAsetFk", columnDefinition = "CHAR(32)", nullable=true, insertable = false, updatable = false)
	private String registrasiAsetId;
	
	@Caption(value = "Keluhan")
	@NotNull(message="Keluhan tidak boleh kosong")
	@Column(name = "Keluhan", nullable = false)
	private String keluhan;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ObjectPelaporFk")
	@Caption(value = "Pelapor")
	private Pegawai pelapor;
	
	@Column(name = "ObjectPelaporFk",nullable=false, insertable = false, updatable = false)
	private Integer pelaporId;
	
	@JsonBackReference
	@OneToOne(cascade=CascadeType.ALL,fetch = FetchType.LAZY, mappedBy = "ipsrsPerbaikan")
	private IpsrsStatusPerbaikan ipsrsStatusPerbaikan;
	
	@JsonBackReference
	@OneToOne(cascade=CascadeType.ALL,fetch = FetchType.LAZY, mappedBy = "ipsrsPerbaikan")
	private IpsrsPelaksanaanPerbaikan ipsrsPelaksanaanPerbaikan;

	public String getNoOrder() {
		return noOrder;
	}

	public void setNoOrder(String noOrder) {
		this.noOrder = noOrder;
	}

	public Date getTglPesan() {
		return tglPesan;
	}

	public void setTglPesan(Date tglPesan) {
		this.tglPesan = tglPesan;
	}

	public RegistrasiAset getRegistrasiAset() {
		return registrasiAset;
	}

	public void setRegistrasiAset(RegistrasiAset registrasiAset) {
		this.registrasiAset = registrasiAset;
	}

	public String getRegistrasiAsetId() {
		return registrasiAsetId;
	}

	public void setRegistrasiAsetId(String registrasiAsetId) {
		this.registrasiAsetId = registrasiAsetId;
	}

	public String getKeluhan() {
		return keluhan;
	}

	public void setKeluhan(String keluhan) {
		this.keluhan = keluhan;
	}

	public Pegawai getPelapor() {
		return pelapor;
	}

	public void setPelapor(Pegawai pelapor) {
		this.pelapor = pelapor;
	}

	public Integer getPelaporId() {
		return pelaporId;
	}

	public void setPelaporId(Integer pelaporId) {
		this.pelaporId = pelaporId;
	}

	public IpsrsStatusPerbaikan getIpsrsStatusPerbaikan() {
		return ipsrsStatusPerbaikan;
	}

	public void setIpsrsStatusPerbaikan(IpsrsStatusPerbaikan ipsrsStatusPerbaikan) {
		this.ipsrsStatusPerbaikan = ipsrsStatusPerbaikan;
	}

	public IpsrsPelaksanaanPerbaikan getIpsrsPelaksanaanPerbaikan() {
		return ipsrsPelaksanaanPerbaikan;
	}

	public void setIpsrsPelaksanaanPerbaikan(IpsrsPelaksanaanPerbaikan ipsrsPelaksanaanPerbaikan) {
		this.ipsrsPelaksanaanPerbaikan = ipsrsPelaksanaanPerbaikan;
	}
	
}
