001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018: package org.apache.roller.pojos;
019:
020: import java.sql.Timestamp;
021: import org.apache.roller.util.PojoUtil;
022:
023: /**
024: * Weblogentry Comment bean.
025: * @author Lance Lavandowska
026: *
027: * @ejb:bean name="CommentData"
028: * @struts.form include-all="true"
029: *
030: * @hibernate.class lazy="false" table="roller_comment"
031: * @hibernate.cache usage="read-write"
032: */
033: public class CommentData extends
034: org.apache.roller.pojos.PersistentObject implements
035: java.io.Serializable {
036: public static final long serialVersionUID = -6668122596726478462L;
037:
038: private String id = null;
039: private String name = null;
040: private String email = null;
041: private String url = null;
042: private String content = null;
043: private Timestamp postTime = null;
044: private Boolean spam = Boolean.FALSE;
045: private Boolean notify = Boolean.FALSE;
046: private String remoteHost = null;
047: private Boolean pending = null;
048: private Boolean approved = null;
049: private WeblogEntryData weblogEntry = null;
050:
051: public CommentData() {
052: spam = Boolean.FALSE;
053: }
054:
055: public CommentData(java.lang.String id, WeblogEntryData entry,
056: java.lang.String name, java.lang.String email,
057: java.lang.String url, java.lang.String content,
058: java.sql.Timestamp postTime, Boolean spam, Boolean notify,
059: Boolean pending, Boolean approved) {
060: this .id = id;
061: this .name = name;
062: this .email = email;
063: this .url = url;
064: this .content = content;
065: this .postTime = postTime;
066: this .spam = spam;
067: this .notify = notify;
068: this .pending = pending;
069: this .approved = approved;
070:
071: weblogEntry = entry;
072: }
073:
074: public CommentData(CommentData otherData) {
075: this .setData(otherData);
076: }
077:
078: /**
079: * @roller.wrapPojoMethod type="simple"
080: * @ejb:persistent-field
081: * @hibernate.id column="id"
082: * generator-class="uuid.hex" unsaved-value="null"
083: */
084: public java.lang.String getId() {
085: return this .id;
086: }
087:
088: /** @ejb:persistent-field */
089: public void setId(java.lang.String id) {
090: this .id = id;
091: }
092:
093: /**
094: * @roller.wrapPojoMethod type="pojo"
095: * @ejb:persistent-field
096: * @hibernate.many-to-one column="entryid" cascade="none" not-null="true"
097: */
098: public WeblogEntryData getWeblogEntry() {
099: return weblogEntry;
100: }
101:
102: /** @ejb:persistent-field */
103: public void setWeblogEntry(WeblogEntryData entry) {
104: weblogEntry = entry;
105: }
106:
107: /**
108: * @roller.wrapPojoMethod type="simple"
109: * @ejb:persistent-field
110: * @hibernate.property column="name" non-null="true" unique="false"
111: */
112: public java.lang.String getName() {
113: return this .name;
114: }
115:
116: /** @ejb:persistent-field */
117: public void setName(java.lang.String name) {
118: this .name = name;
119: }
120:
121: /**
122: * Email
123: *
124: * @roller.wrapPojoMethod type="simple"
125: * @ejb:persistent-field
126: * @hibernate.property column="email" non-null="true" unique="false"
127: */
128: public java.lang.String getEmail() {
129: return this .email;
130: }
131:
132: /** @ejb:persistent-field */
133: public void setEmail(java.lang.String email) {
134: this .email = email;
135: }
136:
137: /**
138: * @roller.wrapPojoMethod type="simple"
139: * @ejb:persistent-field
140: * @hibernate.property column="url" non-null="true" unique="false"
141: */
142: public java.lang.String getUrl() {
143: return this .url;
144: }
145:
146: /** @ejb:persistent-field */
147: public void setUrl(java.lang.String url) {
148: this .url = url;
149: }
150:
151: /**
152: * @roller.wrapPojoMethod type="simple"
153: * @ejb:persistent-field
154: * @hibernate.property column="content" non-null="true" unique="false"
155: */
156: public java.lang.String getContent() {
157: return this .content;
158: }
159:
160: /** @ejb:persistent-field */
161: public void setContent(java.lang.String content) {
162: this .content = content;
163: }
164:
165: /**
166: * @roller.wrapPojoMethod type="simple"
167: * @ejb:persistent-field
168: * @hibernate.property column="posttime" non-null="true" unique="false"
169: */
170: public java.sql.Timestamp getPostTime() {
171: return this .postTime;
172: }
173:
174: /** @ejb:persistent-field */
175: public void setPostTime(java.sql.Timestamp postTime) {
176: this .postTime = postTime;
177: }
178:
179: /**
180: * @roller.wrapPojoMethod type="simple"
181: * @ejb:persistent-field
182: * @hibernate.property column="spam" non-null="false" unique="false"
183: */
184: public Boolean getSpam() {
185: return this .spam;
186: }
187:
188: /** @ejb:persistent-field */
189: public void setSpam(Boolean spam) {
190: this .spam = spam;
191: }
192:
193: /**
194: * @roller.wrapPojoMethod type="simple"
195: * @ejb:persistent-field
196: * @hibernate.property column="notify" non-null="false" unique="false"
197: */
198: public Boolean getNotify() {
199: return this .notify;
200: }
201:
202: /** @ejb:persistent-field */
203: public void setNotify(Boolean notify) {
204: this .notify = notify;
205: }
206:
207: /**
208: * @roller.wrapPojoMethod type="simple"
209: * @ejb:persistent-field
210: * @hibernate.property column="pending" non-null="false" unique="false"
211: */
212: public Boolean getPending() {
213: return this .pending;
214: }
215:
216: /** @ejb:persistent-field */
217: public void setPending(Boolean pending) {
218: this .pending = pending;
219: }
220:
221: /**
222: * @roller.wrapPojoMethod type="simple"
223: * @ejb:persistent-field
224: * @hibernate.property column="approved" non-null="false" unique="false"
225: */
226: public Boolean getApproved() {
227: return this .approved;
228: }
229:
230: /** @ejb:persistent-field */
231: public void setApproved(Boolean approved) {
232: this .approved = approved;
233: }
234:
235: /**
236: * @ejb:persistent-field
237: */
238: public void setRemoteHost(String remoteHost) {
239: this .remoteHost = remoteHost;
240: }
241:
242: /**
243: * @roller.wrapPojoMethod type="simple"
244: * @ejb:persistent-field
245: * @hibernate.property column="remotehost" non-null="true" unique="false"
246: */
247: public String getRemoteHost() {
248: return this .remoteHost;
249: }
250:
251: public String toString() {
252: StringBuffer str = new StringBuffer("{");
253:
254: str.append("id=" + id + " " + "name=" + name + " " + "email="
255: + email + " " + "url=" + url + " " + "content="
256: + content + " " + "postTime=" + postTime + " "
257: + "spam=" + spam + "notify=" + notify + "pending"
258: + pending + "approved" + approved);
259: str.append('}');
260:
261: return (str.toString());
262: }
263:
264: public boolean equals(Object pOther) {
265: if (pOther instanceof CommentData) {
266: CommentData lTest = (CommentData) pOther;
267: boolean lEquals = true;
268:
269: lEquals = PojoUtil.equals(lEquals, this .id, lTest.getId());
270: lEquals = PojoUtil.equals(lEquals, this .weblogEntry, lTest
271: .getWeblogEntry());
272: lEquals = PojoUtil.equals(lEquals, this .name, lTest
273: .getName());
274: lEquals = PojoUtil.equals(lEquals, this .email, lTest
275: .getEmail());
276: lEquals = PojoUtil
277: .equals(lEquals, this .url, lTest.getUrl());
278: lEquals = PojoUtil.equals(lEquals, this .content, lTest
279: .getContent());
280: lEquals = PojoUtil.equals(lEquals, this .postTime, lTest
281: .getPostTime());
282: lEquals = PojoUtil.equals(lEquals, this .spam, lTest
283: .getSpam());
284: lEquals = PojoUtil.equals(lEquals, this .notify, lTest
285: .getNotify());
286: lEquals = PojoUtil.equals(lEquals, this .pending, lTest
287: .getPending());
288: lEquals = PojoUtil.equals(lEquals, this .approved, lTest
289: .getApproved());
290: return lEquals;
291: } else {
292: return false;
293: }
294: }
295:
296: public int hashCode() {
297: int result = 17;
298: result = PojoUtil.addHashCode(result, this .id);
299: result = PojoUtil.addHashCode(result, this .weblogEntry);
300: result = PojoUtil.addHashCode(result, this .name);
301: result = PojoUtil.addHashCode(result, this .email);
302: result = PojoUtil.addHashCode(result, this .url);
303: result = PojoUtil.addHashCode(result, this .content);
304: result = PojoUtil.addHashCode(result, this .postTime);
305: result = PojoUtil.addHashCode(result, this .spam);
306: result = PojoUtil.addHashCode(result, this .notify);
307: result = PojoUtil.addHashCode(result, this .pending);
308: result = PojoUtil.addHashCode(result, this .approved);
309:
310: return result;
311: }
312:
313: /**
314: * Setter is needed in RollerImpl.storePersistentObject()
315: */
316: public void setData(
317: org.apache.roller.pojos.PersistentObject otherData) {
318: CommentData otherComment = (CommentData) otherData;
319:
320: this .id = otherComment.getId();
321: this .weblogEntry = otherComment.getWeblogEntry();
322: this .name = otherComment.getName();
323: this .email = otherComment.getEmail();
324: this .url = otherComment.getUrl();
325: this .content = otherComment.getContent();
326: this .postTime = otherComment.getPostTime();
327: this .spam = otherComment.getSpam();
328: this .notify = otherComment.getNotify();
329: this .pending = otherComment.getPending();
330: this .approved = otherComment.getApproved();
331: }
332:
333: /**
334: * Timestamp to be used to formulate comment permlink.
335: * @roller.wrapPojoMethod type="simple"
336: */
337: public String getTimestamp() {
338: if (postTime != null) {
339: return Long.toString(postTime.getTime());
340: }
341: return null;
342: }
343:
344: /** No-op to please XDoclet */
345: public void setTimestamp(String timeStamp) {
346: }
347: }
|