19 package org.turro.jpa.iterator;
21 import java.io.IOException;
22 import java.io.Writer;
23 import java.lang.reflect.ParameterizedType;
24 import java.util.Collection;
25 import java.util.HashMap;
27 import java.util.logging.Level;
28 import java.util.logging.Logger;
29 import org.turro.string.ObjectString;
30 import org.turro.string.Strings;
31 import org.turro.action.content.IContentIterator;
32 import org.turro.assistant.ParticipationInfo;
33 import org.turro.collections.KeyValueMap;
34 import org.turro.elephant.context.ElephantContext;
35 import org.turro.elephant.context.IConstructor;
36 import org.turro.elephant.web.ElContext;
37 import org.turro.html.HTMLHelper;
38 import org.turro.jpa.Dao;
39 import org.turro.jpa.entity.EntityWebUrls;
40 import org.turro.jpa.search.DaoHtmlSearch;
41 import org.turro.marker.ElephantMarker;
42 import org.turro.marker.MarkerHelper;
43 import org.turro.participation.ParticipationReason;
44 import org.turro.path.Path;
45 import org.turro.skills.tags.SkillCloud;
46 import org.turro.tags.TagCloud;
47 import org.turro.tags.TagSet;
48 import org.turro.tags.Tags;
49 import org.turro.visual.EmptyVisualElements;
50 import org.turro.visual.VisualElements;
66 private String summaryTemplate, fullTemplate;
67 private boolean restricted;
68 private boolean allowInterest, allowComments, allowVotes, allowForum,
69 allowDescriptions, allowAttachments, allowFiles, allowPolls;
70 private boolean allowRanking =
true, allowMatching =
true, allowSorting =
true;
71 private String rankingInstance, matchingInstance;
72 private boolean doMatching;
73 private boolean navigatorTop =
true, navigatorBottom =
true,
74 searchOption =
true, forceSummary =
false;
75 private int page, currentIndex, currentSize;
78 private final Class<ID> idClass;
79 private Writer writer;
80 private final Map<String, Object> markerAttributes;
92 this.idClass = (Class<ID>) ((ParameterizedType) getClass()
93 .getGenericSuperclass()).getActualTypeArguments()[1];
94 markerAttributes =
new HashMap<>();
98 this.summaryTemplate = summaryTemplate;
102 return Strings.isBlank(summaryTemplate) ?
"summary" : summaryTemplate;
106 this.fullTemplate = fullTemplate;
110 return Strings.isBlank(fullTemplate) ?
"full" : fullTemplate;
118 this.restricted = restricted;
122 return allowInterest;
126 this.allowInterest = allowInterest;
130 return allowComments;
134 this.allowComments = allowComments;
142 this.allowVotes = allowVotes;
150 this.allowForum = allowForum;
154 return allowDescriptions;
158 this.allowDescriptions = allowDescriptions;
162 return allowAttachments;
166 this.allowAttachments = allowAttachments;
174 this.allowFiles = allowFiles;
182 this.allowPolls = allowPolls;
190 this.allowRanking = allowRanking;
194 return allowMatching;
198 this.allowMatching = allowMatching;
206 this.doMatching = doMatching;
210 return rankingInstance;
214 this.rankingInstance = rankingInstance;
218 return matchingInstance;
222 this.matchingInstance = matchingInstance;
230 this.allowSorting = allowSorting;
238 this.navigatorTop = navigatorTop;
242 return navigatorBottom;
246 this.navigatorBottom = navigatorBottom;
271 this.searchOption = searchOption;
279 this.forceSummary = forceSummary;
287 return entity !=
null;
291 return entity(value) !=
null;
296 return markerAttributes.put(key, value);
303 }
catch (IOException ex) {
321 entity = entity(item);
329 entity = entity(item);
334 return entity !=
null ?
title(entity) :
null;
338 return entity !=
null ?
metas(entity) :
null;
347 marker.
put(
"navigatorTop", navigatorTop);
348 marker.
put(
"navigatorBottom", navigatorBottom);
349 marker.
put(
"searchOption", searchOption);
378 currentSize =
items.size();
379 if(currentSize == 0) {
400 if(countValids == 0) {
413 return currentIndex == 0;
417 return currentIndex == currentSize - 1;
451 if(_visuals ==
null) {
457 private VisualElements _visuals;
474 protected abstract String
title(E e);
475 protected abstract Collection<String>
metas(E e);
486 if(!Strings.isBlank(entityPath)) {
487 Path path =
new Path(entityPath);
488 if(path.getSize() == 2) {
489 return parseId(path.getNode(1));
502 if(kvm !=
null && !kvm.isEmpty() && kvm.containsKey(
"item")) {
503 return parseId(kvm.get(
"item"));
520 return (ID) ObjectString.parseString(value, idClass,
false);
524 return String.valueOf(value);
529 private void markAsSeen(E entity) {
static String logMsg(String msg)
static String extractPath(String path)
HTMLGenerator endAllTags()
static boolean sameURL(String url1, String url2)
static String getEntityPath(String entityRoot, String url)
void setAllowAttachments(boolean allowAttachments)
void setNavigationTree(DaoHtmlTree navigationTree)
void setAllowInterest(boolean allowInterest)
void setFullTemplate(String fullTemplate)
DaoHtmlIterator(Dao dao, ElephantMarker marker)
ID getIDFromURL(String root)
DaoHtmlSearch getSearchEngine()
abstract Collection< String > metas(E e)
abstract String entityRoot()
void setDoMatching(boolean doMatching)
boolean isAllowAttachments()
boolean isAllowMatching()
String renderTreeSelection()
boolean isNavigatorBottom()
void setAllowDescriptions(boolean allowDescriptions)
String getSummaryTemplate()
abstract void renderItem(ElephantMarker marker, E e, int page)
void setAllowForum(boolean allowForum)
void setSearchEngine(DaoHtmlSearch searchEngine)
DaoHtmlTree navigationTree
void setForceSummary(boolean forceSummary)
VisualElements getVisuals()
void setAllowSorting(boolean allowSorting)
void setRankingInstance(String rankingInstance)
void setRestricted(boolean restricted)
DaoHtmlSearch searchEngine
void setAllowComments(boolean allowComments)
abstract E entity(ID value)
void setNavigatorBottom(boolean navigatorBottom)
Collection< String > getMetas()
void setAllowMatching(boolean allowMatching)
boolean isSeen(Object entity)
void setSearchOption(boolean searchOption)
abstract void renderSummary(ElephantMarker marker, E e, int page)
String renderSearchEngine()
boolean checkEntity(ID value)
void setSummaryTemplate(String summaryTemplate)
String stringId(ID value)
void setMatchingInstance(String matchingInstance)
DaoHtmlIterator(Dao dao, ElephantMarker marker, Writer writer)
void setNavigatorTop(boolean navigatorTop)
TagSet getEntityTags(Object entity)
void setAllowVotes(boolean allowVotes)
String getRankingInstance()
DaoHtmlTree getNavigationTree()
void renderForbidden(ElephantMarker marker, int page)
void setAllowRanking(boolean allowRanking)
void setAllowFiles(boolean allowFiles)
Object addAttribute(String key, Object value)
boolean isAllowInterest()
boolean isAllowDescriptions()
boolean isAllowComments()
VisualElements loadVisuals()
String getMatchingInstance()
abstract String title(E e)
void setAllowPolls(boolean allowPolls)
String render(IConstructor constructor)
void setIterator(IContentIterator iterator)
IConstructor getConstructor()
Object put(Object key, Object value)
static KeyValueMap getObfuscatedParameters()
static String PRELOAD_TMPL
ElContext getCurrentContext()
HttpServletRequest getRequest()
String getParameter(String param)