19 package org.turro.publication.entity;
21 import java.io.IOException;
22 import java.io.Writer;
23 import java.util.TreeSet;
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.Lob;
30 import javax.persistence.ManyToOne;
31 import org.turro.string.Strings;
32 import org.turro.action.content.ContentContext;
33 import org.turro.action.content.ContentProviders;
34 import org.turro.action.content.ContentRenderer;
35 import org.turro.jpa.entity.IDaoEntity;
36 import org.turro.plugin.contacts.IContact;
37 import org.turro.util.CompareUtil;
47 @GeneratedValue(strategy=GenerationType.IDENTITY)
48 @Column(name=
"IDENTIFIER")
54 private int newsOrder;
56 private boolean newColumn, useAsTrigger, hideIfEmpty;
64 private String banner;
87 this.newsletter = newsletter;
95 this.newsOrder = newsOrder;
103 this.newColumn = newColumn;
111 this.useAsTrigger = useAsTrigger;
119 this.hideIfEmpty = hideIfEmpty;
135 this.banner = banner;
171 return Strings.isBlank(body);
189 boolean firstColumn =
false;
190 boolean lastColumn =
false;
192 firstColumn = newsletter.checkStartRow(
this);
193 lastColumn = newsletter.checkEndRow(
this);
195 template.write(
"<@start_row/>\n");
196 template.write(
"<@start_column/>\n");
197 template.write(
"<@start_full_table \"0\" \"0\"/>\n");
198 template.write(
"<@start_row/>\n");
200 template.write(
"<@start_stackable style=\"width:" + getColumnWidth(
this) +
"\"/>\n");
202 template.write(
"<@start_row/>\n");
203 template.write(
"<@start_column/>\n");
206 if(!Strings.isBlank(banner)) {
208 template.write(
"<a target='_blank' href='" + banner +
"'>");
210 template.write(banner);
215 template.write(
"${newsSection" + newsOrder +
".generateBody()}\n");
217 template.write(
"${newsSection" + newsOrder +
".body}\n");
220 if(!Strings.isBlank(banner)) {
222 template.write(
"</a>");
227 template.write(
"<@stackable_divider/>");
230 template.write(
"<@end_column/>\n");
234 template.write(
"<@end_row/>\n");
235 template.write(
"<@end_table/>\n");
236 template.write(
"<@end_column/>\n");
237 template.write(
"<@end_row/>\n");
238 template.write(
"<@row_summary_divider height=\"20px\"/>");
241 template.write(
"<@end_row/>\n");
242 template.write(
"<@row_summary_divider height=\"20px\"/>");
258 return content !=
null ? content.
execute() :
"";
272 return "NewsSection" +
getId();
279 int result = CompareUtil.compare(newsOrder, o.newsOrder);
280 if(result == 0 &&
id !=
null && o.id !=
null) {
281 result = CompareUtil.compare(
id, o.id);
286 private String getColumnWidth(
NewsSection section) {
287 if(!Strings.isBlank(section.
getWidth())) {
290 TreeSet<NewsSection> sections =
new TreeSet(newsletter.getNewsSections());
292 boolean iAmIn =
false;
293 for(NewsSection ns : sections) {
294 if(ns.isNewColumn()) {
301 return (100 / count) +
"%";
306 if(iAmIn && count > 0) {
307 return (100 / count) +
"%";
static void removeContent(String context)
static ContentRenderer loadCommand(String command, IContact contact, String idContext)
IContentIterator getIterator()
int compareTo(NewsSection o)
void setHideIfEmpty(boolean hideIfEmpty)
void setWidth(String width)
boolean canShow(IContact contact)
void setNewsOrder(int newsOrder)
Newsletter getNewsletter()
void setNewColumn(boolean newColumn)
void resetGlobalContext()
void setWiki(String wiki)
void setBody(String body)
void setBanner(String banner)
void generateSection(Writer template)
void setUseAsTrigger(boolean useAsTrigger)
void setNewsletter(Newsletter newsletter)
NewsSectionType getType()
void loadBody(IContact contact)
void setType(NewsSectionType type)