KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > communication > forum > hibernate > ForumDependencyObjectManager


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.services.communication.forum.hibernate;
6
7 import java.util.List JavaDoc;
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 /**
14  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
15  * @since Nov 25, 2004
16  * @version $Id$
17  */

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 JavaDoc {
24     Session session = (Session) resources.getResource(Session.class) ;
25     List JavaDoc 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 JavaDoc {
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 JavaDoc {
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 JavaDoc { }
52 }
Popular Tags