001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/contrib/phpbb2mvnforum/src/org/mvnforum/phpbb2mvnforum/db/PostBean.java,v 1.3 2007/01/15 10:27:32 dungbtm Exp $
003: * $Author: dungbtm $
004: * $Revision: 1.3 $
005: * $Date: 2007/01/15 10:27:32 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Minh Nguyen
039: * @author: Mai Nguyen
040: */
041: package org.mvnforum.phpbb2mvnforum.db;
042:
043: import java.sql.Timestamp;
044: import java.util.Collection;
045: import java.util.Iterator;
046:
047: import org.w3c.dom.Document;
048: import org.w3c.dom.Element;
049: import org.w3c.dom.Node;
050:
051: import net.myvietnam.mvncore.util.StringUtil;
052:
053: /*
054: * Included columns: PostID, ParentPostID, ForumID, ThreadID, MemberID,
055: * MemberName, LastEditMemberName, PostTopic, PostBody, PostCreationDate,
056: * PostLastEditDate, PostCreationIP, PostLastEditIP, PostEditCount, PostFormatOption,
057: * PostOption, PostStatus, PostIcon, PostAttachCount
058: * Excluded columns:
059: */
060: public class PostBean {
061: /*************************************************************************
062: * NOTE: below constants MUST NOT be changed IN ALL CASES,
063: * or it will break the compatibility
064: *************************************************************************/
065: /**
066: * The default value mean post is enable and normal
067: */
068: public final static int POST_STATUS_DEFAULT = 0;
069:
070: /**
071: * The disable post is invisible for normal user and visible to moderator
072: */
073: public final static int POST_STATUS_DISABLED = 1;
074:
075: private int postID;
076: private int parentPostID;
077: private int forumID;
078: private int threadID;
079: private int memberID;
080: private String memberName;
081: private String lastEditMemberName;
082: private String postTopic;
083: private String postBody;
084: private Timestamp postCreationDate;
085: private Timestamp postLastEditDate;
086: private String postCreationIP;
087: private String postLastEditIP;
088: private int postEditCount;
089: private int postFormatOption;
090: private int postOption;
091: private int postStatus;
092: private String postIcon;
093: private int postAttachCount;
094:
095: public int getPostID() {
096: return postID;
097: }
098:
099: public void setPostID(int postID) {
100: this .postID = postID;
101: }
102:
103: public int getParentPostID() {
104: return parentPostID;
105: }
106:
107: public void setParentPostID(int parentPostID) {
108: this .parentPostID = parentPostID;
109: }
110:
111: public int getForumID() {
112: return forumID;
113: }
114:
115: public void setForumID(int forumID) {
116: this .forumID = forumID;
117: }
118:
119: public int getThreadID() {
120: return threadID;
121: }
122:
123: public void setThreadID(int threadID) {
124: this .threadID = threadID;
125: }
126:
127: public int getMemberID() {
128: return memberID;
129: }
130:
131: public void setMemberID(int memberID) {
132: this .memberID = memberID;
133: }
134:
135: public String getMemberName() {
136: return memberName;
137: }
138:
139: public void setMemberName(String memberName) {
140: this .memberName = memberName;
141: }
142:
143: public String getLastEditMemberName() {
144: return lastEditMemberName;
145: }
146:
147: public void setLastEditMemberName(String lastEditMemberName) {
148: this .lastEditMemberName = StringUtil
149: .getEmptyStringIfNull(lastEditMemberName);
150: }
151:
152: public String getPostTopic() {
153: return postTopic;
154: }
155:
156: public void setPostTopic(String postTopic) {
157: this .postTopic = postTopic;
158: }
159:
160: public String getPostBody() {
161: return postBody;
162: }
163:
164: public void setPostBody(String postBody) {
165: this .postBody = postBody;
166: }
167:
168: public Timestamp getPostCreationDate() {
169: return postCreationDate;
170: }
171:
172: public void setPostCreationDate(Timestamp postCreationDate) {
173: this .postCreationDate = postCreationDate;
174: }
175:
176: public Timestamp getPostLastEditDate() {
177: return postLastEditDate;
178: }
179:
180: public void setPostLastEditDate(Timestamp postLastEditDate) {
181: this .postLastEditDate = postLastEditDate;
182: }
183:
184: public String getPostCreationIP() {
185: return postCreationIP;
186: }
187:
188: public void setPostCreationIP(String postCreationIP) {
189: this .postCreationIP = postCreationIP;
190: }
191:
192: public String getPostLastEditIP() {
193: return postLastEditIP;
194: }
195:
196: public void setPostLastEditIP(String postLastEditIP) {
197: this .postLastEditIP = StringUtil
198: .getEmptyStringIfNull(postLastEditIP);
199: }
200:
201: public int getPostEditCount() {
202: return postEditCount;
203: }
204:
205: public void setPostEditCount(int postEditCount) {
206: this .postEditCount = postEditCount;
207: }
208:
209: public int getPostFormatOption() {
210: return postFormatOption;
211: }
212:
213: public void setPostFormatOption(int postFormatOption) {
214: this .postFormatOption = postFormatOption;
215: }
216:
217: public int getPostOption() {
218: return postOption;
219: }
220:
221: public void setPostOption(int postOption) {
222: this .postOption = postOption;
223: }
224:
225: public int getPostStatus() {
226: return postStatus;
227: }
228:
229: public void setPostStatus(int postStatus) {
230: this .postStatus = postStatus;
231: }
232:
233: public String getPostIcon() {
234: return postIcon;
235: }
236:
237: public void setPostIcon(String postIcon) {
238: this .postIcon = StringUtil.getEmptyStringIfNull(postIcon);
239: }
240:
241: public int getPostAttachCount() {
242: return postAttachCount;
243: }
244:
245: public void setPostAttachCount(int postAttachCount) {
246: this .postAttachCount = postAttachCount;
247: }
248:
249: public String getXMLTag() {
250: StringBuffer xml = new StringBuffer(1024);
251: xml.append("<Post");
252: xml.append(" postID=\"").append(String.valueOf(postID)).append(
253: "\"");
254: xml.append(" parentPostID=\"").append(
255: String.valueOf(parentPostID)).append("\"");
256: xml.append(" forumID=\"").append(String.valueOf(forumID))
257: .append("\"");
258: xml.append(" threadID=\"").append(String.valueOf(threadID))
259: .append("\"");
260: xml.append(" memberID=\"").append(String.valueOf(memberID))
261: .append("\"");
262: xml.append(" memberName=\"").append(String.valueOf(memberName))
263: .append("\"");
264: xml.append(" lastEditMemberName=\"").append(
265: String.valueOf(lastEditMemberName)).append("\"");
266: xml.append(" postTopic=\"").append(String.valueOf(postTopic))
267: .append("\"");
268: xml.append(" postBody=\"").append(String.valueOf(postBody))
269: .append("\"");
270: xml.append(" postCreationDate=\"").append(
271: String.valueOf(postCreationDate)).append("\"");
272: xml.append(" postLastEditDate=\"").append(
273: String.valueOf(postLastEditDate)).append("\"");
274: xml.append(" postCreationIP=\"").append(
275: String.valueOf(postCreationIP)).append("\"");
276: xml.append(" postLastEditIP=\"").append(
277: String.valueOf(postLastEditIP)).append("\"");
278: xml.append(" postEditCount=\"").append(
279: String.valueOf(postEditCount)).append("\"");
280: xml.append(" postFormatOption=\"").append(
281: String.valueOf(postFormatOption)).append("\"");
282: xml.append(" postOption=\"").append(String.valueOf(postOption))
283: .append("\"");
284: xml.append(" postStatus=\"").append(String.valueOf(postStatus))
285: .append("\"");
286: xml.append(" postIcon=\"").append(String.valueOf(postIcon))
287: .append("\"");
288: xml.append(" postAttachCount=\"").append(
289: String.valueOf(postAttachCount)).append("\"");
290: xml.append(">");
291: return xml.toString();
292: }
293:
294: public void getBeanDocument(Document doc, Element element) {
295: Element category = doc.createElement("Category");
296: element.appendChild(category);
297:
298: category.appendChild(getNode(doc, "PostID", String
299: .valueOf(postID)));
300: category.appendChild(getNode(doc, "ParentPostID", String
301: .valueOf(parentPostID)));
302: category.appendChild(getNode(doc, "ForumID", String
303: .valueOf(forumID)));
304: category.appendChild(getNode(doc, "ThreadID", String
305: .valueOf(threadID)));
306: category.appendChild(getNode(doc, "MemberID", String
307: .valueOf(memberID)));
308: category.appendChild(getNode(doc, "MemberName", String
309: .valueOf(memberName)));
310: category.appendChild(getNode(doc, "LastEditMemberName", String
311: .valueOf(lastEditMemberName)));
312: category.appendChild(getNode(doc, "PostTopic", String
313: .valueOf(postTopic)));
314: category.appendChild(getNode(doc, "PostBody", String
315: .valueOf(postBody)));
316: category.appendChild(getNode(doc, "PostCreationDate", String
317: .valueOf(postCreationDate)));
318: category.appendChild(getNode(doc, "PostLastEditDate", String
319: .valueOf(postLastEditDate)));
320: category.appendChild(getNode(doc, "PostCreationIP", String
321: .valueOf(postCreationIP)));
322: category.appendChild(getNode(doc, "PostLastEditIP", String
323: .valueOf(postLastEditIP)));
324: category.appendChild(getNode(doc, "PostEditCount", String
325: .valueOf(postEditCount)));
326: category.appendChild(getNode(doc, "PostFormatOption", String
327: .valueOf(postFormatOption)));
328: category.appendChild(getNode(doc, "PostOption", String
329: .valueOf(postOption)));
330: category.appendChild(getNode(doc, "PostStatus", String
331: .valueOf(postStatus)));
332: category.appendChild(getNode(doc, "PostIcon", String
333: .valueOf(postIcon)));
334: category.appendChild(getNode(doc, "PostAttachCount", String
335: .valueOf(postAttachCount)));
336: }
337:
338: public static Node getNode(Document doc, String childName,
339: String childValue) {
340: Element child = doc.createElement(childName);
341: child.appendChild(doc.createTextNode(childValue));
342: return child;
343: }
344:
345: public String getXML() {
346: StringBuffer xml = new StringBuffer(1024);
347: xml.append("<PostSection>\n");
348: xml.append(" <Rows>\n");
349: xml.append(" <Row>\n");
350: xml.append(" <Column>\n");
351: xml.append(" <Name>PostID</Name>\n");
352: xml.append(" <Value>").append(String.valueOf(postID))
353: .append("</Value>\n");
354: xml.append(" </Column>\n");
355: xml.append(" <Column>\n");
356: xml.append(" <Name>ParentPostID</Name>\n");
357: xml.append(" <Value>").append(
358: String.valueOf(parentPostID)).append("</Value>\n");
359: xml.append(" </Column>\n");
360: xml.append(" <Column>\n");
361: xml.append(" <Name>ForumID</Name>\n");
362: xml.append(" <Value>").append(String.valueOf(forumID))
363: .append("</Value>\n");
364: xml.append(" </Column>\n");
365: xml.append(" <Column>\n");
366: xml.append(" <Name>ThreadID</Name>\n");
367: xml.append(" <Value>").append(String.valueOf(threadID))
368: .append("</Value>\n");
369: xml.append(" </Column>\n");
370: xml.append(" <Column>\n");
371: xml.append(" <Name>MemberID</Name>\n");
372: xml.append(" <Value>").append(String.valueOf(memberID))
373: .append("</Value>\n");
374: xml.append(" </Column>\n");
375: xml.append(" <Column>\n");
376: xml.append(" <Name>MemberName</Name>\n");
377: xml.append(" <Value>")
378: .append(String.valueOf(memberName))
379: .append("</Value>\n");
380: xml.append(" </Column>\n");
381: xml.append(" <Column>\n");
382: xml.append(" <Name>LastEditMemberName</Name>\n");
383: xml.append(" <Value>").append(
384: String.valueOf(lastEditMemberName))
385: .append("</Value>\n");
386: xml.append(" </Column>\n");
387: xml.append(" <Column>\n");
388: xml.append(" <Name>PostTopic</Name>\n");
389: xml.append(" <Value>").append(String.valueOf(postTopic))
390: .append("</Value>\n");
391: xml.append(" </Column>\n");
392: xml.append(" <Column>\n");
393: xml.append(" <Name>PostBody</Name>\n");
394: xml.append(" <Value>").append(String.valueOf(postBody))
395: .append("</Value>\n");
396: xml.append(" </Column>\n");
397: xml.append(" <Column>\n");
398: xml.append(" <Name>PostCreationDate</Name>\n");
399: xml.append(" <Value>").append(
400: String.valueOf(postCreationDate)).append("</Value>\n");
401: xml.append(" </Column>\n");
402: xml.append(" <Column>\n");
403: xml.append(" <Name>PostLastEditDate</Name>\n");
404: xml.append(" <Value>").append(
405: String.valueOf(postLastEditDate)).append("</Value>\n");
406: xml.append(" </Column>\n");
407: xml.append(" <Column>\n");
408: xml.append(" <Name>PostCreationIP</Name>\n");
409: xml.append(" <Value>").append(
410: String.valueOf(postCreationIP)).append("</Value>\n");
411: xml.append(" </Column>\n");
412: xml.append(" <Column>\n");
413: xml.append(" <Name>PostLastEditIP</Name>\n");
414: xml.append(" <Value>").append(
415: String.valueOf(postLastEditIP)).append("</Value>\n");
416: xml.append(" </Column>\n");
417: xml.append(" <Column>\n");
418: xml.append(" <Name>PostEditCount</Name>\n");
419: xml.append(" <Value>").append(
420: String.valueOf(postEditCount)).append("</Value>\n");
421: xml.append(" </Column>\n");
422: xml.append(" <Column>\n");
423: xml.append(" <Name>PostFormatOption</Name>\n");
424: xml.append(" <Value>").append(
425: String.valueOf(postFormatOption)).append("</Value>\n");
426: xml.append(" </Column>\n");
427: xml.append(" <Column>\n");
428: xml.append(" <Name>PostOption</Name>\n");
429: xml.append(" <Value>")
430: .append(String.valueOf(postOption))
431: .append("</Value>\n");
432: xml.append(" </Column>\n");
433: xml.append(" <Column>\n");
434: xml.append(" <Name>PostStatus</Name>\n");
435: xml.append(" <Value>")
436: .append(String.valueOf(postStatus))
437: .append("</Value>\n");
438: xml.append(" </Column>\n");
439: xml.append(" <Column>\n");
440: xml.append(" <Name>PostIcon</Name>\n");
441: xml.append(" <Value>").append(String.valueOf(postIcon))
442: .append("</Value>\n");
443: xml.append(" </Column>\n");
444: xml.append(" <Column>\n");
445: xml.append(" <Name>PostAttachCount</Name>\n");
446: xml.append(" <Value>").append(
447: String.valueOf(postAttachCount)).append("</Value>\n");
448: xml.append(" </Column>\n");
449: xml.append(" </Row>\n");
450: xml.append(" </Rows>\n");
451: xml.append("</PostSection>\n");
452: return xml.toString();
453: }
454:
455: public static String getXML(Collection objPostBeans) {
456: StringBuffer xml = new StringBuffer(1024);
457: Iterator iterator = objPostBeans.iterator();
458: xml.append("<PostSection>\n");
459: xml.append(" <Rows>\n");
460: while (iterator.hasNext()) {
461: PostBean objPostBean = (PostBean) iterator.next();
462: xml.append(" <Row>\n");
463: xml.append(" <Column>\n");
464: xml.append(" <Name>PostID</Name>\n");
465: xml.append(" <Value>").append(
466: String.valueOf(objPostBean.postID)).append(
467: "</Value>\n");
468: xml.append(" </Column>\n");
469: xml.append(" <Column>\n");
470: xml.append(" <Name>ParentPostID</Name>\n");
471: xml.append(" <Value>").append(
472: String.valueOf(objPostBean.parentPostID)).append(
473: "</Value>\n");
474: xml.append(" </Column>\n");
475: xml.append(" <Column>\n");
476: xml.append(" <Name>ForumID</Name>\n");
477: xml.append(" <Value>").append(
478: String.valueOf(objPostBean.forumID)).append(
479: "</Value>\n");
480: xml.append(" </Column>\n");
481: xml.append(" <Column>\n");
482: xml.append(" <Name>ThreadID</Name>\n");
483: xml.append(" <Value>").append(
484: String.valueOf(objPostBean.threadID)).append(
485: "</Value>\n");
486: xml.append(" </Column>\n");
487: xml.append(" <Column>\n");
488: xml.append(" <Name>MemberID</Name>\n");
489: xml.append(" <Value>").append(
490: String.valueOf(objPostBean.memberID)).append(
491: "</Value>\n");
492: xml.append(" </Column>\n");
493: xml.append(" <Column>\n");
494: xml.append(" <Name>MemberName</Name>\n");
495: xml.append(" <Value>").append(
496: String.valueOf(objPostBean.memberName)).append(
497: "</Value>\n");
498: xml.append(" </Column>\n");
499: xml.append(" <Column>\n");
500: xml.append(" <Name>LastEditMemberName</Name>\n");
501: xml.append(" <Value>").append(
502: String.valueOf(objPostBean.lastEditMemberName))
503: .append("</Value>\n");
504: xml.append(" </Column>\n");
505: xml.append(" <Column>\n");
506: xml.append(" <Name>PostTopic</Name>\n");
507: xml.append(" <Value>").append(
508: String.valueOf(objPostBean.postTopic)).append(
509: "</Value>\n");
510: xml.append(" </Column>\n");
511: xml.append(" <Column>\n");
512: xml.append(" <Name>PostBody</Name>\n");
513: xml.append(" <Value>").append(
514: String.valueOf(objPostBean.postBody)).append(
515: "</Value>\n");
516: xml.append(" </Column>\n");
517: xml.append(" <Column>\n");
518: xml.append(" <Name>PostCreationDate</Name>\n");
519: xml.append(" <Value>").append(
520: String.valueOf(objPostBean.postCreationDate))
521: .append("</Value>\n");
522: xml.append(" </Column>\n");
523: xml.append(" <Column>\n");
524: xml.append(" <Name>PostLastEditDate</Name>\n");
525: xml.append(" <Value>").append(
526: String.valueOf(objPostBean.postLastEditDate))
527: .append("</Value>\n");
528: xml.append(" </Column>\n");
529: xml.append(" <Column>\n");
530: xml.append(" <Name>PostCreationIP</Name>\n");
531: xml.append(" <Value>").append(
532: String.valueOf(objPostBean.postCreationIP)).append(
533: "</Value>\n");
534: xml.append(" </Column>\n");
535: xml.append(" <Column>\n");
536: xml.append(" <Name>PostLastEditIP</Name>\n");
537: xml.append(" <Value>").append(
538: String.valueOf(objPostBean.postLastEditIP)).append(
539: "</Value>\n");
540: xml.append(" </Column>\n");
541: xml.append(" <Column>\n");
542: xml.append(" <Name>PostEditCount</Name>\n");
543: xml.append(" <Value>").append(
544: String.valueOf(objPostBean.postEditCount)).append(
545: "</Value>\n");
546: xml.append(" </Column>\n");
547: xml.append(" <Column>\n");
548: xml.append(" <Name>PostFormatOption</Name>\n");
549: xml.append(" <Value>").append(
550: String.valueOf(objPostBean.postFormatOption))
551: .append("</Value>\n");
552: xml.append(" </Column>\n");
553: xml.append(" <Column>\n");
554: xml.append(" <Name>PostOption</Name>\n");
555: xml.append(" <Value>").append(
556: String.valueOf(objPostBean.postOption)).append(
557: "</Value>\n");
558: xml.append(" </Column>\n");
559: xml.append(" <Column>\n");
560: xml.append(" <Name>PostStatus</Name>\n");
561: xml.append(" <Value>").append(
562: String.valueOf(objPostBean.postStatus)).append(
563: "</Value>\n");
564: xml.append(" </Column>\n");
565: xml.append(" <Column>\n");
566: xml.append(" <Name>PostIcon</Name>\n");
567: xml.append(" <Value>").append(
568: String.valueOf(objPostBean.postIcon)).append(
569: "</Value>\n");
570: xml.append(" </Column>\n");
571: xml.append(" <Column>\n");
572: xml.append(" <Name>PostAttachCount</Name>\n");
573: xml.append(" <Value>").append(
574: String.valueOf(objPostBean.postAttachCount))
575: .append("</Value>\n");
576: xml.append(" </Column>\n");
577: xml.append(" </Row>\n");
578: }//while
579: xml.append(" </Rows>\n");
580: xml.append("</PostSection>\n");
581: return xml.toString();
582: }
583:
584: /************************************************
585: * Customized methods come below
586: ************************************************/
587: private MemberBean memberBean = null;
588: private Collection attachmentBeans = null;
589:
590: public MemberBean getMemberBean() {
591: return memberBean;
592: }
593:
594: public void setMemberBean(MemberBean memberBean) {
595: this .memberBean = memberBean;
596: }
597:
598: public Collection getAttachmentBeans() {
599: return attachmentBeans;
600: }
601:
602: public void setAttachmentBeans(Collection attachmentBeans) {
603: this .attachmentBeans = attachmentBeans;
604: }
605:
606: } //end of class PostBean
|