BrightSide Workbench Full Report + Source Code
PublicationBean.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.publication.www;
19 
20 import java.io.IOException;
21 import java.util.List;
22 import org.turro.string.ObjectString;
23 import org.turro.elephant.context.ElephantContext;
24 import org.turro.elephant.context.IConstructor;
25 import org.turro.i18n.I_;
26 import org.turro.publication.db.PublicationPU;
27 import org.turro.publication.entity.Publication;
28 import org.turro.publication.entity.PublicationCategory;
29 import org.turro.publication.util.PublicationCategories;
30 import org.turro.publication.zul.portal.PublicationContent;
31 import org.zkoss.lang.Strings;
32 
37 public class PublicationBean {
38 
39  private IConstructor constructor;
40  private String context, sclass, contactId, summaryTemplate, fullTemplate;
41  private boolean showTitle, showSummary, showDetails, showBody;
42  private long groupId, categoryId, publicationId;
43  private int count;
44 
45  public String getPublished() throws IOException {
46  if(!Strings.isBlank(summaryTemplate) || !Strings.isBlank(fullTemplate)) {
47  constructor.setOutputToString();
48  PublicationIterator pi = new PublicationIterator(constructor, ElephantContext.getRootWebPath() + context, null);
49  pi.setNavigatorTop(false);
50  pi.setNavigatorBottom(false);
51  pi.setFullTemplate(fullTemplate);
52  pi.setSummaryTemplate(summaryTemplate);
53  pi.setPage(count);
54  pi.setContactId(contactId);
55  pi.setGroupId(groupId);
56  pi.setCategoryId(categoryId);
57  pi.load();
58  pi.render();
59  constructor.setOut(null);
60  return constructor.getOutputString();
61  } else if(publicationId != 0) {
62  Publication pub = new PublicationPU().find(Publication.class, publicationId);
64  pub, sclass, showTitle, showDetails, showSummary, showBody,
65  ElephantContext.getRootWebPath() + context, false,
66  I_.get("See all"), constructor);
67  } else {
68  List<Publication> list = PublicationCategories.getPublicationsBy(
69  count, groupId, categoryId, contactId, true);
71  list, sclass, showTitle, showDetails, showSummary, showBody,
72  ElephantContext.getRootWebPath() + context, false, null, constructor);
73  }
74  }
75 
76  public String getCategoryTitle() {
77  return new PublicationPU().find(PublicationCategory.class, categoryId).getName();
78  }
79 
80  public String getCategoryRSS() {
81  return "<div class='rss_feed'>" +
82  "<a href='" + ElephantContext.getRootResourcePath() +
83  "/print_" + context + "?rss'>" +
84  "<img border='0' src='" + ElephantContext.getRootResourcePath() +
85  "/_internal/system/images/feed.png'/>" +
86  "</a></div>";
87  }
88 
89  public void setSummaryTemplate(String summaryTemplate) {
90  this.summaryTemplate = summaryTemplate;
91  }
92 
93  public void setFullTemplate(String fullTemplate) {
94  this.fullTemplate = fullTemplate;
95  }
96 
97  public void setCategoryId(String categoryId) {
98  this.categoryId = (Long) ObjectString.parseNativeString(categoryId, Long.class, true);
99  }
100 
101  public void setConstructor(IConstructor constructor) {
102  this.constructor = constructor;
103  }
104 
105  public void setContactId(String contactId) {
106  this.contactId = contactId;
107  }
108 
109  public void setContext(String context) {
110  this.context = context;
111  }
112 
113  public void setCount(String count) {
114  this.count = (Integer) ObjectString.parseNativeString(count, Integer.class, true);
115  }
116 
117  public void setGroupId(String groupId) {
118  this.groupId = (Long) ObjectString.parseNativeString(groupId, Long.class, true);
119  }
120 
121  public void setPublicationId(String publicationId) {
122  this.publicationId = (Long) ObjectString.parseNativeString(publicationId, Long.class, true);
123  }
124 
125  public void setSclass(String sclass) {
126  this.sclass = sclass;
127  }
128 
129  public void setShowBody(String showBody) {
130  this.showBody = "true".equals(showBody);
131  }
132 
133  public void setShowDetails(String showDetails) {
134  this.showDetails = "true".equals(showDetails);
135  }
136 
137  public void setShowSummary(String showSummary) {
138  this.showSummary = "true".equals(showSummary);
139  }
140 
141  public void setShowTitle(String showTitle) {
142  this.showTitle = "true".equals(showTitle);
143  }
144 
145 }
static String get(String msg)
Definition: I_.java:41
void setFullTemplate(String fullTemplate)
void setNavigatorBottom(boolean navigatorBottom)
void setSummaryTemplate(String summaryTemplate)
void setNavigatorTop(boolean navigatorTop)
static List< Publication > getPublicationsBy(int max, long group, long category, String idContact, boolean accepted)
void setSummaryTemplate(String summaryTemplate)
void setPublicationId(String publicationId)
void setConstructor(IConstructor constructor)
static String getPublicationsStr(List< Publication > publications, String sclass, boolean title, boolean details, boolean summary, boolean body, String path, boolean asMail, String readAll, IConstructor constructor)
static String getPublicationStr(Publication publication, String sclass, boolean title, boolean details, boolean summary, boolean body, String path, boolean asMail, String readAll, IConstructor constructor)