BrightSide Workbench Full Report + Source Code
IssueComment.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.dossier.entity;
19 
20 import java.util.Date;
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.JoinColumn;
27 import javax.persistence.Lob;
28 import javax.persistence.ManyToOne;
29 import javax.persistence.Temporal;
30 import org.turro.action.Contacts;
31 import org.turro.dossier.issue.parser.CommentParser;
32 import org.turro.elephant.impl.util.StringParser;
33 import org.turro.plugin.contacts.IContact;
34 
39 @Entity
40 public class IssueComment implements java.io.Serializable {
41 
42  @Id
43  @GeneratedValue(strategy=GenerationType.IDENTITY)
44  @Column(name="IDENTIFIER")
45  private Long id;
46 
47  private String idContact, participantName;
48 
49  @Lob
50  @Column(length=4096)
51  private String comment;
52 
53  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
54  private java.util.Date modification;
55 
56  private double expenses, hours, price;
57 
58  private boolean processed = false;
59 
60  @ManyToOne
61  @JoinColumn(name = "ISSUE_FK")
62  private Issue issue;
63 
64  public String getComment() {
65  return comment;
66  }
67 
68  public void setComment(String comment) {
69  this.comment = comment;
70  }
71 
72  public double getExpenses() {
73  return expenses;
74  }
75 
76  public void setExpenses(double expenses) {
77  this.expenses = expenses;
78  }
79 
80  public double getHours() {
81  return hours;
82  }
83 
84  public void setHours(double hours) {
85  this.hours = hours;
86  }
87 
88  public Long getId() {
89  return id;
90  }
91 
92  public void setId(Long id) {
93  this.id = id;
94  }
95 
96  public String getIdContact() {
97  return idContact;
98  }
99 
100  public void setIdContact(String idContact) {
101  this.idContact = idContact;
102  resetIContact();
103  }
104 
105  public Issue getIssue() {
106  return issue;
107  }
108 
109  public void setIssue(Issue issue) {
110  this.issue = issue;
111  }
112 
113  public Date getModification() {
114  return modification;
115  }
116 
117  public void setModification(Date modification) {
118  this.modification = modification;
119  }
120 
121  public String getParticipantName() {
122  return participantName;
123  }
124 
125  public void setParticipantName(String participantName) {
126  this.participantName = participantName;
127  }
128 
129  public double getPrice() {
130  return price;
131  }
132 
133  public void setPrice(double price) {
134  this.price = price;
135  }
136 
137  public boolean isProcessed() {
138  return processed;
139  }
140 
141  public void setProcessed(boolean processed) {
142  this.processed = processed;
143  }
144 
145  public String getHtmlComment() {
146  return StringParser.toHTML(comment);
147  }
148 
149  /* Helpers */
150 
151  public boolean hasData() {
152  return hasExpenses() || hasHours() || hasPrice();
153  }
154 
155  public boolean hasExpenses() {
156  return expenses != 0;
157  }
158 
159  public boolean hasHours() {
160  return hours != 0;
161  }
162 
163  public boolean hasPrice() {
164  return price != 0;
165  }
166 
167  private transient CommentParser _parser;
168 
170  if(_parser == null) {
171  _parser = new CommentParser(comment);
172  }
173  return _parser;
174  }
175 
178  private transient IContact _contact;
179 
181  if(_contact == null) {
182  _contact = Contacts.getContactById(idContact);
183  }
184  return _contact;
185  }
186 
187  public void setIContact(IContact contact) {
188  _contact = contact;
189  idContact = _contact != null ? _contact.getId() : null;
190  participantName = _contact != null ? _contact.getName() : null;
191  }
192 
193  private void resetIContact() {
194  _contact = null;
195  }
196 
197 }
static IContact getContactById(String id)
Definition: Contacts.java:72
void setProcessed(boolean processed)
void setModification(Date modification)
void setParticipantName(String participantName)
static String toHTML(String value)