package com.athena.meerkat.controller.web.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonBackReference;

@Entity
@Table(name = "mon_alert_config")
public class MonAlertConfig {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	private int id;

	@Column(name = "tomcat_domain_id", insertable = false, updatable = false)
	private int domainId;
	
	@Column(name = "server_id", insertable = false, updatable = false)
	private int serverId;

	@Column(name = "alert_item_cd_id")
	private int alertItemCdId;

	@Column(name = "threshold_op_cd_id")
	private int thresholdOpCdId;

	@Column(name = "threshold_value")
	private Integer thresholdValue;

	@Column(name = "status")
	private boolean status;
	
	
	@Column(name = "mon_factor_id")
	private String monFactorId;

	@Transient
	private String alertItemCdNm;
	@Transient
	private String thresholdOpCdNm;

	@ManyToOne(fetch = FetchType.LAZY)
	private TomcatDomain tomcatDomain;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private Server server;

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public Integer getThresholdValue() {
		return thresholdValue;
	}

	public void setThresholdValue(Integer thresholdValue) {
		this.thresholdValue = thresholdValue;
	}

	public int getThresholdOpCdId() {
		return thresholdOpCdId;
	}

	public void setThresholdOpCdId(int thresholdOpCdId) {
		this.thresholdOpCdId = thresholdOpCdId;
	}

	public int getAlertItemCdId() {
		return alertItemCdId;
	}

	public void setAlertItemCdId(int alertItemCdId) {
		this.alertItemCdId = alertItemCdId;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getDomainId() {
		return domainId;
	}

	public void setDomainId(int domainId) {
		this.domainId = domainId;
		if (this.tomcatDomain == null) {
			this.tomcatDomain = new TomcatDomain();
		}
		this.tomcatDomain.setId(domainId);
	}

	public String getAlertItemCdNm() {
		return alertItemCdNm;
	}

	public void setAlertItemCdNm(String alertItemCdNm) {
		this.alertItemCdNm = alertItemCdNm;
	}

	public String getThresholdOpCdNm() {
		return thresholdOpCdNm;
	}

	public void setThresholdOpCdNm(String thresholdOpCdNm) {
		this.thresholdOpCdNm = thresholdOpCdNm;
	}

	public String getMonFactorId() {
		return monFactorId;
	}

	public void setMonFactorId(String monFactorId) {
		this.monFactorId = monFactorId;
	}

	public int getServerId() {
		return serverId;
	}

	public void setServerId(int serverId) {
		this.serverId = serverId;
		
		if (this.server == null) {
			this.server = new Server();
		}
		this.server.setId(serverId);
	}

	public TomcatDomain getTomcatDomain() {
		return tomcatDomain;
	}

	public void setTomcatDomain(TomcatDomain tomcatDomain) {
		this.tomcatDomain = tomcatDomain;
	}

	public Server getServer() {
		return server;
	}

	public void setServer(Server server) {
		this.server = server;
	}

}

@@ -654,206 +654,8 @@
 %0D%0A%0D%0A
-%09@Column(name = %22tomcat_domain_id%22, insertable = false, updatable = false)%0D%0A%09private int domainId;%0D%0A%09%0D%0A%09@Column(name = %22server_id%22, insertable = false, updatable = false)%0D%0A%09private int serverId;%0D%0A%0D%0A
 %09@Co
@@ -679,32 +679,32 @@
 t_item_cd_id%22)%0D%0A
+
 %09private int ale
@@ -766,19 +766,23 @@
 private 
-i
+I
 nt
+eger
  thresho
@@ -923,14 +923,10 @@
 s;%0D%0A
-%09%0D%0A%09
 %0D%0A
+
 %09@Co
@@ -1155,19 +1155,18 @@
 omain;%0D%0A
-%09
 %0D%0A
+
 %09@ManyTo
@@ -1625,19 +1625,23 @@
 dOpCdId(
-i
+I
 nt
+eger
  thresho
@@ -1706,27 +1706,31 @@
 %0D%0A%0D%0A%09public 
-i
+I
 nt
+eger
  getAlertIte
@@ -2006,188 +2006,35 @@
 urn 
-domainId;%0D%0A%09%7D%0D%0A%0D%0A%09public void setDomainId(int domainId) %7B%0D%0A%09%09this.domainId = domainId;%0D%0A%09%09if (this.tomcatDomain == null) %7B%0D%0A%09%09%09this.tomcatDomain = new TomcatDomain();%0D%0A%09%09%7D%0D%0A%09%09this.
+tomcatDomain == null ? 0 : 
 tomc
@@ -2046,22 +2046,14 @@
 ain.
-s
+g
 etId(
-domainId
 );%0D%0A
@@ -2610,189 +2610,36 @@
 rver
-Id;%0D%0A%09%7D%0D%0A%0D%0A%09public void setServerId(int serverId) %7B%0D%0A%09%09this.serverId = serverId;%0D%0A%09%09%0D%0A%09%09if (this.server == null) %7B%0D%0A%09%09%09this.server = new Server();%0D%0A%09%09%7D%0D%0A%09%09this.
+ == null ? 0 : 
 server.
-s
+g
 etId(
-serverId
 );%0D%0A

update int --> Integer