1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
package org.directdemocracyportal.democracy.model.core; |
6 | |
|
7 | |
import java.util.HashSet; |
8 | |
import java.util.Set; |
9 | |
|
10 | |
import javax.persistence.Entity; |
11 | |
import javax.persistence.FetchType; |
12 | |
import javax.persistence.GeneratedValue; |
13 | |
import javax.persistence.GenerationType; |
14 | |
import javax.persistence.Id; |
15 | |
import javax.persistence.Inheritance; |
16 | |
import javax.persistence.InheritanceType; |
17 | |
import javax.persistence.JoinColumn; |
18 | |
import javax.persistence.ManyToMany; |
19 | |
import javax.persistence.ManyToOne; |
20 | |
|
21 | |
import org.hibernate.annotations.Cache; |
22 | |
import org.hibernate.annotations.CacheConcurrencyStrategy; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
@Entity |
28 | |
@Inheritance(strategy = InheritanceType.JOINED) |
29 | |
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) |
30 | |
public class Role extends BaseEntity |
31 | |
{ |
32 | |
|
33 | |
|
34 | |
private static final long serialVersionUID = 3342667773031897040L; |
35 | |
|
36 | |
|
37 | |
private Long id; |
38 | |
|
39 | |
|
40 | |
private String name; |
41 | |
|
42 | |
|
43 | |
private String shortDescription; |
44 | |
|
45 | |
|
46 | |
private String longDescription; |
47 | |
|
48 | |
|
49 | |
private GroupAgent groupAgent; |
50 | |
|
51 | |
|
52 | 2 | private Set<Agent> players = new HashSet<Agent>(); |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | 2 | public Role() { |
58 | 2 | } |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
@Override |
66 | |
@Id |
67 | |
@GeneratedValue(strategy = GenerationType.AUTO) |
68 | |
public Long getId() { |
69 | 2 | return this.id; |
70 | |
} |
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
public void setId(Long id) { |
78 | 0 | this.id = id; |
79 | 0 | } |
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
public String getName() { |
87 | 0 | return name; |
88 | |
} |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
public void setName(String name) { |
96 | 0 | this.name = name; |
97 | 0 | } |
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
@ManyToOne |
105 | |
@JoinColumn |
106 | |
public GroupAgent getGroupAgent() { |
107 | 0 | return this.groupAgent; |
108 | |
} |
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
public void setGroupAgent(GroupAgent organisation) { |
116 | 0 | this.groupAgent = organisation; |
117 | 0 | } |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
@ManyToMany(fetch = FetchType.LAZY) |
125 | |
public Set<Agent> getPlayers() { |
126 | 0 | return players; |
127 | |
} |
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
public void setPlayers(Set<Agent> players) { |
135 | 0 | this.players = players; |
136 | 0 | } |
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
public String getShortDescription() { |
144 | 0 | return shortDescription; |
145 | |
} |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
public void setShortDescription(String shortDescription) { |
153 | 0 | this.shortDescription = shortDescription; |
154 | 0 | } |
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
public String getLongDescription() { |
162 | 0 | return longDescription; |
163 | |
} |
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
public void setLongDescription(String longDescription) { |
171 | 0 | this.longDescription = longDescription; |
172 | 0 | } |
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
@Override |
180 | |
public int hashCode() { |
181 | |
final int prime = 31; |
182 | 0 | int result = 1; |
183 | 0 | result = prime * result + ((id == null) ? 0 : id.hashCode()); |
184 | 0 | result = prime * result |
185 | |
+ ((longDescription == null) ? 0 : longDescription.hashCode()); |
186 | 0 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
187 | 0 | result = prime |
188 | |
* result |
189 | |
+ ((shortDescription == null) ? 0 : shortDescription.hashCode()); |
190 | 0 | return result; |
191 | |
} |
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
@Override |
199 | |
public boolean equals(Object obj) { |
200 | 0 | if (this == obj) |
201 | 0 | return true; |
202 | 0 | if (obj == null) |
203 | 0 | return false; |
204 | 0 | if (getClass() != obj.getClass()) |
205 | 0 | return false; |
206 | 0 | final Role other = (Role) obj; |
207 | 0 | if (id == null) { |
208 | 0 | if (other.id != null) |
209 | 0 | return false; |
210 | 0 | } else if (!id.equals(other.id)) |
211 | 0 | return false; |
212 | 0 | if (longDescription == null) { |
213 | 0 | if (other.longDescription != null) |
214 | 0 | return false; |
215 | 0 | } else if (!longDescription.equals(other.longDescription)) |
216 | 0 | return false; |
217 | 0 | if (name == null) { |
218 | 0 | if (other.name != null) |
219 | 0 | return false; |
220 | 0 | } else if (!name.equals(other.name)) |
221 | 0 | return false; |
222 | 0 | if (shortDescription == null) { |
223 | 0 | if (other.shortDescription != null) |
224 | 0 | return false; |
225 | 0 | } else if (!shortDescription.equals(other.shortDescription)) |
226 | 0 | return false; |
227 | 0 | return true; |
228 | |
} |
229 | |
} |