BrightSide Workbench Full Report + Source Code
WorthValue.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2017 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 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.ManyToOne;
27 import org.turro.action.Contacts;
28 import org.turro.plugin.contacts.IContact;
29 
34 @Entity
35 public class WorthValue implements java.io.Serializable {
36 
37  @Id
38  @GeneratedValue(strategy=GenerationType.IDENTITY)
39  @Column(name="IDENTIFIER")
40  private Long id;
41 
42  @ManyToOne
43  private WorthDefinition worthDefinition;
44 
45  @ManyToOne
46  private Dossier dossier;
47 
48  private String idContact;
49 
50  private double value;
51 
52  public Long getId() {
53  return id;
54  }
55 
56  public void setId(Long id) {
57  this.id = id;
58  }
59 
61  return worthDefinition;
62  }
63 
64  public void setWorthDefinition(WorthDefinition worthDefinition) {
65  this.worthDefinition = worthDefinition;
66  }
67 
68  public Dossier getDossier() {
69  return dossier;
70  }
71 
72  public void setDossier(Dossier dossier) {
73  this.dossier = dossier;
74  }
75 
76  public String getIdContact() {
77  return idContact;
78  }
79 
80  public void setIdContact(String idContact) {
81  this.idContact = idContact;
82  }
83 
84  public double getValue() {
85  return value;
86  }
87 
88  public void setValue(double value) {
89  this.value = value;
90  }
91 
92  /* Helpers */
93 
94  public boolean isEmpty() {
95  return false;
96  }
97 
100  private transient IContact _contact;
101 
103  if(_contact == null) {
104  _contact = Contacts.getContactById(idContact);
105  }
106  return _contact;
107  }
108 
109  public void setIContact(IContact contact) {
110  _contact = contact;
111  idContact = _contact != null ? _contact.getId() : null;
112  }
113 
114 }
static IContact getContactById(String id)
Definition: Contacts.java:72
void setDossier(Dossier dossier)
Definition: WorthValue.java:72
WorthDefinition getWorthDefinition()
Definition: WorthValue.java:60
void setIdContact(String idContact)
Definition: WorthValue.java:80
void setWorthDefinition(WorthDefinition worthDefinition)
Definition: WorthValue.java:64
void setIContact(IContact contact)