BrightSide Workbench Full Report + Source Code
AgreementContentIterator.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 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.string.Strings;
25 import org.turro.agreements.AgreementsUtil;
26 import org.turro.elephant.context.IConstructor;
27 import org.turro.elephant.entities.db.AgreementSignature;
28 import org.turro.jpa.content.EntityItemContentIterator;
29 import org.turro.marker.ElephantMarker;
30 import org.turro.plugin.contacts.IContact;
31 
36 public class AgreementContentIterator extends EntityItemContentIterator<AgreementSignature, Long> {
37 
38  public AgreementContentIterator(IConstructor constructor, Writer writer, IContact contact, boolean mail, String pubPath) {
39  super(AgreementsUtil.notSigned(contact), constructor, writer, contact, mail, pubPath);
40  }
41 
42  @Override
43  protected void renderSummary(ElephantMarker marker, AgreementSignature e, int page) {
44  marker.put("signature", e);
45  prepareValues(e, page);
47  }
48 
49  @Override
50  protected void renderItem(ElephantMarker marker, AgreementSignature e, int page) {
51  marker.put("signature", e);
52  prepareValues(e, page);
54  }
55 
56  @Override
57  protected AgreementSignature entity(Long value) {
58  for(AgreementSignature w : collection) {
59  if(w.getId().equals(value)) {
60  return w;
61  }
62  }
63  return null;
64  }
65 
66  private void prepareValues(AgreementSignature w, int page) {
67  prepareControls(w, page);
68  }
69 
70  @Override
71  protected String title(AgreementSignature e) {
72  return "/**/";
73  }
74 
75  @Override
76  protected Collection<String> metas(AgreementSignature e) {
77  return Collections.EMPTY_LIST;
78  }
79 
80  @Override
81  protected String getTemplateRoot() {
82  return isMail() ? "content/newsletter/sections/agreements" : "agreement";
83  }
84 
85  @Override
86  protected Object doVotesCtrl(AgreementSignature e) {
87  return null;
88  }
89 
90  @Override
91  protected Object doInterestCtrl(AgreementSignature e) {
92  return null;
93  }
94 
95  @Override
96  protected Object doCommentsCtrl(AgreementSignature e) {
97  return null;
98  }
99 
100  @Override
101  protected Object doAttachmentsCtrl(AgreementSignature e) {
102  return null;
103  }
104 
105  @Override
106  protected Object doFilesCtrl(AgreementSignature e) {
107  return null;
108  }
109 
110  @Override
112  return null;
113  }
114 
115  @Override
116  protected Object doPollsCtrl(AgreementSignature e) {
117  return null;
118  }
119 
120  @Override
121  protected String getItemLink(AgreementSignature e) {
122  return getReadAllLink() + "?item=" + e.getId();
123  }
124 
125  @Override
126  protected String getReadAllLink() {
127  if(Strings.isBlank(getContextPath())) {
128  return getRestrictedLink();
129  }
130  return getContextPath();
131  }
132 
133  @Override
134  protected String getRestrictedLink() {
135  return "/user/myagreements";
136  }
137 
138 }
static List< AgreementSignature > notSigned(IContact contact)
void renderItem(ElephantMarker marker, AgreementSignature e, int page)
Collection< String > metas(AgreementSignature e)
void renderSummary(ElephantMarker marker, AgreementSignature e, int page)
AgreementContentIterator(IConstructor constructor, Writer writer, IContact contact, boolean mail, String pubPath)
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)