BrightSide Workbench Full Report + Source Code
RequestAdapter.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.model;
20 
21 import org.turro.dossier.db.DossierPU;
22 import org.turro.dossier.entity.Dossier;
23 import org.turro.json.JsonSearch;
24 import org.turro.json.Jsons;
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 RequestAdapter {
34 
35  private final WsServer server;
36  private Jsons axPending;
37 
38  public RequestAdapter(WsServer server, Jsons axPending) {
39  this.server = server;
40  this.axPending = axPending;
41  }
42 
43  public WsServer getServer() {
44  return server;
45  }
46 
47  public Jsons getAxPending() {
48  return axPending;
49  }
50 
51  public boolean getBeneficiary() {
52  return axPending.getBoolean("beneficiary");
53  }
54 
55  public void setBeneficiary(boolean value) {
56  axPending = Jsons.read(axPending.search().set("$.beneficiary", value).string());
57  }
58 
59  public boolean getOfferer() {
60  return axPending.getBoolean("offerer");
61  }
62 
63  public void setOfferer(boolean value) {
64  axPending = Jsons.read(axPending.search().set("$.offerer", value).string());
65  }
66 
67  public boolean getConsortium() {
68  return axPending.getBoolean("consortium");
69  }
70 
71  public void setConsortium(boolean value) {
72  axPending = Jsons.read(axPending.search().set("$.consortium", value).string());
73  }
74 
75  public String getMemberName() {
76  return Servers.getElephantString(server.getServerDomain(), WsConstants.MEMBER_NAME,
77  Jsons.object().add("memberId", JsonSearch.of(axPending).read("$.relation.relatedMemberId", Long.class)));
78  }
79 
80  public Dossier getProject() {
81  return new DossierPU().find(Dossier.class, JsonSearch.of(axPending).read("$.relation.mainEntityId", Long.class));
82  }
83 
84  public <T> T getRequest() {
85  return JsonSearch.of(axPending).silent().root();
86  }
87 
88 }
RequestAdapter(WsServer server, Jsons axPending)
String getServerDomain()
Definition: WsServer.java:52