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 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 = "DetailRup_T")
public class DetailRup extends BaseTransaction {

	@Column(name = "PelaksanaanPemilihanAwal")
	@Caption(value="Pelaksanaan Pemilihan Awal")
	private Date pelaksanaanPemilihanAwal;
	
	@Column(name = "PelaksanaanPemilihanAhir")
	@Caption(value="Pelaksanaan Pemilihan Ahir")
	private Date pelaksanaanPemilihanAhir;
	
	@Column(name = "PelaksanaanPekerjaanAwal")
	@Caption(value = "Pelaksanaan Pekerjaan Awal")
	private Date pelaksanaanPekerjaanAwal;
	
	@Column(name = "PelaksanaanPekerjaanAhir")
	@Caption(value="Pelaksanaan Pekerjaan Ahir")
	private Date pelaksanaanPekerjaanAhir;

	@Column(name = "keterangan")
	@Caption(value="Keterangan")
	private String keterangan;
	
	@ManyToOne
	@JoinColumn(name = "ObjectDetailSpekAnggaran")
	@Caption(value="Object Detail Spek Agggaran")
	private DetailSpekAnggaran detailSpekAnggaran;

	@Column(name = "ObjectDetailSpekAnggaran", insertable=false,updatable=false)
	private String detailSpekAnggaranId;
	
	@ManyToOne
	@JoinColumn(name = "ObjectHeadRup")
	@Caption(value="Object Head ")
	private HeadRup headRup;

	@Column(name = "ObjectHeadRup", insertable=false,updatable=false)
	private String headRupId;
	
	@JsonManagedReference
	@OneToMany(cascade=ALL,fetch = LAZY, mappedBy = "detailRup")
	private Set<DetailPengadaan> detailPengadaan= new HashSet<>();

}
