19 package org.turro.alliance.content;
21 import java.io.Writer;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import org.apache.commons.lang3.ObjectUtils;
25 import org.turro.action.Interceptors;
26 import org.turro.string.Strings;
27 import org.turro.alliance.db.AlliancePU;
28 import org.turro.alliance.db.entities.AxProject;
29 import org.turro.alliance.db.entities.ProcedenceId;
30 import org.turro.alliance.www.CategoriesTree;
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.content.EntityDaoContentIterator;
40 import org.turro.jpa.search.DaoHtmlSearch;
41 import org.turro.jpa.search.DaoSearchKey;
42 import org.turro.marker.ElephantMarker;
43 import org.turro.plugin.contacts.IContact;
44 import org.turro.tags.TagCloud;
45 import org.turro.util.Arrays;
46 import org.turro.ws.WsMember;
54 private long lastCategoryId = -1;
61 if(ObjectUtils.allNotNull(member, project)) {
79 wc.
addClause(
"select distinct project from AxProject as project");
80 wc.
addClause(
"join AxCategory as category on project.categoryId = category.categoryId");
81 wc.
addClause(
"left outer join project.participations participant");
83 addCriteria(wc,
true);
84 wc.
addClause(
"order by project.creation desc");
91 wc.
addClause(
"select count(distinct project) from AxProject as project");
92 wc.
addClause(
"join AxCategory as category on project.categoryId = category.categoryId");
93 wc.
addClause(
"left outer join project.participations participant");
95 addCriteria(wc,
true);
96 wc.
addClause(
"order by project.creation desc");
110 prepareValues(e, page);
119 prepareValues(e, page);
132 wc.
addClause(
"select distinct project from AxProject as project");
133 wc.
addClause(
"join AxCategory as category on project.categoryId = category.categoryId");
134 wc.
addClause(
"left outer join project.participations participant");
136 addCriteria(wc,
true);
137 wc.
addClause(
"and project.projectId = :id");
145 if(identifier ==
null) {
146 identifier = super.getIdentifier();
151 private void addCriteria(
WhereClause wc,
boolean filterPhase) {
154 if(!Strings.isBlank(selected)) {
155 wc.
addClause(
"and concat(category.uniquePath, '/') like :category");
160 DaoHtmlSearch dhs = DaoHtmlSearch.getInstance(
constructor, ElephantContext.getContextVariable(
constructor));
162 DaoSearchKey dsk = dhs.get(
"search-value");
164 dsk.applyToQuery(wc, Arrays.objects(
"project.name"),
true);
168 PhaseHtmlFilter phf = PhaseHtmlFilter.getInstance(
constructor, ElephantContext.getContextVariable(
constructor));
169 if(phf !=
null && !phf.isEmpty()) {
170 int phase = Integer.valueOf(phf.getPhase());
173 wc.
addClause(
"and project.phaseIndex = :" + par);
179 if(TagCloud.hasSelected(
constructor,
"axproject")) {
180 wc.
addIn(
"and",
"project.id", TagCloud.getIdentifiers(
constructor,
"axproject"));
184 private void prepareValues(
final AxProject project,
int page) {
190 if(!Strings.isBlank(e.
getName())) {
198 ArrayList<RepositoryFile> files =
new ArrayList<>();
212 return isMail() ?
"content/newsletter/sections/alliance/projects" :
"alliance/project";
258 if(Strings.isBlank(path)) {
261 if(Strings.isBlank(path)) {
269 return "/user/alliance/projects";
static Parameters parameters(String root)
Parameters add(String key, Object value)
ProjectContentIterator(IConstructor constructor, Writer writer, IContact contact, boolean mail, String pubPath)
String stringId(ProcedenceId value)
Object doCommentsCtrl(AxProject e)
Object doInterestCtrl(AxProject e)
void renderSummary(ElephantMarker marker, AxProject e, int page)
String getItemLink(AxProject project)
Object doFilesCtrl(AxProject e)
AxProject entity(ProcedenceId value)
Object doPollsCtrl(AxProject e)
String getRestrictedLink()
WhereClause getCountClause()
Collection< String > metas(AxProject e)
ProcedenceId getIdentifier()
String getProjectUrl(WsMember member, AxProject project)
ProcedenceId parseId(String value)
Object doAttachmentsCtrl(AxProject e)
String title(AxProject e)
WhereClause getWhereClause()
Object doVotesCtrl(AxProject e)
Object doDescriptionsCtrl(AxProject e)
void renderItem(ElephantMarker marker, AxProject e, int page)
static String getObjectPath(Object object)
ProcedenceId getProjectId()
static ProcedenceId from(String id)
static String getSiteForcedDomain()
static String getEntityWebContext(String path)
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)
Object getSingleResultOrNull(SqlClause sc)
void prepareControls(E entity, int page)
String doItemLink(E entity, ID id, boolean obfuscated)
ID getIDFromURL(String root)
String getSummaryTemplate()
DaoHtmlTree getNavigationTree()
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)