Subversion Repositories SmartDukaan

Rev

Rev 33443 | Blame | Compare with Previous | Last modification | View Log | RSS feed

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

import javax.persistence.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;

@Entity
@Table(name = "fofo.print_resource")
@NamedQueries({
        @NamedQuery(
                name = "PrintResources.findActiveByRegionId",
                query = "select pr from PrintResource pr join PrintResourceRegion pri on pr.id = pri.resourceId where pri.regionId in :regionIds and (pr.endDate > :currentDate OR pr.endDate is NULL)"),

        @NamedQuery(
                name = "PrintResources.findAllPrintResource",
                query = "select pr from PrintResource pr where pr.endDate > :currentDate OR pr.endDate is NULL"),

})
public class PrintResource {

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

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

    @Column(name = "img_url")
    private String imgUrl;

    @Column(name = "thumbnail_url")
    private String thumbnailUrl;

    @Column(name = "start_date")
    private LocalDateTime startDate;

    @Column(name = "end_date")
    private LocalDateTime endDate;


    @Column(name = "create_timestamp")
    private LocalDateTime createTimestamp;

    public int getId() {
        return id;
    }

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

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    public String getThumbnailUrl() {
        return thumbnailUrl;
    }

    public void setThumbnailUrl(String thumbnailUrl) {
        this.thumbnailUrl = thumbnailUrl;
    }

    public LocalDateTime getStartDate() {
        return startDate;
    }

    public void setStartDate(LocalDateTime startDate) {
        this.startDate = startDate;
    }

    public String getFormattedStartdDate() {
        if (startDate == null) {
            return null;
        }
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
        return startDate.format(formatter);
    }

    public LocalDateTime getEndDate() {
        return endDate;
    }

    public void setEndDate(LocalDateTime endDate) {
        this.endDate = endDate;
    }

    public String getFormattedEndDate() {
        if (endDate == null) {
            return null;
        }
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
        return endDate.format(formatter);
    }

    public LocalDateTime getCreateTimestamp() {
        return createTimestamp;
    }

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

    public String getFormattedCreateTimestamp() {
        if (createTimestamp == null) {
            return null;
        }
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
        return createTimestamp.format(formatter);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PrintResource that = (PrintResource) o;
        return id == that.id && Objects.equals(title, that.title) && Objects.equals(imgUrl, that.imgUrl) && Objects.equals(thumbnailUrl, that.thumbnailUrl) && Objects.equals(startDate, that.startDate) && Objects.equals(endDate, that.endDate) && Objects.equals(createTimestamp, that.createTimestamp);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, title, imgUrl, thumbnailUrl, startDate, endDate, createTimestamp);
    }

    @Override
    public String toString() {
        return "PrintResource{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", imgUrl='" + imgUrl + '\'' +
                ", thumbnailUrl='" + thumbnailUrl + '\'' +
                ", startDate=" + startDate +
                ", endDate=" + endDate +
                ", createTimestamp=" + createTimestamp +
                '}';
    }
}