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 open.dolphin.log.LogWriter;
import open.dolphin.queries.DolphinQuery;
import org.hibernate.lob.BlobImpl;

/**
 * StampTreeModel generated by hbm2java
 */
public class StampTreeModel extends InfoModel implements IStampTreeModel {

    private long id;
    private UserModel user;
    private String name;
    private String publishType;
    private String category;
    private String partyName;
    private String url;
    private String description;
    private Date publishedDate;
    private Date lastUpdated;
    private String published;
    private byte[] treeBytes;
    private Blob treeBlob;

    public StampTreeModel() {
    }

    public void initialize(UserModel user, String name, String description, String partyName, String url, String xml) {
        setUser(user);
        setName(name);
        setDescription(description);
        setPartyName(partyName);
        setUrl(url);
        setTreeXml(xml);
    }

    @Override
    public boolean search(DolphinQuery query) {
        return false;
    }

    /**
     *
     * @return
     */
    @Override
    public long getId() {
        return this.id;
    }
    
    /**
     *
     * @param id
     */
    @Override
    public void setId(long id) {
        this.id = id;
    }

    @Override
    public UserModel getUser() {
        return this.user;
    }
    
    public void setUser(UserModel DUsers) {
        this.user = DUsers;
    }
    @Override
    public String getName() {
        return this.name;
    }
    
    public void setName(String treeName) {
        this.name = treeName;
    }

    @Override
    public String getPublishType() {
        return this.publishType;
    }
    
    @Override
    public void setPublishType(String publishType) {
        this.publishType = publishType;
    }
    /**
     *
     * @return
     */
    @Override
    public String getCategory() {
        return this.category;
    }
    
    /**
     *
     * @param category
     */
    @Override
    public void setCategory(String category) {
        this.category = category;
    }

    @Override
    public String getPartyName() {
        return this.partyName;
    }
    
    public void setPartyName(String partyName) {
        this.partyName = partyName;
    }

    @Override
    public String getUrl() {
        return this.url;
    }
    
    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public String getDescription() {
        return this.description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    @Override
    public Date getPublishedDate() {
        return this.publishedDate;
    }
    
    @Override
    public void setPublishedDate(Date publisheddate) {
        this.publishedDate = publisheddate;
    }

    /**
     *
     * @return
     */
    @Override
    public Date getLastUpdated() {
        return this.lastUpdated;
    }
    
    @Override
    public void setLastUpdated(Date lastupdated) {
        this.lastUpdated = lastupdated;
    }

    public String getPublished() {
        return this.published;
    }
    
    public void setPublished(String published) {
        this.published = published;
    }

    @Override
    public byte[] getTreeBytes() {
        return this.treeBytes;
    }
    
    public void setTreeBytes(byte[] treeBytes) {
        if (treeBytes != null) {
            this.treeBytes = treeBytes;
            this.treeBlob = new BlobImpl(treeBytes);
        }
    }

    public Blob getTreeBlob() {
        return this.treeBlob;
    }

    public void setTreeBlob(Blob treeBlob) throws SQLException {
        if (treeBlob != null) {
            this.treeBlob = treeBlob;
            this.treeBytes = treeBlob.getBytes(1, (int)treeBlob.length());
        }
    }

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

    /**
     *
     * @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(), null, ex);
            }
        }
    }

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

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final StampTreeModel other = (StampTreeModel) obj;
        if (getId() != other.getId()) {
            return false;
        }
        return true;
    }
}


