Subversion Repositories SmartDukaan

Rev

Rev 21720 | Rev 22009 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.dtr;

import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
import com.spice.profitmandi.dao.enumuration.dtr.ContentType;


@Entity
@Table(name="dtr.document", schema = "dtr")
public class Document{

        @Id
        @Column(name="id", unique=true, updatable=false)
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int id;

        @Column(name="name", unique = true)
        private String name;

        @Column(name = "path")
        private String path;

        @Column(name = "content_type")
        @Enumerated(EnumType.STRING)
        private ContentType contentType;

        private long size;

        @Convert(converter = LocalDateTimeAttributeConverter.class)
        private LocalDateTime createTimestamp;

        @Convert(converter = LocalDateTimeAttributeConverter.class)
        private LocalDateTime updateTimestamp;
        
        @Column(columnDefinition="tinyint(1) default 0")
        private boolean persisted;

        public int getId() {
                return id;
        }

        public void setId(int id) {
                this.id = id;
        }

        public String getName() {
                return name;
        }

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

        public String getPath() {
                return path;
        }

        public void setPath(String path) {
                this.path = path;
        }

        public ContentType getContentType() {
                return contentType;
        }

        public void setContentType(ContentType contentType) {
                this.contentType = contentType;
        }

        public long getSize() {
                return size;
        }

        public void setSize(long size) {
                this.size = size;
        }

        public LocalDateTime getCreateTimestamp() {
                return createTimestamp;
        }

        public void setCreateTimestamp(LocalDateTime createTimestamp) {
                this.createTimestamp = createTimestamp;
        }

        public LocalDateTime getUpdateTimestamp() {
                return updateTimestamp;
        }

        public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
                this.updateTimestamp = updateTimestamp;
        }


        public boolean isPersisted() {
                return persisted;
        }

        public void setPersisted(boolean persisted) {
                this.persisted = persisted;
        }

        
        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + ((contentType == null) ? 0 : contentType.hashCode());
                result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
                result = prime * result + id;
                result = prime * result + ((name == null) ? 0 : name.hashCode());
                result = prime * result + ((path == null) ? 0 : path.hashCode());
                result = prime * result + (persisted ? 1231 : 1237);
                result = prime * result + (int) (size ^ (size >>> 32));
                result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.hashCode());
                return result;
        }

        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                Document other = (Document) obj;
                if (contentType != other.contentType)
                        return false;
                if (createTimestamp == null) {
                        if (other.createTimestamp != null)
                                return false;
                } else if (!createTimestamp.equals(other.createTimestamp))
                        return false;
                if (id != other.id)
                        return false;
                if (name == null) {
                        if (other.name != null)
                                return false;
                } else if (!name.equals(other.name))
                        return false;
                if (path == null) {
                        if (other.path != null)
                                return false;
                } else if (!path.equals(other.path))
                        return false;
                if (persisted != other.persisted)
                        return false;
                if (size != other.size)
                        return false;
                if (updateTimestamp == null) {
                        if (other.updateTimestamp != null)
                                return false;
                } else if (!updateTimestamp.equals(other.updateTimestamp))
                        return false;
                return true;
        }

        @Override
        public String toString() {
                return "Document [id=" + id + ", name=" + name + ", path=" + path + ", contentType=" + contentType + ", size="
                                + size + ", createTimestamp=" + createTimestamp + ", updateTimestamp=" + updateTimestamp
                                + ", persisted=" + persisted + "]";
        }
        
        

}