1 40 package com.mvnforum.admin.importexport.mvnforum; 41 42 import com.mvnforum.admin.PostXML; 43 import net.myvietnam.mvncore.exception.*; 44 45 56 public class MvnForumPostXML { 57 58 private PostXML postXML=null; 59 private boolean postCreated=false; 60 private MvnForumThreadXML parentThread =null; 62 private MvnForumPostXML parentPost =null; 63 64 String postMemberName = null; 65 String postLastEditMemberName = null; 66 String postTopic = null; 67 String postBody = null; 68 String postCreationDate = null; 69 String postLastEditDate = null; 70 String postCreationIP = null; 71 String postLastEditIP = null; 72 String postEditCount = null; 73 String postFormatOption = null; 74 String postOption = null; 75 String postStatus = null; 76 String postIcon = null; 77 String postAttachCount = null; 78 79 public MvnForumPostXML() { 80 super(); 81 postXML=new PostXML(); 82 postCreated=false; 83 parentThread=null; 84 parentPost=null; 85 } 86 87 public int getPostID() { 88 return postXML.getPostID(); 89 } 90 91 public void setPostID(String id) { 92 postXML.setPostID(id); 93 } 94 95 101 public void setPostId(String id) { 102 setPostID(id); 103 } 104 105 public int getParentCategoryID() { 106 return postXML.getParentCategoryID(); 107 } 108 109 public int getParentForumID() { 110 return postXML.getParentForumID(); 111 } 112 113 public int getParentThreadID() { 114 return postXML.getParentThreadID(); 115 } 116 117 public int getParentPostID() { 118 return postXML.getParentPostID(); 119 } 120 121 public void setParentThreadOrPost(Object o) 122 throws ForeignKeyNotFoundException { 123 if (o instanceof MvnForumThreadXML) { 124 parentThread=(MvnForumThreadXML)o; 125 parentPost=null; 127 } else if (o instanceof MvnForumPostXML) { 128 parentPost=(MvnForumPostXML)o; 129 parentThread=null; 131 } else { 132 throw new ForeignKeyNotFoundException("Can't find neither parent thread nor post."); 133 } 134 } 135 136 public void setPostMemberName(String value) { 137 postMemberName=value; 138 } 139 140 public void setPostLastEditMemberName(String value) { 141 postLastEditMemberName=value; 142 } 143 144 public void setPostTopic(String value) { 145 postTopic=value; 146 } 147 148 public void setPostBody(String value) { 149 postBody=value; 150 } 151 152 public void setPostCreationDate(String value) { 153 postCreationDate=value; 154 } 155 156 public void setPostLastEditDate(String value) { 157 postLastEditDate=value; 158 } 159 160 public void setPostCreationIP(String value) { 161 postCreationIP=value; 162 } 163 164 public void setPostLastEditIP(String value) { 165 postLastEditIP=value; 166 } 167 168 public void setPostEditCount(String value) { 169 postEditCount=value; 170 } 171 172 public void setPostFormatOption(String value) { 173 postFormatOption=value; 174 } 175 176 public void setPostOption(String value) { 177 postOption=value; 178 } 179 180 public void setPostStatus(String value) { 181 postStatus=value; 182 } 183 184 public void setPostIcon(String value) { 185 postIcon=value; 186 } 187 188 public void setPostAttachCount(String value) { 189 postAttachCount=value; 190 } 191 192 public void addPost() throws CreateException, DuplicateKeyException, 193 ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException, BadInputException { 194 199 if (postCreated) return; 200 201 if (parentPost!=null) { 202 parentPost.addPost(); 203 postXML.setParentPostID(parentPost.getPostID()); 204 postXML.setParentThreadID(parentPost.getParentThreadID()); 205 postXML.setParentForumID(parentPost.getParentForumID()); 206 postXML.setParentCategoryID(parentPost.getParentCategoryID()); 207 } else if (parentThread!=null) { 208 parentThread.addThread(); 209 postXML.setParentThreadID(parentThread.getThreadID()); 211 postXML.setParentForumID(parentThread.getParentForumID()); 212 postXML.setParentCategoryID(parentThread.getParentCategoryID()); 213 } 214 215 ImportMvnForum.addMessage("Adding post \""+postTopic+"\"."); 216 postXML.addPost(postMemberName, postLastEditMemberName, 217 postTopic, postBody, 218 postCreationDate, postLastEditDate, 219 postCreationIP, postLastEditIP, 220 postEditCount, postFormatOption, 221 postOption, postStatus, 222 postIcon, postAttachCount); 223 postCreated=true; 224 225 if (parentPost!=null) { 226 parentPost.updateAddedReply(this, postMemberName, postCreationDate); 227 } else if (parentThread!=null) { 228 parentThread.updateAddedPost(this, postMemberName, postCreationDate); 229 } 230 } 231 232 public void updateAddedReply(MvnForumPostXML subPost, String postUsername, String postCreationDate) { 233 if ((!postCreated) || (postXML.getPostID()<0)) return; if (parentPost!=null) { 241 parentPost.updateAddedReply(subPost, postUsername, postCreationDate); 242 } else if (parentThread!=null) { 243 parentThread.updateAddedPost(subPost, postUsername, postCreationDate); 244 } 245 } 246 247 public void updateAddedAttachment(MvnForumAttachmentXML subAttachment) { 248 if ((!postCreated) || (postXML.getPostID()<0)) return; if (parentPost!=null) { 252 parentPost.updateAddedAttachment(subAttachment); 253 } else if (parentThread!=null) { 254 parentThread.updateAddedAttachment(subAttachment); 255 } 256 } 257 258 259 } 260 | Popular Tags |