package kr.co.kihyun.beans.entity;

import javax.jdo.PersistenceManager;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.NullValue;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class UserDept extends MoumiEntity<Long> implements HandySync {
	/**
	 * 
	 */
	private static final long serialVersionUID = 954601303189534253L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.NATIVE)
	private Long userDeptId;

	@Persistent
	private String handyId;

	@Persistent(nullValue = NullValue.EXCEPTION)
	private String id;

	@Persistent(nullValue = NullValue.EXCEPTION)
	private String name;

	@Persistent
	private UserPart userPart; // COLUMN: part_id

	public UserDept() {
	}

	public Long getId() {
		return this.userDeptId;
	}

	public void setId(Long userDeptId) {
		this.userDeptId = userDeptId;
	}

	public void setHandyId(String handyId) {
		this.handyId = handyId;
	}

	public String getHandyId() {
		return handyId;
	}

	public MDept getDept(PersistenceManager pm) {
		return pm.getObjectById(MDept.class, id);
	}

	public void setDept(MDept id) {
		this.id = id.getId();
	}

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

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

	public UserPart getUserPart() {
		return this.userPart;
	}

	public void setUserPart(UserPart part) {
		this.userPart = part;
	}

	public UserDept(MDept dept, String name, UserPart userPart) {
		this.setDept(dept);
		this.setName(name);
		this.setUserPart(userPart);
	}
}
