Subversion Repositories SmartDukaan

Rev

Rev 36101 | Go to most recent revision | 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.util.Objects;

@Entity
@Table(name = "fofo.rbm_rating")
@NamedQueries({
        @NamedQuery(name = "RbMRatingByMonth", query = "" +
                "SELECT r FROM RbmRating r WHERE r.fofoId = :fofoId AND r.rbmId = :rbmId AND r.createTimeStamp BETWEEN :startOfMonth AND :endOfMonth"
        ),
        @NamedQuery(name = "RbMRatingByFofoIdAndWeek", query = "" +
                "SELECT r FROM RbmRating r WHERE r.fofoId = :fofoId AND r.createTimeStamp BETWEEN :startOfMonth AND :endOfMonth"
        ),
        @NamedQuery(
                name = "Visit.FindAverageRatingByRbmIds",
                query = "SELECT new com.spice.profitmandi.dao.model.RbMRatingModel(v.rbmId, AVG(v.rating)) " +
                        "FROM RbmRating v WHERE v.rbmId IN :rbmIds GROUP BY v.rbmId"
        ),
        @NamedQuery(
                name = "Visit.FindAverageRatingByRbmIdsAndDateRange",
                query = "SELECT new com.spice.profitmandi.dao.model.RbMRatingModel(v.rbmId, AVG(v.rating), COUNT(v.id)) " +
                        "FROM RbmRating v WHERE v.rbmId IN :rbmIds " +
                        "AND v.createTimeStamp BETWEEN :startDate AND :endDate " +
                        "GROUP BY v.rbmId"
        ),
        @NamedQuery(
                name = "Visit.FindRbmFeedback",
                query = "SELECT r FROM RbmRating r" +
                        " WHERE r.rbmId IN :rbmIds" +
                        " AND r.createTimeStamp BETWEEN :startDate AND :endDate"
        )
})
public class RbmRating {
    @Id
    @Column(name = "id", unique = true, updatable = false)
    private int id;

    @Column(name = "rating")
    private int rating;

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

    @Column(name = "fofo_id")
    private int fofoId;

    @Column(name = "rbm_id")
    private int rbmId;

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

    public int getId() {
        return id;
    }

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

    public int getRating() {
        return rating;
    }

    public void setRating(int rating) {
        this.rating = rating;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public int getFofoId() {
        return fofoId;
    }

    public void setFofoId(int fofoId) {
        this.fofoId = fofoId;
    }

    public int getRbmId() {
        return rbmId;
    }

    public void setRbmId(int rbmId) {
        this.rbmId = rbmId;
    }

    public LocalDateTime getCreateTimeStamp() {
        return createTimeStamp;
    }

    public void setCreateTimeStamp(LocalDateTime createTimeStamp) {
        this.createTimeStamp = createTimeStamp;
    }

    @Override
    public String toString() {
        return "RbmRating{" +
                "id=" + id +
                ", rating=" + rating +
                ", comment='" + comment + '\'' +
                ", fofoId=" + fofoId +
                ", rbmId=" + rbmId +
                ", createTimeStamp=" + createTimeStamp +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RbmRating rbmRating = (RbmRating) o;
        return id == rbmRating.id && rating == rbmRating.rating && fofoId == rbmRating.fofoId && rbmId == rbmRating.rbmId && Objects.equals(comment, rbmRating.comment) && Objects.equals(createTimeStamp, rbmRating.createTimeStamp);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, rating, comment, fofoId, rbmId, createTimeStamp);
    }
}