Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
33443 ranu 1
package com.spice.profitmandi.dao.entity.fofo;
2
 
3
import javax.persistence.*;
4
import java.time.LocalDateTime;
5
import java.time.format.DateTimeFormatter;
6
import java.util.Objects;
7
 
8
@Entity
9
@Table(name = "fofo.print_resource")
10
@NamedQueries({
11
        @NamedQuery(
12
                name = "PrintResources.findActiveByRegionId",
13
                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)"),
14
 
15
        @NamedQuery(
16
                name = "PrintResources.findAllPrintResource",
17
                query = "select pr from PrintResource pr where pr.endDate > :currentDate OR pr.endDate is NULL"),
18
 
19
})
20
public class PrintResource {
21
 
22
    @Id
23
    @Column(name = "id", unique = true, updatable = false)
24
    @GeneratedValue(strategy = GenerationType.IDENTITY)
25
    private int id;
26
 
27
    @Column(name = "title")
28
    private String title;
29
 
30
    @Column(name = "img_url")
31
    private String imgUrl;
32
 
33
    @Column(name = "start_date")
34
    private LocalDateTime startDate;
35
 
36
    @Column(name = "end_date")
37
    private LocalDateTime endDate;
38
 
39
 
40
    @Column(name = "create_timestamp")
41
    private LocalDateTime createTimestamp;
42
 
43
    public int getId() {
44
        return id;
45
    }
46
 
47
    public void setId(int id) {
48
        this.id = id;
49
    }
50
 
51
    public String getTitle() {
52
        return title;
53
    }
54
 
55
    public void setTitle(String title) {
56
        this.title = title;
57
    }
58
 
59
    public String getImgUrl() {
60
        return imgUrl;
61
    }
62
 
63
    public void setImgUrl(String imgUrl) {
64
        this.imgUrl = imgUrl;
65
    }
66
 
67
    public LocalDateTime getStartDate() {
68
        return startDate;
69
    }
70
 
71
    public void setStartDate(LocalDateTime startDate) {
72
        this.startDate = startDate;
73
    }
74
 
75
    public String getFormattedStartdDate() {
76
        if (startDate == null) {
77
            return null;
78
        }
79
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
80
        return startDate.format(formatter);
81
    }
82
 
83
    public LocalDateTime getEndDate() {
84
        return endDate;
85
    }
86
 
87
    public void setEndDate(LocalDateTime endDate) {
88
        this.endDate = endDate;
89
    }
90
 
91
    public String getFormattedEndDate() {
92
        if (endDate == null) {
93
            return null;
94
        }
95
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
96
        return endDate.format(formatter);
97
    }
98
 
99
    public LocalDateTime getCreateTimestamp() {
100
        return createTimestamp;
101
    }
102
 
103
    public void setCreateTimestamp(LocalDateTime createTimestamp) {
104
        this.createTimestamp = createTimestamp;
105
    }
106
 
107
    public String getFormattedCreateTimestamp() {
108
        if (createTimestamp == null) {
109
            return null;
110
        }
111
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
112
        return createTimestamp.format(formatter);
113
    }
114
 
115
    @Override
116
    public boolean equals(Object o) {
117
        if (this == o) return true;
118
        if (o == null || getClass() != o.getClass()) return false;
119
        PrintResource that = (PrintResource) o;
120
        return id == that.id && Objects.equals(title, that.title) && Objects.equals(imgUrl, that.imgUrl) && Objects.equals(startDate, that.startDate) && Objects.equals(endDate, that.endDate) && Objects.equals(createTimestamp, that.createTimestamp);
121
    }
122
 
123
    @Override
124
    public int hashCode() {
125
        return Objects.hash(id, title, imgUrl, startDate, endDate, createTimestamp);
126
    }
127
 
128
    @Override
129
    public String toString() {
130
        return "PrintResource{" +
131
                "id=" + id +
132
                ", title='" + title + '\'' +
133
                ", imgUrl='" + imgUrl + '\'' +
134
                ", startDate=" + startDate +
135
                ", endDate=" + endDate +
136
                ", createTimestamp=" + createTimestamp +
137
                '}';
138
    }
139
}