package kr.co.kihyun.beans.entity; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.Inheritance; import javax.jdo.annotations.InheritanceStrategy; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import kr.co.kihyun.lang.MString; @PersistenceCapable(identityType = IdentityType.APPLICATION) @Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE) public abstract class AbstractPublicDocument extends LongEntity { /** * */ private static final long serialVersionUID = -3268905356285972843L; @Persistent private String managementCode; @Persistent private String ownerName; private transient boolean isDecrypted; private transient String decName; @Persistent private String ownerPhone; @Persistent private String ownerEmail; public AbstractPublicDocument() { super(); } public final String getManagementCode() { return managementCode; } public final void setManagementCode(String managementCode) { this.managementCode = managementCode; } public String getOwnerName() { return this.getEncName(); } /** * @return the ownerName */ public String getOwnerName(PersistenceManager pm) { if (!this.isDecrypted) { Query q = pm.newQuery("javax.jdo.query.SQL", "SELECT ? FROM dual"); q.setUnique(true); this.setDecName((String) q.execute(this.getEncName())); this.isDecrypted = true; } return this.getDecName(); } private void setDecName(String decName) { this.decName = decName; } private String getDecName() { return this.decName; } private String getEncName() { return this.ownerName; } /** * @param ownerName the ownerName to set */ public void setOwnerName(String ownerName) { this.ownerName = ownerName; } /** * @return the ownerPhone */ public String getOwnerPhone() { return MString.checkNull(ownerPhone); } /** * @param ownerPhone the ownerPhone to set */ public void setOwnerPhone(String ownerPhone) { this.ownerPhone = ownerPhone; } /** * @return the ownerEmail */ public String getOwnerEmail() { return MString.checkNull(ownerEmail); } /** * @param ownerEmail the ownerEmail to set */ public void setOwnerEmail(String ownerEmail) { this.ownerEmail = ownerEmail; } }