19 package org.turro.contacts.www;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collection;
24 import java.util.HashMap;
25 import java.util.List;
26 import org.turro.string.Strings;
27 import org.turro.contacts.Connector;
28 import org.turro.contacts.Contact;
29 import org.turro.contacts.db.ContactsPU;
30 import org.turro.contacts.form.ContactWrapper;
31 import org.turro.elephant.context.ElephantContext;
32 import org.turro.elephant.context.IConstructor;
33 import org.turro.elephant.db.WhereClause;
34 import org.turro.elephant.impl.repository.Repository;
35 import org.turro.elephant.impl.repository.RepositoryFile;
36 import org.turro.elephant.web.SocialImageMap;
37 import org.turro.elephant.web.SocialNet;
38 import org.turro.file.util.FileAttach;
39 import org.turro.jpa.iterator.DaoHtmlIterator;
40 import org.turro.jpa.search.DaoHtmlSearch;
41 import org.turro.jpa.search.DaoSearchKey;
42 import org.turro.mail.recipients.MailContact;
43 import org.turro.marker.ElephantMarker;
44 import org.turro.tags.TagCloud;
52 private String pubPath, syndicationId, actualParameters, uniqueId;
53 private HashMap<String, String> connectors;
54 private List<String> groupings;
58 this.pubPath = pubPath;
59 this.uniqueId = uniqueId;
60 connectors =
new HashMap<>();
61 groupings =
new ArrayList<>();
65 this.syndicationId = syndicationId;
69 connectors.put(connector, values);
73 this.groupings.addAll(groupings);
85 wc.
addClause(
"select distinct c from Contact as c");
86 wc.
addClause(
"left join c.syndications as s");
87 wc.
addClause(
"left join c.connectors as o");
88 wc.
addClause(
"left outer join c.comments as m with m.comment like '#cv%'");
97 wc.
addClause(
"select count(distinct c) from Contact as c");
98 wc.
addClause(
"left join c.syndications as s");
99 wc.
addClause(
"left join c.connectors as o");
100 wc.
addClause(
"left outer join c.comments as m with m.comment like '#cv%'");
106 return Strings.isBlank(actualParameters) ?
"?a=b" : actualParameters;
121 if(!Strings.isBlank(e.
getName())) {
123 "jQuery('title').html('" + e.
getName().replace(
"'",
"\\'") +
"');"
143 if(!Strings.isBlank(syndicationId)) {
144 wc.
addClause(
"where s.name = :syndication");
146 }
else if(connectors.isEmpty() && groupings.isEmpty()) {
152 DaoHtmlSearch dhs = DaoHtmlSearch.getInstance(
constructor, ElephantContext.getContextVariable(
constructor));
154 DaoSearchKey dsk = dhs.get(
"search-value");
156 dsk.applyToQuery(wc, Arrays.asList(
new String[] {
"c.name",
"o.value",
"m.comment" }),
false);
165 if(!connectors.isEmpty()) {
166 for(String key : connectors.keySet()) {
167 wc.
addClause(
"and o.description = :keyconn");
169 wc.
addClause(
"and o.value in :valueconn");
170 wc.
addNamedValue(
"valueconn", Arrays.asList(connectors.get(key).split(
",")));
173 if(!groupings.isEmpty()) {
174 wc.
addClause(
"and c.grouping in (:groupings)");
178 wc.
addIn(
"and",
"c.id", TagCloud.getIdentifiersAsLong(
constructor,
"contact"));
188 if(asMail && pubPath !=
null) {
191 if(pubPath !=
null) {
206 if(!Strings.isBlank(pubPath)) {
215 return pubPath +
"?item=" + contact.
getId() +
"&page=" + page;
219 return pubPath +
"?page=" + page;
229 ArrayList<RepositoryFile> files =
new ArrayList<>();
static String getRootWebPath()
void addClause(String clause)
void addIn(String operator, String field, List values)
void addNamedValue(String name, Object value)
Set< RepositoryFile > getRepositoryFiles(String pattern)
static boolean hasImage(String url)
List< String > getMetas()
Repository getPublishableRepository(IConstructor constructor)
String getSummaryTemplate()
void process(String rootTmpl, String tmpl)
IConstructor getConstructor()
Object put(Object key, Object value)
void addOnLoadedJavaScript(String script)