[jboss-svn-commits] JBL Code SVN: r7721 - in labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums: . impl ui/action ui/view
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Nov 20 08:10:18 EST 2006
Author: unibrew
Date: 2006-11-20 08:10:15 -0500 (Mon, 20 Nov 2006)
New Revision: 7721
Modified:
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsModule.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java
Log:
[JBFORUMS-135] Tuning of admin actions.
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsModule.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsModule.java 2006-11-20 12:56:16 UTC (rev 7720)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsModule.java 2006-11-20 13:10:15 UTC (rev 7721)
@@ -190,6 +190,16 @@
*/
Forum findForumById(Integer id)
throws ModuleException;
+
+ /**
+ * Find a forum by specifying its ID and fetch Topics of this Forum.
+ *
+ * @param id ID of the forum to retrieve
+ * @return Forum with specified ID
+ * @throws ModuleException Throws an exception if the forum cannot be found
+ */
+ Forum findForumByIdFetchTopics(Integer id)
+ throws ModuleException;
/**
* DOCUMENT_ME
@@ -415,9 +425,11 @@
*
* @param source DOCUMENT_ME
* @param target DOCUMENT_ME
+ * @throws ModuleException DOCUMENT_ME
*/
void addAllForums(Category source,
- Category target);
+ Category target)
+ throws ModuleException;
/**
* @param topicID
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2006-11-20 12:56:16 UTC (rev 7720)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2006-11-20 13:10:15 UTC (rev 7721)
@@ -186,6 +186,44 @@
throw new IllegalArgumentException("id cannot be null");
}
}
+
+ public Forum findForumByIdFetchTopics(Integer id)
+ throws ModuleException
+ {
+ if (id != null)
+ {
+ try
+ {
+ Session session = getSession();
+ Query query = session.createQuery("select f " +
+ "from ForumImpl f " +
+ "join f.topics " +
+ "where f.id = :forumId ");
+ query.setParameter("forumId",id);
+ List forumList = query.list();
+ if (forumList == null)
+ {
+ throw new ModuleException("No forum found for " + id);
+ }
+
+ if (forumList.size()>0) {
+ return (Forum)forumList.get(0);
+ } else {
+ return null;
+ }
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find forum by id " + id;
+ log.error(message, e);
+ throw new ModuleException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+ }
public Category findCategoryById(Integer id)
throws ModuleException
@@ -1237,10 +1275,12 @@
public void addAllForums(Category source,
Category target)
+ throws ModuleException
{
- List list = source.getForums();
- target.getForums().addAll(source.getForums());
- Iterator iterator = target.getForums().iterator();
+ List sourceForums = this.findForumsByCategoryId(source.getId());
+ List targetForums = this.findForumsByCategoryId(target.getId());
+ targetForums.addAll(sourceForums);
+ Iterator iterator = targetForums.iterator();
while (iterator.hasNext())
{
Forum forum = (Forum)iterator.next();
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-11-20 12:56:16 UTC (rev 7720)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-11-20 13:10:15 UTC (rev 7721)
@@ -36,6 +36,7 @@
* Created on May 16, 2006
*
* @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ * @author <a href="mailto:ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
*/
public class AdminController extends ActionController
{
@@ -313,6 +314,7 @@
JSFUtil.setMessage(Constants.FEEDBACK,start+"\""+this.categoryName+"\""+end);
navState = Constants.DELETE_CATEGORY;
+ getForumsModule().getHibernate().getSessionFactory().getCurrentSession().flush();
success = true;
}
catch(Exception e)
@@ -437,12 +439,12 @@
forumId = Integer.parseInt(cour);
}
- Forum source = BaseController.getForumsModule().findForumById(new Integer(forumId));
+ Forum source = BaseController.getForumsModule().findForumByIdFetchTopics(new Integer(forumId));
//move all the topics/posts of this forum to the specified target forum
if(this.selectedForum!=-1)
{
- Forum target = BaseController.getForumsModule().findForumById(new Integer(selectedForum));
+ Forum target = BaseController.getForumsModule().findForumByIdFetchTopics(new Integer(selectedForum));
target.getTopics().addAll(source.getTopics());
target.setPostCount(target.getPostCount() + source.getPostCount());
target.setTopicCount(target.getTopicCount() + source.getTopicCount());
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java 2006-11-20 12:56:16 UTC (rev 7720)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java 2006-11-20 13:10:15 UTC (rev 7721)
@@ -40,6 +40,7 @@
{
private List categories = null;
+ private List forums = null;
/**
*
@@ -75,4 +76,26 @@
}
}
+ public List getForums()
+ {
+ if (forums!=null) {
+ return forums;
+ }
+ synchronized(this) {
+ if (forums!=null) {
+ return categories;
+ }
+ try
+ {
+ forums = getForumsModule().findForums();
+ return forums;
+ }
+ catch(Exception e)
+ {
+ JSFUtil.handleException(e);
+ }
+ }
+ return null;
+ }
+
}
More information about the jboss-svn-commits
mailing list