18 package org.turro.dossier.search;
21 import org.turro.action.Contacts;
22 import org.turro.auth.Authentication;
23 import org.turro.dossier.db.DossierPU;
24 import org.turro.dossier.entity.*;
25 import org.turro.dossier.issue.IssueSet;
26 import org.turro.dossier.issue.IssueWrapper;
27 import org.turro.elephant.context.Application;
28 import org.turro.elephant.db.WhereClause;
29 import org.turro.jpa.Dao;
30 import org.turro.plugin.contacts.IContact;
31 import org.turro.util.Chars;
32 import org.zkoss.lang.Strings;
42 private String issueValue =
"*";
44 ckStartPosible =
false,
46 private IContact byParticipant, byResponsible, byReporter, byQA;
47 private Long dossierId;
49 private Set<IssueParticipantRole> roles =
new HashSet<IssueParticipantRole>();
50 private Set<IssueStatus> status =
new HashSet<IssueStatus>();
51 private Set<IssueResolution> resolutions =
new HashSet<IssueResolution>();
52 private Set<IssueType> types =
new HashSet<IssueType>();
58 types.addAll(Arrays.asList(
IssueType.values()));
69 ckStartPosible =
true;
71 ckOthers = app.
isInRole(
"issue:all");
74 types.addAll(Arrays.asList(
IssueType.values()));
82 wc.
addClause(
"select count(distinct issue) from Issue as issue");
83 wc.
addClause(
"left outer join issue.participants participant");
84 wc.
addClause(
"left outer join issue.comments comment");
93 wc.
addClause(
"select distinct issue from Issue as issue");
94 wc.
addClause(
"left outer join issue.participants participant");
95 wc.
addClause(
"left outer join issue.comments comment");
99 return new ArrayList(
new IssueSet(dao.getResultList(wc), ckStartPosible, byParticipant));
107 this.category = category;
115 this.resolutions = resolutions;
122 public void setRoles(Set<IssueParticipantRole> roles) {
131 this.status = status;
139 this.subject = subject;
151 this.types = EnumSet.of(type);
155 boolean asParticipant =
161 if(Strings.isEmpty(issueValue) || (!asParticipant && !app.
isInRole(
"issue:all"))) {
166 if(byParticipant ==
null) {
172 id = Long.valueOf(issueValue);
178 }
catch(Exception ex) {}
183 }, (issueValue ==
null ?
"" : issueValue.replaceAll(
"\\*",
"%")));
191 wc.
addClause(
"and (issue.startDate >= :startDate or issue.startDate is null)");
195 if(asParticipant && !(ckOthers && app.
isInRole(
"issue:all"))) {
199 if(roles.contains(ii)) {
203 wc.
addClause(
"participant.idContact = :idContact");
205 wc.
addClause(
"and participant.role = :" + ii.toString());
213 if(byResponsible !=
null && byResponsible.
getId() !=
null) {
215 wc.
addClause(
"participant.idContact = :idRes");
217 wc.
addClause(
"and participant.role = :byRes");
222 if(byReporter !=
null && byReporter.
getId() !=
null) {
224 wc.
addClause(
"participant.idContact = :idInf");
226 wc.
addClause(
"and participant.role = :byInf");
231 if(byQA !=
null && byQA.
getId() !=
null) {
233 wc.
addClause(
"participant.idContact = :idQA");
235 wc.
addClause(
"and participant.role = :byQA");
243 if(status.contains(ii)) {
246 wc.
addClause(
"issue.status = :" + ii.toString());
255 if(resolutions.contains(ii)) {
258 wc.
addClause(
"issue.resolution = :" + ii.toString());
267 if(types.contains(ii)) {
270 wc.
addClause(
"issue.type = :" + ii.toString());
276 if(subject !=
null) {
277 wc.
addClause(
"and exists ( select subject from Participant as subject");
278 wc.
addClause(
"where subject.dossier = issue.dossier");
279 wc.
addClause(
"and subject.idContact = :idSubject");
281 wc.
addClause(
"and subject.role = :roleSubject )");
285 if(dossier !=
null) {
286 wc.
addClause(
"and issue.dossier = :dossier");
288 }
else if(dossierId !=
null && dossierId > 0) {
289 wc.
addClause(
"and issue.dossier.id = :dossierId");
292 wc.
addClause(
"and issue.dossier.status = :dstatus");
296 if(category !=
null) {
297 wc.
addClause(
"and (issue.dossier.category.fullDescription = :decat");
299 wc.
addClause(
"or issue.dossier.category.fullDescription like :dlcat)");
311 this.ckOthers = ckOthers;
315 return ckStartPosible;
319 this.ckStartPosible = ckStartPosible;
327 this.dossier = dossier;
335 this.dossierId = dossierId;
343 this.issueValue = issueValue;
355 return byResponsible;
359 this.byResponsible = byResponsible;
367 this.byReporter = byReporter;
371 return byParticipant;
375 this.byParticipant = byParticipant;
static IContact getIContact()
String getFullDescription()
void setIssueValue(String issueValue)
Set< IssueResolution > getResolutions()
IContact getByResponsible()
void addClause(WhereClause wc)
void setByResponsible(IContact byResponsible)
void setDossierId(Long dossierId)
void setTypes(Set< IssueType > types)
Set< IssueType > getTypes()
java.util.List< IssueWrapper > getIssueList()
void setResolutions(Set< IssueResolution > resolutions)
void setType(IssueType type)
void setByReporter(IContact byReporter)
void setCategory(Category category)
void setSubject(IContact subject)
void setCkOthers(boolean ckOthers)
Set< IssueParticipantRole > getRoles()
void setDossier(Dossier dossier)
boolean isCkStartPosible()
void setByQA(IContact byQA)
void addCriteria(WhereClause wc)
void setCkStartPosible(boolean ckStartPosible)
IContact getByParticipant()
void setByParticipantId(String id)
Set< IssueStatus > getStatus()
void setRoles(Set< IssueParticipantRole > roles)
void setApplication(Application app)
void setStatus(Set< IssueStatus > status)
void setByParticipant(IContact byParticipant)
boolean isInRole(String role)
static Application getApplication()
void setPrefix(String prefix)
void addClause(String clause)
void addLikeFields(String[] fields, String value)
void addNamedValue(String name, Object value)
Object getSingleResult(WhereClause wc)