BrightSide Workbench Full Report + Source Code
Acceptance.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.contacts;
19 
20 import java.util.Date;
21 import javax.persistence.*;
22 import org.turro.action.Contacts;
23 import org.turro.action.IAcceptance;
24 import org.turro.entities.Entities;
25 import org.turro.entities.IElephantEntity;
26 import org.turro.i18n.I_;
27 import org.turro.plugin.contacts.IContact;
28 
33 @Entity
34 @org.hibernate.annotations.GenericGenerator(name = "hibernate-uuid", strategy = "uuid")
35 public class Acceptance implements java.io.Serializable, IAcceptance {
36 
37  @Id
38  @GeneratedValue(generator = "hibernate-uuid")
39  @Column(name="IDENTIFIER")
40  private String id;
41 
42  @Column(name="ACCEPTANCE_PATH")
43  private String path;
44 
45  @ManyToOne
46  @JoinColumn(name="PETITIONER_FK")
47  private org.turro.contacts.Contact petitioner;
48 
49  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
50  private java.util.Date dateRequest;
51 
52  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
53  private java.util.Date dateAcceptance;
54 
55  @Lob
56  @Column(length=4096)
57  private String acceptanceComment;
58 
59  @ManyToOne
60  @JoinColumn(name="CONTACT_FK")
61  private org.turro.contacts.Contact contact;
62 
63  @Override
64  public String getAcceptanceComment() {
65  return acceptanceComment;
66  }
67 
68  @Override
69  public void setAcceptanceComment(String acceptanceComment) {
70  this.acceptanceComment = acceptanceComment;
71  }
72 
73  public Contact getContact() {
74  return contact;
75  }
76 
77  public void setContact(Contact contact) {
78  this.contact = contact;
79  }
80 
81  @Override
82  public Date getDateAcceptance() {
83  return dateAcceptance;
84  }
85 
86  @Override
87  public void setDateAcceptance(Date dateAcceptance) {
88  this.dateAcceptance = dateAcceptance;
89  }
90 
91  @Override
92  public Date getDateRequest() {
93  return dateRequest;
94  }
95 
96  @Override
97  public void setDateRequest(Date dateRequest) {
98  this.dateRequest = dateRequest;
99  }
100 
101  @Override
102  public String getId() {
103  return id;
104  }
105 
106  @Override
107  public void setId(String id) {
108  this.id = id;
109  }
110 
111  @Override
112  public String getPath() {
113  return path;
114  }
115 
116  @Override
117  public void setPath(String path) {
118  this.path = path;
119  }
120 
122  return petitioner;
123  }
124 
125  public void setPetitioner(Contact petitioner) {
126  this.petitioner = petitioner;
127  }
128 
129  /* Helpers */
130 
131  @Override
133  return Contacts.getContact(contact);
134  }
135 
136  @Override
137  public void setIContact(IContact icontact) {
138  if(icontact != null && icontact.isValid()) {
139  contact = (Contact) icontact.getContact();
140  }
141  }
142 
143  @Override
145  return Contacts.getContact(petitioner);
146  }
147 
148  @Override
149  public void setIPetitioner(IContact icontact) {
150  if(icontact != null && icontact.isValid()) {
151  petitioner = (Contact) icontact.getContact();
152  }
153  }
154 
155  public String getString() {
156  if(dateAcceptance != null) {
157  return getContact().getName() + " " + I_.get("Accepted");
158  } else {
159  return I_.format("%s requires acceptation from %s",
160  getPetitioner().getName(), getContact().getName());
161  }
162  }
163 
164  @Override
166  return Entities.getController(path);
167  }
168 
169 }
static IContact getContact(Object object)
Definition: Contacts.java:109
void setContact(Contact contact)
Definition: Acceptance.java:77
void setPetitioner(Contact petitioner)
void setIContact(IContact icontact)
void setDateAcceptance(Date dateAcceptance)
Definition: Acceptance.java:87
IElephantEntity getEntity()
void setAcceptanceComment(String acceptanceComment)
Definition: Acceptance.java:69
void setIPetitioner(IContact icontact)
void setDateRequest(Date dateRequest)
Definition: Acceptance.java:97
static IElephantEntity getController(String path)
Definition: Entities.java:78
static String format(String msg, Object... arguments)
Definition: I_.java:49
static String get(String msg)
Definition: I_.java:41