/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package kr.co.kihyun.beans.entity.ecross; import java.util.Date; import javax.jdo.JDOObjectNotFoundException; import javax.jdo.PersistenceManager; 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.Board; import kr.co.kihyun.beans.entity.Category; import kr.co.kihyun.beans.entity.MUser; import kr.co.kihyun.beans.entity.TotDoc; import kr.co.kihyun.beans.entity.util.MPersistenceManager; import kr.co.kihyun.lang.MString; /** * * @author bhs */ @PersistenceCapable(identityType = IdentityType.APPLICATION) @Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE) public abstract class ECrossBoard extends ECross { @Persistent private String mUser; @Persistent private String password; @Persistent(nullValue = NullValue.EXCEPTION) private String title; @Persistent private String contents; @Persistent(customValueStrategy = "timestamp", nullValue = NullValue.EXCEPTION) private Date writeDate; @Persistent(nullValue = NullValue.EXCEPTION) private int visit = 0; @Persistent(nullValue = NullValue.EXCEPTION) private int step = 0; @Persistent(nullValue = NullValue.EXCEPTION) private int repLevel = 0; @Persistent(nullValue = NullValue.EXCEPTION) private String category; @Persistent private Long totDoc; // COLUMN: doc_id @Persistent private Long upperBoard; @Persistent private Long id; /** * @param id * the id to set */ public void setId(Long id) { this.id = id; } /** * @return the id */ public Long getId() { return id; } public ECrossBoard(Board board) { super(board); this.setCategory(board.getCategory()); this.setContents(board.getContents()); this.setId(board.getId()); this.setPassword(board.getPassword()); this.setRepLevel(board.getRepLevel()); this.setStep(board.getStep()); this.setTitle(board.getTitle()); this.setTotDoc(board.getTotDoc()); this.setUpperBoard(board.getUpperBoard()); this.setUser(null); this.setVisit(board.getVisit()); this.setWriteDate(board.getWriteDate()); } @Override protected Board setFieldValues(MPersistenceManager pm, Board board) { board.setCategory(category == null ? null : pm.getObjectById(Category.class, category)); board.setContents(contents); board.setPassword(password); board.setRepLevel(repLevel); board.setStep(step); board.setTitle(title); board.setTotDoc(totDoc == null ? null : pm.getObjectById(TotDoc.class, totDoc)); board.setUpperBoard(upperBoard == null ? null : pm.getObjectById(Board.class, upperBoard)); board.setUser(null); board.setVisit(visit); board.setWriteDate(writeDate); return board; } public MUser getUser(PersistenceManager pm) { try { return pm.getObjectById(MUser.class, mUser); } catch (JDOObjectNotFoundException jonfe) { return null; } } public void setUser(MUser mUser) { if (mUser == null) this.mUser = null; else this.mUser = mUser.getId(); } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } public String getTitle() { return this.title; } public final void setTitle(String title) { if (MString.isNull(title)) title = " "; this.title = title; } public String getContents() { return this.contents; } public void setContents(String contents) { this.contents = contents; } public Date getWriteDate() { return this.writeDate; } public void setWriteDate(Date writeDate) { this.writeDate = writeDate; } public int getVisit() { return this.visit; } public void setVisit(int visit) { this.visit = visit; } public int getStep() { return this.step; } public void setStep(int step) { this.step = step; } public int getRepLevel() { return this.repLevel; } public void setRepLevel(int level) { this.repLevel = level; } public void setCategory(Category groupId) { this.category = groupId == null ? null : groupId.getId(); } public void setTotDoc(TotDoc doc) { this.totDoc = doc.getId(); } public void setUpperBoard(Board upperBoard) { this.upperBoard = upperBoard == null ? null : upperBoard.getId(); } }