BrightSide Workbench Full Report + Source Code
org.turro.publication.www.PublicationWeb Class Reference
Inheritance diagram for org.turro.publication.www.PublicationWeb:
Collaboration diagram for org.turro.publication.www.PublicationWeb:

Public Member Functions

 PublicationWeb ()
 
void loadData () throws ServletException, IOException
 
void setRootCategories (ElContext root)
 
void startConstruction () throws ServletException, IOException
 
String getStart ()
 
String getEnd ()
 
FoundList search (String value, boolean ignoreCase)
 
List< SyndEntry > getSyndEntries ()
 
- Public Member Functions inherited from org.turro.elephant.impl.abstracts.AbstractElement
 AbstractElement ()
 
String getId ()
 
String getType ()
 
String getTitle ()
 
void setTitle (String title)
 
Collection< String > getMetas ()
 
void setMetas (Collection< String > metas)
 
ElContext getContext ()
 
IConstructor getConstructor ()
 
void setConfiguration (IConstructor constructor, ElContext context)
 
String getStartTitle ()
 
String getEndTitle ()
 
String getStartBody ()
 
String getEndBody ()
 
String getStartFooter ()
 
String getEndFooter ()
 
String getStartOption ()
 
String getEndOption ()
 
boolean canDisplay ()
 
boolean isSelectable ()
 
boolean isInRole ()
 
boolean canPrint ()
 
String getElementFolder ()
 
boolean isOriginalContext ()
 
String getTypeName ()
 
AttributeSupport getAttributes ()
 
void applyChanges ()
 
void populateFromParent ()
 
void setDefaultMetas ()
 
void setConfiguration (Element conf, Element factory)
 

Protected Attributes

String sclass
 
long groupId
 
int count
 
boolean showTitle
 
PublicationIterator pi
 
- Protected Attributes inherited from org.turro.elephant.impl.abstracts.AbstractElement
IConstructor constructor
 
ElContext context
 
AttributeSupport attrSupport
 
Element conf = null
 
String[] types
 
String title
 
Collection< String > metas
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 56 of file PublicationWeb.java.

Constructor & Destructor Documentation

◆ PublicationWeb()

org.turro.publication.www.PublicationWeb.PublicationWeb ( )

Definition at line 64 of file PublicationWeb.java.

64  {
65  super();
66  }

Member Function Documentation

◆ getEnd()

String org.turro.publication.www.PublicationWeb.getEnd ( )

Reimplemented from org.turro.elephant.impl.abstracts.AbstractElement.

Definition at line 184 of file PublicationWeb.java.

184  {
185  return "</div>";
186  }
Here is the caller graph for this function:

◆ getStart()

String org.turro.publication.www.PublicationWeb.getStart ( )

Reimplemented from org.turro.elephant.impl.abstracts.AbstractElement.

Definition at line 179 of file PublicationWeb.java.

179  {
180  return "<div class='" + sclass + "publication-web'>";
181  }
Here is the caller graph for this function:

◆ getSyndEntries()

List<SyndEntry> org.turro.publication.www.PublicationWeb.getSyndEntries ( )

Implements org.turro.elephant.feed.IRSSable.

Definition at line 239 of file PublicationWeb.java.

239  {
240  contactId = getAttributes().getAttributeValue("attrib:contactId", null);
241  groupId = getAttributes().getAttributeIntegerValue("attrib:groupId", 0);
242  categoryId = getAttributes().getAttributeIntegerValue("attrib:categoryId", 0);
243  SyndEntry entry;
244  SyndContent description;
245  List<SyndEntry> entries = new ArrayList<>();
246  int rsscount = this.getAttributes().getAttributeIntegerValue("attrib:rss_count", 10);
247  List<Publication> list = PublicationCategories.getPublicationsBy(
248  rsscount, groupId, categoryId, contactId, true);
249  String serverBase = ElephantContext.getServerBase("http");
250  for(Publication pub : list) {
251  entry = new SyndEntryImpl();
252  entry.setTitle(pub.getTitle());
253  entry.setLink(serverBase + context.getFullPath() + getItemLink(pub));
254  entry.setPublishedDate(pub.getDate());
255  entry.setAuthor(pub.getAuthor());
256  description = new SyndContentImpl();
257  description.setType("text/html");
258  String summary = pub.getSummary();
259  if(!Strings.isBlank(summary)) {
260  summary = summary.replaceAll("href=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'", "href=\\'" + serverBase + "$1$2\\'")
261  .replaceAll("src=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'", "src=\\'" + serverBase + "$1$2\\'")
262  .replaceAll("href=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"", "href=\\\"" + serverBase + "$1$2\\\"")
263  .replaceAll("src=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"", "src=\\\"" + serverBase + "$1$2\\\"");
264  description.setValue(summary);
265  }
266  entry.setDescription(description);
267  entries.add(entry);
268  }
269  return entries;
270  }
Here is the call graph for this function:

