BrightSide Workbench Full Report + Source Code
ContractParticipant.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.financials.entity;
19 
20 import javax.persistence.Column;
21 import javax.persistence.Entity;
22 import javax.persistence.GeneratedValue;
23 import javax.persistence.GenerationType;
24 import javax.persistence.Id;
25 import javax.persistence.ManyToOne;
26 import org.turro.string.Strings;
27 import org.turro.action.Contacts;
28 import org.turro.jpa.entity.IDaoEntity;
29 import org.turro.plugin.contacts.IContact;
30 
35 @Entity
36 public class ContractParticipant implements java.io.Serializable, IDaoEntity {
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  @ManyToOne
49  private Contract contract;
50 
51  private ContractInterventionType interventionType;
52 
53  private boolean sendDocuments, showDocuments, showBalance, signature;
54 
55  public Contract getContract() {
56  return contract;
57  }
58 
59  public void setContract(Contract contract) {
60  this.contract = contract;
61  }
62 
63  public Long getId() {
64  return id;
65  }
66 
67  public void setId(Long id) {
68  this.id = id;
69  }
70 
71  public String getIdContact() {
72  return idContact;
73  }
74 
75  public void setIdContact(String idContact) {
76  this.idContact = idContact;
77  resetIContact();
78  }
79 
81  return interventionType;
82  }
83 
84  public void setInterventionType(ContractInterventionType interventionType) {
85  this.interventionType = interventionType;
86  }
87 
88  public String getName() {
89  return name;
90  }
91 
92  public void setName(String name) {
93  this.name = name;
94  }
95 
96  public boolean isSendDocuments() {
97  return sendDocuments;
98  }
99 
100  public void setSendDocuments(boolean sendDocuments) {
101  this.sendDocuments = sendDocuments;
102  }
103 
104  public boolean isShowBalance() {
105  return showBalance;
106  }
107 
108  public void setShowBalance(boolean showBalance) {
109  this.showBalance = showBalance;
110  }
111 
112  public boolean isShowDocuments() {
113  return showDocuments;
114  }
115 
116  public void setShowDocuments(boolean showDocuments) {
117  this.showDocuments = showDocuments;
118  }
119 
120  public boolean isSignature() {
121  return signature;
122  }
123 
124  public void setSignature(boolean signature) {
125  this.signature = signature;
126  }
127 
128  /* IDaoEntity */
129 
130  @Override
131  public Object entityId() {
132  return id;
133  }
134 
135  @Override
136  public boolean isEmpty() {
137  return contract == null || Strings.isBlank(idContact) || interventionType == null;
138  }
139 
142  private transient IContact _contact;
143 
145  if(_contact == null) {
146  _contact = Contacts.getContactById(idContact);
147  }
148  return _contact;
149  }
150 
151  public void setIContact(IContact contact) {
152  _contact = contact;
153  idContact = _contact != null ? _contact.getId() : null;
154  name = _contact != null ? _contact.getName() : null;
155  }
156 
157  private void resetIContact() {
158  _contact = null;
159  }
160 
161 }
static IContact getContactById(String id)
Definition: Contacts.java:72
void setInterventionType(ContractInterventionType interventionType)