package com.eactive.eai.rms.ext.meta.epb;

import java.text.ParseException;
import java.util.Date;

import com.eactive.eai.common.util.DatetimeUtil;

public class EpbMetaVo {
	
	public static final String DOM_ID_APP		= "D0000004161"; // 어플리케이션 코드
	public static final String DOM_ID_EXT	 	= "D0000005289"; // 대외구분코드
	public static final String DOM_ID_SYS 		= "D0000004079"; // 시스템코드
	public static final String DOM_ID_INST 		= "D0000005288"; // 대외연계기관코드
	public static final String DOM_ID_EXTBAP 	= "D0000006211"; // 대외일괄업무코드
	
	public static final String INPUTDSTCD_APP = "APP";
	public static final String INPUTDSTCD_EXT = "EXT";
	public static final String INPUTDSTCD_SYS = "SYS";
	public static final String INPUTDSTCD_INST = "ADPTR_DESC";
	
	public static final String PREFIX_APP = "";
	public static final String PREFIX_EXT = "E";
	public static final String PREFIX_SYS = "I";

	private String eaiBzwkDstcd; // TSEAICM01 APP:XXX, SYS:IXXX, EXT:EXXX
	private String inputDstcd;	// TSEAICM01 "APP", "EXT", "SYS"
	
	private String domId;
    private String codeId;
    private String codeDesc;
    private String codeValidName;
    private String codeValidValue;
    private String domEngName;
    private String domGroupName;
    private String domName;
    private Date lastModDtm;
    private String stdId;
    private String stdName;
    private String upperCodeValidName;
    private String upperCodeValidValue;
    private String useYn;
    
	public String schemaId;
	
	public String getEaiBzwkDstcd() {
		return eaiBzwkDstcd;
	}

	public void setEaiBzwkDstcd(String eaiBzwkDstcd) {
		this.eaiBzwkDstcd = eaiBzwkDstcd;
	}
	
	public String getInputDstcd() {
		return inputDstcd;
	}

	public void setInputDstcd(String inputDstcd) {
		this.inputDstcd = inputDstcd;
	}

	public String getDomId() {
		return domId;
	}

	public void setDomId(String domId) {
		this.domId = domId;
	}

	public String getCodeId() {
		return codeId;
	}

	public void setCodeId(String codeId) {
		this.codeId = codeId;
	}

	public String getCodeDesc() {
		return codeDesc;
	}

	public void setCodeDesc(String codeDesc) {
		this.codeDesc = codeDesc;
	}

	public String getCodeValidName() {
		return codeValidName;
	}

	public void setCodeValidName(String codeValidName) {
		this.codeValidName = codeValidName;
	}

	public String getCodeValidValue() {
		return codeValidValue;
	}

	public void setCodeValidValue(String codeValidValue) {
		this.codeValidValue = codeValidValue;
	}

	public String getDomEngName() {
		return domEngName;
	}

	public void setDomEngName(String domEngName) {
		this.domEngName = domEngName;
	}

	public String getDomGroupName() {
		return domGroupName;
	}

	public void setDomGroupName(String domGroupName) {
		this.domGroupName = domGroupName;
	}

	public String getDomName() {
		return domName;
	}

	public void setDomName(String domName) {
		this.domName = domName;
	}

	public Date getLastModDtm() {
		return lastModDtm;
	}

	public void setLastModDtm(String lastModDtm) throws ParseException {
		if(lastModDtm != null) {
			this.lastModDtm = new Date(DatetimeUtil.getLongTimeFormat("yyyyMMddHHmmss", lastModDtm));
		} else {
			this.lastModDtm = null;
		}
	}

	public String getStdId() {
		return stdId;
	}

	public void setStdId(String stdId) {
		this.stdId = stdId;
	}

	public String getStdName() {
		return stdName;
	}

	public void setStdName(String stdName) {
		this.stdName = stdName;
	}

	public String getUpperCodeValidName() {
		return upperCodeValidName;
	}

	public void setUpperCodeValidName(String upperCodeValidName) {
		this.upperCodeValidName = upperCodeValidName;
	}

	public String getUpperCodeValidValue() {
		return upperCodeValidValue;
	}

	public void setUpperCodeValidValue(String upperCodeValidValue) {
		this.upperCodeValidValue = upperCodeValidValue;
	}

	public String getUseYn() {
		return useYn;
	}

	public void setUseYn(String useYn) {
		this.useYn = useYn;
	}

	public String getSchemaId() {
		return schemaId;
	}

	public void setSchemaId(String schemaId) {
		this.schemaId = schemaId;
	}
	
	public boolean compareDateEquals(EpbMetaVo epbMetaVo) {
		if(this.getLastModDtm() != null) {
			return this.getLastModDtm().getTime() == epbMetaVo.getLastModDtm().getTime();
		} else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((codeDesc == null) ? 0 : codeDesc.hashCode());
		result = prime * result + ((codeValidValue == null) ? 0 : codeValidValue.hashCode());
		result = prime * result + ((codeValidName == null) ? 0 : codeValidName.hashCode());
		result = prime * result + ((lastModDtm == null) ? 0 : lastModDtm.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EpbMetaVo other = (EpbMetaVo) obj;
		if (codeDesc == null) {
			if (other.codeDesc != null)
				return false;
		} else if (!codeDesc.equals(other.codeDesc))
			return false;
		if (codeValidValue == null) {
			if (other.codeValidValue != null)
				return false;
		} else if (!codeValidValue.equals(other.codeValidValue))
			return false;
		if (codeValidName == null) {
			if (other.codeValidName != null)
				return false;
		} else if (!codeValidName.equals(other.codeValidName))
			return false;
		if (lastModDtm == null) {
			if (other.lastModDtm != null)
				return false;
		} else if (!this.compareDateEquals((EpbMetaVo) obj))
			return false;
		return true;
	}

	public boolean equalsNoDesc(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EpbMetaVo other = (EpbMetaVo) obj;
		if (codeValidValue == null) {
			if (other.codeValidValue != null)
				return false;
		} else if (!codeValidValue.equals(other.codeValidValue))
			return false;
		if (codeValidName == null) {
			if (other.codeValidName != null)
				return false;
		} else if (!codeValidName.equals(other.codeValidName))
			return false;
		if (lastModDtm == null) {
			if (other.lastModDtm != null)
				return false;
		} else if (!this.compareDateEquals((EpbMetaVo) obj))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "MetaVo [codeValidValue=" + codeValidValue + ", codeValidName=" + codeValidName + ", codeDesc="
				+ codeDesc + ", lastModDtm=" + lastModDtm + ", useYn=" + useYn + "]";
	}

}
