1 40 package com.mvnforum.admin.importexport.mvnforum; 41 42 import com.mvnforum.admin.ThreadXML; 43 import net.myvietnam.mvncore.exception.*; 44 45 57 public class MvnForumThreadXML { 58 59 private ThreadXML threadXML=null; 60 private boolean threadCreated=false; 61 private MvnForumForumXML parentForum =null; 62 63 String threadMemberName =null; 64 String threadLastPostMemberName =null; 65 String threadTopic =null; 66 String threadBody =null; 67 String threadVoteCount =null; 68 String threadVoteTotalStars =null; 69 String threadCreationDate =null; 70 String threadLastPostDate =null; 71 String threadType =null; 72 String threadOption =null; 73 String threadStatus =null; 74 String threadHasPoll =null; 75 String threadViewCount =null; 76 String threadReplyCount =null; 77 String threadIcon =null; 78 String threadDuration =null; 79 String threadAttachCount =null; 80 81 public MvnForumThreadXML() { 82 super(); 83 threadXML=new ThreadXML(); 84 threadCreated=false; 85 parentForum=null; 86 } 87 88 public int getThreadID() { 89 return threadXML.getThreadID(); 90 } 91 92 public void setThreadID(String id) { 93 threadXML.setThreadID(id); 94 } 95 96 102 public void setThreadId(String id) { 103 setThreadID(id); 104 } 105 106 public int getParentCategoryID() { 107 return threadXML.getParentCategoryID(); } 109 110 public int getParentForumID() { 111 return threadXML.getParentForumID(); } 113 114 public void setParentForum(Object o) 115 throws ForeignKeyNotFoundException { 116 if (o instanceof MvnForumForumXML) { 117 parentForum=(MvnForumForumXML)o; 118 } else { 120 throw new ForeignKeyNotFoundException("Can't find parent forum."); 121 } 122 } 123 124 public void setThreadMemberName(String value) { 125 threadMemberName=value; 126 } 127 128 public void setThreadLastPostMemberName(String value) { 129 threadLastPostMemberName=value; 130 } 131 132 public void setThreadTopic(String value) { 133 threadTopic=value; 134 } 135 136 public void setThreadBody(String value) { 137 threadBody=value; 138 } 139 140 public void setThreadVoteCount(String value) { 141 threadVoteCount=value; 142 } 143 144 public void setThreadVoteTotalStars(String value) { 145 threadVoteTotalStars=value; 146 } 147 148 public void setThreadCreationDate(String value) { 149 threadCreationDate=value; 150 } 151 152 public void setThreadLastPostDate(String value) { 153 threadLastPostDate=value; 154 } 155 156 public void setThreadType(String value) { 157 threadType=value; 158 } 159 160 public void setThreadOption(String value) { 161 threadOption=value; 162 } 163 164 public void setThreadStatus(String value) { 165 threadStatus=value; 166 } 167 168 public void setThreadHasPoll(String value) { 169 threadHasPoll=value; 170 } 171 172 public void setThreadViewCount(String value) { 173 threadViewCount=value; 174 } 175 176 public void setThreadReplyCount(String value) { 177 threadReplyCount=value; 178 } 179 180 public void setThreadIcon(String value) { 181 threadIcon=value; 182 } 183 184 public void setThreadDuration(String value) { 185 threadDuration=value; 186 } 187 188 public void setThreadAttachCount(String value) { 189 threadAttachCount=value; 190 } 191 192 public void addThread() throws CreateException, DuplicateKeyException, 193 ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException, BadInputException { 194 199 if (threadCreated) return; 200 201 if (parentForum!=null) { 202 parentForum.addForum(); 203 threadXML.setParentForumID(parentForum.getForumID()); 204 threadXML.setParentCategoryID(parentForum.getParentCategoryID()); 205 } 206 207 ImportMvnForum.addMessage("Adding thread \""+threadTopic+"\"."); 208 threadXML.addThread(threadMemberName, threadLastPostMemberName, 209 threadTopic, threadBody, 210 threadVoteCount, threadVoteTotalStars, 211 threadCreationDate, threadLastPostDate, 212 threadType, threadOption, 213 threadStatus, threadHasPoll, 214 threadViewCount, threadReplyCount, 215 threadIcon, threadDuration, threadAttachCount); 216 threadCreated=true; 217 218 if (parentForum!=null) { 219 parentForum.updateAddedThread(this); 220 } 221 } 222 223 public void addThreadWatch(String memberName, 224 String watchType, String watchOption, 225 String watchStatus, String watchCreationDate, 226 String watchLastSentDate, String watchEndDate) 227 throws CreateException, DuplicateKeyException, ObjectNotFoundException, 228 DatabaseException, ForeignKeyNotFoundException, BadInputException { 229 if ( (!threadCreated) || (threadXML.getThreadID()<0) ) { 230 addThread(); 231 } 232 ImportMvnForum.addMessage("Adding thread watch for member \""+memberName+"\"."); 233 threadXML.addThreadWatch(memberName, 234 watchType, watchOption, watchStatus, 235 watchCreationDate, watchLastSentDate, watchEndDate); 236 } 237 238 public void addFavoriteThread(String memberName, 239 String favoriteCreationDate, String favoriteType, 240 String favoriteOption, String favoriteStatus) 241 throws CreateException, DuplicateKeyException, ObjectNotFoundException, 242 DatabaseException, ForeignKeyNotFoundException, BadInputException { 243 if ( (!threadCreated) || (threadXML.getThreadID()<0) ) { 244 addThread(); 245 } 246 ImportMvnForum.addMessage("Adding favorite-thread for member \""+memberName+"\"."); 247 threadXML.addFavoriteThread(memberName, 248 favoriteCreationDate, favoriteType, 249 favoriteOption, favoriteStatus); 250 } 251 252 public void updateAddedPost(MvnForumPostXML subPost, String postUsername, String postCreationDate) { 253 if ((!threadCreated) || (threadXML.getThreadID()<0)) return; if (parentForum!=null) { 261 parentForum.updateAddedPost(subPost, postUsername, postCreationDate); 262 } 263 } 264 265 public void updateAddedAttachment(MvnForumAttachmentXML subAttachment) { 266 if ((!threadCreated) || (threadXML.getThreadID()<0)) return; if (parentForum!=null) { 270 parentForum.updateAddedAttachment(subAttachment); 271 } 272 } 273 274 275 } 276 | Popular Tags |