BrightSide Workbench Full Report + Source Code
AbstractDaoDashboard.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2020 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 
19 package org.turro.dashboard;
20 
21 import java.io.IOException;
22 import java.io.PrintWriter;
23 import javax.servlet.ServletException;
24 import org.turro.elephant.context.ElephantContext;
25 import org.turro.elephant.impl.abstracts.AbstractElement;
26 import org.turro.jpa.iterator.DaoHtmlIterator;
27 import org.turro.jpa.search.DaoHtmlSearch;
28 
33 public abstract class AbstractDaoDashboard extends AbstractElement {
34 
35  private String fullTemplate, summaryTemplate, sclass;
36  private int count;
37  private boolean allowInterest, allowComments, allowVotes, allowDescriptions,
38  allowAttachments, allowFiles, allowPolls, restricted,
39  allowRanking, allowMatching, allowSorting, doMatching;
40  private DaoHtmlIterator iterator;
41 
42  @Override
43  public void loadData() throws ServletException, IOException {
44  sclass = getAttributes().getAttributeValue("attrib:sclass", "");
45  count = getAttributes().getAttributeIntegerValue("attrib:count", 10);
46  restricted = getAttributes().getAttributeBooleanValue("attrib:restricted", false);
47  fullTemplate = getAttributes().getAttributeValue("attrib:fullTemplate", "");
48  summaryTemplate = getAttributes().getAttributeValue("attrib:summaryTemplate", "");
49  allowInterest = getAttributes().getAttributeBooleanValue("attrib:allowInterest", true);
50  allowComments = getAttributes().getAttributeBooleanValue("attrib:allowComments", true);
51  allowVotes = getAttributes().getAttributeBooleanValue("attrib:allowVotes", true);
52  allowAttachments = getAttributes().getAttributeBooleanValue("attrib:allowAttachments", true);
53  allowDescriptions = getAttributes().getAttributeBooleanValue("attrib:allowDescriptions", true);
54  allowFiles = getAttributes().getAttributeBooleanValue("attrib:allowFiles", true);
55  allowPolls = getAttributes().getAttributeBooleanValue("attrib:allowPolls", true);
56  allowRanking = getAttributes().getAttributeBooleanValue("attrib:allowRanking", false);
57  allowMatching = getAttributes().getAttributeBooleanValue("attrib:allowMatching", false);
58  allowSorting = getAttributes().getAttributeBooleanValue("attrib:allowSorting", false);
59  doMatching = getAttributes().getAttributeBooleanValue("attrib:doMatching", false);
60  iterator = initIterator();
62  if(dhs != null) {
63  iterator.setSearchEngine(dhs);
65  }
66  iterator.setPage(count);
67  iterator.setRestricted(restricted);
68  iterator.setFullTemplate(fullTemplate);
69  iterator.setSummaryTemplate(summaryTemplate);
70  iterator.setAllowComments(allowComments);
71  iterator.setAllowInterest(allowInterest);
72  iterator.setAllowVotes(allowVotes);
73  iterator.setAllowAttachments(allowAttachments);
74  iterator.setAllowDescriptions(allowDescriptions);
75  iterator.setAllowFiles(allowFiles);
76  iterator.setAllowPolls(allowPolls);
77  iterator.setAllowRanking(allowRanking);
78  iterator.setAllowMatching(allowMatching);
79  iterator.setAllowSorting(allowSorting);
80  iterator.setDoMatching(doMatching);
81  iterator.load();
82  setTitle(iterator.getTitle());
83  if(iterator.isItem()) {
84  setMetas(iterator.getMetas());
85  } else {
87  }
88  }
89 
91  return iterator;
92  }
93 
94  public String getFullTemplate() {
95  return fullTemplate;
96  }
97 
98  public String getSummaryTemplate() {
99  return summaryTemplate;
100  }
101 
102  public int getCount() {
103  return count;
104  }
105 
106  public boolean isAllowInterest() {
107  return allowInterest;
108  }
109 
110  public boolean isAllowComments() {
111  return allowComments;
112  }
113 
114  public boolean isAllowVotes() {
115  return allowVotes;
116  }
117 
118  public boolean isAllowDescriptions() {
119  return allowDescriptions;
120  }
121 
122  public boolean isAllowAttachments() {
123  return allowAttachments;
124  }
125 
126  public boolean isAllowFiles() {
127  return allowFiles;
128  }
129 
130  public boolean isAllowPolls() {
131  return allowPolls;
132  }
133 
134  public boolean isRestricted() {
135  return restricted;
136  }
137 
138  public boolean isAllowRanking() {
139  return allowRanking;
140  }
141 
142  public boolean isAllowMatching() {
143  return allowMatching;
144  }
145 
146  public boolean isAllowSorting() {
147  return allowSorting;
148  }
149 
150  public boolean isDoMatching() {
151  return doMatching;
152  }
153 
154  public String getSclass() {
155  return sclass;
156  }
157 
158  @Override
159  public String getStart() {
160  return "<div class='dashboard " + getSclass() + "'>";
161  }
162 
163  @Override
164  public String getEnd() {
165  return "</div>";
166  }
167 
168  @Override
169  public void startConstruction() throws ServletException, IOException {
170  PrintWriter out = getConstructor().getOut();
171  out.print(getStart());
172  out.print(getStartBody());
173 
174  if(!getIterator().isItem()) {
176  if(dhs != null) {
178  }
179  }
180  getIterator().render();
181 
182  out.print(getEndBody());
183  out.print(getEnd());
184  }
185 
186  protected abstract DaoHtmlIterator initIterator();
187  protected abstract void initSearchEngine();
188 
191  }
192 
193 }
abstract DaoHtmlIterator initIterator()
static String getContextVariable(IConstructor constructor)
void setAllowAttachments(boolean allowAttachments)
void setAllowInterest(boolean allowInterest)
void setFullTemplate(String fullTemplate)
void setAllowDescriptions(boolean allowDescriptions)
void setSearchEngine(DaoHtmlSearch searchEngine)
void setAllowSorting(boolean allowSorting)
void setAllowComments(boolean allowComments)
void setAllowMatching(boolean allowMatching)
void setSummaryTemplate(String summaryTemplate)
void setAllowRanking(boolean allowRanking)
static DaoHtmlSearch getInstance(IConstructor constructor, String context)