19 package org.turro.alliance.client;
21 import java.io.Writer;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Objects;
25 import javax.json.JsonObject;
26 import org.turro.alliance.content.control.ProjectAction;
27 import org.turro.alliance.content.control.ProjectCtrl;
28 import org.turro.alliance.service.AxConstants;
29 import org.turro.alliance.service.AxP2PServer;
30 import org.turro.collections.Item;
31 import org.turro.elephant.context.ElephantContext;
32 import org.turro.elephant.context.IConstructor;
33 import org.turro.elephant.impl.repository.RepositoryFile;
34 import org.turro.elephant.web.SocialNet;
35 import org.turro.entities.Entities;
36 import org.turro.jpa.search.DaoSearchKey;
37 import org.turro.json.JsonSearch;
38 import org.turro.json.Jsons;
39 import org.turro.marker.ElephantMarker;
40 import org.turro.plugin.contacts.IContact;
41 import org.turro.string.Strings;
42 import org.turro.util.Converter;
43 import org.turro.ws.WsServer;
44 import org.turro.ws.content.iterator.JsonHtmlClientIterator;
45 import org.turro.ws.content.search.JsonHtmlSearch;
46 import org.turro.ws.service.WsConstants;
47 import org.turro.ws.service.member.Servers;
48 import org.turro.ws.service.p2p.P2Ps;
57 super(constructor, contact, server, writer, mail);
67 protected Jsons
entity(String value) {
68 return items.getStructure().getArrayValues(JsonObject.class).stream()
69 .filter(item -> item.getString(
"id").equals(value.replaceAll(
"_",
"#")))
70 .map(item -> Jsons.read(item.toString()))
71 .findFirst().orElse(
null);
79 pctrl.
setAxId(e.getString(
"id"));
81 marker.
put(
"banctrl", pctrl);
83 marker.
put(
"project", JsonSearch.of(e).silent().root());
84 marker.
put(
"server", getServer());
92 criteria.add(
"projectId", e.context().read(
"$.projectId.entityId", String.class));
93 Jsons project = P2Ps.getP2PData(getServer().getServerDomain(),
94 e.context().read(
"$.projectId.memberId", Long.class),
97 Jsons memberInfo = Servers.getData(getServer(), WsConstants.CLIENT_INFO);
100 banctrl.
setAxId(e.getString(
"id"));
102 marker.
put(
"banctrl", banctrl);
105 offctrl.
setAxId(e.getString(
"id"));
108 marker.
put(
"offctrl", offctrl);
111 benctrl.
setAxId(e.getString(
"id"));
114 marker.
put(
"benctrl", benctrl);
117 conctrl.
setAxId(e.getString(
"id"));
120 marker.
put(
"conctrl", conctrl);
122 marker.
put(
"dossier", JsonSearch.of(project).silent().root());
124 criteria.add(
"projectId", e.context().read(
"$.projectId.entityId", String.class));
125 Jsons attachments = P2Ps.getP2PData(getServer().getServerDomain(),
126 e.context().read(
"$.projectId.memberId", Long.class),
128 marker.
put(
"attachments", JsonSearch.of(attachments).silent().root());
129 marker.
put(
"server", getServer());
130 marker.
put(
"domain", getServer().getServerDomain());
131 marker.
put(
"service", getServer().getService());
132 marker.
put(
"member", e.context().read(
"$.projectId.memberId", Long.class));
133 marker.
put(
"serverFace", getServer().getContact().getFaces().getUrl());
134 marker.
put(
"axid", e.getString(
"id"));
135 marker.
put(
"selfMember", memberInfo.getLong(
"id"));
136 if(Objects.equals(marker.
get(
"member"), marker.
get(
"selfMember"))) {
145 return Strings.isBlank(e.getString(
"name"),
null);
149 protected Collection<String>
metas(Jsons e) {
150 ArrayList<RepositoryFile> files =
new ArrayList<>();
152 SocialNet sn =
new SocialNet(path, e.getString(
"name"), e.getString(
"summary",
"*"), files);
158 return isMail() ?
"content/newsletter/sections/alliance/client/projects" :
"alliance/client/project";
163 return constructor.getCurrentContext().getFullPath() +
164 "?item=" + e.getString(
"id").replaceAll(
"#",
"_");
175 criteria.add(
"withBanned", contact.isAdmin());
176 Item<Jsons, Long> selected = getNavigationTree().getSelectedItem();
177 if(selected !=
null) {
179 selected.selfAndChildrenIds().forEach(
id -> {
183 if(isSearchOption()) {
189 dsk = dhs.get(
"phase");
190 criteria.add(
"phase", Converter.STANDARD.convert(Strings.isBlank(dsk.
getValue(),
"-1"), Integer.class, -1));
void renderSummary(ElephantMarker marker, Jsons e, int page)
ProjectJsonIterator(IConstructor constructor, IContact contact, WsServer server, Writer writer, boolean mail)
Collection< String > metas(Jsons e)
Jsons entity(String value)
void renderItem(ElephantMarker marker, Jsons e, int page)
String getItemLink(Jsons e)
void setServer(WsServer server)
void setAxId(String axId)
void setAction(ProjectAction action)
void setParticiationLabel(String particiationLabel)
static final String AX_P2P_SERVICE
static String getContextVariable(IConstructor constructor)
List< String > getMetas()
static IElephantEntity getController(String path)
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)