◆ loadData()

void org.turro.publication.www.PublicationWeb.loadData ( ) throws ServletException, IOException

This method loads element's data. It gets called within IConstructor.startConstruction() and before element's startConstruction() method.

Exceptions
javax.servlet.ServletException
java.io.IOException

Implements org.turro.elephant.context.IElement.

Definition at line 69 of file PublicationWeb.java.

69  {
70  sclass = getAttributes().getAttributeValue("attrib:sclass", "");
71  fullTemplate = getAttributes().getAttributeValue("attrib:fullTemplate", "");
72  summaryTemplate = getAttributes().getAttributeValue("attrib:summaryTemplate", "");
73  contactId = getAttributes().getAttributeValue("attrib:contactId", null);
74  groupId = getAttributes().getAttributeIntegerValue("attrib:groupId", 0);
75  categoryId = getAttributes().getAttributeIntegerValue("attrib:categoryId", 0);
76  publicationId = getAttributes().getAttributeIntegerValue("attrib:publicationId", 0);
77  count = getAttributes().getAttributeIntegerValue("attrib:count", 10);
78  showTitle = getAttributes().getAttributeBooleanValue("attrib:showTitle", true);
79  showDetails = getAttributes().getAttributeBooleanValue("attrib:showDetails", true);
80  showSummary = getAttributes().getAttributeBooleanValue("attrib:showSummary", true);
81  showBody = getAttributes().getAttributeBooleanValue("attrib:showBody", false);
82  navigate = getAttributes().getAttributeBooleanValue("attrib:navigate", false);
83  onTop = getAttributes().getAttributeValue("attrib:onTop", null);
84  onBottom = getAttributes().getAttributeValue("attrib:onBottom", null);
85  blogger = getAttributes().getAttributeBooleanValue("attrib:blogger", false);
86 
87  if(navigate) {
88  } else if(publicationId > 0) {
89  } else {
90  pi = new PublicationIterator(getConstructor(), getContext().getFullPath(), getId());
91  pi.setFullTemplate(fullTemplate);
92  pi.setSummaryTemplate(summaryTemplate);
93  pi.setPage(count);
94  pi.setContactId(contactId);
96  pi.setCategoryId(categoryId);
97  pi.setBlogger(blogger);
98  pi.setLang("_" + I_.api().used().getLanguage());
99  pi.load();
100  setTitle(pi.getTitle());
101  if(pi.isItem()) {
102  setMetas(pi.getMetas());
103  } else {
104  setDefaultMetas();
105  }
106  }
107  }
void setFullTemplate(String fullTemplate)
void setSummaryTemplate(String summaryTemplate)
void setMetas(Collection< String > metas)
Here is the call graph for this function:

◆ search()

FoundList org.turro.publication.www.PublicationWeb.search ( String  value,
boolean  ignoreCase 
)

This method is called by Elephant search implementation.

Parameters
valueValue to search.
ignoreCaseWhether to ignore case.
Returns
A list of coincidences.

Implements org.turro.elephant.search.ISearchable.

Definition at line 199 of file PublicationWeb.java.

199  {
200  FoundList fl = new FoundList();
201 
202  String extraSql =
203  "and (" + SearchFormatter.queryToSQL("publication.publicationCategory.name", value, ignoreCase) +
204  "or " + SearchFormatter.queryToSQL("publication.title", value, ignoreCase) +
205  "or " + SearchFormatter.queryToSQL("publication.summary", value, ignoreCase) +
206  "or " + SearchFormatter.queryToSQL("publication.body", value, ignoreCase) +
207  ")";
208 
209  List<Publication> list = PublicationCategories.getPublicationsBy(
210  0, groupId, categoryId, contactId, true, extraSql);
211 
212  for(Publication pub : list) {
213  SearchFormatter sf = new SearchFormatter(value, ignoreCase);
214  sf.processLine(pub.getTitle());
215  sf.processLine(pub.getPublicationCategory().getName());
216  sf.processLine(pub.getSummary());
217  sf.processLine(pub.getBody());
218  if(sf.wasFound()) {
219  fl.addItem(
220  getId() == null ? "" : getId(),
221  context.getPath(),
222  "<img src='" + ElephantContext.getRootResourcePath() + "/_internal/system/images/blog.gif'/>",
223  pub.getTitle(),
224  sf.getResult(),
225  (double)sf.getFound(),
226  value
227  );
228  }
229  }
230 
231  return fl;
232  }
Here is the call graph for this function:

