BrightSide Workbench Full Report + Source Code
VoteIt.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.ManyToOne;
29 import javax.persistence.Temporal;
30 import org.turro.elephant.security.IUser;
31 import org.turro.entities.Entities;
32 import org.turro.entities.IElephantEntity;
33 import org.turro.path.Path;
34 
39 @Entity
40 @org.hibernate.annotations.GenericGenerator(name = "hibernate-uuid", strategy = "uuid")
41 public class VoteIt implements Serializable {
42 
43  @Id
44  @GeneratedValue(generator = "hibernate-uuid")
45  @Column(name="IDENTIFIER")
46  private String id;
47 
48  private int vote;
49 
50  @Column(name="VOTEIT_PATH")
51  private String path;
52 
53  @ManyToOne
54  @JoinColumn(name="CREATOR_FK")
55  private org.turro.contacts.Contact creator;
56 
57  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
58  private java.util.Date dateCreation;
59 
60  public String getId() {
61  return id;
62  }
63 
64  public void setId(String id) {
65  this.id = id;
66  }
67 
68  public int getVote() {
69  return vote;
70  }
71 
72  public void setVote(int vote) {
73  this.vote = vote;
74  }
75 
76  public String getPath() {
77  return path;
78  }
79 
80  public void setPath(String path) {
81  this.path = path;
82  }
83 
84  public Contact getCreator() {
85  return creator;
86  }
87 
88  public void setCreator(Contact creator) {
89  this.creator = creator;
90  }
91 
92  public Date getDateCreation() {
93  return dateCreation;
94  }
95 
96  public void setDateCreation(Date dateCreation) {
97  this.dateCreation = dateCreation;
98  }
99 
100  /* Helpers */
101 
102  public String getName() {
103  if(creator != null) {
104  return creator.getName();
105  } else {
106  return null;
107  }
108  }
109 
110  public String getEmail() {
111  if(creator != null) {
112  Connector c = creator.getConnectorMap().get(IUser.CONNECTOR_EMAIL);
113  return c != null ? c.getValue() : null;
114  } else {
115  return null;
116  }
117  }
118 
119  public String getWeb() {
120  if(creator != null) {
121  Connector c = creator.getConnectorMap().get("Web");
122  return c != null ? c.getValue() : null;
123  } else {
124  return null;
125  }
126  }
127 
128  /* Entity help */
129 
131  return Entities.getController(new Path(path).getTill(2));
132  }
133 
134 }
Map< String, Connector > getConnectorMap()
Definition: Contact.java:499
IElephantEntity getOwnerEntity()
Definition: VoteIt.java:130
void setId(String id)
Definition: VoteIt.java:64
void setVote(int vote)
Definition: VoteIt.java:72
void setCreator(Contact creator)
Definition: VoteIt.java:88
void setPath(String path)
Definition: VoteIt.java:80
void setDateCreation(Date dateCreation)
Definition: VoteIt.java:96
static IElephantEntity getController(String path)
Definition: Entities.java:78
static final String CONNECTOR_EMAIL
Definition: IUser.java:27