1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.exoplatform.social.core.jpa.storage.entity;
19
20 import java.io.Serializable;
21 import java.util.Date;
22 import java.util.HashSet;
23 import java.util.Set;
24
25 import javax.persistence.CascadeType;
26 import javax.persistence.CollectionTable;
27 import javax.persistence.Column;
28 import javax.persistence.ElementCollection;
29 import javax.persistence.Entity;
30 import javax.persistence.FetchType;
31 import javax.persistence.GeneratedValue;
32 import javax.persistence.GenerationType;
33 import javax.persistence.Id;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.NamedQueries;
36 import javax.persistence.NamedQuery;
37 import javax.persistence.OneToMany;
38 import javax.persistence.SequenceGenerator;
39 import javax.persistence.Table;
40 import javax.persistence.Temporal;
41 import javax.persistence.TemporalType;
42
43 import org.exoplatform.commons.api.persistence.ExoEntity;
44
45 @Entity(name = "SocSpaceEntity")
46 @ExoEntity
47 @Table(name = "SOC_SPACES")
48 @NamedQueries({
49 @NamedQuery(name = "SpaceEntity.getLastSpaces", query = "SELECT sp FROM SocSpaceEntity sp ORDER BY sp.createdDate DESC"),
50 @NamedQuery(name = "SpaceEntity.getSpaceByGroupId", query = "SELECT sp FROM SocSpaceEntity sp WHERE sp.groupId = :groupId"),
51 @NamedQuery(name = "SpaceEntity.getSpaceByPrettyName", query = "SELECT sp FROM SocSpaceEntity sp WHERE sp.prettyName = :prettyName"),
52 @NamedQuery(name = "SpaceEntity.getSpaceByDisplayName", query = "SELECT sp FROM SocSpaceEntity sp WHERE sp.displayName = :displayName"),
53 @NamedQuery(name = "SpaceEntity.getSpaceByURL", query = "SELECT sp FROM SocSpaceEntity sp WHERE sp.url = :url") })
54 public class SpaceEntity implements Serializable {
55
56 private static final long serialVersionUID = 3223615477747436986L;
57
58 @Id
59 @SequenceGenerator(name = "SEQ_SOC_SPACES_ID", sequenceName = "SEQ_SOC_SPACES_ID")
60 @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SOC_SPACES_ID")
61 @Column(name = "SPACE_ID")
62 private Long id;
63
64 @OneToMany(fetch = FetchType.LAZY, mappedBy = "space", cascade = CascadeType.ALL, orphanRemoval = true)
65 private Set<SpaceMemberEntity> members = new HashSet<>();
66
67
68
69
70
71 @ElementCollection
72 @CollectionTable(name = "SOC_APPS", joinColumns = @JoinColumn(name = "SPACE_ID") )
73 private Set<AppEntity> app = new HashSet<>();
74
75 @Column(name = "PRETTY_NAME")
76 private String prettyName;
77
78 @Column(name = "DISPLAY_NAME")
79 private String displayName;
80
81 @Column(name = "REGISTRATION")
82 private REGISTRATION registration;
83
84 @Column(name = "DESCRIPTION")
85 private String description;
86
87 @Temporal(TemporalType.TIMESTAMP)
88 @Column(name = "AVATAR_LAST_UPDATED")
89 private Date avatarLastUpdated;
90
91 @Temporal(TemporalType.TIMESTAMP)
92 @Column(name = "BANNER_LAST_UPDATED")
93 private Date bannerLastUpdated;
94
95 @Column(name = "VISIBILITY")
96 public VISIBILITY visibility;
97
98 @Column(name = "PRIORITY")
99 public PRIORITY priority;
100
101 @Column(name = "GROUP_ID")
102 public String groupId;
103
104 @Column(name = "URL")
105 public String url;
106
107 @Column(name = "TEMPLATE")
108 private String template;
109
110 @Temporal(TemporalType.TIMESTAMP)
111 @Column(name = "CREATED_DATE", nullable = false)
112 private Date createdDate = new Date();
113
114 public Long getId() {
115 return id;
116 }
117
118 public void setId(Long id) {
119 this.id = id;
120 }
121
122 public Set<AppEntity> getApp() {
123 return app;
124 }
125
126 public void setApp(Set<AppEntity> app) {
127 this.app = app;
128 }
129
130 public String getPrettyName() {
131 return prettyName;
132 }
133
134 public void setPrettyName(String prettyName) {
135 this.prettyName = prettyName;
136 }
137
138 public String getDisplayName() {
139 return displayName;
140 }
141
142 public void setDisplayName(String displayName) {
143 this.displayName = displayName;
144 }
145
146 public REGISTRATION getRegistration() {
147 return registration;
148 }
149
150 public void setRegistration(REGISTRATION registration) {
151 this.registration = registration;
152 }
153
154 public String getDescription() {
155 return description;
156 }
157
158 public void setDescription(String description) {
159 this.description = description;
160 }
161
162 public Date getAvatarLastUpdated() {
163 return avatarLastUpdated;
164 }
165
166 public void setAvatarLastUpdated(Date avatarLastUpdated) {
167 this.avatarLastUpdated = avatarLastUpdated;
168 }
169
170 public Date getBannerLastUpdated() {
171 return bannerLastUpdated;
172 }
173
174 public void setBannerLastUpdated(Date bannerLastUpdated) {
175 this.bannerLastUpdated = bannerLastUpdated;
176 }
177
178 public VISIBILITY getVisibility() {
179 return visibility;
180 }
181
182 public void setVisibility(VISIBILITY visibility) {
183 this.visibility = visibility;
184 }
185
186 public PRIORITY getPriority() {
187 return priority;
188 }
189
190 public void setPriority(PRIORITY priority) {
191 this.priority = priority;
192 }
193
194 public String getGroupId() {
195 return groupId;
196 }
197
198 public void setGroupId(String groupId) {
199 this.groupId = groupId;
200 }
201
202 public String getUrl() {
203 return url;
204 }
205
206 public void setUrl(String url) {
207 this.url = url;
208 }
209
210 public Date getCreatedDate() {
211 return createdDate;
212 }
213
214 public void setCreatedDate(Date createdDate) {
215 this.createdDate = createdDate;
216 }
217
218 public String getTemplate() {
219 return template;
220 }
221
222 public void setTemplate(String template) {
223 this.template = template;
224 }
225
226 public Set<SpaceMemberEntity> getMembers() {
227 return members;
228 }
229
230 public void setMembers(Set<SpaceMemberEntity> members) {
231 this.members = members;
232 }
233
234 @Override
235 public boolean equals(Object o) {
236 if (this == o) {
237 return true;
238 }
239 if (o == null || getClass() != o.getClass()) {
240 return false;
241 }
242 SpaceEntity that = (SpaceEntity) o;
243 return id.equals(that.id);
244 }
245
246 @Override
247 public int hashCode() {
248 return id == null ? 0 : id.intValue();
249 }
250
251 public static enum VISIBILITY {
252 PUBLIC, PRIVATE, HIDDEN
253 }
254
255 public static enum PRIORITY {
256 HIGH, INTERMEDIATE, LOW
257 }
258
259 public static enum REGISTRATION {
260 OPEN, VALIDATION, CLOSE
261 }
262 }