BrightSide Workbench Full Report + Source Code
org.turro.dossier.kb.KnowledgeBaseQuery Class Reference

Public Member Functions

 KnowledgeBaseQuery ()
 
 KnowledgeBaseQuery (IContact contact)
 
KnowledgeBaseList getResultList ()
 
Category getCategory ()
 
void setCategory (Category category)
 
Set< IssueResolutiongetResolutions ()
 
void setResolutions (Set< IssueResolution > resolutions)
 
Set< IssueParticipantRolegetRoles ()
 
void setRoles (Set< IssueParticipantRole > roles)
 
Set< IssueStatusgetStatus ()
 
void setStatus (Set< IssueStatus > status)
 
Set< IssueTypegetTypes ()
 
void setTypes (Set< IssueType > types)
 
void setType (IssueType type)
 
int getMaxResults ()
 
void setMaxResults (int maxResults)
 
WhereClause createCriteria ()
 
Dossier getDossier ()
 
void setDossier (Dossier dossier)
 
Long getDossierId ()
 
void setDossierId (Long dossierId)
 
String getSearchValue ()
 
void setSearchValue (String searchValue)
 
boolean isOnlyTitle ()
 
void setOnlyTitle (boolean onlyTitle)
 
IContact getByParticipant ()
 
void setByParticipant (IContact byParticipant)
 
void setByParticipantId (String id)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 44 of file KnowledgeBaseQuery.java.

Constructor & Destructor Documentation

◆ KnowledgeBaseQuery() [1/2]

org.turro.dossier.kb.KnowledgeBaseQuery.KnowledgeBaseQuery ( )

Definition at line 59 of file KnowledgeBaseQuery.java.

59  {
60  resetToDefault();
61  realContact = Authentication.getIContact();
62  }
Here is the call graph for this function:

◆ KnowledgeBaseQuery() [2/2]

org.turro.dossier.kb.KnowledgeBaseQuery.KnowledgeBaseQuery ( IContact  contact)

Definition at line 64 of file KnowledgeBaseQuery.java.

64  {
65  resetToDefault();
66  realContact = contact;
67  }

Member Function Documentation

◆ createCriteria()

WhereClause org.turro.dossier.kb.KnowledgeBaseQuery.createCriteria ( )

Definition at line 138 of file KnowledgeBaseQuery.java.

