BrightSide Workbench Full Report + Source Code
IssueParticipant.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 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 package org.turro.dossier.entity;
19 
20 import java.util.Objects;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.GenerationType;
25 import javax.persistence.Id;
26 import javax.persistence.JoinColumn;
27 import javax.persistence.ManyToOne;
28 import org.turro.action.Contacts;
29 import org.turro.plugin.contacts.IContact;
30 
35 @Entity
36 public class IssueParticipant implements java.io.Serializable {
37 
38  @Id
39  @GeneratedValue(strategy=GenerationType.IDENTITY)
40  @Column(name="IDENTIFIER")
41  private Long id;
42 
43  @Column(name="PARTICIPANT_NAME", nullable = false)
44  private String name;
45 
46  private String idContact;
47 
48  @Column(name="PARTICIPANT_ROLE")
49  private IssueParticipantRole role;
50 
51  private boolean pendingRevision;
52 
53  @ManyToOne
54  @JoinColumn(name="ISSUE_FK")
55  private Issue issue;
56 
57  public Long getId() {
58  return id;
59  }
60 
61  public void setId(Long id) {
62  this.id = id;
63  }
64 
65  public String getIdContact() {
66  return idContact;
67  }
68 
69  public void setIdContact(String idContact) {
70  this.idContact = idContact;
71  resetIContact();
72  }
73 
74  public Issue getIssue() {
75  return issue;
76  }
77 
78  public void setIssue(Issue issue) {
79  this.issue = issue;
80  }
81 
82  public String getName() {
83  return name;
84  }
85 
86  public void setName(String name) {
87  this.name = name;
88  }
89 
91  return role;
92  }
93 
94  public void setRole(IssueParticipantRole role) {
95  this.role = role;
96  }
97 
98  public boolean isPendingRevision() {
99  return pendingRevision;
100  }
101 
102  public void setPendingRevision(boolean pendingRevision) {
103  this.pendingRevision = pendingRevision;
104  }
105 
106  /* Helpers */
107 
108  public boolean isEmpty() {
109  return role == null || !getIContact().isValid();
110  }
111 
114  private transient IContact _contact;
115 
117  if(_contact == null) {
118  _contact = Contacts.getContactById(idContact);
119  }
120  return _contact;
121  }
122 
123  public void setIContact(IContact contact) {
124  _contact = contact;
125  idContact = _contact != null ? _contact.getId() : null;
126  name = _contact != null ? _contact.getName() : null;
127  }
128 
129  private void resetIContact() {
130  _contact = null;
131  }
132 
133  /* Utils */
134 
135  @Override
136  public int hashCode() {
137  int hash = 7;
138  hash = 97 * hash + Objects.hashCode(this.id);
139  return hash;
140  }
141 
142  @Override
143  public boolean equals(Object obj) {
144  if (this == obj) {
145  return true;
146  }
147  if (obj == null) {
148  return false;
149  }
150  if (getClass() != obj.getClass()) {
151  return false;
152  }
153  final IssueParticipant other = (IssueParticipant) obj;
154  return Objects.equals(this.id, other.id);
155  }
156 
157 }
static IContact getContactById(String id)
Definition: Contacts.java:72
void setRole(IssueParticipantRole role)
void setPendingRevision(boolean pendingRevision)