19 package org.turro.publication.content;
21 import java.io.Writer;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Date;
25 import org.turro.string.Strings;
26 import org.turro.elephant.context.ElephantContext;
27 import org.turro.elephant.context.IConstructor;
28 import org.turro.elephant.db.WhereClause;
29 import org.turro.elephant.impl.repository.RepositoryFile;
30 import org.turro.elephant.web.SocialImageMap;
31 import org.turro.elephant.web.SocialNet;
32 import org.turro.entities.Entities;
33 import org.turro.file.util.FileAttach;
34 import org.turro.jpa.content.EntityDaoContentIterator;
35 import org.turro.jpa.search.DaoHtmlSearch;
36 import org.turro.jpa.search.DaoSearchKey;
37 import org.turro.marker.ElephantMarker;
38 import org.turro.plugin.contacts.IContact;
39 import org.turro.polls.PollsCtrl;
40 import org.turro.publication.db.PublicationPU;
41 import org.turro.publication.entity.Publication;
42 import org.turro.publication.entity.PublicationCategory;
43 import org.turro.publication.www.CategoryFilter;
44 import org.turro.www.commentit.CommentItCtrl;
45 import org.turro.www.starit.StarItCtrl;
53 private String contactId, lang;
54 private long groupId, categoryId;
56 private boolean blogger, notSent, future;
63 this.contactId = contactId;
67 this.groupId = groupId;
71 this.categoryId = categoryId;
79 return categoryFilter;
83 this.categoryFilter = categoryFilter;
91 this.blogger = blogger;
99 this.notSent = notSent;
107 this.future = future;
117 ArrayList<RepositoryFile> files =
new ArrayList<>();
133 wc.
addClause(
"select distinct p from Publication as p");
142 wc.
addClause(
"select count(p) from Publication as p");
154 prepareValues(e, page);
161 prepareValues(e, page);
168 return "publication";
179 if(identifier ==
null) {
180 identifier = super.getIdentifier();
187 wc.
addClause(
"where p.accepted = false");
190 wc.
addClause(
"select ps from PublicationBlogger ps");
191 wc.
addClause(
"where ps.publicationCategory = p.publicationCategory");
192 wc.
addClause(
"and ps.idContact = :blogger");
193 wc.
addClause(
"and ps.administrator = TRUE");
194 wc.
addClause(
") or ( p.idContact = :blogger and exists (");
195 wc.
addClause(
"select ps from PublicationBlogger ps");
196 wc.
addClause(
"where ps.publicationCategory = p.publicationCategory");
197 wc.
addClause(
"and ps.idContact = p.idContact");
198 wc.
addClause(
"and ps.administrator = FALSE");
208 DaoHtmlSearch dhs = DaoHtmlSearch.getInstance(
constructor, ElephantContext.getContextVariable(
constructor));
210 DaoSearchKey dsk = dhs.get(
"search-value");
212 String searchValue = dsk.getValue();
213 if(!Strings.isBlank(searchValue)) {
214 wc.
addClause(
"and (p.title like :search01");
216 wc.
addClause(
"or p.summary like :search02)");
224 wc.
addClause(
"and (p.retainTill is null or p.retainTill <= :now)");
232 wc.
addClause(
"and p.publicationGroup.id = :group");
235 wc.
addClause(
"and p.publicationGroup.publishable = TRUE");
237 if(categoryId != 0) {
238 wc.
addClause(
"and p.publicationCategory.id = :category");
241 wc.
addClause(
"and p.publicationCategory.publishable = TRUE");
243 if(!Strings.isBlank(contactId)) {
244 wc.
addClause(
"and p.idContact = :idContact");
247 if(!Strings.isBlank(lang)) {
248 wc.
addClause(
"and (p.lang is null or p.lang = :lang)");
253 wc.
addClause(
"and p.publicationCategory = :selectedCat");
258 private void prepareValues(Publication pub,
int page) {
269 return isMail() ?
"content/newsletter/sections/publications" :
"publication";
274 throw new UnsupportedOperationException(
"Not supported yet.");
291 throw new UnsupportedOperationException(
"Not supported yet.");
302 throw new UnsupportedOperationException(
"Not supported yet.");
319 if(Strings.isBlank(path)) {
static String getEntityWebContext(String path)
void addClause(String clause)
void addNamedValue(String name, Object value)
Set< RepositoryFile > getRepositoryFiles(String pattern)
static boolean hasImage(String url)
List< String > getMetas()
static IElephantEntity getController(String path)
Repository getPublishableRepository(IConstructor constructor)
void prepareControls(E entity, int page)
String doItemLink(E entity, ID id, boolean obfuscated)
void setAllowInterest(boolean allowInterest)
ID getIDFromURL(String root)
String getSummaryTemplate()
void setAllowComments(boolean allowComments)
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)
void renderItem(ElephantMarker marker, Publication e, int page)
Object doDescriptionsCtrl(Publication e)
Object doFilesCtrl(Publication e)
CategoryFilter getCategoryFilter()
Object doCommentsCtrl(Publication e)
String getItemLink(Publication e)
void setCategoryId(long categoryId)
Object doInterestCtrl(Publication e)
void setNotSent(boolean notSent)
WhereClause getWhereClause()
void setBlogger(boolean blogger)
void renderSummary(ElephantMarker marker, Publication e, int page)
PublicationContentIterator(IConstructor constructor, Writer writer, IContact contact, boolean mail, String pubPath)
Collection< String > metas(Publication e)
void setGroupId(long groupId)
Object doAttachmentsCtrl(Publication e)
Object doVotesCtrl(Publication e)
String title(Publication e)
void setContactId(String contactId)
void setCategoryFilter(CategoryFilter categoryFilter)
void setLang(String lang)
Publication entity(Long value)
String getRestrictedLink()
void setFuture(boolean future)
WhereClause getCountClause()
Object doPollsCtrl(Publication e)
static String getObjectPath(Object object)
static boolean isAnyBlogger(IContact contact)
void updateReadings(Dao dao)
Object configureCtrl(Object ctrl, IContact contact)