Subversion Repositories SmartDukaan

Rev

Rev 34322 | Rev 36336 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
34300 ranu 1
package com.spice.profitmandi.dao.entity.fofo;
2
 
3
import javax.persistence.*;
4
import java.time.LocalDateTime;
5
import java.util.Objects;
6
 
7
@Entity
8
@Table(name = "fofo.rbm_rating")
9
@NamedQueries({
10
        @NamedQuery(name = "RbMRatingByMonth", query = "" +
11
                "SELECT r FROM RbmRating r WHERE r.fofoId = :fofoId AND r.rbmId = :rbmId AND r.createTimeStamp BETWEEN :startOfMonth AND :endOfMonth"
12
        ),
13
        @NamedQuery(
14
                name = "Visit.FindAverageRatingByRbmIds",
15
                query = "SELECT new com.spice.profitmandi.dao.model.RbMRatingModel(v.rbmId, AVG(v.rating)) " +
16
                        "FROM RbmRating v WHERE v.rbmId IN :rbmIds GROUP BY v.rbmId"
34322 ranu 17
        ),
18
        @NamedQuery(
36101 ranu 19
                name = "Visit.FindAverageRatingByRbmIdsAndDateRange",
20
                query = "SELECT new com.spice.profitmandi.dao.model.RbMRatingModel(v.rbmId, AVG(v.rating), COUNT(v.id)) " +
21
                        "FROM RbmRating v WHERE v.rbmId IN :rbmIds " +
22
                        "AND v.createTimeStamp BETWEEN :startDate AND :endDate " +
23
                        "GROUP BY v.rbmId"
24
        ),
25
        @NamedQuery(
34322 ranu 26
                name = "Visit.FindRbmFeedback",
27
                query = "SELECT r FROM RbmRating r" +
28
                        " WHERE r.rbmId IN :rbmIds" +
29
                        " AND r.createTimeStamp BETWEEN :startDate AND :endDate"
34300 ranu 30
        )
31
})
32
public class RbmRating {
33
    @Id
34
    @Column(name = "id", unique = true, updatable = false)
35
    private int id;
36
 
37
    @Column(name = "rating")
38
    private int rating;
39
 
40
    @Column(name = "comment")
41
    private String comment;
42
 
43
    @Column(name = "fofo_id")
44
    private int fofoId;
45
 
46
    @Column(name = "rbm_id")
47
    private int rbmId;
48
 
49
    @Column(name = "create_timestamp")
50
    private LocalDateTime createTimeStamp;
51
 
52
    public int getId() {
53
        return id;
54
    }
55
 
56
    public void setId(int id) {
57
        this.id = id;
58
    }
59
 
60
    public int getRating() {
61
        return rating;
62
    }
63
 
64
    public void setRating(int rating) {
65
        this.rating = rating;
66
    }
67
 
68
    public String getComment() {
69
        return comment;
70
    }
71
 
72
    public void setComment(String comment) {
73
        this.comment = comment;
74
    }
75
 
76
    public int getFofoId() {
77
        return fofoId;
78
    }
79
 
80
    public void setFofoId(int fofoId) {
81
        this.fofoId = fofoId;
82
    }
83
 
84
    public int getRbmId() {
85
        return rbmId;
86
    }
87
 
88
    public void setRbmId(int rbmId) {
89
        this.rbmId = rbmId;
90
    }
91
 
92
    public LocalDateTime getCreateTimeStamp() {
93
        return createTimeStamp;
94
    }
95
 
96
    public void setCreateTimeStamp(LocalDateTime createTimeStamp) {
97
        this.createTimeStamp = createTimeStamp;
98
    }
99
 
100
    @Override
101
    public String toString() {
102
        return "RbmRating{" +
103
                "id=" + id +
104
                ", rating=" + rating +
105
                ", comment='" + comment + '\'' +
106
                ", fofoId=" + fofoId +
107
                ", rbmId=" + rbmId +
108
                ", createTimeStamp=" + createTimeStamp +
109
                '}';
110
    }
111
 
112
    @Override
113
    public boolean equals(Object o) {
114
        if (this == o) return true;
115
        if (o == null || getClass() != o.getClass()) return false;
116
        RbmRating rbmRating = (RbmRating) o;
117
        return id == rbmRating.id && rating == rbmRating.rating && fofoId == rbmRating.fofoId && rbmId == rbmRating.rbmId && Objects.equals(comment, rbmRating.comment) && Objects.equals(createTimeStamp, rbmRating.createTimeStamp);
118
    }
119
 
120
    @Override
121
    public int hashCode() {
122
        return Objects.hash(id, rating, comment, fofoId, rbmId, createTimeStamp);
123
    }
124
}