1 5 package org.exoplatform.services.communication.forum.hibernate; 6 7 import java.util.List ; 8 import net.sf.hibernate.Hibernate; 9 import net.sf.hibernate.Session; 10 import org.exoplatform.services.database.XResources; 11 import org.exoplatform.services.communication.forum.* ; 12 13 18 public class ForumDependencyObjectManager extends ForumEventListener { 19 public ForumDependencyObjectManager(ForumServiceContainer container) { 20 super(container) ; 21 } 22 23 public void onDelete(XResources resources, Category category) throws Exception { 24 Session session = (Session) resources.getResource(Session.class) ; 25 List forums = session.find(ForumServiceImpl.queryForumsByCategory, 26 category.getId(), Hibernate.STRING ); 27 for (int i = 0; i < forums.size(); i++) { 28 Forum forum = (Forum) forums.get(i) ; 29 onDelete(resources, forum) ; 30 } 31 session.delete(ForumServiceImpl.queryForumsByCategory, category.getId(), Hibernate.STRING ); 32 } 33 34 public void onDelete(XResources resources, Forum forum) throws Exception { 35 Session session = (Session) resources.getResource(Session.class) ; 36 session.delete(ForumServiceImpl.queryTopicsByForum, forum.getId(), Hibernate.STRING ); 37 session.delete(ForumServiceImpl.queryPostsByForum, forum.getId(), Hibernate.STRING ); 38 session.delete("from w in class org.exoplatform.services.communication.forum.hibernate.WatcherImpl " + 39 "where w.forumId = ?", 40 forum.getId(), Hibernate.STRING ); 41 } 42 43 public void onDelete(XResources resources, Topic topic) throws Exception { 44 Session session = (Session) resources.getResource(Session.class) ; 45 session.delete(ForumServiceImpl.queryPostsByTopic, topic.getId(), Hibernate.STRING); 46 session.delete("from w in class org.exoplatform.services.communication.forum.hibernate.WatcherImpl " + 47 "where w.topicId = ?", 48 topic.getId(), Hibernate.STRING ); 49 } 50 51 public void onDelete(XResources resources, Post post) throws Exception { } 52 } | Popular Tags |