184 boolean canSeeAll = app !=
null && app.
isInRole(
"issue:all");
186 WhereClause wc =
new WhereClause();
187 wc.addClause(
"select distinct issue from Issue as issue");
188 wc.addClause(
"left outer join issue.participants participant");
189 wc.addClause(
"left outer join issue.sources source");
190 if(!
"*".equals(searchValue)) {
191 wc.addClause(
"left outer join issue.comments comment");
193 wc.addClause(
"where 1=1");
195 boolean asParticipant =
196 roles.contains(IssueParticipantRole.ISSUE_REPORTER) ||
197 roles.contains(IssueParticipantRole.ISSUE_RESPONSIBLE) ||
198 roles.contains(IssueParticipantRole.ISSUE_QA) ||
199 roles.contains(IssueParticipantRole.ISSUE_ASSISTANT);
201 if(Strings.isEmpty(searchValue) || (!asParticipant && !canSeeAll)) {
205 if(byParticipant ==
null) {
206 byParticipant = realParticipant;
212 if(searchValue.startsWith(
"#") && canSeeAll) {
213 id = Long.valueOf(searchValue.substring(1));
215 wc.addClause(
"and issue.id = :id");
216 wc.addNamedValue(
"id",
id);
220 id = Long.valueOf(searchValue);
222 wc.addClause(
"and ((issue.id = :id)");
223 wc.addNamedValue(
"id",
id);
226 }
catch(Exception ex) {}
228 if(searchValue.startsWith(
"#") && searchValue.length() > 2 && canSeeAll) {
229 wc.addLikeFields(
new String[] {
232 }, searchValue.substring(1).replaceAll(
"\\*",
"%"));
236 if(!
"*".equals(searchValue)) {
237 wc.addLikeFields(
new String[] {
240 }, (searchValue ==
null ?
"" : searchValue.replaceAll(
"\\*",
"%")));
249 wc.addClause(
"and participant.idContact = :idContact");
250 wc.addNamedValue(
"idContact", byParticipant.
getId());
251 if(!roles.containsAll(EnumSet.allOf(IssueParticipantRole.class))) {
252 wc.addClause(
"and participant.role in (:roles)");
253 wc.addNamedValue(
"roles", roles);
257 if(!status.containsAll(EnumSet.allOf(IssueStatus.class))) {
258 wc.addClause(
"and issue.status in (:status)");
259 wc.addNamedValue(
"status", status);
262 if(!resolutions.containsAll(EnumSet.allOf(IssueResolution.class))) {
263 wc.addClause(
"and issue.resolution in (:resolutions)");
264 wc.addNamedValue(
"resolutions", resolutions);
267 if(!types.containsAll(EnumSet.allOf(IssueType.class))) {
268 wc.addClause(
"and issue.type in (:types)");
269 wc.addNamedValue(
"types", types);
272 if(subject !=
null) {
273 wc.addClause(
"and exists ( select subject from Participant as subject");
274 wc.addClause(
"where subject.dossier = issue.dossier");
275 wc.addClause(
"and subject.idContact = :idSubject");
276 wc.addNamedValue(
"idSubject", subject.
getId());
277 wc.addClause(
"and subject.role = :roleSubject )");
278 wc.addNamedValue(
"roleSubject", ParticipantRole.PARTICIPANT_SUBJECT);
281 if(dossier !=
null) {
282 wc.addClause(
"and issue.dossier = :dossier");
283 wc.addNamedValue(
"dossier", dossier);
284 }
else if(dossierId !=
null && dossierId > 0) {
285 wc.addClause(
"and issue.dossier.id = :dossierId");
286 wc.addNamedValue(
"dossierId", dossierId);
288 wc.addClause(
"and issue.dossier.status = :dstatus");
289 wc.addNamedValue(
"dstatus", DossierStatus.DOSSIER_OPENED);
292 if(category !=
null) {
293 wc.addClause(
"and (");
294 wc.addClause(
"issue.dossier.category.fullDescription = :fullCatDesc");
295 wc.addClause(
"or issue.dossier.category.fullDescription like concat(:fullCatDesc, '" + Chars.backward().spaced() +
"%')");
300 if(!realParticipant.
getId().equals(byParticipant.
getId()) && !canSeeAll) {
301 wc.addClause(
"and (");
303 wc.addClause(
"exists (");
304 wc.addClause(
"select p from Participant as p");
305 wc.addClause(
"where p.dossier = issue.dossier");
306 wc.addClause(
"and p.idContact = :idObserver");
307 wc.addClause(
"and p.showAllIssues = TRUE");
310 wc.addClause(
"or exists (");
311 wc.addClause(
"select cp from CategoryParticipant as cp");
312 wc.addClause(
"where cp.idContact = :idObserver");
313 wc.addClause(
"and cp.showAllIssues = TRUE");
314 wc.addClause(
"and (");
315 wc.addClause(
"cp.category.fullDescription = issue.dossier.category.fullDescription");
316 wc.addClause(
"or issue.dossier.category.fullDescription like concat(cp.category.fullDescription, '" + Chars.backward().spaced() +
"%')");
321 wc.addNamedValue(
"idObserver", realParticipant.
getId());
String getFullDescription()
boolean isInRole(String role)