/src/main/java/com/google/ie/business/domain/User.java

http://thoughtsite.googlecode.com/ · Java · 233 lines · 125 code · 38 blank · 70 comment · 2 complexity · 7fe06c36a54ed092833c983d1285e4bb MD5 · raw file

  1. /* Copyright 2010 Google Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS.
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License
  14. */
  15. package com.google.ie.business.domain;
  16. import org.compass.annotations.Searchable;
  17. import org.compass.annotations.SearchableId;
  18. import org.compass.annotations.SearchableProperty;
  19. import java.io.Serializable;
  20. import java.util.Date;
  21. import java.util.HashSet;
  22. import java.util.Set;
  23. import javax.jdo.annotations.Extension;
  24. import javax.jdo.annotations.IdGeneratorStrategy;
  25. import javax.jdo.annotations.IdentityType;
  26. import javax.jdo.annotations.PersistenceCapable;
  27. import javax.jdo.annotations.Persistent;
  28. import javax.jdo.annotations.PrimaryKey;
  29. @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
  30. @Searchable(alias = "User")
  31. public class User implements Serializable {
  32. /** A unique identifier for the class */
  33. private static final long serialVersionUID = -1507109590723476666L;
  34. /** Constant for rolename user */
  35. public static final String ROLE_USER = "user";
  36. /** Constant for rolename admin */
  37. public static final String ROLE_ADMIN = "admin";
  38. /** Constant for rolename admin */
  39. public static final String STATUS_ACTIVE = "active";
  40. public static final String STATUS_BANNED = "banned";
  41. @PrimaryKey
  42. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  43. @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
  44. @SearchableId
  45. private String userKey;
  46. @Persistent
  47. private long reputationPoints;
  48. @Persistent
  49. private String roleName;
  50. @Persistent
  51. private String id;
  52. @Persistent
  53. private Set<String> ideaKeys;
  54. @Persistent
  55. private Date createdOn;
  56. @Persistent
  57. private String thumbnailUrl;
  58. @Persistent
  59. @SearchableProperty
  60. private String displayName;
  61. @Persistent
  62. private String emailId;
  63. @Persistent
  64. private String status;
  65. /**
  66. * @return the emailId
  67. */
  68. public String getEmailId() {
  69. return emailId;
  70. }
  71. /**
  72. * @param emailId the emailId to set
  73. */
  74. public void setEmailId(String emailId) {
  75. this.emailId = emailId;
  76. }
  77. public User() {
  78. this.status = STATUS_ACTIVE;
  79. }
  80. /**
  81. * @return the ideaKeys
  82. */
  83. public Set<String> getIdeaKeys() {
  84. if (ideaKeys == null)
  85. ideaKeys = new HashSet<String>();
  86. return ideaKeys;
  87. }
  88. /**
  89. * @param ideaKeys the ideaKeys to set
  90. */
  91. public void setIdeaKeys(Set<String> ideaKeys) {
  92. this.ideaKeys = ideaKeys;
  93. }
  94. /**
  95. * @return the status
  96. */
  97. public String getStatus() {
  98. return status;
  99. }
  100. /**
  101. * @param status the status to set
  102. */
  103. public void setStatus(String status) {
  104. this.status = status;
  105. }
  106. public String getDisplayName() {
  107. return displayName;
  108. }
  109. public String getId() {
  110. return id;
  111. }
  112. /**
  113. * @return the key
  114. */
  115. public String getUserKey() {
  116. return userKey;
  117. }
  118. /**
  119. * @return the reputationPoints
  120. */
  121. public long getReputationPoints() {
  122. return reputationPoints;
  123. }
  124. /**
  125. * @return the roleName
  126. */
  127. public String getRoleName() {
  128. return roleName;
  129. }
  130. public String getThumbnailUrl() {
  131. return thumbnailUrl;
  132. }
  133. public void setDisplayName(String displayName) {
  134. this.displayName = displayName;
  135. }
  136. public void setId(String id) {
  137. this.id = id;
  138. }
  139. /**
  140. * @param key the key to set
  141. */
  142. public void setUserKey(String key) {
  143. this.userKey = key;
  144. }
  145. /**
  146. * @param reputationPoints the reputationPoints to set
  147. */
  148. public void setReputationPoints(long reputationPoints) {
  149. this.reputationPoints = reputationPoints;
  150. }
  151. /**
  152. * @param roleName the roleName to set
  153. */
  154. public void setRoleName(String roleName) {
  155. this.roleName = roleName;
  156. }
  157. public void setThumbnailUrl(String thumbnailUrl) {
  158. this.thumbnailUrl = thumbnailUrl;
  159. }
  160. /**
  161. * @param userIdeaKeys the userIdeaKeys to set
  162. */
  163. public void setUserIdeaKeys(Set<String> userIdeaKeys) {
  164. this.ideaKeys = userIdeaKeys;
  165. }
  166. /**
  167. * @return the userIdeaKeys
  168. */
  169. public Set<String> getUserIdeaKeys() {
  170. return ideaKeys;
  171. }
  172. /**
  173. * @param createdOn the createdOn to set
  174. */
  175. public void setCreatedOn(Date createdOn) {
  176. this.createdOn = createdOn;
  177. }
  178. /**
  179. * @return the createdOn
  180. */
  181. public Date getCreatedOn() {
  182. return createdOn;
  183. }
  184. /*
  185. * (non-Javadoc)
  186. * @see java.lang.Object#toString()
  187. */
  188. @Override
  189. public String toString() {
  190. return "User [createdOn=" + createdOn + ", displayName=" + displayName + ", emailId="
  191. + emailId + ", id=" + id + ", ideaKeys=" + ideaKeys + ", reputationPoints="
  192. + reputationPoints + ", roleName=" + roleName + ", status=" + status
  193. + ", thumbnailUrl=" + thumbnailUrl + ", userKey=" + userKey + "]";
  194. }
  195. }