package com.jasamedika.medifirst2000.entities;

import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.NotBlank;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

import static javax.persistence.FetchType.LAZY;

/**
 * @author salmanoe
 * @version 1.0.0
 * @since 07/03/2024
 */
@Getter
@Setter
@Entity
@Table(name = "component_object_m", schema = "mkko")
public class ComponentObject extends BaseTransaction implements Serializable {

	@Column(name = "param_key", length = 20, nullable = false)
	@NotBlank(message = "Parameter key tidak boleh kosong")
	@Size(max = 20, message = "Param key maksimal {max} karakter")
	@Caption("Parameter Key")
	private String paramKey;

	@Column(name = "param_logic", length = 50, nullable = false)
	@NotBlank(message = "Parameter logic tidak boleh kosong")
	@Size(max = 50, message = "Parameter logic maksimal {max} karakter")
	@Caption("Parameter Logic")
	private String paramLogic;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "capital_component_fk", nullable = false)
	@NotNull(message = "Capital component tidak boleh kosong")
	@Caption(value = "Capital Component")
	private CapitalComponent capitalComponent;

	@Column(name = "object_name", length = 150, nullable = false)
	@NotBlank(message = "Object name tidak boleh kosong")
	@Size(max = 150, message = "Object name maksimal {max} karakter")
	@Caption("Object Name")
	private String objectName;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "capital_component_head_fk", nullable = false)
	@NotNull(message = "Capital component head tidak boleh kosong")
	@Caption(value = "Capital Component Head")
	private ComponentObject componentObjectHead;

}
