package kr.go.neis;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ApproveDetail implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5314568451003294315L;
	private static final Logger LOG = LoggerFactory.getLogger(ApproveDetail.class);

	@PrimaryKey
	private ApproveDetail approveMaster;

	@Persistent
	private String iemNm = "reportID";

	@Persistent
	private String iemEngNm = "reportID";

	@Persistent
	private String keyNm = "reportID";

	@Persistent
	private int keySeq = 1;

	@Persistent
	private int keyLen = 20;

	@Persistent
	private boolean priorBltnYn = true;

	@Persistent
	private boolean markYn = true;

	@Persistent
	private String updid = "SYSTEM";

	@Persistent
	private String mdfcYmd;

	public void setApproveMaster(ApproveDetail approveMaster) {
		this.approveMaster = approveMaster;
	}

	public ApproveDetail getApproveMaster() {
		return approveMaster;
	}

	public final String getIemNm() {
		return iemNm;
	}

	public final void setIemNm(String iemNm) {
		this.iemNm = iemNm;
	}

	public final String getIemEngNm() {
		return iemEngNm;
	}

	public final void setIemEngNm(String iemEngNm) {
		this.iemEngNm = iemEngNm;
	}

	public final String getKeyNm() {
		return keyNm;
	}

	public final void setKeyNm(String keyNm) {
		this.keyNm = keyNm;
	}

	public final int getKeySeq() {
		return keySeq;
	}

	public final void setKeySeq(int keySeq) {
		this.keySeq = keySeq;
	}

	public final int getKeyLen() {
		return keyLen;
	}

	public final void setKeyLen(int keyLen) {
		this.keyLen = keyLen;
	}

	public final boolean isPriorBltnYn() {
		return priorBltnYn;
	}

	public final void setPriorBltnYn(boolean priorBltnYn) {
		this.priorBltnYn = priorBltnYn;
	}

	public final boolean isMarkYn() {
		return markYn;
	}

	public final void setMarkYn(boolean markYn) {
		this.markYn = markYn;
	}

	public final void setMdfcYmd(String mdfcYmd) {
		this.mdfcYmd = mdfcYmd;
	}

	public final String getUpdid() {
		return updid;
	}

	public final void setUpdid(String updid) {
		this.updid = updid;
	}

	public final Date getMdfcYmd() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		try {
			return sdf.parse(this.mdfcYmd);
		} catch (ParseException e) {
			LOG.error("{} has invalid date format : {}", this, this.mdfcYmd);
			return null;
		}
	}

	public final void setMdfcYmd(Date mdfcYmd) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		this.mdfcYmd = sdf.format(mdfcYmd);
	}

	public static class PK implements Serializable {

		/**
		 * 
		 */
		private static final long serialVersionUID = -8406765554932443039L;

		public ApproveMaster.PK approveMaster;

		public PK() {
		}

		public boolean equals(Object obj) {
			if (obj != null && (obj instanceof PK)) {
				PK c = (PK) obj;
				return this.approveMaster.equals(c.approveMaster);
			}
			return false;
		}

		public int hashCode() {
			return this.approveMaster.hashCode();
		}

		public String toString() {
			return this.approveMaster.toString();
		}
	}

}
