BrightSide Workbench Full Report + Source Code
AxProjectBan.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 javax.persistence.EmbeddedId;
23 import javax.persistence.Entity;
24 import org.hibernate.annotations.Formula;
25 import org.turro.alliance.db.entities.RelationId;
26 import org.turro.string.Strings;
27 import org.turro.util.Converter;
28 
33 @Entity
34 public class AxProjectBan implements Serializable {
35 
36  @EmbeddedId private RelationId relation;
37 
38  @Formula("concat(mainEntityId,'##',mainMemberId)")
39  private String id; /* Widgets compatibility */
40 
41  private boolean banned;
42 
43  public String getId() {
44  return id;
45  }
46 
47  public void setId(String id) {
48  this.id = id;
49  if(!Strings.isBlank(id) && id.contains("##")) {
50  String v[] = id.split("##");
51  relation.setMainEntityId(v[0]);
52  relation.setMainMemberId(Converter.STANDARD.convert(v[1], Long.class));
53  }
54  }
55 
57  return relation;
58  }
59 
60  public void setRelation(RelationId relation) {
61  this.relation = relation;
62  }
63 
64  public boolean isBanned() {
65  return banned;
66  }
67 
68  public void setBanned(boolean banned) {
69  this.banned = banned;
70  }
71 
72 }
void setRelation(RelationId relation)