138  {
139  WhereClause wc = new WhereClause();
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");
144 
145  boolean asParticipant = false;
146 
147  if(byParticipant != null && byParticipant.isValid()) {
148  asParticipant = roles.isEmpty() ||
149  roles.contains(IssueParticipantRole.ISSUE_REPORTER) ||
150  roles.contains(IssueParticipantRole.ISSUE_RESPONSIBLE) ||
151  roles.contains(IssueParticipantRole.ISSUE_QA) ||
152  roles.contains(IssueParticipantRole.ISSUE_ASSISTANT);
153  }
154 
155  if(Strings.isEmpty(searchValue)) {
156  return null;
157  }
158 
159  try {
160  long id = Long.valueOf(searchValue);
161  if(id > 0) {
162  wc.addClause("and issue.id = :id");
163  wc.addNamedValue("id", id);
164  return wc;
165  }
166  } catch(Exception ex) {}
167 
168  if(onlyTitle) {
169  wc.addLikeFields(new String[] {
170  "issue.description"
171  }, (searchValue == null ? "" : searchValue.replaceAll("\\*", "%")));
172  } else {
173  wc.addLikeFields(new String[] {
174  "issue.description",
175  "comment.comment"
176  }, (searchValue == null ? "" : searchValue.replaceAll("\\*", "%")));
177  }
178 
179  if(asParticipant) {
180  String sep = "";
181  wc.addClause("and (");
182  if(roles.isEmpty()) {
183  wc.addClause("(");
184  wc.addClause("participant.idContact = :idContact");
185  wc.addNamedValue("idContact", byParticipant.getId());
186  wc.addClause(")");
187  } else {
188  for(IssueParticipantRole ii : roles) {
189  wc.addClause(sep);
190  sep = "or";
191  wc.addClause("(");
192  wc.addClause("participant.idContact = :idContact");
193  wc.addNamedValue("idContact", byParticipant.getId());
194  wc.addClause("and participant.role = :" + ii.toString());
195  wc.addNamedValue(ii.toString(), ii);
196  wc.addClause(")");
197  }
198  }
199  wc.addClause(")");
200  }
201 
202  if(!status.isEmpty()) {
203  String sep = "";
204  wc.addClause("and (");
205  for(IssueStatus ii : status) {
206  wc.addClause(sep);
207  sep = "or";
208  wc.addClause("issue.status = :" + ii.toString());
209  wc.addNamedValue(ii.toString(), ii);
210  }
211  wc.addClause(")");
212  }
213 
214  if(!resolutions.isEmpty()) {
215  String sep = "";
216  wc.addClause("and (");
217  for(IssueResolution ii : resolutions) {
218  wc.addClause(sep);
219  sep = "or";
220  wc.addClause("issue.resolution = :" + ii.toString());
221  wc.addNamedValue(ii.toString(), ii);
222  }
223  wc.addClause(")");
224  }
225 
226  if(!types.isEmpty()) {
227  String sep = "";
228  wc.addClause("and (");
229  for(IssueType ii : types) {
230  wc.addClause(sep);
231  sep = "or";
232  wc.addClause("issue.type = :" + ii.toString());
233  wc.addNamedValue(ii.toString(), ii);
234  }
235  wc.addClause(")");
236  }
237 
238  if(dossier != null) {
239  wc.addClause("and issue.dossier = :dossier");
240  wc.addNamedValue("dossier", dossier);
241  } else if(dossierId != null && dossierId > 0) {
242  wc.addClause("and issue.dossier.id = :dossierId");
243  wc.addNamedValue("dossierId", dossierId);
244  } else {
245  wc.addClause("and issue.dossier.status = :dstatus");
246  wc.addNamedValue("dstatus", DossierStatus.DOSSIER_OPENED);
247  }
248 
249  if(category != null) {
250  wc.addClause("and (");
251  wc.addClause("issue.dossier.category.fullDescription = :fullCatDesc");
252  wc.addClause("or issue.dossier.category.fullDescription like concat(:fullCatDesc, '" + Chars.backward().spaced() + "%')");
253  wc.addNamedValue("fullCatDesc", category.getFullDescription());
254  wc.addClause(")");
255  }
256 
257  wc.addClause("order by issue.modification desc");
258 
259  return wc;
260  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getByParticipant()

IContact org.turro.dossier.kb.KnowledgeBaseQuery.getByParticipant ( )

Definition at line 294 of file KnowledgeBaseQuery.java.

294  {
295  return byParticipant;
296  }
Here is the caller graph for this function:

◆ getCategory()

Category org.turro.dossier.kb.KnowledgeBaseQuery.getCategory ( )

Definition at line 86 of file KnowledgeBaseQuery.java.

86  {
87  return category;
88  }
Here is the caller graph for this function:

◆ getDossier()

Dossier org.turro.dossier.kb.KnowledgeBaseQuery.getDossier ( )

Definition at line 262 of file KnowledgeBaseQuery.java.

262  {
263  return dossier;
264  }
Here is the caller graph for this function:

◆ getDossierId()

Long org.turro.dossier.kb.KnowledgeBaseQuery.getDossierId ( )

Definition at line 270 of file KnowledgeBaseQuery.java.

270  {
271  return dossierId;
272  }
Here is the caller graph for this function:

◆ getMaxResults()

int org.turro.dossier.kb.KnowledgeBaseQuery.getMaxResults ( )

Definition at line 130 of file KnowledgeBaseQuery.java.

130  {
131  return maxResults;
132  }
Here is the caller graph for this function:

◆ getResolutions()

Set<IssueResolution> org.turro.dossier.kb.KnowledgeBaseQuery.getResolutions ( )

Definition at line 94 of file KnowledgeBaseQuery.java.

94  {
95  return resolutions;
96  }
Here is the caller graph for this function:

◆ getResultList()

KnowledgeBaseList org.turro.dossier.kb.KnowledgeBaseQuery.getResultList ( )

Definition at line 76 of file KnowledgeBaseQuery.java.

76  {
77  Dao dao = new DossierPU();
78  WhereClause wc = createCriteria();
79  if(wc != null) {
80  return new KnowledgeBaseList(dao.getResultList(wc, maxResults), realContact);
81  } else {
82  return new KnowledgeBaseList(Collections.EMPTY_LIST, realContact);
83  }
84  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRoles()

Set<IssueParticipantRole> org.turro.dossier.kb.KnowledgeBaseQuery.getRoles ( )

Definition at line 102 of file KnowledgeBaseQuery.java.

102  {
103  return roles;
104  }

◆ getSearchValue()

String org.turro.dossier.kb.KnowledgeBaseQuery.getSearchValue ( )

Definition at line 278 of file KnowledgeBaseQuery.java.

278  {
279  return searchValue;
280  }
Here is the caller graph for this function:

◆ getStatus()

Set<IssueStatus> org.turro.dossier.kb.KnowledgeBaseQuery.getStatus ( )

Definition at line 110 of file KnowledgeBaseQuery.java.

110  {
111  return status;
112  }
Here is the caller graph for this function:

◆ getTypes()

Set<IssueType> org.turro.dossier.kb.KnowledgeBaseQuery.getTypes ( )

Definition at line 118 of file KnowledgeBaseQuery.java.

118  {
119  return types;
120  }
Here is the caller graph for this function:

◆ isOnlyTitle()

boolean org.turro.dossier.kb.KnowledgeBaseQuery.isOnlyTitle ( )

Definition at line 286 of file KnowledgeBaseQuery.java.

286  {
287  return onlyTitle;
288  }
Here is the caller graph for this function:

◆ setByParticipant()

void org.turro.dossier.kb.KnowledgeBaseQuery.setByParticipant ( IContact  byParticipant)

Definition at line 298 of file KnowledgeBaseQuery.java.

298  {
299  this.byParticipant = byParticipant;
300  }
Here is the caller graph for this function:

◆ setByParticipantId()

void org.turro.dossier.kb.KnowledgeBaseQuery.setByParticipantId ( String  id)

Definition at line 302 of file KnowledgeBaseQuery.java.

302  {
303  this.byParticipant = Contacts.getContactById(id);
304  }
Here is the call graph for this function:

◆ setCategory()

void org.turro.dossier.kb.KnowledgeBaseQuery.setCategory ( Category  category)

Definition at line 90 of file KnowledgeBaseQuery.java.

90  {
91  this.category = category;
92  }
Here is the caller graph for this function:

◆ setDossier()

void org.turro.dossier.kb.KnowledgeBaseQuery.setDossier ( Dossier  dossier)

Definition at line 266 of file KnowledgeBaseQuery.java.

266  {
267  this.dossier = dossier;
268  }
Here is the caller graph for this function:

◆ setDossierId()

void org.turro.dossier.kb.KnowledgeBaseQuery.setDossierId ( Long  dossierId)

Definition at line 274 of file KnowledgeBaseQuery.java.

274  {
275  this.dossierId = dossierId;
276  }
Here is the caller graph for this function:

◆ setMaxResults()

void org.turro.dossier.kb.KnowledgeBaseQuery.setMaxResults ( int  maxResults)

Definition at line 134 of file KnowledgeBaseQuery.java.

134  {
135  this.maxResults = maxResults;
136  }
Here is the caller graph for this function:

◆ setOnlyTitle()

void org.turro.dossier.kb.KnowledgeBaseQuery.setOnlyTitle ( boolean  onlyTitle)

Definition at line 290 of file KnowledgeBaseQuery.java.

290  {
291  this.onlyTitle = onlyTitle;
292  }
Here is the caller graph for this function:

◆ setResolutions()

void org.turro.dossier.kb.KnowledgeBaseQuery.setResolutions ( Set< IssueResolution resolutions)

Definition at line 98 of file KnowledgeBaseQuery.java.

98  {
99  this.resolutions = resolutions.isEmpty() ? EnumSet.noneOf(IssueResolution.class) : EnumSet.copyOf(resolutions);
100  }
Here is the caller graph for this function:

◆ setRoles()

void org.turro.dossier.kb.KnowledgeBaseQuery.setRoles ( Set< IssueParticipantRole roles)

Definition at line 106 of file KnowledgeBaseQuery.java.

106  {
107  this.roles = EnumSet.copyOf(roles);
108  }

◆ setSearchValue()

void org.turro.dossier.kb.KnowledgeBaseQuery.setSearchValue ( String  searchValue)

Definition at line 282 of file KnowledgeBaseQuery.java.

282  {
283  this.searchValue = searchValue;
284  }
Here is the caller graph for this function:

◆ setStatus()

void org.turro.dossier.kb.KnowledgeBaseQuery.setStatus ( Set< IssueStatus status)

Definition at line 114 of file KnowledgeBaseQuery.java.

114  {
115  this.status = status.isEmpty() ? EnumSet.noneOf(IssueStatus.class) : EnumSet.copyOf(status);
116  }
Here is the caller graph for this function:

◆ setType()

void org.turro.dossier.kb.KnowledgeBaseQuery.setType ( IssueType  type)

Definition at line 126 of file KnowledgeBaseQuery.java.

126  {
127  this.types = EnumSet.of(type);
128  }

◆ setTypes()

void org.turro.dossier.kb.KnowledgeBaseQuery.setTypes ( Set< IssueType types)

Definition at line 122 of file KnowledgeBaseQuery.java.

122  {
123  this.types = types.isEmpty() ? EnumSet.noneOf(IssueType.class) : EnumSet.copyOf(types);
124  }
Here is the caller graph for this function:

The documentation for this class was generated from the following file: