[jboss-svn-commits] JBL Code SVN: r26699 - in labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main: java/org/jboss/labs/clearspace/plugin/nfm/dao and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 22 12:00:59 EDT 2009
Author: lkrzyzanek
Date: 2009-05-22 12:00:59 -0400 (Fri, 22 May 2009)
New Revision: 26699
Added:
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbViewCountDAO.java
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/ViewCountDAO.java
Modified:
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java
labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml
Log:
added view count capabilities
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java 2009-05-22 15:02:14 UTC (rev 26698)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java 2009-05-22 16:00:59 UTC (rev 26699)
@@ -36,6 +36,7 @@
import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsMappingDAO;
import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsPostBean;
import org.jboss.labs.clearspace.plugin.nfm.dao.NukesForumsTopicBean;
+import org.jboss.labs.clearspace.plugin.nfm.dao.ViewCountDAO;
import org.springframework.dao.DataIntegrityViolationException;
import com.jivesoftware.base.User;
@@ -48,8 +49,11 @@
import com.jivesoftware.community.ForumManager;
import com.jivesoftware.community.ForumMessage;
import com.jivesoftware.community.ForumThread;
+import com.jivesoftware.community.JiveConstants;
import com.jivesoftware.community.QuestionManager;
import com.jivesoftware.community.RejectedException;
+import com.jivesoftware.community.cache.CacheManager;
+import com.jivesoftware.community.stats.ViewCountManager;
/**
* Db implementation
@@ -66,6 +70,8 @@
private NukesForumsDAO nukesForumsDAO;
+ private ViewCountDAO viewCountDAO;
+
private ForumManager forumManager;
private CommunityManager communityManager;
@@ -74,6 +80,8 @@
private QuestionManager questionManager;
+ private ViewCountManager viewCountManager;
+
Map<Long, Long> categoryMappings = null;
Map<Long, Long> forumMappings = null;
@@ -155,6 +163,9 @@
} catch (CommunityNotFoundException e) {
throw new RuntimeException(e);
}
+ // Caches must be cleared because we modify view count
+ // communityManager.clearCache(community);
+
ForumMessage rootMessage = forumManager.createMessage(community,
rootMessageUser);
// creationDate taken from first post.
@@ -174,6 +185,11 @@
try {
forumManager.addThread(community, thread);
+ if (topic.getViewCount() > 0) {
+ viewCountDAO.updateViewCount(JiveConstants.THREAD, thread.getID(),
+ topic.getViewCount());
+ }
+
nukesForumsMappingDAO.saveTopicMapping(topic.getTopicID(), thread
.getID());
@@ -318,4 +334,12 @@
this.questionManager = questionManager;
}
+ public void setViewCountDAO(ViewCountDAO viewCountDAO) {
+ this.viewCountDAO = viewCountDAO;
+ }
+
+ public void setViewCountManager(ViewCountManager viewCountManager) {
+ this.viewCountManager = viewCountManager;
+ }
+
}
Added: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbViewCountDAO.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbViewCountDAO.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbViewCountDAO.java 2009-05-22 16:00:59 UTC (rev 26699)
@@ -0,0 +1,41 @@
+/*
+ * JBoss.org http://jboss.org/
+ *
+ * Copyright (c) 2009 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.labs.clearspace.plugin.nfm.dao;
+
+import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
+
+/**
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ *
+ */
+public class DbViewCountDAO extends SimpleJdbcDaoSupport implements
+ ViewCountDAO {
+
+ private final static String UPDATE_VIEW_COUNT = "UPDATE jiveViewCount SET viewCount=? "
+ + "WHERE objectType=? AND objectID=?";
+
+ public void updateViewCount(int objectType, long objectID, int count) {
+ this.getSimpleJdbcTemplate().update(UPDATE_VIEW_COUNT, objectType,
+ objectID, count);
+ }
+
+}
Property changes on: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/DbViewCountDAO.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/ViewCountDAO.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/ViewCountDAO.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/ViewCountDAO.java 2009-05-22 16:00:59 UTC (rev 26699)
@@ -0,0 +1,40 @@
+/*
+ * JBoss.org http://jboss.org/
+ *
+ * Copyright (c) 2009 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.labs.clearspace.plugin.nfm.dao;
+
+/**
+ * DAO for jiveViewCount that extend functionality of ViewCountManager
+ *
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+public interface ViewCountDAO {
+
+ /**
+ * Update view count for specified objectID and objectType
+ *
+ * @param objectType
+ * @param objectID
+ * @param count
+ */
+ public void updateViewCount(int objectType, long objectID, int count);
+
+}
Property changes on: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/dao/ViewCountDAO.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml 2009-05-22 15:02:14 UTC (rev 26698)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml 2009-05-22 16:00:59 UTC (rev 26699)
@@ -9,9 +9,11 @@
class="org.jboss.labs.clearspace.plugin.nfm.DbNukesForumsManager">
<property name="nukesForumsMappingDAO" ref="nukesForumsMappingDAO" />
<property name="nukesForumsDAO" ref="nukesForumsDAO" />
+ <property name="viewCountDAO" ref="viewCountDAO" />
<property name="communityManager" ref="communityManager" />
<property name="forumManager" ref="forumManager" />
<property name="userManager" ref="userManager" />
+ <property name="viewCountManager" ref="viewCountManager" />
<property name="questionManager" ref="questionManager" />
<property name="defaultTopicTimeStr" value="2002-01-01" />
</bean>
@@ -23,6 +25,13 @@
</property>
</bean>
+ <bean id="viewCountDAO"
+ class="org.jboss.labs.clearspace.plugin.nfm.dao.DbViewCountDAO">
+ <property name="dataSource">
+ <util:property-path path="dataSourceFactory.dataSource" />
+ </property>
+ </bean>
+
<bean id="nukesForumsDAO"
class="org.jboss.labs.clearspace.plugin.nfm.dao.DbNukesForumsDAOImpl">
<property name="dataSource" ref="forumsDataSource" />
More information about the jboss-svn-commits
mailing list