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

http://thoughtsite.googlecode.com/ · Java · 452 lines · 233 code · 71 blank · 148 comment · 2 complexity · 696dad4023e89a8dda2ec195b23c9b01 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 com.google.ie.common.util.StringUtility;
  17. import org.compass.annotations.Searchable;
  18. import org.compass.annotations.SearchableId;
  19. import org.compass.annotations.SearchableProperty;
  20. import java.io.Serializable;
  21. import java.util.ArrayList;
  22. import java.util.Date;
  23. import java.util.HashSet;
  24. import java.util.List;
  25. import java.util.Set;
  26. import javax.jdo.annotations.Extension;
  27. import javax.jdo.annotations.IdGeneratorStrategy;
  28. import javax.jdo.annotations.IdentityType;
  29. import javax.jdo.annotations.NotPersistent;
  30. import javax.jdo.annotations.PersistenceCapable;
  31. import javax.jdo.annotations.Persistent;
  32. import javax.jdo.annotations.PrimaryKey;
  33. @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
  34. @Searchable(alias = "Idea")
  35. public class Idea implements Serializable {
  36. /** A unique identifier for the class */
  37. private static final long serialVersionUID = -2605556889201805705L;
  38. /** variable for storing idea status value */
  39. public static final String STATUS_OBJECTIONABLE = "Objectionable";
  40. public static final String STATUS_PUBLISHED = "Published";
  41. public static final String STATUS_SAVED = "Saved";
  42. public static final String STATUS_DELETED = "Deleted";
  43. public static final String STATUS_DUPLICATE = "Duplicate";
  44. /** variable for storing FlagType value */
  45. public static final String FLAG_TYPE_OBJECTIONABLE = "Objectionable";
  46. public static final String FLAG_TYPE_DUPLICATE = "Duplicate";
  47. @PrimaryKey
  48. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  49. @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
  50. @SearchableId
  51. private String key;
  52. @Persistent
  53. @SearchableProperty
  54. private String title;
  55. @Persistent
  56. @SearchableProperty
  57. private List<String> description = new ArrayList<String>();
  58. @Persistent
  59. @SearchableProperty
  60. private String competition;
  61. @Persistent
  62. private boolean ideaRightsGivenUp = false;
  63. @Persistent
  64. private List<String> ideaSummary = new ArrayList<String>();
  65. @Persistent
  66. private boolean ipGivenUp = false;
  67. @Persistent
  68. @SearchableProperty
  69. private String monetization;
  70. @Persistent
  71. @SearchableProperty
  72. private String targetAudience;
  73. @Persistent
  74. private long totalNegativeVotes;
  75. /* This would hold the algeberic sum of votes */
  76. @Persistent
  77. private long totalVotes;
  78. @Persistent
  79. private long totalPositiveVotes;
  80. @Persistent
  81. private Date publishDate;
  82. @Persistent
  83. private Date lastUpdated;
  84. /**
  85. * Key of original idea
  86. */
  87. @Persistent
  88. private String originalIdeaKey;
  89. @Persistent
  90. private String status;
  91. /**
  92. * Set of tag keys
  93. */
  94. @Persistent
  95. private Set<String> tagKeys;
  96. @SearchableProperty
  97. @Persistent
  98. private String tags;
  99. @Persistent
  100. private String creatorKey;
  101. @Persistent
  102. @SearchableProperty
  103. private String ideaCategoryKey;
  104. @NotPersistent
  105. private String category;
  106. private Set<String> flagType;
  107. public Idea() {
  108. }
  109. /**
  110. * @return the key
  111. */
  112. public String getKey() {
  113. return key;
  114. }
  115. /**
  116. * @return the flagType
  117. */
  118. public Set<String> getFlagType() {
  119. if (flagType == null)
  120. flagType = new HashSet<String>();
  121. return flagType;
  122. }
  123. /**
  124. * @param flagType the flagType to set
  125. */
  126. public void setFlagType(Set<String> flagType) {
  127. this.flagType = flagType;
  128. }
  129. /**
  130. * @param key the key to set
  131. */
  132. public void setKey(String key) {
  133. this.key = key;
  134. }
  135. /**
  136. * @return the title
  137. */
  138. public String getTitle() {
  139. return title;
  140. }
  141. /**
  142. * @param title the title to set
  143. */
  144. public void setTitle(String title) {
  145. this.title = title;
  146. }
  147. /**
  148. * @return the competition
  149. */
  150. public String getCompetition() {
  151. return competition;
  152. }
  153. /**
  154. * @param competition the competition to set
  155. */
  156. public void setCompetition(String competition) {
  157. this.competition = competition;
  158. }
  159. /**
  160. * @return the ideaRightsGivenUp
  161. */
  162. public boolean isIdeaRightsGivenUp() {
  163. return ideaRightsGivenUp;
  164. }
  165. /**
  166. * @param ideaRightsGivenUp the ideaRightsGivenUp to set
  167. */
  168. public void setIdeaRightsGivenUp(boolean ideaRightsGivenUp) {
  169. this.ideaRightsGivenUp = ideaRightsGivenUp;
  170. }
  171. /**
  172. * @return the ipGivenUp
  173. */
  174. public boolean isIpGivenUp() {
  175. return ipGivenUp;
  176. }
  177. /**
  178. * @param ipGivenUp the ipGivenUp to set
  179. */
  180. public void setIpGivenUp(boolean ipGivenUp) {
  181. this.ipGivenUp = ipGivenUp;
  182. }
  183. /**
  184. * @return the monetization
  185. */
  186. public String getMonetization() {
  187. return monetization;
  188. }
  189. /**
  190. * @param monetization the monetization to set
  191. */
  192. public void setMonetization(String monetization) {
  193. this.monetization = monetization;
  194. }
  195. /**
  196. * @return the targetAudience
  197. */
  198. public String getTargetAudience() {
  199. return targetAudience;
  200. }
  201. /**
  202. * @param targetAudience the targetAudience to set
  203. */
  204. public void setTargetAudience(String targetAudience) {
  205. this.targetAudience = targetAudience;
  206. }
  207. /**
  208. * @return the totalNegativeVotes
  209. */
  210. public long getTotalNegativeVotes() {
  211. return totalNegativeVotes;
  212. }
  213. /**
  214. * @param totalNegativeVotes the totalNegativeVotes to set
  215. */
  216. public void setTotalNegativeVotes(long totalNegativeVotes) {
  217. this.totalNegativeVotes = totalNegativeVotes;
  218. }
  219. /**
  220. * @return the totalPositiveVotes
  221. */
  222. public long getTotalPositiveVotes() {
  223. return totalPositiveVotes;
  224. }
  225. /**
  226. * @param totalPositiveVotes the totalPositiveVotes to set
  227. */
  228. public void setTotalPositiveVotes(long totalPositiveVotes) {
  229. this.totalPositiveVotes = totalPositiveVotes;
  230. }
  231. /**
  232. * @return the lastUpdated
  233. */
  234. public Date getLastUpdated() {
  235. return lastUpdated;
  236. }
  237. /**
  238. * @param lastUpdated the lastUpdated to set
  239. */
  240. public void setLastUpdated(Date lastUpdated) {
  241. this.lastUpdated = lastUpdated;
  242. }
  243. /**
  244. * @return the originalIdeaKey
  245. */
  246. public String getOriginalIdeaKey() {
  247. return originalIdeaKey;
  248. }
  249. /**
  250. * @param originalIdeaKey the originalIdeaKey to set
  251. */
  252. public void setOriginalIdeaKey(String originalIdeaKey) {
  253. this.originalIdeaKey = originalIdeaKey;
  254. }
  255. /**
  256. * @return the status
  257. */
  258. public String getStatus() {
  259. return status;
  260. }
  261. /**
  262. * @param status the status to set
  263. */
  264. public void setStatus(String status) {
  265. this.status = status;
  266. }
  267. /**
  268. * @return the creatorKey
  269. */
  270. public String getCreatorKey() {
  271. return creatorKey;
  272. }
  273. /**
  274. * @param creatorKey the creatorKey to set
  275. */
  276. public void setCreatorKey(String creatorKey) {
  277. this.creatorKey = creatorKey;
  278. }
  279. /**
  280. * @param tags the tags to set
  281. */
  282. public void setTags(String tags) {
  283. this.tags = tags;
  284. }
  285. /**
  286. * @return the tags
  287. */
  288. public String getTags() {
  289. return tags;
  290. }
  291. /**
  292. * @param description the description to set
  293. */
  294. public void setDescription(String description) {
  295. this.description = StringUtility.convertStringToList(description);
  296. }
  297. /**
  298. * @return the description
  299. */
  300. public String getDescription() {
  301. return StringUtility.convertListToString(description);
  302. }
  303. /**
  304. * @param ideaSummary the ideaSummary to set
  305. */
  306. public void setIdeaSummary(String ideaSummary) {
  307. this.ideaSummary = StringUtility.convertStringToList(ideaSummary);
  308. }
  309. /**
  310. * @return the ideaSummary
  311. */
  312. public String getIdeaSummary() {
  313. return StringUtility.convertListToString(ideaSummary);
  314. }
  315. public void setIdeaCategoryKey(String ideaCategoryKey) {
  316. this.ideaCategoryKey = ideaCategoryKey;
  317. }
  318. public String getIdeaCategoryKey() {
  319. return ideaCategoryKey;
  320. }
  321. public void setCategory(String category) {
  322. this.category = category;
  323. }
  324. public String getCategory() {
  325. return category;
  326. }
  327. /**
  328. * @param tagKeys the tagKeys to set
  329. */
  330. public void setTagKeys(Set<String> tagKeys) {
  331. this.tagKeys = tagKeys;
  332. }
  333. /**
  334. * @return the tagKeys
  335. */
  336. public Set<String> getTagKeys() {
  337. return tagKeys;
  338. }
  339. /**
  340. * @param totalVtes the totalVtes to set
  341. */
  342. public void setTotalVotes(long totalVotes) {
  343. this.totalVotes = totalVotes;
  344. }
  345. /**
  346. * @return the totalVotes
  347. */
  348. public long getTotalVotes() {
  349. return totalVotes;
  350. }
  351. /**
  352. * @param publishDate the publishDate to set
  353. */
  354. public void setPublishDate(Date publishDate) {
  355. this.publishDate = publishDate;
  356. }
  357. /**
  358. * @return the publishDate
  359. */
  360. public Date getPublishDate() {
  361. return publishDate;
  362. }
  363. /*
  364. * (non-Javadoc)
  365. * @see java.lang.Object#toString()
  366. */
  367. @Override
  368. public String toString() {
  369. return "Idea [category=" + category + ", competition=" + competition + ", creatorKey="
  370. + creatorKey + ", description=" + description + ", flagType=" + flagType
  371. + ", ideaCategoryKey=" + ideaCategoryKey + ", ideaRightsGivenUp="
  372. + ideaRightsGivenUp + ", ideaSummary=" + ideaSummary + ", ipGivenUp="
  373. + ipGivenUp + ", key=" + key + ", lastUpdated=" + lastUpdated
  374. + ", monetization=" + monetization + ", originalIdeaKey=" + originalIdeaKey
  375. + ", publishDate=" + publishDate + ", status=" + status + ", tagKeys="
  376. + tagKeys + ", tags=" + tags + ", targetAudience=" + targetAudience
  377. + ", title=" + title + ", totalNegativeVotes=" + totalNegativeVotes
  378. + ", totalPositiveVotes=" + totalPositiveVotes + ", totalVotes="
  379. + totalVotes + "]";
  380. }
  381. }