BrightSide Workbench Full Report + Source Code
WarningContentIterator.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.content;
20 
21 import java.io.Writer;
22 import java.util.Collection;
23 import java.util.Collections;
24 import org.turro.action.Interceptors;
25 import org.turro.string.Strings;
26 import org.turro.elephant.context.IConstructor;
27 import org.turro.jpa.content.EntityItemContentIterator;
28 import org.turro.marker.ElephantMarker;
29 import org.turro.plugin.contacts.IContact;
30 import org.turro.warnings.ElephantWarnings;
31 import org.turro.warnings.IWarning;
32 
37 public class WarningContentIterator extends EntityItemContentIterator<IWarning, String> {
38 
39 
40  public WarningContentIterator(IConstructor constructor, Writer writer, IContact contact, boolean mail, String pubPath) {
41  super(ElephantWarnings.getWarningList(), constructor, writer, contact, mail, pubPath);
42  }
43 
44  @Override
45  protected void renderSummary(ElephantMarker marker, IWarning e, int page) {
46  marker.put("warning", e);
47  prepareValues(e, page);
49  }
50 
51  @Override
52  protected void renderItem(ElephantMarker marker, IWarning e, int page) {
53  marker.put("warning", e);
54  prepareValues(e, page);
56  }
57 
58  @Override
59  protected IWarning entity(String value) {
60  for(IWarning w : collection) {
61  if(w.getEntity().equals(value)) {
62  return w;
63  }
64  }
65  return null;
66  }
67 
68  private void prepareValues(IWarning w, int page) {
69  prepareControls(w, page);
70  }
71 
72  @Override
73  protected String title(IWarning e) {
74  return "/**/";
75  }
76 
77  @Override
78  protected Collection<String> metas(IWarning e) {
79  return Collections.EMPTY_LIST;
80  }
81 
82  @Override
83  protected String getTemplateRoot() {
84  return isMail() ? "content/newsletter/sections/warnings" : "warning";
85  }
86 
87  @Override
88  protected Object doVotesCtrl(IWarning e) {
89  return null;
90  }
91 
92  @Override
93  protected Object doInterestCtrl(IWarning e) {
94  return null;
95  }
96 
97  @Override
98  protected Object doCommentsCtrl(IWarning e) {
99  return null;
100  }
101 
102  @Override
103  protected Object doAttachmentsCtrl(IWarning e) {
104  return null;
105  }
106 
107  @Override
108  protected Object doFilesCtrl(IWarning e) {
109  return null;
110  }
111 
112  @Override
113  protected Object doDescriptionsCtrl(IWarning e) {
114  return null;
115  }
116 
117  @Override
118  protected Object doPollsCtrl(IWarning e) {
119  return null;
120  }
121 
122  @Override
123  protected String getItemLink(IWarning e) {
124  return null;
125  }
126 
127  @Override
128  protected String getReadAllLink() {
129  if(Strings.isBlank(getContextPath())) {
130  return "/app/frame?" + Interceptors.parameters("warnings").encoded();
131  }
132  return getContextPath();
133  }
134 
135  @Override
136  protected String getRestrictedLink() {
137  return null;
138  }
139 
140 }
static Parameters parameters(String root)
WarningContentIterator(IConstructor constructor, Writer writer, IContact contact, boolean mail, String pubPath)
void renderSummary(ElephantMarker marker, IWarning e, int page)
void renderItem(ElephantMarker marker, IWarning e, int page)
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)
static List< IWarning > getWarningList()