BrightSide Workbench Full Report + Source Code
CategoryRequest.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2019 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.dossier.entity;
20 
21 import java.util.Date;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.GenerationType;
26 import javax.persistence.Id;
27 import javax.persistence.JoinColumn;
28 import javax.persistence.ManyToOne;
29 import javax.persistence.Temporal;
30 import org.turro.action.Contacts;
31 import org.turro.plugin.contacts.IContact;
32 
37 @Entity
38 public class CategoryRequest implements java.io.Serializable {
39 
40  @Id
41  @GeneratedValue(strategy=GenerationType.IDENTITY)
42  @Column(name="IDENTIFIER")
43  private Long id;
44 
45  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
46  private java.util.Date creation;
47 
48  private String idContact;
49 
50  private String contactName, contactEmail;
51 
52  @ManyToOne
53  @JoinColumn(name="CATEGORY_FK")
54  private Category category;
55 
56  public Long getId() {
57  return id;
58  }
59 
60  public void setId(Long id) {
61  this.id = id;
62  }
63 
64  public Date getCreation() {
65  return creation;
66  }
67 
68  public void setCreation(Date creation) {
69  this.creation = creation;
70  }
71 
72  public String getIdContact() {
73  return idContact;
74  }
75 
76  public void setIdContact(String idContact) {
77  this.idContact = idContact;
78  resetIContact();
79  }
80 
81  public String getContactName() {
82  return contactName;
83  }
84 
85  public void setContactName(String contactName) {
86  this.contactName = contactName;
87  }
88 
89  public String getContactEmail() {
90  return contactEmail;
91  }
92 
93  public void setContactEmail(String contactEmail) {
94  this.contactEmail = contactEmail;
95  }
96 
97  public Category getCategory() {
98  return category;
99  }
100 
101  public void setCategory(Category category) {
102  this.category = category;
103  }
104 
105  /* Helpers */
106 
107  public boolean isEmpty() {
108  return !getIContact().isValid();
109  }
110 
113  private transient IContact _contact;
114 
116  if(_contact == null) {
117  _contact = Contacts.getContactById(idContact);
118  }
119  return _contact;
120  }
121 
122  public void setIContact(IContact contact) {
123  _contact = contact;
124  idContact = _contact != null ? _contact.getId() : null;
125  }
126 
127  private void resetIContact() {
128  _contact = null;
129  }
130 
131 }
static IContact getContactById(String id)
Definition: Contacts.java:72
void setContactEmail(String contactEmail)