BrightSide Workbench Full Report + Source Code
org.turro.dossier.search.DossierResults Class Reference

Public Member Functions

 DossierResults ()
 
void markAll ()
 
long getDossierCount ()
 
java.util.List< DossiergetDossierList ()
 
java.util.List< DossierIdsgetDossierIdList ()
 
Category getCategory ()
 
void setCategory (Category category)
 
Set< ParticipantRolegetRoles ()
 
void setRoles (Set< ParticipantRole > roles)
 
Set< DossierStatusgetStatus ()
 
void setStatus (Set< DossierStatus > status)
 
Set< DossierTypegetType ()
 
void setType (Set< DossierType > type)
 
void setOrderBy (String orderBy)
 
void addCriteria (WhereClause wc)
 
boolean isCkOthers ()
 
void setCkOthers (boolean ckOthers)
 
String getDossierValue ()
 
void setDossierValue (String dossierValue)
 
IContact getByParticipant ()
 
void setByParticipant (IContact byParticipant)
 
Contact getSubject ()
 
void setSubject (Contact subject)
 

Static Public Member Functions

static void addSubjectAffiliance (WhereClause wc, String sep, String id, String dossier)
 
static String getCategoryJoins ()
 
static void addCategoryConditionals (WhereClause wc, String sep, String id, ParticipantRole participantRole, String operator)
 
static void addCategoryAffiliance (WhereClause wc, Category category, String field)
 

Static Public Attributes

static final int CATEGORY_SQL_ITERATIONS = 5
 

Detailed Description

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

Definition at line 43 of file DossierResults.java.

Constructor & Destructor Documentation

◆ DossierResults()

org.turro.dossier.search.DossierResults.DossierResults ( )

Definition at line 59 of file DossierResults.java.

59  {
60  roles.add(ParticipantRole.PARTICIPANT_OWNER);
61  roles.add(ParticipantRole.PARTICIPANT_ASSISTANT);
62 
63  status.add(DossierStatus.DOSSIER_OPENED);
64 
65  type.add(DossierType.TYPE_DOSSIER);
66  type.add(DossierType.TYPE_ELECTION);
67  type.add(DossierType.TYPE_PROJECT);
68  type.add(DossierType.TYPE_PROPOSAL);
69  type.add(DossierType.TYPE_SECRET_ELECTION);
70  type.add(DossierType.TYPE_SECRET_PROPOSAL);
71  }

Member Function Documentation

◆ addCategoryAffiliance()

static void org.turro.dossier.search.DossierResults.addCategoryAffiliance ( WhereClause  wc,
Category  category,
String  field 
)
static

Definition at line 400 of file DossierResults.java.

400  {
401  for(int i = 0; i < CATEGORY_SQL_ITERATIONS; i++) {
402  StringBuilder sb = new StringBuilder(field);
403  for(int ci = 0; ci < i; ci++) {
404  sb.append(".parent");
405  }
406  wc.addClause(sb.toString() + " = :category" + i);
407  wc.addNamedValue("category" + i, category);
408  if(i < CATEGORY_SQL_ITERATIONS - 1) wc.addClause("or");
409  }
410  }
Here is the call graph for this function:

◆ addCategoryConditionals()

static void org.turro.dossier.search.DossierResults.addCategoryConditionals ( WhereClause  wc,
String  sep,
String  id,
ParticipantRole  participantRole,
String  operator 
)
static

Definition at line 386 of file DossierResults.java.

387  {
388  for(int i = 0; i < CATEGORY_SQL_ITERATIONS; i++) {
389  wc.addClause(sep);
390  wc.addClause("(");
391  wc.addClause("cparticipant" + i + ".idContact = :idContact" + participantRole.name() + i);
392  wc.addNamedValue("idContact" + participantRole.name() + i, id);
393  wc.addClause("and cparticipant" + i + ".role " + operator + " :" + participantRole.name() + i);
394  wc.addNamedValue(participantRole.name() + i, participantRole);
395  wc.addClause(")");
396  }
397  }
Here is the call graph for this function:

◆ addCriteria()

