BrightSide Workbench Full Report + Source Code
AxParticipationRequest.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.server.db.entities;
20 
21 import java.io.Serializable;
22 import java.util.Date;
23 import java.util.Map;
24 import java.util.Objects;
25 import javax.json.JsonValue;
26 import javax.persistence.EmbeddedId;
27 import javax.persistence.Entity;
28 import javax.persistence.Temporal;
29 import org.hibernate.annotations.Formula;
30 import org.turro.alliance.contact.AllianceContact;
31 import org.turro.alliance.db.AlliancePU;
32 import org.turro.alliance.db.entities.AxContact;
33 import org.turro.alliance.db.entities.AxProject;
34 import org.turro.alliance.db.entities.RelationId;
35 import org.turro.jpa.entity.IDaoEntity;
36 import org.turro.json.IJSONizable;
37 import org.turro.string.Strings;
38 import org.turro.util.Converter;
39 
44 @Entity
45 public class AxParticipationRequest implements Serializable, IDaoEntity, IJSONizable {
46 
47  @EmbeddedId private RelationId relation;
48 
49  @Formula("concat(mainEntityId,'##',mainMemberId)")
50  private String id; /* Widgets compatibility */
51 
52  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
53  private java.util.Date creation;
54 
55  private boolean driver, coordinator, beneficiary, offerer, research, funding, support, consortium, admin;
56 
57  private String name, face, company, companyFace, memberName;
58 
59  private boolean validated = false;
60 
62  return relation;
63  }
64 
65  public void setRelation(RelationId relation) {
66  this.relation = relation;
67  }
68 
69  public String getId() {
70  return id;
71  }
72 
73  public void setId(String id) {
74  this.id = id;
75  if(!Strings.isBlank(id) && id.contains("##")) {
76  String v[] = id.split("##");
77  relation.setMainEntityId(v[0]);
78  relation.setMainMemberId(Converter.STANDARD.convert(v[1], Long.class));
79  }
80  }
81 
82  public Date getCreation() {
83  return creation;
84  }
85 
86  public void setCreation(Date creation) {
87  this.creation = creation;
88  }
89 
90  public boolean isDriver() {
91  return driver;
92  }
93 
94  public void setDriver(boolean driver) {
95  this.driver = driver;
96  }
97 
98  public boolean isCoordinator() {
99  return coordinator;
100  }
101 
102  public void setCoordinator(boolean coordinator) {
103  this.coordinator = coordinator;
104  }
105 
106  public boolean isBeneficiary() {
107  return beneficiary;
108  }
109 
110  public void setBeneficiary(boolean beneficiary) {
111  this.beneficiary = beneficiary;
112  }
113 
114  public boolean isOfferer() {
115  return offerer;
116  }
117 
118  public void setOfferer(boolean offerer) {
119  this.offerer = offerer;
120  }
121 
122  public boolean isResearch() {
123  return research;
124  }
125 
126  public void setResearch(boolean research) {
127  this.research = research;
128  }
129 
130  public boolean isFunding() {
131  return funding;
132  }
133 
134  public void setFunding(boolean funding) {
135  this.funding = funding;
136  }
137 
138  public boolean isSupport() {
139  return support;
140  }
141 
142  public void setSupport(boolean support) {
143  this.support = support;
144  }
145 
146  public boolean isConsortium() {
147  return consortium;
148  }
149 
150  public void setConsortium(boolean consortium) {
151  this.consortium = consortium;
152  }
153 
154  public boolean isAdmin() {
155  return admin;
156  }
157 
158  public void setAdmin(boolean admin) {
159  this.admin = admin;
160  }
161 
162  public String getName() {
163  return name;
164  }
165 
166  public void setName(String name) {
167  this.name = name;
168  }
169 
170  public String getFace() {
171  return face;
172  }
173 
174  public void setFace(String face) {
175  this.face = face;
176  }
177 
178  public String getCompany() {
179  return company;
180  }
181 
182  public void setCompany(String company) {
183  this.company = company;
184  }
185 
186  public String getCompanyFace() {
187  return companyFace;
188  }
189 
190  public void setCompanyFace(String companyFace) {
191  this.companyFace = companyFace;
192  }
193 
194  public String getMemberName() {
195  return memberName;
196  }
197 
198  public void setMemberName(String memberName) {
199  this.memberName = memberName;
200  }
201 
202  public boolean isValidated() {
203  return false;
204  }
205 
206  public void setValidated(boolean validated) {
207  this.validated = false;
208  }
209 
210  /* Project */
211 
213  return new AlliancePU().find(AxProject.class, relation.getMainProcedenceId());
214  }
215 
216  /* Contact */
217 
219  return new AlliancePU().find(AxContact.class, relation.getRelatedProcedenceId());
220  }
221 
223  return new AllianceContact(getContact());
224  }
225 
226  /* IDaoEntity */
227 
228  @Override
229  public Object entityId() {
230  return relation;
231  }
232 
233  @Override
234  public boolean isEmpty() {
235  return relation.isEmpty();
236  }
237 
238  /* JSONizable */
239 
240  @Override
241  public String toJson() {
242  return toJson(this);
243  }
244 
245  @Override
246  public String toJson(Map<String, Object> properties) {
247  return toJson(this, properties);
248  }
249 
250  public static AxParticipationRequest fromJson(JsonValue value) {
251  return IJSONizable.fromJson(value.toString(), AxParticipationRequest.class);
252  }
253 
254  /* Utils */
255 
256  @Override
257  public int hashCode() {
258  int hash = 3;
259  hash = 97 * hash + Objects.hashCode(this.relation);
260  return hash;
261  }
262 
263  @Override
264  public boolean equals(Object obj) {
265  if (this == obj) {
266  return true;
267  }
268  if (obj == null) {
269  return false;
270  }
271  if (getClass() != obj.getClass()) {
272  return false;
273  }
275  return Objects.equals(this.relation, other.relation);
276  }
277 
278 }
static AxParticipationRequest fromJson(JsonValue value)