| 36287 |
ranu |
1 |
package com.spice.profitmandi.dao.entity.fofo;
|
|
|
2 |
|
|
|
3 |
import javax.persistence.*;
|
|
|
4 |
import java.time.LocalDate;
|
|
|
5 |
import java.time.LocalDateTime;
|
|
|
6 |
import java.util.Objects;
|
|
|
7 |
|
|
|
8 |
@Entity
|
|
|
9 |
@Table(name = "fofo.rating_reminder",
|
|
|
10 |
uniqueConstraints = @UniqueConstraint(name = "uk_rating_reminder_fofo_week",
|
|
|
11 |
columnNames = {"fofo_id", "week_start"}))
|
|
|
12 |
@NamedQueries({
|
|
|
13 |
@NamedQuery(
|
|
|
14 |
name = "RatingReminder.findByFofoIdAndWeek",
|
|
|
15 |
query = "SELECT r FROM RatingReminder r WHERE r.fofoId = :fofoId AND r.weekStart = :weekStart"
|
|
|
16 |
),
|
|
|
17 |
@NamedQuery(
|
|
|
18 |
name = "RatingReminder.decrementRemaining",
|
|
|
19 |
query = "UPDATE RatingReminder r " +
|
|
|
20 |
"SET r.attemptsRemaining = r.attemptsRemaining - 1, r.updateTimestamp = :now " +
|
|
|
21 |
"WHERE r.id = :id AND r.attemptsRemaining > 0"
|
|
|
22 |
)
|
|
|
23 |
})
|
|
|
24 |
public class RatingReminder {
|
|
|
25 |
|
|
|
26 |
public static final int MAX_ATTEMPTS_PER_WEEK = 4;
|
|
|
27 |
|
|
|
28 |
@Id
|
|
|
29 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
30 |
@Column(name = "id", unique = true, updatable = false)
|
|
|
31 |
private int id;
|
|
|
32 |
|
|
|
33 |
@Column(name = "fofo_id")
|
|
|
34 |
private int fofoId;
|
|
|
35 |
|
|
|
36 |
@Column(name = "week_start")
|
|
|
37 |
private LocalDate weekStart;
|
|
|
38 |
|
|
|
39 |
@Column(name = "week_end")
|
|
|
40 |
private LocalDate weekEnd;
|
|
|
41 |
|
|
|
42 |
@Column(name = "attempts_remaining")
|
|
|
43 |
private int attemptsRemaining;
|
|
|
44 |
|
|
|
45 |
@Column(name = "create_timestamp")
|
|
|
46 |
private LocalDateTime createTimestamp;
|
|
|
47 |
|
|
|
48 |
@Column(name = "update_timestamp")
|
|
|
49 |
private LocalDateTime updateTimestamp;
|
|
|
50 |
|
|
|
51 |
public int getId() {
|
|
|
52 |
return id;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
public void setId(int id) {
|
|
|
56 |
this.id = id;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
public int getFofoId() {
|
|
|
60 |
return fofoId;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
public void setFofoId(int fofoId) {
|
|
|
64 |
this.fofoId = fofoId;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public LocalDate getWeekStart() {
|
|
|
68 |
return weekStart;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
public void setWeekStart(LocalDate weekStart) {
|
|
|
72 |
this.weekStart = weekStart;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
public LocalDate getWeekEnd() {
|
|
|
76 |
return weekEnd;
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
public void setWeekEnd(LocalDate weekEnd) {
|
|
|
80 |
this.weekEnd = weekEnd;
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public int getAttemptsRemaining() {
|
|
|
84 |
return attemptsRemaining;
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
public void setAttemptsRemaining(int attemptsRemaining) {
|
|
|
88 |
this.attemptsRemaining = attemptsRemaining;
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
public LocalDateTime getCreateTimestamp() {
|
|
|
92 |
return createTimestamp;
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
public void setCreateTimestamp(LocalDateTime createTimestamp) {
|
|
|
96 |
this.createTimestamp = createTimestamp;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
public LocalDateTime getUpdateTimestamp() {
|
|
|
100 |
return updateTimestamp;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
|
|
|
104 |
this.updateTimestamp = updateTimestamp;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
@Override
|
|
|
108 |
public String toString() {
|
|
|
109 |
return "RatingReminder{" +
|
|
|
110 |
"id=" + id +
|
|
|
111 |
", fofoId=" + fofoId +
|
|
|
112 |
", weekStart=" + weekStart +
|
|
|
113 |
", weekEnd=" + weekEnd +
|
|
|
114 |
", attemptsRemaining=" + attemptsRemaining +
|
|
|
115 |
", createTimestamp=" + createTimestamp +
|
|
|
116 |
", updateTimestamp=" + updateTimestamp +
|
|
|
117 |
'}';
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
@Override
|
|
|
121 |
public boolean equals(Object o) {
|
|
|
122 |
if (this == o) return true;
|
|
|
123 |
if (o == null || getClass() != o.getClass()) return false;
|
|
|
124 |
RatingReminder that = (RatingReminder) o;
|
|
|
125 |
return id == that.id && fofoId == that.fofoId && attemptsRemaining == that.attemptsRemaining
|
|
|
126 |
&& Objects.equals(weekStart, that.weekStart) && Objects.equals(weekEnd, that.weekEnd)
|
|
|
127 |
&& Objects.equals(createTimestamp, that.createTimestamp) && Objects.equals(updateTimestamp, that.updateTimestamp);
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
@Override
|
|
|
131 |
public int hashCode() {
|
|
|
132 |
return Objects.hash(id, fofoId, weekStart, weekEnd, attemptsRemaining, createTimestamp, updateTimestamp);
|
|
|
133 |
}
|
|
|
134 |
}
|