/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kr.co.kihyun.beans.entity.ecross;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.NullValue;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import kr.co.kihyun.beans.entity.TotDoc;
import kr.co.kihyun.beans.entity.TotTable;
import kr.co.kihyun.beans.entity.TotTable.TotTableType;
import kr.co.kihyun.beans.entity.util.MPersistenceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author bhs
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class ECrossTotTable extends ECross<TotTable> {

	private static final Logger LOG = LoggerFactory.getLogger(ECrossTotTable.class);
	@Persistent(nullValue = NullValue.EXCEPTION)
	private String form;
	@Persistent
	private Long id;
	@Persistent
	private int itemSize = 10;
	@Persistent
	private String name;
	@Persistent
	private String note;
	@Persistent(nullValue = NullValue.EXCEPTION)
	private int num = 1;
	@Persistent(nullValue = NullValue.EXCEPTION)
	private Long totDoc;
	@Persistent(nullValue = NullValue.EXCEPTION)
	private TotTableType type = TotTableType.DYNA;
	@Persistent
	private String types;

	public ECrossTotTable(TotTable table) {
		super(table);
		this.setForm(table.getForm());
		this.setId(table.getId());
		this.setItemSize(table.getItemSize());
		this.setName(table.getName());
		this.setNote(table.getNote());
		this.setNum(table.getNum());
		this.setTotDoc(table.getTotDoc());
		this.setType(table.getType());
		this.setTypes(table.getTypes());
	}

	@Override
	protected TotTable setFieldValues(MPersistenceManager pm, TotTable totTable) {
		totTable.setId(id);
		totTable.setForm(form);
		totTable.setItemSize(itemSize);
		totTable.setName(name);
		totTable.setNote(note);
		totTable.setNum(num);
		totTable.setTotDoc(totDoc == null ? null : pm.getObjectById(TotDoc.class, totDoc));
		totTable.setType(type);
		totTable.setTypes(types);

		return totTable;
	}

	public String getForm() {
		return this.form;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	public int getItemSize() {
		return this.itemSize;
	}

	public String getName() {
		return this.name;
	}

	public String getNote() {
		return this.note;
	}

	public int getNum() {
		return this.num;
	}

	public TotTableType getType() {
		return this.type;
	}

	public String getTypes() {
		return this.types;
	}

	@Deprecated
	public void setForm(String form) {
		this.form = form;
	}

	/**
	 * @param id
	 * the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	public void setItemSize(int size) {
		this.itemSize = size;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public void setTotDoc(TotDoc doc) {
		this.totDoc = doc == null ? null : doc.getId();
	}

	@Deprecated
	public void setType(TotTableType t) {
		this.type = t;
	}

	public void setTypes(String types) {
		this.types = types;
	}
}
