
issue: Fix failures related assignee.
* Remove initialization for assignee in initial-data.yml. It causes Referential integrity constraint violation. * Remove unnecessary code.
@9a0749b286d89a939d6f1baf963bc332a06b0ddd
--- app/controllers/IssueApp.java
+++ app/controllers/IssueApp.java
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 |
|
12 | 12 |
import jxl.write.WriteException; |
13 | 13 |
|
14 |
+import models.Assignee; |
|
14 | 15 |
import models.Attachment; |
15 | 16 |
import models.Issue; |
16 | 17 |
import models.IssueComment; |
... | ... | @@ -137,8 +138,8 @@ |
137 | 138 |
newIssue.authorName = UserApp.currentUser().name; |
138 | 139 |
newIssue.project = project; |
139 | 140 |
newIssue.state = State.OPEN; |
140 |
- if (newIssue.assignee.id != null) { |
|
141 |
- newIssue.assignee.project = project; |
|
141 |
+ if (newIssue.assignee.user.id != null) { |
|
142 |
+ newIssue.assignee = Assignee.add(newIssue.assignee.user.id, project.id); |
|
142 | 143 |
} else { |
143 | 144 |
newIssue.assignee = null; |
144 | 145 |
} |
... | ... | @@ -185,8 +186,8 @@ |
185 | 186 |
issue.authorId = originalIssue.authorId; |
186 | 187 |
issue.authorName = originalIssue.authorName; |
187 | 188 |
issue.project = originalIssue.project; |
188 |
- if (issue.assignee.id != null) { |
|
189 |
- issue.assignee.project = originalIssue.project; |
|
189 |
+ if (issue.assignee.user.id != null) { |
|
190 |
+ issue.assignee = Assignee.add(issue.assignee.user.id, originalIssue.project.id); |
|
190 | 191 |
} else { |
191 | 192 |
issue.assignee = null; |
192 | 193 |
} |
... | ... | @@ -199,10 +200,6 @@ |
199 | 200 |
} |
200 | 201 |
|
201 | 202 |
Issue.edit(issue); |
202 |
- |
|
203 |
- if (originalIssue.assignee != null) { |
|
204 |
- originalIssue.assignee.deleteIfEmpty(); |
|
205 |
- } |
|
206 | 203 |
|
207 | 204 |
// Attach the files in the current user's temporary storage. |
208 | 205 |
Attachment.attachFiles(UserApp.currentUser().id, originalIssue.project.id, Resource.ISSUE_POST, id); |
--- app/models/Assignee.java
+++ app/models/Assignee.java
... | ... | @@ -54,29 +54,13 @@ |
54 | 54 |
return assignee; |
55 | 55 |
} |
56 | 56 |
|
57 |
- @Override |
|
58 |
- public boolean equals(Object that) { |
|
59 |
- if (!(that instanceof Assignee)) |
|
60 |
- return false; |
|
61 |
- Assignee castedThat = (Assignee) that; |
|
62 |
- if (id == castedThat.id) |
|
63 |
- return true; |
|
64 |
- return (this == castedThat) || (user.id == castedThat.user.id) |
|
65 |
- && (project.id == castedThat.project.id); |
|
66 |
- } |
|
67 |
- |
|
68 |
- @Override |
|
69 |
- public int hashCode() { |
|
70 |
- return new HashCodeBuilder().append(user.hashCode()).append(project.hashCode()) |
|
71 |
- .toHashCode(); |
|
72 |
- } |
|
73 |
- |
|
74 |
- public void deleteIfEmpty() { |
|
75 |
- Logger.debug("empty?"); |
|
76 |
- Logger.debug(String.valueOf(issues.size())); |
|
77 |
- if (this.issues.isEmpty()) { |
|
78 |
- Logger.debug("del"); |
|
79 |
- super.delete(); |
|
57 |
+ public static Assignee add(Long userId, Long projectId) { |
|
58 |
+ Assignee assignee = finder.where() |
|
59 |
+ .eq("user.id", userId).eq("project.id", projectId).findUnique(); |
|
60 |
+ if (assignee != null) { |
|
61 |
+ return assignee; |
|
62 |
+ } else { |
|
63 |
+ return new Assignee(userId, projectId); |
|
80 | 64 |
} |
81 | 65 |
} |
82 | 66 |
}(No newline at end of file) |
--- app/models/Issue.java
+++ app/models/Issue.java
... | ... | @@ -225,12 +225,7 @@ |
225 | 225 |
Milestone milestone = Milestone.findById(issue.milestoneId); |
226 | 226 |
milestone.delete(issue); |
227 | 227 |
} |
228 |
- Assignee a = issue.assignee; |
|
229 | 228 |
issue.delete(); |
230 |
- if (a != null) { |
|
231 |
- a.refresh(); |
|
232 |
- a.deleteIfEmpty(); |
|
233 |
- } |
|
234 | 229 |
} |
235 | 230 |
|
236 | 231 |
/** |
--- app/models/support/FinderTemplate.java
+++ app/models/support/FinderTemplate.java
... | ... | @@ -4,11 +4,8 @@ |
4 | 4 |
|
5 | 5 |
import play.Logger; |
6 | 6 |
import play.db.ebean.*; |
7 |
-import play.db.ebean.Model.Finder; |
|
8 | 7 |
|
9 | 8 |
import java.util.*; |
10 |
- |
|
11 |
-import models.Issue; |
|
12 | 9 |
|
13 | 10 |
public class FinderTemplate { |
14 | 11 |
|
--- conf/initial-data.yml
+++ conf/initial-data.yml
... | ... | @@ -103,11 +103,6 @@ |
103 | 103 |
id: 1 |
104 | 104 |
- !!models.Issue |
105 | 105 |
authorId: 3 |
106 |
- assignee: !!models.Assignee |
|
107 |
- user: !!models.User |
|
108 |
- id: 2 |
|
109 |
- project: !!models.Project |
|
110 |
- id: 1 |
|
111 | 106 |
title: 다운로드는 익명 댓글에도 사용자명에 링크가 걸림 |
112 | 107 |
body: 내용 다운로드는 익명 댓글에도 사용자명에 링크가 걸림 |
113 | 108 |
state: OPEN |
... | ... | @@ -117,11 +112,6 @@ |
117 | 112 |
id: 1 |
118 | 113 |
- !!models.Issue |
119 | 114 |
authorId: 4 |
120 |
- assignee: !!models.Assignee |
|
121 |
- user: !!models.User |
|
122 |
- id: 2 |
|
123 |
- project: !!models.Project |
|
124 |
- id: 1 |
|
125 | 115 |
title: gittracker.php의 메모리 제한 에러 |
126 | 116 |
body: 내용 gittracker.php의 메모리 제한 에러 |
127 | 117 |
state: CLOSED |
... | ... | @@ -132,11 +122,6 @@ |
132 | 122 |
numOfComments: 1 |
133 | 123 |
- !!models.Issue |
134 | 124 |
authorId: 4 |
135 |
- assignee: !!models.Assignee |
|
136 |
- user: !!models.User |
|
137 |
- id: 3 |
|
138 |
- project: !!models.Project |
|
139 |
- id: 1 |
|
140 | 125 |
title: git/hg 코드 브라우저에 i18n이 적용되지 않음 |
141 | 126 |
body: 내용 git/hg 코드 브라우저에 i18n이 적용되지 않음 |
142 | 127 |
state: CLOSED |
... | ... | @@ -146,11 +131,6 @@ |
146 | 131 |
id: 1 |
147 | 132 |
- !!models.Issue |
148 | 133 |
authorId: 4 |
149 |
- assignee: !!models.Assignee |
|
150 |
- user: !!models.User |
|
151 |
- id: 3 |
|
152 |
- project: !!models.Project |
|
153 |
- id: 1 |
|
154 | 134 |
title: CUBRID 설치 문제 |
155 | 135 |
body: IOS는 설치 못하나요? |
156 | 136 |
state: OPEN |
... | ... | @@ -160,11 +140,6 @@ |
160 | 140 |
id: 3 |
161 | 141 |
- !!models.Issue |
162 | 142 |
authorId: 4 |
163 |
- assignee: !!models.Assignee |
|
164 |
- user: !!models.User |
|
165 |
- id: 3 |
|
166 |
- project: !!models.Project |
|
167 |
- id: 1 |
|
168 | 143 |
title: 메모리 누수 현상 |
169 | 144 |
body: 메모리가 너무 누수가 되는듯. |
170 | 145 |
state: CLOSED |
... | ... | @@ -174,11 +149,6 @@ |
174 | 149 |
id: 3 |
175 | 150 |
- !!models.Issue |
176 | 151 |
authorId: 4 |
177 |
- assignee: !!models.Assignee |
|
178 |
- user: !!models.User |
|
179 |
- id: 3 |
|
180 |
- project: !!models.Project |
|
181 |
- id: 1 |
|
182 | 152 |
title: Client application for Mac. |
183 | 153 |
body: Please make it. |
184 | 154 |
state: OPEN |
... | ... | @@ -188,11 +158,6 @@ |
188 | 158 |
id: 3 |
189 | 159 |
- !!models.Issue |
190 | 160 |
authorId: 4 |
191 |
- assignee: !!models.Assignee |
|
192 |
- user: !!models.User |
|
193 |
- id: 3 |
|
194 |
- project: !!models.Project |
|
195 |
- id: 1 |
|
196 | 161 |
title: CPU 무한 점유울 문제. |
197 | 162 |
body: CPU를 무한사용 중이에요. |
198 | 163 |
state: CLOSED |
... | ... | @@ -202,11 +167,6 @@ |
202 | 167 |
id: 3 |
203 | 168 |
- !!models.Issue |
204 | 169 |
authorId: 1 |
205 |
- assignee: !!models.Assignee |
|
206 |
- user: !!models.User |
|
207 |
- id: 3 |
|
208 |
- project: !!models.Project |
|
209 |
- id: 1 |
|
210 | 170 |
title: Less chained imports causes compile error |
211 | 171 |
body: When using Play, when I chain less files such as a.less imports b.less which in turn imports c.less |
212 | 172 |
state: CLOSED |
... | ... | @@ -216,11 +176,6 @@ |
216 | 176 |
id: 1 |
217 | 177 |
- !!models.Issue |
218 | 178 |
authorId: 1 |
219 |
- assignee: !!models.Assignee |
|
220 |
- user: !!models.User |
|
221 |
- id: 2 |
|
222 |
- project: !!models.Project |
|
223 |
- id: 1 |
|
224 | 179 |
title: Weird TypeDoesNotMatch exception in RC-3 and final |
225 | 180 |
body: The following code works as expected in RC1-Snapshot, but breaks with an TypeDoesNotMatch exception in RC-3 and 2.0 final. |
226 | 181 |
state: CLOSED |
... | ... | @@ -239,11 +194,6 @@ |
239 | 194 |
id: 1 |
240 | 195 |
- !!models.Issue |
241 | 196 |
authorId: 1 |
242 |
- assignee: !!models.Assignee |
|
243 |
- user: !!models.User |
|
244 |
- id: 3 |
|
245 |
- project: !!models.Project |
|
246 |
- id: 2 |
|
247 | 197 |
title: Update sbt-idea to 1.1.0 |
248 | 198 |
body: Create sbt project definition module, if exists, for each subproject (pull 128) |
249 | 199 |
state: CLOSED |
... | ... | @@ -253,11 +203,6 @@ |
253 | 203 |
id: 2 |
254 | 204 |
- !!models.Issue |
255 | 205 |
authorId: 1 |
256 |
- assignee: !!models.Assignee |
|
257 |
- user: !!models.User |
|
258 |
- id: 3 |
|
259 |
- project: !!models.Project |
|
260 |
- id: 2 |
|
261 | 206 |
title: Support Tuple 22, not just Tuple 18 in api/data/Forms.scala |
262 | 207 |
body: While creating some complex forms, Eclipse started hanging for some unknown reason. |
263 | 208 |
state: CLOSED |
... | ... | @@ -267,11 +212,6 @@ |
267 | 212 |
id: 2 |
268 | 213 |
- !!models.Issue |
269 | 214 |
authorId: 1 |
270 |
- assignee: !!models.Assignee |
|
271 |
- user: !!models.User |
|
272 |
- id: 3 |
|
273 |
- project: !!models.Project |
|
274 |
- id: 2 |
|
275 | 215 |
title: Support Tuple 22, not just Tuple 18 in api/data/Forms.scala |
276 | 216 |
body: While creating some complex forms, Eclipse started hanging for some unknown reason. |
277 | 217 |
state: OPEN |
... | ... | @@ -281,11 +221,6 @@ |
281 | 221 |
id: 2 |
282 | 222 |
- !!models.Issue |
283 | 223 |
authorId: 1 |
284 |
- assignee: !!models.Assignee |
|
285 |
- user: !!models.User |
|
286 |
- id: 3 |
|
287 |
- project: !!models.Project |
|
288 |
- id: 2 |
|
289 | 224 |
title: Cookie Expires date |
290 | 225 |
body: With Play 2.0.2, when creating a cookie with response().setCookie, HTTP output is like |
291 | 226 |
state: OPEN |
... | ... | @@ -295,11 +230,6 @@ |
295 | 230 |
id: 2 |
296 | 231 |
- !!models.Issue |
297 | 232 |
authorId: 1 |
298 |
- assignee: !!models.Assignee |
|
299 |
- user: !!models.User |
|
300 |
- id: 3 |
|
301 |
- project: !!models.Project |
|
302 |
- id: 2 |
|
303 | 233 |
title: require is not work in windows (Closure Compiler) |
304 | 234 |
body: Test on Play2.1-Snapshot |
305 | 235 |
state: OPEN |
... | ... | @@ -309,11 +239,6 @@ |
309 | 239 |
id: 2 |
310 | 240 |
- !!models.Issue |
311 | 241 |
authorId: 2 |
312 |
- assignee: !!models.Assignee |
|
313 |
- user: !!models.User |
|
314 |
- id: 3 |
|
315 |
- project: !!models.Project |
|
316 |
- id: 3 |
|
317 | 242 |
title: Remember me is not working |
318 | 243 |
body: Test on Play2.1-Snapshot |
319 | 244 |
state: OPEN |
--- test/models/IssueTest.java
+++ test/models/IssueTest.java
... | ... | @@ -122,10 +122,17 @@ |
122 | 122 |
|
123 | 123 |
@Test |
124 | 124 |
public void findAssigneeByIssueId() { |
125 |
+ // Given |
|
126 |
+ Long issueId = 2l; |
|
127 |
+ Long userId = 1l; |
|
128 |
+ |
|
125 | 129 |
// When |
126 |
- Long assignee = Issue.findAssigneeIdByIssueId(2l); |
|
130 |
+ Issue issue = Issue.findById(issueId); |
|
131 |
+ issue.assignee = Assignee.add(userId, issue.project.id); |
|
132 |
+ issue.save(); |
|
133 |
+ |
|
127 | 134 |
// Then |
128 |
- assertThat(assignee).isEqualTo(2l); |
|
135 |
+ assertThat(Issue.findAssigneeIdByIssueId(issueId)).isEqualTo(userId); |
|
129 | 136 |
} |
130 | 137 |
|
131 | 138 |
@Test |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?