BrightSide Workbench Full Report + Source Code
FinancialsContentProvider.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2018 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.financials.content;
20 
21 import java.io.StringWriter;
22 import java.io.Writer;
23 import org.turro.action.content.AbstractContentProvider;
24 import org.turro.action.content.ContentRenderer;
25 import org.turro.action.content.IContentIterator;
26 import org.turro.annotation.ContentProvider;
27 import org.turro.command.MacroCommand;
28 import org.turro.elephant.context.HeadlessApplication;
29 import org.turro.plugin.contacts.IContact;
30 
35 @ContentProvider
37 
39  addCommands();
40  }
41 
42  private void addCommands() {
43  MacroCommand mc = new MacroCommand("contracts");
44  mc.addParameter("status", "active", true)
45  .setPossibleValuesString("active|closed|all");
46  mc.addParameter("context", "", true);
47  mc.addParameter("count", Integer.valueOf(10), true);
48  mc.addParameter("intervention", Boolean.TRUE, true);
49  mc.addParameter("type", Integer.valueOf(0), true);
50  mc.addParameter("template", "summary", true);
51  commands.add(mc);
52  }
53 
54  @Override
55  public ContentRenderer loadCommand(MacroCommand macroCommand, IContact contact, String idContext) {
56  if(macroCommand.itsMe("contracts(")) {
57  StringWriter sw = new StringWriter();
60  sw, contact, true,
61  macroCommand.getParameterValue(String.class, "context"));
62  if(macroCommand.getParameterValue(String.class, "status").equals("active")) {
63  ci.setStatus(1);
64  } else if(macroCommand.getParameterValue(String.class, "status").equals("closed")) {
65  ci.setStatus(2);
66  }
67  ci.setPage(macroCommand.getParameterValue(Integer.class, "count"));
68  ci.setAllowAttachments(true);
69  ci.setAllowFiles(true);
70  ci.setAllowDescriptions(true);
71  ci.setAllowInterest(true);
72  ci.setAllowVotes(true);
73  ci.setAllowComments(true);
74  ci.setAllowPolls(true);
75  ci.setSummaryTemplate(macroCommand.getParameterValue(String.class, "template"));
76  ci.setCheckParticipation(macroCommand.getParameterValue(Boolean.class, "intervention"));
77  ci.setType(macroCommand.getParameterValue(Integer.class, "type"));
78  ci.setNavigatorTop(false);
79  ci.setNavigatorBottom(false);
80  ci.load();
81  return new ContentRenderer(macroCommand, ci, sw, (IContentIterator iterator, Writer writer) -> {
82  iterator.render();
83  return writer.toString();
84  });
85  }
86  return null;
87  }
88 
89 }
ContentRenderer loadCommand(MacroCommand macroCommand, IContact contact, String idContext)
void setAllowAttachments(boolean allowAttachments)
void setAllowInterest(boolean allowInterest)
void setAllowDescriptions(boolean allowDescriptions)
void setAllowComments(boolean allowComments)
void setNavigatorBottom(boolean navigatorBottom)
void setSummaryTemplate(String summaryTemplate)
void setNavigatorTop(boolean navigatorTop)