Subversion Repositories SmartDukaan

Rev

Rev 25651 | 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 org.hibernate.annotations.UpdateTimestamp;

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

@Entity
@Table(name = "dtr.document")
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;

        @Column(name = "display_name")
        private String displayName;

        public String getDisplayName() {
                return displayName;
        }

        public void setDisplayName(String displayName) {
                this.displayName = displayName;
        }

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

        @Convert(converter = LocalDateTimeAttributeConverter.class)
        @UpdateTimestamp
        private LocalDateTime updateTimestamp = LocalDateTime.now();

        @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 + id;
                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 (id != other.id)
                        return false;
                return true;
        }

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

}