View Javadoc
1   /**
2    * Copyright 2011-2013 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.mobility.writer.entity;
17  
18  import java.util.Date;
19  
20  import javax.persistence.*;
21  
22  /**
23   * A class representing a comment placed on an article.
24   * @author Kuali Mobility Team (mobility.collab@kuali.org)
25   * @since 3.0.0
26   */
27  @NamedQueries({
28      @NamedQuery(
29              name = "Comment.getCommentsForArticle",
30              query = "SELECT c FROM Comment c WHERE article_id = :articleId ORDER BY c.timestamp DESC"),
31      @NamedQuery(
32              name = "Comment.deleteComment",
33              query = "DELETE Comment WHERE id = :commentId"
34      )
35  })
36  @Entity
37  @Table(name="WRITER_COMMENT")
38  public class Comment {
39  
40  	/** Display name for the user that created the comment */
41  	@Column(name="USER_DISPLAY_NAME", nullable=false, length=128)
42  	private String userDisplayName;
43  	
44  	/** Primary key of the comment */
45  	@Id
46  	@GeneratedValue(strategy = GenerationType.TABLE)
47      @Column(name="ID")
48  	private Long id;
49  	
50  	/** Id of the article on which this comment is placed */
51  	@Column(name="ARTICLE_ID", nullable=false)
52  	private long articleId;
53  	
54  	/** Timestamp of when the comment was placed */
55  	@Column(name="TIMESTAMP", nullable=false)
56  	private Date timestamp;
57  	
58  	/** Title of the comment */
59  	@Column(name="TITLE", nullable=false, length=64)
60  	private String title;
61  	
62  	/** The comment text */
63  	@Column(name="TEXT", nullable=false, length=250)
64  	private String text;
65  
66      /** Version number for the comment */
67  	@Version
68  	@Column(name="VER_NBR")
69  	protected long versionNumber;
70  
71  	/**
72  	 * @return the userDisplayName
73  	 */
74  	public String getUserDisplayName() {
75  		return userDisplayName;
76  	}
77  
78  	/**
79  	 * @param userDisplayName the userDisplayName to set
80  	 */
81  	public void setUserDisplayName(String userDisplayName) {
82  		this.userDisplayName = userDisplayName;
83  	}
84  
85  	/**
86  	 * @return the id
87  	 */
88  	public Long getId() {
89  		return id;
90  	}
91  
92  	/**
93  	 * @param id the id to set
94  	 */
95  	public void setId(Long id) {
96  		this.id = id;
97  	}
98  
99  	/**
100 	 * @return the articleId
101 	 */
102 	public long getArticleId() {
103 		return articleId;
104 	}
105 
106 	/**
107 	 * @param articleId the articleId to set
108 	 */
109 	public void setArticleId(long articleId) {
110 		this.articleId = articleId;
111 	}
112 
113 	/**
114 	 * @return the timestamp
115 	 */
116 	public Date getTimestamp() {
117 		return timestamp;
118 	}
119 
120 	/**
121 	 * @param timestamp the timestamp to set
122 	 */
123 	public void setTimestamp(Date timestamp) {
124 		this.timestamp = timestamp;
125 	}
126 
127 	/**
128 	 * @return the title
129 	 */
130 	public String getTitle() {
131 		return title;
132 	}
133 
134 	/**
135 	 * @param title the title to set
136 	 */
137 	public void setTitle(String title) {
138 		this.title = title;
139 	}
140 
141 	/**
142 	 * @return the text
143 	 */
144 	public String getText() {
145 		return text;
146 	}
147 
148 	/**
149 	 * @param text the text to set
150 	 */
151 	public void setText(String text) {
152 		this.text = text;
153 	}
154 	
155 	/**
156 	 * Sets the version number of the Comment
157 	 * @return
158 	 */
159 	public long getVersionNumber() {
160 		return versionNumber;
161 	}
162 	
163 
164 	/**
165 	 * Gets the version number of the Comment
166 	 * @return
167 	 */
168 	public void setVersionNumber(long versionNumber) {
169 		this.versionNumber = versionNumber;
170 	}    
171 	
172 }