[jboss-svn-commits] JBL Code SVN: r12051 - labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon May 21 20:30:59 EDT 2007


Author: unibrew
Date: 2007-05-21 20:30:59 -0400 (Mon, 21 May 2007)
New Revision: 12051

Modified:
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/SplitTopic.java
Log:
[JBFORUMS-238] Split topic problems finally solved.

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/SplitTopic.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/SplitTopic.java	2007-05-22 00:30:30 UTC (rev 12050)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/SplitTopic.java	2007-05-22 00:30:59 UTC (rev 12051)
@@ -146,6 +146,9 @@
         }
         
         try {
+            
+            getForumsModule().getHibernate().getSessionFactory().getCurrentSession().refresh(this.topic);
+            
             Forum destForum = getForumsModule().findForumById(new Integer(toForumId));
             
             // Creating new topic in destination forum.
@@ -178,7 +181,18 @@
             {
                newTopic.addPost((Post)it.next());
             }
+            
+            newTopic.setReplies(newTopic.getPosts().size()-1);
             newTopic.setLastPostDate(newTopic.getLastPost().getCreateDate());
+            
+            Forum fromForum = topic.getForum();
+            topic.setReplies(topic.getReplies()-newTopic.getReplies()-1);
+            fromForum.setPostCount(fromForum.getPostCount()-newTopic.getReplies()-1);
+            topic.setLastPostDate(topic.getLastPost().getCreateDate());
+
+            destForum.addTopicSize();
+            destForum.setPostCount(destForum.getPostCount()+newTopic.getReplies()+1);
+
             getForumsModule().getHibernate().getSessionFactory().getCurrentSession().flush();
         } catch (Exception e) {
             e.printStackTrace();
@@ -261,7 +275,20 @@
                 movedPost = getForumsModule().findPostById((Integer)selectIt.next());
                 newTopic.addPost(movedPost);
             }
+            
+            getForumsModule().getHibernate().getSessionFactory().getCurrentSession().refresh(this.topic);
+            
+            Forum fromForum = topic.getForum();
+            topic.setReplies(topic.getReplies()-checkboxes.size());
+            fromForum.setPostCount(fromForum.getPostCount()-checkboxes.size());
+            topic.setLastPostDate(topic.getLastPost().getCreateDate());
+            
+            newTopic.setReplies(checkboxes.size()-1);
             newTopic.setLastPostDate(newTopic.getLastPost().getCreateDate());
+            
+            destForum.addTopicSize();
+            destForum.setPostCount(destForum.getPostCount()+newTopic.getReplies()+1);
+            
             getForumsModule().getHibernate().getSessionFactory().getCurrentSession().flush();
         } catch (Exception e) {
             e.printStackTrace();




More information about the jboss-svn-commits mailing list