BrightSide Workbench Full Report + Source Code
EntityParticipation.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2020 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.elephant.entities.db;
20 
21 import java.util.Date;
22 import javax.persistence.Entity;
23 import javax.persistence.Id;
24 import javax.persistence.IdClass;
25 import javax.persistence.Temporal;
26 import org.turro.action.Contacts;
27 import org.turro.entities.Entities;
28 import org.turro.entities.IElephantEntity;
29 import org.turro.participation.IEntityParticipation;
30 import org.turro.participation.ParticipationReason;
31 import org.turro.path.ComplexNode;
32 import org.turro.plugin.contacts.IContact;
33 
38 @Entity
39 @IdClass(EntityParticipationPK.class)
40 public class EntityParticipation implements java.io.Serializable, IEntityParticipation {
41 
42  @Id private String entityPath;
43 
44  @Id private String participatorPath;
45 
46  @Id private ParticipationReason reason;
47 
48  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
49  private java.util.Date participationDate;
50 
51  @Override
52  public String getEntityPath() {
53  return entityPath;
54  }
55 
56  public void setEntityPath(String entityPath) {
57  this.entityPath = entityPath;
58  }
59 
60  @Override
61  public String getParticipatorPath() {
62  return participatorPath;
63  }
64 
65  public void setParticipatorPath(String participatorPath) {
66  this.participatorPath = participatorPath;
67  }
68 
69  @Override
71  return reason;
72  }
73 
74  public void setReason(ParticipationReason reason) {
75  this.reason = reason;
76  }
77 
78  @Override
79  public Date getParticipationDate() {
80  return participationDate;
81  }
82 
83  public void setParticipationDate(Date participationDate) {
84  this.participationDate = participationDate;
85  }
86 
87  /* Id utils */
88 
89  public ComplexNode complexId() {
90  return ComplexNode.create(entityPath, participatorPath, reason.toString());
91  }
92 
93  /* Helpers */
94 
95  @Override
96  public IContact getContact() {
97  return Contacts.getContactById(participatorPath);
98  }
99 
100  @Override
102  return Entities.getController(participatorPath);
103  }
104 
105  @Override
107  return Entities.getController(entityPath);
108  }
109 
110 }
static IContact getContactById(String id)
Definition: Contacts.java:72
static IElephantEntity getController(String path)
Definition: Entities.java:78