19 package org.turro.dossier.kb;
21 import java.util.Collections;
22 import java.util.EnumSet;
24 import org.turro.string.Strings;
25 import org.turro.action.Contacts;
26 import org.turro.auth.Authentication;
27 import org.turro.dossier.db.DossierPU;
28 import org.turro.dossier.entity.Category;
29 import org.turro.dossier.entity.Dossier;
30 import org.turro.dossier.entity.DossierStatus;
31 import org.turro.dossier.entity.IssueParticipantRole;
32 import org.turro.dossier.entity.IssueResolution;
33 import org.turro.dossier.entity.IssueStatus;
34 import org.turro.dossier.entity.IssueType;
35 import org.turro.elephant.db.WhereClause;
36 import org.turro.jpa.Dao;
37 import org.turro.plugin.contacts.IContact;
38 import org.turro.util.Chars;
46 private String searchValue =
"";
49 private Long dossierId;
52 private EnumSet<IssueStatus> status = EnumSet.noneOf(
IssueStatus.class);
53 private EnumSet<IssueResolution> resolutions = EnumSet.noneOf(
IssueResolution.class);
54 private EnumSet<IssueType> types = EnumSet.noneOf(
IssueType.class);
56 private int maxResults = 300;
57 private boolean onlyTitle =
false;
66 realContact = contact;
69 private void resetToDefault() {
91 this.category = category;
99 this.resolutions = resolutions.isEmpty() ? EnumSet.noneOf(
IssueResolution.class) : EnumSet.copyOf(resolutions);
106 public void setRoles(Set<IssueParticipantRole> roles) {
107 this.roles = EnumSet.copyOf(roles);
115 this.status = status.isEmpty() ? EnumSet.noneOf(
IssueStatus.class) : EnumSet.copyOf(status);
123 this.types = types.isEmpty() ? EnumSet.noneOf(
IssueType.class) : EnumSet.copyOf(types);
127 this.types = EnumSet.of(type);
135 this.maxResults = maxResults;
140 wc.
addClause(
"select distinct issue from Issue as issue");
141 wc.
addClause(
"left outer join issue.participants participant");
142 wc.
addClause(
"left outer join issue.comments comment");
143 wc.
addClause(
"where issue.publishable = TRUE");
145 boolean asParticipant =
false;
147 if(byParticipant !=
null && byParticipant.
isValid()) {
148 asParticipant = roles.isEmpty() ||
155 if(Strings.isEmpty(searchValue)) {
160 long id = Long.valueOf(searchValue);
166 }
catch(Exception ex) {}
171 }, (searchValue ==
null ?
"" : searchValue.replaceAll(
"\\*",
"%")));
176 }, (searchValue ==
null ?
"" : searchValue.replaceAll(
"\\*",
"%")));
182 if(roles.isEmpty()) {
184 wc.
addClause(
"participant.idContact = :idContact");
192 wc.
addClause(
"participant.idContact = :idContact");
194 wc.
addClause(
"and participant.role = :" + ii.toString());
202 if(!status.isEmpty()) {
208 wc.
addClause(
"issue.status = :" + ii.toString());
214 if(!resolutions.isEmpty()) {
220 wc.
addClause(
"issue.resolution = :" + ii.toString());
226 if(!types.isEmpty()) {
232 wc.
addClause(
"issue.type = :" + ii.toString());
238 if(dossier !=
null) {
239 wc.
addClause(
"and issue.dossier = :dossier");
241 }
else if(dossierId !=
null && dossierId > 0) {
242 wc.
addClause(
"and issue.dossier.id = :dossierId");
245 wc.
addClause(
"and issue.dossier.status = :dstatus");
249 if(category !=
null) {
251 wc.
addClause(
"issue.dossier.category.fullDescription = :fullCatDesc");
252 wc.
addClause(
"or issue.dossier.category.fullDescription like concat(:fullCatDesc, '" + Chars.backward().spaced() +
"%')");
257 wc.
addClause(
"order by issue.modification desc");
267 this.dossier = dossier;
275 this.dossierId = dossierId;
283 this.searchValue = searchValue;
291 this.onlyTitle = onlyTitle;
295 return byParticipant;
299 this.byParticipant = byParticipant;
static IContact getIContact()
String getFullDescription()
void setSearchValue(String searchValue)
void setDossier(Dossier dossier)
void setResolutions(Set< IssueResolution > resolutions)
Set< IssueType > getTypes()
void setByParticipant(IContact byParticipant)
void setRoles(Set< IssueParticipantRole > roles)
void setTypes(Set< IssueType > types)
WhereClause createCriteria()
IContact getByParticipant()
void setCategory(Category category)
void setType(IssueType type)
KnowledgeBaseList getResultList()
KnowledgeBaseQuery(IContact contact)
void setStatus(Set< IssueStatus > status)
void setDossierId(Long dossierId)
void setOnlyTitle(boolean onlyTitle)
void setByParticipantId(String id)
Set< IssueStatus > getStatus()
Set< IssueParticipantRole > getRoles()
Set< IssueResolution > getResolutions()
void setMaxResults(int maxResults)
void addClause(String clause)
void addLikeFields(String[] fields, String value)
void addNamedValue(String name, Object value)