BrightSide Workbench Full Report + Source Code
org.turro.dossier.workload.WorkloadQuery Class Reference
Collaboration diagram for org.turro.dossier.workload.WorkloadQuery:

Public Member Functions

 WorkloadQuery ()
 
 WorkloadQuery (IContact contact)
 
void setApplication (Application app)
 
void markSelf ()
 
WorkloadSet getResults ()
 
Set< IssueWrappergetResultSet ()
 
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)
 
IContact getSubject ()
 
void setSubject (IContact subject)
 
Set< IssueTypegetTypes ()
 
void setTypes (Set< IssueType > types)
 
void setType (IssueType type)
 
WhereClause createCriteria ()
 
Dossier getDossier ()
 
void setDossier (Dossier dossier)
 
Long getDossierId ()
 
void setDossierId (Long dossierId)
 
String getSearchValue ()
 
void setSearchValue (String searchValue)
 
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 51 of file WorkloadQuery.java.

Constructor & Destructor Documentation

◆ WorkloadQuery() [1/2]

org.turro.dossier.workload.WorkloadQuery.WorkloadQuery ( )

Definition at line 66 of file WorkloadQuery.java.

66  {
67  resetToDefault();
68  }

◆ WorkloadQuery() [2/2]

org.turro.dossier.workload.WorkloadQuery.WorkloadQuery ( IContact  contact)

Definition at line 71 of file WorkloadQuery.java.

71  {
72  realParticipant = contact;
73  app = null;
74  resetToDefault();
75  }

Member Function Documentation

◆ createCriteria()

WhereClause org.turro.dossier.workload.WorkloadQuery.createCriteria ( )

Definition at line 183 of file WorkloadQuery.java.

183  {
184  boolean canSeeAll = app != null && app.isInRole("issue:all");
185 
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");
192  }
193  wc.addClause("where 1=1");
194 
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);
200 
201  if(Strings.isEmpty(searchValue) || (!asParticipant && !canSeeAll)) {
202  return null;
203  }
204 
205  if(byParticipant == null) {
206  byParticipant = realParticipant;
207  }
208 
209  long id = 0;
210 
211  try {
212  if(searchValue.startsWith("#") && canSeeAll) {
213  id = Long.valueOf(searchValue.substring(1));
214  if(id > 0) {
215  wc.addClause("and issue.id = :id");
216  wc.addNamedValue("id", id);
217  return wc;
218  }
219  }
220  id = Long.valueOf(searchValue);
221  if(id > 0) {
222  wc.addClause("and ((issue.id = :id)");
223  wc.addNamedValue("id", id);
224  wc.setPrefix("or");
225  }
226  } catch(Exception ex) {}
227 
228  if(searchValue.startsWith("#") && searchValue.length() > 2 && canSeeAll) {
229  wc.addLikeFields(new String[] {
230  "issue.description",
231  "comment.comment"
232  }, searchValue.substring(1).replaceAll("\\*", "%"));
233  return wc;
234  }
235 
236  if(!"*".equals(searchValue)) {
237  wc.addLikeFields(new String[] {
238  "issue.description",
239  "comment.comment"
240  }, (searchValue == null ? "" : searchValue.replaceAll("\\*", "%")));
241  }
242 
243  if(id > 0) {
244  wc.addClause(")");
245  wc.setPrefix(null);
246  }
247 
248  if(asParticipant) {
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);
254  }
255  }
256 
257  if(!status.containsAll(EnumSet.allOf(IssueStatus.class))) {
258  wc.addClause("and issue.status in (:status)");
259  wc.addNamedValue("status", status);
260  }
261 
262  if(!resolutions.containsAll(EnumSet.allOf(IssueResolution.class))) {
263  wc.addClause("and issue.resolution in (:resolutions)");
264  wc.addNamedValue("resolutions", resolutions);
265  }
266 
267  if(!types.containsAll(EnumSet.allOf(IssueType.class))) {
268  wc.addClause("and issue.type in (:types)");
269  wc.addNamedValue("types", types);
270  }
271 
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);
279  }
280 
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);
287  } else {
288  wc.addClause("and issue.dossier.status = :dstatus");
289  wc.addNamedValue("dstatus", DossierStatus.DOSSIER_OPENED);
290  }
291 
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() + "%')");
296  wc.addNamedValue("fullCatDesc", category.getFullDescription());
297  wc.addClause(")");
298  }
299 
300  if(!realParticipant.getId().equals(byParticipant.getId()) && !canSeeAll) {
301  wc.addClause("and (");
302  // dossier
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");
308  wc.addClause(")");
309  // categories
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() + "%')");
317  wc.addClause("))");
318  //
319  wc.addClause(")");
320  // parameter
321  wc.addNamedValue("idObserver", realParticipant.getId());
322  }
323 
324  return wc;
325  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getByParticipant()

