BrightSide Workbench Full Report + Source Code
CommentIt.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2013 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.contacts;
20 
21 import java.io.Serializable;
22 import java.util.Date;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.Id;
27 import javax.persistence.JoinColumn;
28 import javax.persistence.Lob;
29 import javax.persistence.ManyToOne;
30 import javax.persistence.Temporal;
31 import org.turro.elephant.security.IUser;
32 import org.turro.entities.Entities;
33 import org.turro.entities.IElephantEntity;
34 import org.turro.path.Path;
35 
40 @Entity
41 @org.hibernate.annotations.GenericGenerator(name = "hibernate-uuid", strategy = "uuid")
42 public class CommentIt implements Serializable {
43 
44  @Id
45  @GeneratedValue(generator = "hibernate-uuid")
46  @Column(name="IDENTIFIER")
47  private String id;
48 
49  @Column(name="COMMENTIT_PATH")
50  private String path;
51 
52  @ManyToOne
53  @JoinColumn(name="CREATOR_FK")
54  private org.turro.contacts.Contact creator;
55 
56  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
57  private java.util.Date dateCreation;
58 
59  @Lob
60  @Column(length=4096)
61  private String body;
62 
63  private boolean accepted;
64 
65  private String author;
66 
67  private String author_email;
68 
69  private String author_web;
70 
71  private String author_ip;
72 
73  public String getId() {
74  return id;
75  }
76 
77  public void setId(String id) {
78  this.id = id;
79  }
80 
81  public String getPath() {
82  return path;
83  }
84 
85  public void setPath(String path) {
86  this.path = path;
87  }
88 
89  public Contact getCreator() {
90  return creator;
91  }
92 
93  public void setCreator(Contact creator) {
94  this.creator = creator;
95  }
96 
97  public Date getDateCreation() {
98  return dateCreation;
99  }
100 
101  public void setDateCreation(Date dateCreation) {
102  this.dateCreation = dateCreation;
103  }
104 
105  public String getBody() {
106  return body;
107  }
108 
109  public void setBody(String body) {
110  this.body = body;
111  }
112 
113  public boolean isAccepted() {
114  return accepted;
115  }
116 
117  public void setAccepted(boolean accepted) {
118  this.accepted = accepted;
119  }
120 
121  public String getAuthor() {
122  return author;
123  }
124 
125  public void setAuthor(String author) {
126  this.author = author;
127  }
128 
129  public String getAuthor_email() {
130  return author_email;
131  }
132 
133  public void setAuthor_email(String author_email) {
134  this.author_email = author_email;
135  }
136 
137  public String getAuthor_web() {
138  return author_web;
139  }
140 
141  public void setAuthor_web(String author_web) {
142  this.author_web = author_web;
143  }
144 
145  public String getAuthor_ip() {
146  return author_ip;
147  }
148 
149  public void setAuthor_ip(String author_ip) {
150  this.author_ip = author_ip;
151  }
152 
153  /* Helpers */
154 
155  public String getName() {
156  if(creator != null) {
157  return creator.getName();
158  } else {
159  return author;
160  }
161  }
162 
163  public String getEmail() {
164  if(creator != null) {
165  Connector c = creator.getConnectorMap().get(IUser.CONNECTOR_EMAIL);
166  return c != null ? c.getValue() : author_email;
167  } else {
168  return author_email;
169  }
170  }
171 
172  public String getWeb() {
173  if(creator != null) {
174  Connector c = creator.getConnectorMap().get("Web");
175  return c != null ? c.getValue() : author_web;
176  } else {
177  return author_web;
178  }
179  }
180 
181  /* Entity help */
182 
184  return Entities.getController(new Path(path).getTill(2));
185  }
186 
187 }
void setAuthor_ip(String author_ip)
Definition: CommentIt.java:149
void setBody(String body)
Definition: CommentIt.java:109
void setAuthor_web(String author_web)
Definition: CommentIt.java:141
void setPath(String path)
Definition: CommentIt.java:85
void setAuthor(String author)
Definition: CommentIt.java:125
void setAccepted(boolean accepted)
Definition: CommentIt.java:117
IElephantEntity getOwnerEntity()
Definition: CommentIt.java:183
void setCreator(Contact creator)
Definition: CommentIt.java:93
void setDateCreation(Date dateCreation)
Definition: CommentIt.java:101
void setAuthor_email(String author_email)
Definition: CommentIt.java:133
Map< String, Connector > getConnectorMap()
Definition: Contact.java:499
static IElephantEntity getController(String path)
Definition: Entities.java:78
static final String CONNECTOR_EMAIL
Definition: IUser.java:27