18 package org.turro.attach.search;
20 import java.util.ArrayList;
21 import org.turro.attach.db.AttachPU;
22 import org.turro.attach.entity.Attachment;
23 import org.turro.attach.version.AttachVersionMap;
24 import org.turro.attach.version.AttachVersionSet;
25 import org.turro.auth.Authentication;
26 import org.turro.elephant.context.Application;
27 import org.turro.elephant.db.SQLHelper;
28 import org.turro.elephant.db.WhereClause;
29 import org.turro.jpa.Dao;
30 import org.turro.plugin.contacts.IContact;
31 import org.zkoss.lang.Strings;
41 private boolean ckOthers, ckNonValidated =
false, ckExactPath, publicOnly =
false;
42 private String attachValue =
"*", attachPath;
50 ckOthers = app !=
null && app.
isInRole(
"attach-show:all");
51 ckNonValidated =
false;
59 this.publicOnly = publicOnly;
65 wc.
addClause(
"select distinct attachment from Attachment as attachment");
68 wc.
addClause(
"order by attachment.fileName, attachment.modification DESC");
69 return new AttachmentList(dao.getResultList(wc), ckOthers && app!=
null && app.
isInRole(
"attach-show:all"));
77 ArrayList<Attachment> list =
new ArrayList<>();
79 list.add(avs.first());
87 wc.
addClause(
"select distinct attachment.path from Attachment as attachment");
91 return new PathSet(dao.getResultList(wc), currPath, ckOthers && app!=
null && app.
isInRole(
"attach-show:all"));
96 if(Strings.isEmpty(attachValue) || (ckOthers && app!=
null && !app.
isInRole(
"attach-show:all"))) {
100 if(byParticipant ==
null) {
105 "attachment.fileName"
106 }, (attachValue ==
null ?
"" : attachValue.replaceAll(
"\\*",
"%")));
108 if(!(ckOthers && app!=
null && app.
isInRole(
"attach-show:all")) && byParticipant !=
null) {
111 wc.
addClause(
"attachment.onlyOwner = false");
115 wc.
addClause(
"(attachment.onlyOwner = true and attachment.owner = :idOwner)");
122 wc.
addClause(
"and attachment.validated = false");
126 wc.
addClause(
"and attachment.publishable = true");
129 if(attachPath !=
null) {
130 wc.
addClause(
"and UCASE(attachment.path) " +
131 (ckExactPath ?
"=" :
"like") +
142 this.attachPath = attachPath;
150 this.attachValue = attachValue;
154 return byParticipant;
158 this.byParticipant = byParticipant;
166 this.ckExactPath = ckExactPath;
170 return ckNonValidated;
174 this.ckNonValidated = ckNonValidated;
182 this.ckOthers = ckOthers;
188 " select count(attachment) " +
189 " from Attachment as attachment" +
190 " where attachment.path like '" + root +
"/%'");
java.util.Set< String > getPathList(String currPath)
void setByParticipant(IContact byParticipant)
void addCriteria(WhereClause wc)
static long getCountAttachments(String root)
java.util.List< Attachment > getVersionedAttachmentList()
void setCkExactPath(boolean ckExactPath)
void setPublicOnly(boolean publicOnly)
java.util.List< Attachment > getAttachmentList()
IContact getByParticipant()
void setAttachValue(String attachValue)
void setCkOthers(boolean ckOthers)
void setAttachPath(String attachPath)
void setCkNonValidated(boolean ckNonValidated)
boolean isCkNonValidated()
void addAttachment(Attachment attachment)
static IContact getIContact()
boolean isInRole(String role)
static Application getApplication()
static WhereClause getWhereClause(String[] fields, String value)
void addClause(String clause)
void addNamedValue(String name, Object value)
Object getSingleResult(WhereClause wc)