19 package org.turro.alliance.provider;
21 import org.turro.alliance.content.control.Participations;
22 import org.turro.alliance.db.AlliancePU;
23 import org.turro.alliance.db.entities.AxParticipation;
24 import org.turro.alliance.db.entities.AxProject;
25 import org.turro.alliance.db.entities.RelationId;
26 import org.turro.jpa.Dao;
27 import org.turro.json.Jsons;
28 import org.turro.server.db.entities.AxAllianceParticipation;
29 import org.turro.server.db.entities.AxParticipationRequest;
30 import org.turro.sql.SqlClause;
31 import org.turro.string.Strings;
32 import org.turro.util.Cached;
33 import org.turro.ws.WsMember;
43 .where().equal(
"id", projectId)
46 return Jsons.read(
project.toJson());
51 SqlClause.select(
"p").from(
"AxParticipation p")
52 .where().equal(
"id", projectId)
63 SqlClause.select(
"p").from(
"AxAllianceParticipation p")
64 .where().equal(
"id", correctId(projectId))
65 .startIf(!Strings.isBlank(as))
66 .and().isTrue(Strings.lowerCase(as))
78 SqlClause.select(
"p").from(
"AxParticipationRequest p")
79 .where().equal(
"mainMemberId", member.
getMemberId())
90 SqlClause.select(
"p").from(
"AxParticipationRequest p")
91 .where().equal(
"id", correctId(projectId))
97 SqlClause.select(
"p").from(
"AxAllianceParticipation p")
98 .where().equal(
"id", correctId(projectId))
109 SqlClause.select(
"p").from(
"AxParticipationRequest p")
110 .where().equal(
"mainMemberId", member.
getMemberId())
111 .or().equal(
"relatedMemberId", member.
getMemberId())
112 .orderBy(
"p.creation desc")
118 SqlClause.select(
"p").from(
"AxAllianceParticipation p")
119 .where().equal(
"mainMemberId", member.
getMemberId())
120 .or().equal(
"relatedMemberId", member.
getMemberId())
121 .orderBy(
"p.creation desc")
136 axp.
setId(request.getString(
"axId"));
137 switch(request.getString(
"as")) {
142 axp.
setName(request.getString(
"contactName"));
143 axp.
setFace(request.getString(
"contactFace"));
144 axp.
setCompany(request.getString(
"companyName"));
151 return !SqlClause.select(
"p").from(
"AxAllianceParticipation p")
152 .where().equal(
"id", request.getString(
"axId"))
153 .and().equal(
"relatedEntityId", request.getString(
"contactId"))
154 .and().equal(
"relatedMemberId", member.
getMemberId())
155 .and().isTrue(request.getString(
"as").toLowerCase())
161 return !SqlClause.select(
"p").from(
"AxParticipationRequest p")
162 .where().equal(
"id", request.getString(
"axId"))
163 .and().equal(
"relatedEntityId", request.getString(
"contactId"))
164 .and().equal(
"relatedMemberId", member.
getMemberId())
165 .and().isTrue(request.getString(
"as").toLowerCase())
170 public boolean save(Jsons request) {
172 dao.get().saveObject(ap);
179 dao.get().deleteObject(pr);
183 if(axRequest.getBoolean(
"validated")) {
185 dao.get().deleteObject(ap);
188 dao.get().deleteObject(pr);
194 private String correctId(String axId) {
195 if(!Strings.isBlank(axId) && !axId.contains(
"##")) {
203 private final Cached<Dao> dao = Cached.instance(() ->
new AlliancePU());
214 this.member = member;
static Participations from(AxParticipationRequest request)
void setRelatedMemberId(Long relatedMemberId)
void setRelatedEntityId(String relatedEntityId)
void axValidatePending(Jsons axPending)
Jsons axParticipations(String projectId, String as)
boolean save(Jsons request)
void axAskParticipate(Jsons request)
boolean hasRequested(Jsons request)
Jsons participations(String projectId)
void axDeleteParticipation(Jsons axRequest)
boolean isParticipant(Jsons request)
static Projects from(WsMember member)
Jsons axPendingParticipations()
Jsons axFullParticipations()
Jsons project(String projectId)
Jsons axAllParticipations(String projectId)
static AxAllianceParticipation fromJson(JsonValue value)
void setBeneficiary(boolean beneficiary)
void setMemberName(String memberName)
static AxParticipationRequest fromJson(JsonValue value)
void setOfferer(boolean offerer)
void setConsortium(boolean consortium)
void setFace(String face)
void setRelation(RelationId relation)
void setCompanyFace(String companyFace)
void setName(String name)
void setCompany(String company)