void org.turro.dossier.search.DossierResults.addCriteria ( WhereClause  wc)

Definition at line 161 of file DossierResults.java.

161  {
162  boolean asParticipant =
163  roles.contains(ParticipantRole.PARTICIPANT_OWNER) ||
164  roles.contains(ParticipantRole.PARTICIPANT_ASSISTANT);
165 
166  if(Strings.isEmpty(dossierValue) || (!asParticipant && !app.isInRole("dossier:all"))) {
167  wc.addClause("and 0=1");
168  return;
169  }
170 
171  if(byParticipant == null) {
172  byParticipant = Authentication.getIContact();
173  }
174 
175  wc.addClause("and ((");
176  wc.setPrefix("");
177  wc.addLikeFields(new String[] {
178  "dossier.description"
179  }, (dossierValue == null ? "" : dossierValue.replaceAll("\\*", "%")));
180  wc.setPrefix(null);
181  wc.addClause("or exists (select fieldValue from dossier.fieldValues fieldValue where 1=1");
182  wc.addLikeFields(new String[] {
183  "fieldValue.value"
184  }, (dossierValue == null ? "" : dossierValue.replaceAll("\\*", "%")));
185  wc.setPrefix("");
186  wc.addClause("or (fieldValue.value = 'true' and");
187  wc.addLikeFields(new String[] {
188  "fieldValue.fieldDef.labelKey"
189  }, (dossierValue == null ? "" : dossierValue.replaceAll("\\*", "%")));
190  wc.setPrefix(null);
191  wc.addClause("))");
192  wc.addClause("or exists (select parsub from dossier.participants parsub where parsub.role = :subrole");
193  wc.addNamedValue("subrole", ParticipantRole.PARTICIPANT_SUBJECT);
194  wc.addLikeFields(new String[] {
195  "parsub.name"
196  }, (dossierValue == null ? "" : dossierValue.replaceAll("\\*", "%")));
197  wc.addClause("))");
198 
199 // wc = SQLHelper.getWhereClause(new String[] {
200 // "dossier.description",
201 // "fieldValue.value"
202 // }, (dossierValue == null ? "" : dossierValue.replaceAll("\\*", "%")));
203 
204  long id;
205  try {
206  id = Long.valueOf(dossierValue);
207  if(id > 0) {
208  wc.addClause("or dossier.id = :id");
209  wc.addNamedValue("id", id);
210  }
211  } catch(Exception ex) {}
212 
213  wc.addClause(")");
214 
215  if(asParticipant && !(ckOthers && app.isInRole("dossier:all"))) {
216  wc.addClause("and (");
217  wc.addClause("(");
218  wc.addClause("participant.idContact = :idContact");
219  wc.addNamedValue("idContact", byParticipant.getId());
220  wc.addClause("and (participant.role = :cpdrole1 or participant.role = :cpdrole2)");
221  wc.addNamedValue("cpdrole1", ParticipantRole.PARTICIPANT_OWNER);
222  wc.addNamedValue("cpdrole2", ParticipantRole.PARTICIPANT_ASSISTANT);
223  wc.addClause(")");
224  CategoryResults.addParticipantAffiliance(wc, "or", byParticipant.getId(), "dossier");
225  //addCategoryConditionals(wc, sep, byParticipant.getId(), ParticipantRole.PARTICIPANT_OWNER, "=");
226  wc.addClause(")");
227  }
228 
229  String sep = "";
230  wc.addClause("and (");
231  if(status.contains(DossierStatus.DOSSIER_OPENED)) {
232  wc.addClause(sep);
233  sep = "or";
234  wc.addClause("dossier.status = :statusOpened");
235  wc.addNamedValue("statusOpened", DossierStatus.DOSSIER_OPENED);
236  }
237  if(status.contains(DossierStatus.DOSSIER_CLOSED)) {
238  wc.addClause(sep);
239  sep = "or";
240  wc.addClause("dossier.status = :statusClosed");
241  wc.addNamedValue("statusClosed", DossierStatus.DOSSIER_CLOSED);
242  }
243  if(status.contains(DossierStatus.DOSSIER_FROZEN)) {
244  wc.addClause(sep);
245  sep = "or";
246  wc.addClause("dossier.status = :statusFrozen");
247  wc.addNamedValue("statusFrozen", DossierStatus.DOSSIER_FROZEN);
248  }
249  wc.addClause(")");
250 
251  sep = "";
252  wc.addClause("and (");
253  if(type.contains(DossierType.TYPE_DOSSIER)) {
254  wc.addClause(sep);
255  sep = "or";
256  wc.addClause("dossier.type = :typeDossier");
257  wc.addNamedValue("typeDossier", DossierType.TYPE_DOSSIER);
258  }
259  if(type.contains(DossierType.TYPE_ELECTION)) {
260  wc.addClause(sep);
261  sep = "or";
262  wc.addClause("dossier.type = :typeElection");
263  wc.addNamedValue("typeElection", DossierType.TYPE_ELECTION);
264  }
265  if(type.contains(DossierType.TYPE_PROJECT)) {
266  wc.addClause(sep);
267  sep = "or";
268  wc.addClause("dossier.type = :typeProject");
269  wc.addNamedValue("typeProject", DossierType.TYPE_PROJECT);
270  }
271  if(type.contains(DossierType.TYPE_PROPOSAL)) {
272  wc.addClause(sep);
273  sep = "or";
274  wc.addClause("dossier.type = :typeProposal");
275  wc.addNamedValue("typeProposal", DossierType.TYPE_PROPOSAL);
276  }
277  if(type.contains(DossierType.TYPE_SECRET_ELECTION)) {
278  wc.addClause(sep);
279  sep = "or";
280  wc.addClause("dossier.type = :typeSecElection");
281  wc.addNamedValue("typeSecElection", DossierType.TYPE_SECRET_ELECTION);
282  }
283  if(type.contains(DossierType.TYPE_SECRET_PROPOSAL)) {
284  wc.addClause(sep);
285  sep = "or";
286  wc.addClause("dossier.type = :typeSecProposal");
287  wc.addNamedValue("typeSecProposal", DossierType.TYPE_SECRET_PROPOSAL);
288  }
289  wc.addClause(")");
290 
291  if(subject != null) {
292  wc.addClause("and ((");
293  wc.addClause("exists ( select subject from Participant as subject");
294  wc.addClause("where subject.dossier = dossier");
295  wc.addClause("and subject.idContact = :idSubject");
296  wc.addNamedValue("idSubject", subject.getId());
297  wc.addClause("and subject.role = :roleSubject )");
298  wc.addNamedValue("roleSubject", ParticipantRole.PARTICIPANT_SUBJECT);
299  wc.addClause(") or (");
300  wc.addClause("exists ( select csubject from CategoryParticipant as csubject");
301  wc.addClause("where csubject.category = dossier.category");
302  wc.addClause("and csubject.idContact = :cidSubject");
303  wc.addNamedValue("cidSubject", subject.getId());
304  wc.addClause("and csubject.role = :croleSubject )");
305  wc.addNamedValue("croleSubject", ParticipantRole.PARTICIPANT_SUBJECT);
306  wc.addClause("))");
307  }
308 
309  if(category != null) {
310  wc.addClause("and (dossier.category.fullDescription = :decat");
311  wc.addNamedValue("decat", category.getFullDescription());
312  wc.addClause("or dossier.category.fullDescription like :dlcat)");
313  wc.addNamedValue("dlcat", category.getFullDescription() + Chars.backward().spaced() + "%");
314 // wc.addClause("and (");
315 // addCategoryAffiliance(wc, category, "dossier.category");
316 // wc.addClause(")");
317  }
318 
319  if(!Strings.isBlank(orderBy)) {
320  wc.addClause(orderBy);
321  }
322  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addSubjectAffiliance()

static void org.turro.dossier.search.DossierResults.addSubjectAffiliance ( WhereClause  wc,
String  sep,
String  id,
String  dossier 
)
static

Definition at line 357 of file DossierResults.java.

358  {
359  wc.addClause(sep + " exists (");
360  wc.addClause("select cp from CategoryParticipant as cp");
361  wc.addClause("where cp.idContact = :idContact");
362  wc.addNamedValue("idContact", id);
363  wc.addClause("and cp.role = :cprole");
364  wc.addNamedValue("cprole", ParticipantRole.PARTICIPANT_SUBJECT);
365  wc.addClause("and (");
366  wc.addClause("cp.category.fullDescription = " + dossier + ".category.fullDescription");
367  wc.addClause("or " + dossier + ".category.fullDescription like concat(cp.category.fullDescription, '" + Chars.backward().spaced() + "%')");
368  wc.addClause("))");
369  }
Here is the call graph for this function:

◆ getByParticipant()

IContact org.turro.dossier.search.DossierResults.getByParticipant ( )

Definition at line 340 of file DossierResults.java.

340  {
341  return byParticipant;
342  }
Here is the caller graph for this function:

◆ getCategory()

Category org.turro.dossier.search.DossierResults.getCategory ( )

Definition at line 125 of file DossierResults.java.

125  {
126  return category;
127  }
Here is the caller graph for this function:

◆ getCategoryJoins()

static String org.turro.dossier.search.DossierResults.getCategoryJoins ( )
static

Definition at line 372 of file DossierResults.java.

372  {
373  StringBuilder sb = new StringBuilder(
374  " left outer join dossier.category.participants cparticipant");
375  for(int i = 0; i < CATEGORY_SQL_ITERATIONS; i++) {
376  sb.append(" left outer join dossier.category");
377  for(int c = 0; c < i; c++) {
378  sb.append(".parent");
379  }
380  sb.append(".participants cparticipant" + i);
381  }
382  return sb.toString();
383  }

◆ getDossierCount()

long org.turro.dossier.search.DossierResults.getDossierCount ( )

Definition at line 92 of file DossierResults.java.

92  {
93  Dao dao = new DossierPU();
94  WhereClause wc = new WhereClause();
95  wc.addClause("select count(distinct dossier)");
96  wc.addClause("from Dossier as dossier");
97  wc.addClause("left outer join dossier.participants participant");
98  wc.addClause("where 1=1");
99  addCriteria(wc);
100  return (Long) dao.getSingleResult(wc);
101  }
Here is the call graph for this function:

◆ getDossierIdList()

java.util.List<DossierIds> org.turro.dossier.search.DossierResults.getDossierIdList ( )

Definition at line 114 of file DossierResults.java.

114  {
115  Dao dao = new DossierPU();
116  WhereClause wc = new WhereClause();
117  wc.addClause("select distinct new org.turro.dossier.search.DossierIds(dossier.id, dossier.category.id, dossier.category.fullDescription)");
118  wc.addClause("from Dossier as dossier");
119  wc.addClause("left outer join dossier.participants participant");
120  wc.addClause("where 1=1");
121  addCriteria(wc);
122  return dao.getResultList(wc);
123  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDossierList()

java.util.List<Dossier> org.turro.dossier.search.DossierResults.getDossierList ( )

Definition at line 103 of file DossierResults.java.

103  {
104  Dao dao = new DossierPU();
105  WhereClause wc = new WhereClause();
106  wc.addClause("select distinct dossier");
107  wc.addClause("from Dossier as dossier");
108  wc.addClause("left outer join dossier.participants participant");
109  wc.addClause("where 1=1");
110  addCriteria(wc);
111  return new ArrayList(new DossierSet(dao.getResultList(wc)));
112  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDossierValue()

String org.turro.dossier.search.DossierResults.getDossierValue ( )

Definition at line 332 of file DossierResults.java.

332  {
333  return dossierValue;
334  }
Here is the caller graph for this function:

◆ getRoles()

Set<ParticipantRole> org.turro.dossier.search.DossierResults.getRoles ( )

Definition at line 133 of file DossierResults.java.

133  {
134  return roles;
135  }

◆ getStatus()

Set<DossierStatus> org.turro.dossier.search.DossierResults.getStatus ( )

Definition at line 141 of file DossierResults.java.

141  {
142  return status;
143  }
Here is the caller graph for this function:

◆ getSubject()

Contact org.turro.dossier.search.DossierResults.getSubject ( )

Definition at line 348 of file DossierResults.java.

348  {
349  return subject;
350  }

◆ getType()

Set<DossierType> org.turro.dossier.search.DossierResults.getType ( )

Definition at line 149 of file DossierResults.java.

149  {
150  return type;
151  }
Here is the caller graph for this function:

◆ isCkOthers()

boolean org.turro.dossier.search.DossierResults.isCkOthers ( )

Definition at line 324 of file DossierResults.java.

324  {
325  return ckOthers;
326  }
Here is the caller graph for this function:

◆ markAll()

void org.turro.dossier.search.DossierResults.markAll ( )

Definition at line 73 of file DossierResults.java.

73  {
74 
75  roles.add(ParticipantRole.PARTICIPANT_OWNER);
76  roles.add(ParticipantRole.PARTICIPANT_ASSISTANT);
77 
78  ckOthers = app.isInRole("dossier:all");
79 
80  status.add(DossierStatus.DOSSIER_OPENED);
81  status.add(DossierStatus.DOSSIER_CLOSED);
82  status.add(DossierStatus.DOSSIER_FROZEN);
83 
84  type.add(DossierType.TYPE_DOSSIER);
85  type.add(DossierType.TYPE_ELECTION);
86  type.add(DossierType.TYPE_PROJECT);
87  type.add(DossierType.TYPE_PROPOSAL);
88  type.add(DossierType.TYPE_SECRET_ELECTION);
89  type.add(DossierType.TYPE_SECRET_PROPOSAL);
90  }
Here is the call graph for this function:

◆ setByParticipant()

void org.turro.dossier.search.DossierResults.setByParticipant ( IContact  byParticipant)

Definition at line 344 of file DossierResults.java.

344  {
345  this.byParticipant = byParticipant;
346  }
Here is the caller graph for this function:

◆ setCategory()

void org.turro.dossier.search.DossierResults.setCategory ( Category  category)

Definition at line 129 of file DossierResults.java.

129  {
130  this.category = category;
131  }
Here is the caller graph for this function:

◆ setCkOthers()

void org.turro.dossier.search.DossierResults.setCkOthers ( boolean  ckOthers)

Definition at line 328 of file DossierResults.java.

328  {
329  this.ckOthers = ckOthers;
330  }
Here is the caller graph for this function:

◆ setDossierValue()

void org.turro.dossier.search.DossierResults.setDossierValue ( String  dossierValue)

Definition at line 336 of file DossierResults.java.

336  {
337  this.dossierValue = dossierValue;
338  }
Here is the caller graph for this function:

◆ setOrderBy()

void org.turro.dossier.search.DossierResults.setOrderBy ( String  orderBy)

Definition at line 157 of file DossierResults.java.

157  {
158  this.orderBy = orderBy;
159  }
Here is the caller graph for this function:

◆ setRoles()

void org.turro.dossier.search.DossierResults.setRoles ( Set< ParticipantRole roles)

Definition at line 137 of file DossierResults.java.

137  {
138  this.roles = roles;
139  }

◆ setStatus()

void org.turro.dossier.search.DossierResults.setStatus ( Set< DossierStatus status)

Definition at line 145 of file DossierResults.java.

145  {
146  this.status = status;
147  }
Here is the caller graph for this function:

◆ setSubject()

void org.turro.dossier.search.DossierResults.setSubject ( Contact  subject)

Definition at line 352 of file DossierResults.java.

352  {
353  this.subject = subject;
354  }

◆ setType()

void org.turro.dossier.search.DossierResults.setType ( Set< DossierType type)

Definition at line 153 of file DossierResults.java.

153  {
154  this.type = type;
155  }
Here is the caller graph for this function:

Member Data Documentation

◆ CATEGORY_SQL_ITERATIONS

final int org.turro.dossier.search.DossierResults.CATEGORY_SQL_ITERATIONS = 5
static

Definition at line 45 of file DossierResults.java.


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