IContact org.turro.dossier.workload.WorkloadQuery.getByParticipant ( )

Definition at line 351 of file WorkloadQuery.java.

351  {
352  return byParticipant;
353  }
Here is the caller graph for this function:

◆ getCategory()

Category org.turro.dossier.workload.WorkloadQuery.getCategory ( )

Definition at line 131 of file WorkloadQuery.java.

131  {
132  return category;
133  }
Here is the caller graph for this function:

◆ getDossier()

Dossier org.turro.dossier.workload.WorkloadQuery.getDossier ( )

Definition at line 327 of file WorkloadQuery.java.

327  {
328  return dossier;
329  }
Here is the caller graph for this function:

◆ getDossierId()

Long org.turro.dossier.workload.WorkloadQuery.getDossierId ( )

Definition at line 335 of file WorkloadQuery.java.

335  {
336  return dossierId;
337  }

◆ getResolutions()

Set<IssueResolution> org.turro.dossier.workload.WorkloadQuery.getResolutions ( )

Definition at line 139 of file WorkloadQuery.java.

139  {
140  return resolutions;
141  }

◆ getResults()

WorkloadSet org.turro.dossier.workload.WorkloadQuery.getResults ( )

Definition at line 99 of file WorkloadQuery.java.

99  {
100  if(byParticipant == null) {
101  byParticipant = realParticipant;
102  }
103  WorkloadSet results = new WorkloadSet();
104  if((Strings.isEmpty(searchValue) || "*".equals(searchValue)) &&
105  category == null && dossier == null && (dossierId == null || dossierId == 0)) {
106  for(Worksheet worksheet : WorksheetUtil.getWorksheet(byParticipant.getId())) {
107  if(!WorksheetUtil.cleared(worksheet, byParticipant)) {
108  results.add(new WorkloadItem(worksheet));
109  }
110  }
111  }
112  for(IssueWrapper iw : getResultSet()) {
113  WorkloadItem wi = new WorkloadItem(iw);
114  if(!results.inWorksheet(wi.getIssue().getId())) {
115  results.add(wi);
116  }
117  }
118  return results;
119  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getResultSet()

Set<IssueWrapper> org.turro.dossier.workload.WorkloadQuery.getResultSet ( )

Definition at line 121 of file WorkloadQuery.java.

121  {
122  Dao dao = new DossierPU();
123  WhereClause wc = createCriteria();
124  if(wc != null) {
125  return new IssueSet(dao.getResultList(wc), false, byParticipant);
126  } else {
127  return Collections.EMPTY_SET;
128  }
129  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRoles()

Set<IssueParticipantRole> org.turro.dossier.workload.WorkloadQuery.getRoles ( )

Definition at line 147 of file WorkloadQuery.java.

147  {
148  return roles;
149  }

◆ getSearchValue()

String org.turro.dossier.workload.WorkloadQuery.getSearchValue ( )

Definition at line 343 of file WorkloadQuery.java.

343  {
344  return searchValue;
345  }
Here is the caller graph for this function:

◆ getStatus()

Set<IssueStatus> org.turro.dossier.workload.WorkloadQuery.getStatus ( )

Definition at line 155 of file WorkloadQuery.java.

155  {
156  return status;
157  }
Here is the caller graph for this function:

◆ getSubject()

IContact org.turro.dossier.workload.WorkloadQuery.getSubject ( )

Definition at line 163 of file WorkloadQuery.java.

163  {
164  return subject;
165  }

◆ getTypes()

Set<IssueType> org.turro.dossier.workload.WorkloadQuery.getTypes ( )

Definition at line 171 of file WorkloadQuery.java.

171  {
172  return types;
173  }
Here is the caller graph for this function:

◆ markSelf()

void org.turro.dossier.workload.WorkloadQuery.markSelf ( )

Definition at line 95 of file WorkloadQuery.java.

95  {
96  resetToDefault();
97  }

◆ setApplication()

void org.turro.dossier.workload.WorkloadQuery.setApplication ( Application  app)

Definition at line 91 of file WorkloadQuery.java.

91  {
92  this.app = app;
93  }

◆ setByParticipant()

void org.turro.dossier.workload.WorkloadQuery.setByParticipant ( IContact  byParticipant)

Definition at line 355 of file WorkloadQuery.java.

355  {
356  this.byParticipant = byParticipant;
357  }
Here is the caller graph for this function:

◆ setByParticipantId()

void org.turro.dossier.workload.WorkloadQuery.setByParticipantId ( String  id)

Definition at line 359 of file WorkloadQuery.java.

359  {
360  this.byParticipant = Contacts.getContactById(id);
361  }
Here is the call graph for this function:

◆ setCategory()

void org.turro.dossier.workload.WorkloadQuery.setCategory ( Category  category)

Definition at line 135 of file WorkloadQuery.java.

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

◆ setDossier()

void org.turro.dossier.workload.WorkloadQuery.setDossier ( Dossier  dossier)

Definition at line 331 of file WorkloadQuery.java.

331  {
332  this.dossier = dossier;
333  }
Here is the caller graph for this function:

◆ setDossierId()

void org.turro.dossier.workload.WorkloadQuery.setDossierId ( Long  dossierId)

Definition at line 339 of file WorkloadQuery.java.

339  {
340  this.dossierId = dossierId;
341  }

◆ setResolutions()

void org.turro.dossier.workload.WorkloadQuery.setResolutions ( Set< IssueResolution resolutions)

Definition at line 143 of file WorkloadQuery.java.

143  {
144  this.resolutions = EnumSet.copyOf(resolutions);
145  }

◆ setRoles()

void org.turro.dossier.workload.WorkloadQuery.setRoles ( Set< IssueParticipantRole roles)

Definition at line 151 of file WorkloadQuery.java.

151  {
152  this.roles = EnumSet.copyOf(roles);
153  }

◆ setSearchValue()

void org.turro.dossier.workload.WorkloadQuery.setSearchValue ( String  searchValue)

Definition at line 347 of file WorkloadQuery.java.

347  {
348  this.searchValue = searchValue;
349  }
Here is the caller graph for this function:

◆ setStatus()

void org.turro.dossier.workload.WorkloadQuery.setStatus ( Set< IssueStatus status)

Definition at line 159 of file WorkloadQuery.java.

159  {
160  this.status = EnumSet.copyOf(status);
161  }
Here is the caller graph for this function:

◆ setSubject()

void org.turro.dossier.workload.WorkloadQuery.setSubject ( IContact  subject)

Definition at line 167 of file WorkloadQuery.java.

167  {
168  this.subject = subject;
169  }

◆ setType()

void org.turro.dossier.workload.WorkloadQuery.setType ( IssueType  type)

Definition at line 179 of file WorkloadQuery.java.

179  {
180  this.types = EnumSet.of(type);
181  }

◆ setTypes()

void org.turro.dossier.workload.WorkloadQuery.setTypes ( Set< IssueType types)

Definition at line 175 of file WorkloadQuery.java.

175  {
176  this.types = EnumSet.copyOf(types);
177  }
Here is the caller graph for this function:

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