BrightSide Workbench Full Report + Source Code
AbstractDashboard.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2024 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.collections.CollectionHtmlIterator;
25 import org.turro.elephant.impl.abstracts.AbstractElement;
26 
31 public abstract class AbstractDashboard extends AbstractElement {
32 
33  private String fullTemplate, summaryTemplate, sclass;
34  private int count;
35  private CollectionHtmlIterator iterator;
36 
37  @Override
38  public void loadData() throws ServletException, IOException {
39  sclass = getAttributes().getAttributeValue("attrib:sclass", "");
40  count = getAttributes().getAttributeIntegerValue("attrib:count", 10);
41  fullTemplate = getAttributes().getAttributeValue("attrib:fullTemplate", "");
42  summaryTemplate = getAttributes().getAttributeValue("attrib:summaryTemplate", "");
43  iterator = initIterator();
44 // HtmlSearch dhs = getSearchEngine();
45 // if(dhs != null) {
46 // iterator.setSearchEngine(dhs);
47 // initSearchEngine();
48 // }
49  iterator.setPage(count);
50  iterator.setFullTemplate(fullTemplate);
51  iterator.setSummaryTemplate(summaryTemplate);
52  iterator.load();
53  setTitle(iterator.getTitle());
54  if(iterator.isItem()) {
55  setMetas(iterator.getMetas());
56  } else {
58  }
59  }
60 
62  return iterator;
63  }
64 
65  public String getFullTemplate() {
66  return fullTemplate;
67  }
68 
69  public String getSummaryTemplate() {
70  return summaryTemplate;
71  }
72 
73  public int getCount() {
74  return count;
75  }
76 
77  public String getSclass() {
78  return sclass;
79  }
80 
81  @Override
82  public String getStart() {
83  return "<div class='dashboard " + getSclass() + "'>";
84  }
85 
86  @Override
87  public String getEnd() {
88  return "</div>";
89  }
90 
91  @Override
92  public void startConstruction() throws ServletException, IOException {
93  PrintWriter out = getConstructor().getOut();
94  out.print(getStart());
95  out.print(getStartBody());
96 
97 // if(!getIterator().isItem()) {
98 // DaoHtmlSearch dhs = getSearchEngine();
99 // if(dhs != null) {
100 // getIterator().setSearchEngine(dhs);
101 // }
102 // }
103 
104  getIterator().render();
105 
106  out.print(getEndBody());
107  out.print(getEnd());
108  }
109 
110  protected abstract CollectionHtmlIterator initIterator();
111  protected abstract void initSearchEngine();
112 
113 // protected HtmlSearch getSearchEngine() {
114 // return HtmlSearch.getInstance(getConstructor(), ElephantContext.getContextVariable(getConstructor()));
115 // }
116 
119  }
120 
121 }
abstract CollectionHtmlIterator initIterator()
static DashboardContext getInstance(IConstructor constructor)