package open.dolphin.infomodel;
// Generated 2010/06/30 10:57:59 by Hibernate Tools 3.2.1.GA

import java.io.UnsupportedEncodingException;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.Date;
import javax.persistence.Transient;
import open.dolphin.log.LogWriter;
import open.dolphin.queries.DolphinQuery;
import org.hibernate.lob.BlobImpl;

/**
 * 公開スタンプツリー  MEMO:マッピング d_published_tree
 * PublishedTreeModel generated by hbm2java
 */
public class PublishedTreeModel extends InfoModel implements IStampTreeModel {

    private long id;//MEMO:Refrection
    private UserModel user;
    private String name;//MEMO:Refrection
    private String publishType;//MEMO:Refrection
    private String category;//MEMO:Refrection
    private String partyName;//MEMO:Refrection
    private String url;//MEMO:Refrection
    private String description;//MEMO:Refrection
    private Date publishedDate;//MEMO:Refrection
    private Blob treeBlob;//MEMO:Refrection
    private byte[] treeBytes;
    private Date lastUpdated;//MEMO:Refrection
    @Transient
    private boolean imported;

    /**
     *
     */
    public PublishedTreeModel() {
    }

    /**
     * 検索 MEMO:何もしない
     * @param query
     * @return false
     */
    @Override
    public boolean search(DolphinQuery query) {
        return false;
    }

    /**
     * idのGetter
     * MEMO:Refrection
     * @return
     */
    @Override
    public long getId() {
        return id;
    }

    /**
     * idのSetter
     * MEMO:Refrection
     * @param id
     */
    @Override
    public void setId(long id) {
        this.id = id;
    }

    /**
     * userのGetter
     * @return
     */
    @Override
    public UserModel getUser() {
        return user;
    }

    /**
     * userのSetter
     * @param user
     */
    public void setUser(UserModel user) {
        this.user = user;
    }

    /**
     * nameのGetter
     * MEMO:Refrection
     * @return
     */
    @Override
    public String getName() {
        return name;
    }

    /**
     * nameのSetter
     * MEMO:Refrection
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * publishTypeのGetter
     * MEMO:Refrection
     * @return
     */
    @Override
    public String getPublishType() {
        return publishType;
    }

    /**
     * publishTypeのSetter
     * MEMO:Refrection
     * @param publishType
     */
    @Override
    public void setPublishType(String publishType) {
        this.publishType = publishType;
    }

    /**
     * categoryのGetter
     * MEMO:Refrection
     * @return
     */
    @Override
    public String getCategory() {
        return category;
    }

    /**
     * categoryのSetter
     * MEMO:Refrection
     * @param category
     */
    @Override
    public void setCategory(String category) {
        this.category = category;
    }

    /**
     * partyNameのGetter
     * MEMO:Refrection
     * @return
     */
    @Override
    public String getPartyName() {
        return partyName;
    }

    /**
     * partyNameのSetter
     * MEMO:Refrection
     * @param partyName
     */
    public void setPartyName(String partyName) {
        this.partyName = partyName;
    }

    /**
     * urlのGetter
     * MEMO:Refrection
     * @return
     */
    @Override
    public String getUrl() {
        return url;
    }

    /**
     * urlのSetter
     * MEMO:Refrection
     * @param url
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * descriptionのGetter
     * MEMO:Refrection
     * @return
     */
    @Override
    public String getDescription() {
        return description;
    }

    /**
     * descriptionのSetter
     * MEMO:Refrection
     * @param description
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * publishedDateのGetter
     * MEMO:Refrection
     * @return
     */
    @Override
    public Date getPublishedDate() {
        return publishedDate;
    }

    /**
     * publishedDateのSetter
     * MEMO:Refrection
     * @param publishedDate
     */
    @Override
    public void setPublishedDate(Date publishedDate) {
        this.publishedDate = publishedDate;
    }

    /**
     * treeBytesのGetter
     * @return
     */
    @Override
    public byte[] getTreeBytes() {
        return treeBytes;
    }

    /**
     * treeBytesのSetter
     * @param treeBytes
     */
    public void setTreeBytes(byte[] treeBytes) {
        this.treeBytes = treeBytes;
        if (treeBytes == null) {
            this.treeBlob = null;
        } else {
            this.treeBlob = new BlobImpl(treeBytes);
        }
    }

    /**
     * treeBlobのGetter
     * MEMO:Refrection
     * @return
     */
    public Blob getTreeBlob() {
        return this.treeBlob;
    }

    /**
     * treeBlobのSetter
     * MEMO:Refrection
     * @param treeBlob
     * @throws SQLException
     */
    public void setTreeBlob(Blob treeBlob) throws SQLException {
        if (treeBlob != null) {
            this.treeBlob = treeBlob;
            this.treeBytes = treeBlob.getBytes(1, (int) treeBlob.length());
        }
    }

    /**
     * treeXmlのGetter
     * @return
     */
    @Override
    public String getTreeXml() {
        if (treeBytes != null) {
            try {
                return new String(treeBytes, "UTF-8");
            } catch (UnsupportedEncodingException ex) {
                LogWriter.error(getClass(), ex);
            }
        }
        return "";
    }

    /**
     * treeXmlのSetter
     * @param treeXml
     */
    @Override
    public void setTreeXml(String treeXml) {
        if (treeXml != null) {
            try {
                treeBytes = treeXml.getBytes("UTF-8");
                if (treeBytes == null) {
                    treeBlob = null;
                } else {
                    treeBlob = new BlobImpl(treeBytes);
                }
            } catch (UnsupportedEncodingException ex) {
                LogWriter.error(getClass(), ex);
            }
        }
    }

    /**
     * lastUpdatedのGetter
     * MEMO:Refrection
     * @return
     */
    @Override
    public Date getLastUpdated() {
        return lastUpdated;
    }

    /**
     * lastUpdatedのSetter
     * MEMO:Refrection
     * @param updatedDate
     */
    @Override
    public void setLastUpdated(Date updatedDate) {
        this.lastUpdated = updatedDate;
    }

    /**
     *
     * @return
     */
    public boolean isImported() {
        return imported;
    }

    /**
     * importedのSetter
     * @param imported
     */
    public void setImported(boolean imported) {
        this.imported = imported;
    }

    /**
     *
     * @return
     */
    @Override
    public int hashCode() {
        final int PRIME = 31;
        int result = super.hashCode();
        result = PRIME * result + (int) (id ^ (id >>> 32));
        return result;
    }

    /**
     *
     * @param obj
     * @return
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!super.equals(obj)) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PublishedTreeModel other = (PublishedTreeModel) obj;
        if (getId() != other.getId()) {
            return false;
        }
        return true;
    }
}
