BrightSide Workbench Full Report + Source Code
AxProjectGrantPublic.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2024 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.member.db.entities;
20 
21 import java.io.Serializable;
22 import javax.persistence.Entity;
23 import javax.persistence.Id;
24 import javax.persistence.IdClass;
25 import org.turro.dossier.db.DossierPU;
26 import org.turro.dossier.entity.ProjectGrant;
27 import org.turro.jpa.entity.IDaoEntity;
28 import org.turro.string.Strings;
29 
34 @Entity
35 @IdClass(AxProjectGrantPublicPK.class)
36 public class AxProjectGrantPublic implements Serializable, IDaoEntity {
37 
38  @Id private String serverDomain;
39  @Id private String projectGrantId;
40 
41  public String getServerDomain() {
42  return serverDomain;
43  }
44 
45  public void setServerDomain(String serverDomain) {
46  this.serverDomain = serverDomain;
47  }
48 
49  public String getProjectGrantId() {
50  return projectGrantId;
51  }
52 
53  public void setProjectGrantId(String projectGrantId) {
54  this.projectGrantId = projectGrantId;
55  }
56 
57  /* Utils */
58 
59  private transient ProjectGrant projectGrant;
60 
62  return Strings.isBlank(projectGrantId) ? null :
63  (projectGrant == null ? new DossierPU().find(ProjectGrant.class, Long.valueOf(projectGrantId)) : projectGrant);
64  }
65 
66  public void setProjectGrant(ProjectGrant projectGrant) {
67  this.projectGrant = projectGrant;
68  this.projectGrantId = projectGrant == null ? null : Long.toString(projectGrant.getId());
69  }
70 
71  /* IDaoEntity */
72 
73  @Override
74  public Object entityId() {
75  return AxProjectGrantPublicPK.from(this);
76  }
77 
78  @Override
79  public boolean isEmpty() {
80  return Strings.isBlank(serverDomain) ||
81  Strings.isBlank(projectGrantId);
82  }
83 
84 }
static AxProjectGrantPublicPK from(AxProjectGrantPublic pg)