162 boolean asParticipant =
163 roles.contains(ParticipantRole.PARTICIPANT_OWNER) ||
164 roles.contains(ParticipantRole.PARTICIPANT_ASSISTANT);
166 if(Strings.isEmpty(dossierValue) || (!asParticipant && !app.
isInRole(
"dossier:all"))) {
167 wc.addClause(
"and 0=1");
171 if(byParticipant ==
null) {
172 byParticipant = Authentication.getIContact();
175 wc.addClause(
"and ((");
177 wc.addLikeFields(
new String[] {
178 "dossier.description"
179 }, (dossierValue ==
null ?
"" : dossierValue.replaceAll(
"\\*",
"%")));
181 wc.addClause(
"or exists (select fieldValue from dossier.fieldValues fieldValue where 1=1");
182 wc.addLikeFields(
new String[] {
184 }, (dossierValue ==
null ?
"" : dossierValue.replaceAll(
"\\*",
"%")));
186 wc.addClause(
"or (fieldValue.value = 'true' and");
187 wc.addLikeFields(
new String[] {
188 "fieldValue.fieldDef.labelKey"
189 }, (dossierValue ==
null ?
"" : dossierValue.replaceAll(
"\\*",
"%")));
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[] {
196 }, (dossierValue ==
null ?
"" : dossierValue.replaceAll(
"\\*",
"%")));
206 id = Long.valueOf(dossierValue);
208 wc.addClause(
"or dossier.id = :id");
209 wc.addNamedValue(
"id",
id);
211 }
catch(Exception ex) {}
215 if(asParticipant && !(ckOthers && app.
isInRole(
"dossier:all"))) {
216 wc.addClause(
"and (");
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);
224 CategoryResults.addParticipantAffiliance(wc,
"or", byParticipant.
getId(),
"dossier");
230 wc.addClause(
"and (");
231 if(status.contains(DossierStatus.DOSSIER_OPENED)) {
234 wc.addClause(
"dossier.status = :statusOpened");
235 wc.addNamedValue(
"statusOpened", DossierStatus.DOSSIER_OPENED);
237 if(status.contains(DossierStatus.DOSSIER_CLOSED)) {
240 wc.addClause(
"dossier.status = :statusClosed");
241 wc.addNamedValue(
"statusClosed", DossierStatus.DOSSIER_CLOSED);
243 if(status.contains(DossierStatus.DOSSIER_FROZEN)) {
246 wc.addClause(
"dossier.status = :statusFrozen");
247 wc.addNamedValue(
"statusFrozen", DossierStatus.DOSSIER_FROZEN);
252 wc.addClause(
"and (");
253 if(type.contains(DossierType.TYPE_DOSSIER)) {
256 wc.addClause(
"dossier.type = :typeDossier");
257 wc.addNamedValue(
"typeDossier", DossierType.TYPE_DOSSIER);
259 if(type.contains(DossierType.TYPE_ELECTION)) {
262 wc.addClause(
"dossier.type = :typeElection");
263 wc.addNamedValue(
"typeElection", DossierType.TYPE_ELECTION);
265 if(type.contains(DossierType.TYPE_PROJECT)) {
268 wc.addClause(
"dossier.type = :typeProject");
269 wc.addNamedValue(
"typeProject", DossierType.TYPE_PROJECT);
271 if(type.contains(DossierType.TYPE_PROPOSAL)) {
274 wc.addClause(
"dossier.type = :typeProposal");
275 wc.addNamedValue(
"typeProposal", DossierType.TYPE_PROPOSAL);
277 if(type.contains(DossierType.TYPE_SECRET_ELECTION)) {
280 wc.addClause(
"dossier.type = :typeSecElection");
281 wc.addNamedValue(
"typeSecElection", DossierType.TYPE_SECRET_ELECTION);
283 if(type.contains(DossierType.TYPE_SECRET_PROPOSAL)) {
286 wc.addClause(
"dossier.type = :typeSecProposal");
287 wc.addNamedValue(
"typeSecProposal", DossierType.TYPE_SECRET_PROPOSAL);
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);
309 if(category !=
null) {
310 wc.addClause(
"and (dossier.category.fullDescription = :decat");
312 wc.addClause(
"or dossier.category.fullDescription like :dlcat)");
313 wc.addNamedValue(
"dlcat", category.
getFullDescription() + Chars.backward().spaced() +
"%");
319 if(!Strings.isBlank(orderBy)) {
320 wc.addClause(orderBy);
String getFullDescription()
boolean isInRole(String role)