◆ setRootCategories()

void org.turro.publication.www.PublicationWeb.setRootCategories ( ElContext  root)
Parameters
rootCategories root Calls

Implements org.turro.elephant.context.IElement.

Definition at line 110 of file PublicationWeb.java.

110  {
111  Tree<PublicationCategory, String> tree = new Tree<PublicationCategory, String>() {
112  @Override
113  protected String getId(PublicationCategory entity) {
114  return entity.getName();
115  }
116 
117  @Override
118  protected String getParentId(PublicationCategory entity) {
119  return null;
120  }
121 
122  @Override
123  protected PublicationCategory getEntity(String id) {
124  return null;
125  }
126  };
127  tree.setPath("");
128  tree.addLeaf(null, I_.get("All categories"));
129  for(PublicationCategory pc : PublicationCategories.getPublicCategories()) {
130  tree.addLeaf(pc, pc.getName());
131  }
132  root.generateCategoriesChildren(tree, (t) -> {
133  return "?category=" + (t.getValue() == null ? "0" : ((PublicationCategory) t.getValue()).getId());
134  });
135  }
Here is the call graph for this function:

◆ startConstruction()

void org.turro.publication.www.PublicationWeb.startConstruction ( ) throws ServletException, IOException

This method start element's construction. It gets called within IConstructor.startConstruction().

Exceptions
javax.servlet.ServletException
java.io.IOException

Implements org.turro.elephant.context.IElement.

Definition at line 138 of file PublicationWeb.java.

138  {
139  PrintWriter out = getConstructor().getOut();
140  out.print(getStart());
141  out.print(getStartBody());
142 
143  if(!Strings.isBlank(onTop)) {
145  }
146 
147  long fullPub = (Long) ObjectString.parseNativeString(getConstructor().getParameter("pubid"), Long.class, true);
148 
149  if(navigate) {
150  getConstructor().includeContent("/WEB-INF/_zul/www/publication-viewer.zul?groupId=" + groupId + "&categoryId=" + categoryId + "&fullPub=" + fullPub);
151  } else if(publicationId > 0) {
152  Publication pub = new PublicationPU().find(Publication.class, publicationId);
153  out.print(PublicationContent.getPublicationStr(
154  pub, sclass, showTitle, showDetails, showSummary, showBody, "", false, null, getConstructor()));
155  } else {
156  CategoryFilter cf = null;
157  if(categoryId == 0) {
158  cf = new CategoryFilter(getConstructor(), getId());
159  cf.setBlogger(blogger);
160  cf.processParameters();
161  }
162  if(cf != null) {
163  DaoHtmlSearch dhs = DaoHtmlSearch.getInstance(getConstructor(), ElephantContext.getContextVariable(getConstructor()));
164  pi.setSearchEngine(dhs);
165  pi.setCategoryFilter(cf);
166  }
167  pi.render();
168  }
169 
170  if(!Strings.isBlank(onBottom)) {
171  getConstructor().includeContent(onBottom);
172  }
173 
174  out.print(getEndBody());
175  out.print(getEnd());
176  }
void setSearchEngine(DaoHtmlSearch searchEngine)
void setCategoryFilter(CategoryFilter categoryFilter)
Here is the call graph for this function:

Member Data Documentation

◆ count

int org.turro.publication.www.PublicationWeb.count
protected

Definition at line 60 of file PublicationWeb.java.

◆ groupId

long org.turro.publication.www.PublicationWeb.groupId
protected

Definition at line 59 of file PublicationWeb.java.

◆ pi

PublicationIterator org.turro.publication.www.PublicationWeb.pi
protected

Definition at line 62 of file PublicationWeb.java.

◆ sclass

String org.turro.publication.www.PublicationWeb.sclass
protected

Definition at line 58 of file PublicationWeb.java.

◆ showTitle

boolean org.turro.publication.www.PublicationWeb.showTitle
protected

Definition at line 61 of file PublicationWeb.java.


The documentation for this class was generated from the following file: