BrightSide Workbench Full Report + Source Code
ContactsProcessor.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.parser.processor;
20 
21 import org.turro.auth.Authentication;
22 import org.turro.contacts.content.DirectoryContentIterator;
23 import org.turro.jpa.search.DaoHtmlSearch;
24 import org.turro.parser.MacroMap;
25 import org.turro.parser.MacroParameter;
26 import org.turro.string.Strings;
27 
33 
34  @Override
35  public String getName() {
36  return "Contacts";
37  }
38 
39  @Override
40  protected void doProcess(MacroProcessorContext context) {
41  final MacroAdapter macro = context.getMacro();
42  switch(macro.getName()) {
43  case "directory" -> {
46  context.getConstructor(), context.getWriter(),
47  Authentication.getIContact(), false, context.getContextPath(true));
48  pci.setAllowAttachments(true);
49  pci.setAllowFiles(true);
50  pci.setTypes(macro.get("type"));
51  pci.setSyndications(macro.get("syndicationId"));
52  pci.setContactIds(Strings.csvToList(macro.get("contactId")));
53  pci.assignDefaultsByMacro(context);
54  pci.load();
55  pci.render();
56  }
57  }
58  }
59 
60  @Override
61  protected void explainMacros(MacroMap macros) {
62  macros.addMacro("directory")
63  .addParameter(MacroParameter.strict("type", "typed",
64  "companies", "centers", "professionals",
65  "educators", "students", "singletons").multiple())
66  .addParameter(MacroParameter.optional("syndicationId").multiple())
67  .addParameter(MacroParameter.optional("contactId").multiple())
68  .addIterator(12, true, false, false, false)
69  .addTemplate("summary");
70  }
71 }
void assignDefaultsByMacro(MacroProcessorContext context)
void setAllowAttachments(boolean allowAttachments)
static void renderInstance(IConstructor constructor)
void doProcess(MacroProcessorContext context)