1 40 package com.mvnforum.admin.importexport.mvnforum; 41 42 import com.mvnforum.admin.CategoryXML; 43 import net.myvietnam.mvncore.exception.*; 44 45 57 public class MvnForumCategoryXML { 58 59 private CategoryXML categoryXML=null; 60 private boolean categoryCreated=false; 61 private MvnForumCategoryXML parentCategory=null; 62 63 String categoryName =null; 64 String categoryDesc =null; 65 String categoryCreationDate =null; 66 String categoryModifiedDate =null; 67 String categoryOrder =null; 68 String categoryOption =null; 69 String categoryStatus =null; 70 71 public MvnForumCategoryXML() { 72 super(); 73 categoryXML=new CategoryXML(); 74 categoryCreated=false; 75 parentCategory=null; 76 } 77 78 public int getCategoryID() { 79 return categoryXML.getCategoryID(); 80 } 81 82 public void setCategoryID(String id) { 83 categoryXML.setCategoryID(id); 84 } 85 86 92 public void setCategoryId(String id) { 93 setCategoryID(id); 94 } 95 96 public int getParentCategoryID() { 97 return categoryXML.getParentCategoryID(); } 99 100 public void setParentCategoryIfHave(Object o) 101 throws ForeignKeyNotFoundException { 102 if (o instanceof MvnForumCategoryXML) { 103 parentCategory=(MvnForumCategoryXML)o; 104 108 } else { 109 } 112 } 113 114 public void setCategoryName(String value) { 115 categoryName=value; 116 } 117 118 public void setCategoryDesc(String value) { 119 categoryDesc=value; 120 } 121 122 public void setCategoryCreationDate(String value) { 123 categoryCreationDate=value; 124 } 125 126 public void setCategoryModifiedDate(String value) { 127 categoryModifiedDate=value; 128 } 129 130 public void setCategoryOrder(String value) { 131 categoryOrder=value; 132 } 133 134 public void setCategoryOption(String value) { 135 categoryOption=value; 136 } 137 138 public void setCategoryStatus(String value) { 139 categoryStatus=value; 140 } 141 142 public void addCategory() throws CreateException, DuplicateKeyException, 143 ObjectNotFoundException, DatabaseException, ForeignKeyNotFoundException, BadInputException { 144 149 if (categoryCreated) return; 150 151 if (parentCategory!=null) { 152 parentCategory.addCategory(); 153 categoryXML.setParentCategoryID(parentCategory.getCategoryID()); 154 } 155 156 ImportMvnForum.addMessage("Adding category \""+categoryName+"\"."); 157 categoryXML.addCategory(categoryName, categoryDesc, 158 categoryCreationDate, categoryModifiedDate, 159 categoryOrder, categoryOption, categoryStatus); 160 categoryCreated=true; 161 162 if (parentCategory!=null) { 163 parentCategory.updateAddedCategory(this); 164 } 165 } 166 167 public void addCategoryWatch(String memberName, 168 String watchType, String watchOption, 169 String watchStatus, String watchCreationDate, 170 String watchLastSentDate, String watchEndDate) 171 throws CreateException, DuplicateKeyException, ObjectNotFoundException, 172 DatabaseException, ForeignKeyNotFoundException, BadInputException { 173 if ( (!categoryCreated) || (categoryXML.getCategoryID()<0) ) { 174 addCategory(); 175 } 176 ImportMvnForum.addMessage("Adding category watch for member \""+memberName+"\"."); 177 categoryXML.addCategoryWatch(memberName, 178 watchType, watchOption, watchStatus, 179 watchCreationDate, watchLastSentDate, watchEndDate); 180 } 181 182 public void updateAddedCategory(MvnForumCategoryXML subCategory) { 183 if (parentCategory!=null) { 185 parentCategory.updateAddedCategory(subCategory); 186 } 187 } 188 189 public void updateAddedForum(MvnForumForumXML subForum) { 190 if (parentCategory!=null) { 192 parentCategory.updateAddedForum(subForum); 193 } 194 } 195 196 public void updateAddedThread(MvnForumThreadXML subThread) { 197 if (parentCategory!=null) { 199 parentCategory.updateAddedThread(subThread); 200 } 201 } 202 203 public void updateAddedPost(MvnForumPostXML subPost) { 204 if (parentCategory!=null) { 206 parentCategory.updateAddedPost(subPost); 207 } 208 } 209 210 public void updateAddedAttachment(MvnForumAttachmentXML subAttachment) { 211 if (parentCategory!=null) { 213 parentCategory.updateAddedAttachment(subAttachment); 214 } 215 } 216 217 218 } 219 | Popular Tags |