BrightSide Workbench Full Report + Source Code
client/Projects.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2023 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.alliance.client;
20 
21 import org.turro.alliance.service.AxConstants;
22 import org.turro.alliance.service.AxServer;
23 import org.turro.json.Jsons;
24 import org.turro.string.Strings;
25 import org.turro.ws.WsServer;
26 import org.turro.ws.service.WsConstants;
27 import org.turro.ws.service.member.Servers;
28 
33 public class Projects {
34 
35  public Jsons project(String axId) {
36  return Servers.getData(WsServer.from(server.getServerDomain(), AxServer.SERVER_SERVICE),
37  AxConstants.PROJECT, Jsons.object().add("id", correctId(axId)));
38  }
39 
40  public Jsons participations(String axId) {
41  return Servers.getData(WsServer.from(server.getServerDomain(), AxServer.SERVER_SERVICE),
42  AxConstants.PARTICIPATIONS, Jsons.object().add("id", correctId(axId)));
43  }
44 
45  public Jsons axParticipations(String axId) {
46  return Servers.getData(WsServer.from(server.getServerDomain(), AxServer.SERVER_SERVICE),
47  AxConstants.AXPARTICIPATIONS, Jsons.object().add("id", correctId(axId)));
48  }
49 
50  public Jsons axParticipations(String axId, String as) {
51  return Servers.getData(WsServer.from(server.getServerDomain(), AxServer.SERVER_SERVICE),
52  AxConstants.AXPARTICIPATIONS, Jsons.object().add("id", correctId(axId)).add("as", as));
53  }
54 
55  public Jsons axParticipations() {
56  return Servers.getData(WsServer.from(server.getServerDomain(), AxServer.SERVER_SERVICE),
57  AxConstants.AXPARTICIPATIONS, Jsons.object().add("full", true));
58  }
59 
60  public Jsons axPendingRequests(String axId) {
61  return Servers.getData(WsServer.from(server.getServerDomain(), AxServer.SERVER_SERVICE),
62  AxConstants.AXPENDING_REQUESTS, Jsons.object().add("id", correctId(axId)));
63  }
64 
65  public Jsons status(String axId, String contactId, String as) {
66  return Servers.getData(WsServer.from(server.getServerDomain(), AxServer.SERVER_SERVICE),
67  AxConstants.AXPARTICIPATION_STATUS, Jsons.object()
68  .add("contactId", contactId)
69  .add("axId", correctId(axId))
70  .add("as", as));
71  }
72 
73  public Jsons hasRequested(String axId, String contactId, String as) {
74  return Servers.getData(WsServer.from(server.getServerDomain(), AxServer.SERVER_SERVICE),
75  AxConstants.AXPARTICIPATION_REQUESTED, Jsons.object()
76  .add("contactId", contactId)
77  .add("axId", correctId(axId))
78  .add("as", as));
79  }
80 
81  /* Utils */
82 
83  private String correctId(String axId) {
84  if(!Strings.isBlank(axId) && !axId.contains("##")) {
85  Jsons memberInfo = Servers.getData(server, WsConstants.CLIENT_INFO);
86  if(!Jsons.isEmpty(memberInfo)) axId += "##" + memberInfo.getLong("id");
87  }
88  return axId;
89  }
90 
91  /* Factory */
92 
93  public static Projects from(WsServer server) {
94  return new Projects(server);
95  }
96 
97  private final WsServer server;
98 
99  private Projects(WsServer server) {
100  this.server = server;
101  }
102 
103 }
Jsons status(String axId, String contactId, String as)
static Projects from(WsServer server)
Jsons axParticipations(String axId, String as)
Jsons hasRequested(String axId, String contactId, String as)
static final String SERVER_SERVICE
Definition: AxServer.java:51
static WsServer from(String serverDomain, String service)
Definition: WsServer.java:149
String getServerDomain()
Definition: WsServer.java:52