BrightSide Workbench Full Report + Source Code
AgreementSignature.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2018 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.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 AgreementSignature implements java.io.Serializable {
39 
40  @Id
41  @GeneratedValue(strategy=GenerationType.IDENTITY)
42  @Column(name="IDENTIFIER")
43  private Long id;
44 
45  private String idContact;
46 
47  @ManyToOne
48  @JoinColumn(name="AGREEMENT_FK")
49  private Agreement agreement;
50 
51  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
52  private java.util.Date signedDate;
53 
54  private boolean agreed;
55 
56  private int sentCount;
57 
58  public Long getId() {
59  return id;
60  }
61 
62  public void setId(Long id) {
63  this.id = id;
64  }
65 
66  public String getIdContact() {
67  return idContact;
68  }
69 
70  public void setIdContact(String idContact) {
71  this.idContact = idContact;
72  }
73 
75  return agreement;
76  }
77 
78  public void setAgreement(Agreement agreement) {
79  this.agreement = agreement;
80  }
81 
82  public Date getSignedDate() {
83  return signedDate;
84  }
85 
86  public void setSignedDate(Date signedDate) {
87  this.signedDate = signedDate;
88  }
89 
90  public boolean isAgreed() {
91  return agreed;
92  }
93 
94  public void setAgreed(boolean agreed) {
95  this.agreed = agreed;
96  }
97 
98  public int getSentCount() {
99  return sentCount;
100  }
101 
102  public void setSentCount(int sentCount) {
103  this.sentCount = sentCount;
104  }
105 
106  /* Helpers */
107 
108  public IContact getContact() {
109  return Contacts.getContactById(idContact);
110  }
111 
112  public boolean isSigned() {
113  return (signedDate != null);
114  }
115 
116  public boolean doesAgree() {
117  return (signedDate != null) && agreed;
118  }
119 
120  public boolean shouldSend() {
121  return sentCount == 0 || ((sentCount < 10) && agreement.isPeremptory());
122  }
123 
124 }
static IContact getContactById(String id)
Definition: Contacts.java:72