Index: lams_tool_forum/.classpath
===================================================================
diff -u -rf2dc26e95cad64b7d5c55b483a0fbb32691d7f13 -rd3558795f19f456d9caed6ac5dafdb0a71cb0029
--- lams_tool_forum/.classpath (.../.classpath) (revision f2dc26e95cad64b7d5c55b483a0fbb32691d7f13)
+++ lams_tool_forum/.classpath (.../.classpath) (revision d3558795f19f456d9caed6ac5dafdb0a71cb0029)
@@ -8,5 +8,7 @@
-
+
+
+
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java
===================================================================
diff -u -rbb86b2d50b113e03e7ead098db991c1ae922d99c -rd3558795f19f456d9caed6ac5dafdb0a71cb0029
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java (.../ForumDao.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java (.../ForumDao.java) (revision d3558795f19f456d9caed6ac5dafdb0a71cb0029)
@@ -2,8 +2,6 @@
import java.util.List;
-import org.hibernate.FlushMode;
-import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
@@ -45,32 +43,6 @@
else
return null;
}
- /**
- * Delete content instruction files according to contentID, file version ID and its type.
- *
- * @param contentID
- * @param uuid
- * @param versionID
- * @param type
- */
- public void deleteInstrcutionFile(Long contentID, Long uuid, Long versionID, String type) {
- HibernateTemplate templ = this.getHibernateTemplate();
- if ( contentID != null && uuid != null && versionID != null ) {
- List list = getSession().createQuery(FIND_INSTRUCTION_FILE)
- .setLong(0,contentID.longValue())
- .setLong(1,uuid.longValue())
- .setLong(2,versionID.longValue())
- .setString(3,type)
- .list();
- if(list != null && list.size() > 0){
- Attachment file = (Attachment) list.get(0);
- this.getSession().setFlushMode(FlushMode.AUTO);
- templ.delete(file);
- templ.flush();
- }
- }
- }
-
public void flush() {
this.getHibernateTemplate().flush();
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java
===================================================================
diff -u -rbb86b2d50b113e03e7ead098db991c1ae922d99c -rd3558795f19f456d9caed6ac5dafdb0a71cb0029
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java (.../MessageDao.java) (revision bb86b2d50b113e03e7ead098db991c1ae922d99c)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java (.../MessageDao.java) (revision d3558795f19f456d9caed6ac5dafdb0a71cb0029)
@@ -38,30 +38,52 @@
public Message getById(Long messageId) {
return (Message) getHibernateTemplate().get(Message.class,messageId);
}
-
+ /**
+ * Get all root (first level) topics in a special Session.
+ * @param sessionId
+ * @return
+ */
public List getRootTopics(Long sessionId) {
return this.getHibernateTemplate().find(SQL_QUERY_FIND_ROOT_TOPICS, sessionId);
}
+ /**
+ * Get all message posted by author role in a special forum.
+ * @param forumUid
+ * @return
+ */
public List getTopicsFromAuthor(Long forumUid) {
return this.getHibernateTemplate().find(SQL_QUERY_FIND_TOPICS_FROM_AUTHOR, forumUid);
}
- public void deleteById(Long uid) {
+ public void delete(Long uid) {
Message msg = getById(uid);
if(msg != null){
this.getHibernateTemplate().delete(msg);
this.getHibernateTemplate().flush();
}
}
-
+ /**
+ * Get all children message from the given parent topic ID.
+ * @param parentId
+ * @return
+ */
public List getChildrenTopics(Long parentId) {
return this.getHibernateTemplate().find(SQL_QUERY_FIND_CHILDREN, parentId);
}
-
+ /**
+ * Get all messages according to special user and session.
+ * @param userId
+ * @param sessionId
+ * @return
+ */
public List getByUserAndSession(Long userId, Long sessionId) {
return this.getHibernateTemplate().find(SQL_QUERY_BY_USER_SESSION, new Object[]{userId,sessionId});
}
-
+ /**
+ * Get all messages according to special session.
+ * @param sessionId
+ * @return
+ */
public List getBySession(Long sessionId) {
return this.getHibernateTemplate().find(SQL_QUERY_BY_SESSION, sessionId);
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java
===================================================================
diff -u -r80eff1f58f1205ddc908f3eca5ea8706a0c444d2 -rd3558795f19f456d9caed6ac5dafdb0a71cb0029
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 80eff1f58f1205ddc908f3eca5ea8706a0c444d2)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision d3558795f19f456d9caed6ac5dafdb0a71cb0029)
@@ -156,7 +156,7 @@
}
}
messageSeqDao.deleteByTopicId(topicUid);
- messageDao.deleteById(topicUid);
+ messageDao.delete(topicUid);
}
public Message replyTopic(Long parentId,Long sessionId, Message replyMessage) throws PersistenceException {
Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/ForumDAOTest.java
===================================================================
diff -u -r80eff1f58f1205ddc908f3eca5ea8706a0c444d2 -rd3558795f19f456d9caed6ac5dafdb0a71cb0029
--- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/ForumDAOTest.java (.../ForumDAOTest.java) (revision 80eff1f58f1205ddc908f3eca5ea8706a0c444d2)
+++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/ForumDAOTest.java (.../ForumDAOTest.java) (revision d3558795f19f456d9caed6ac5dafdb0a71cb0029)
@@ -20,12 +20,39 @@
*/
package org.lamsfoundation.lams.tool.forum.test.dao;
+import org.lamsfoundation.lams.tool.forum.persistence.Forum;
+import org.lamsfoundation.lams.tool.forum.persistence.ForumDao;
+import org.lamsfoundation.lams.tool.forum.persistence.ForumUser;
import org.lamsfoundation.lams.tool.forum.test.BaseTest;
public class ForumDAOTest extends BaseTest{
public ForumDAOTest(String name) {
super(name);
}
+
+ public void testSave(){
+ ForumUser user = new ForumUser();
+ user.setFirstName("Steve");
+ user.setUserId(new Long(1));
+
+ Forum forum = new Forum();
+
+ forum.setContentId(new Long(1));
+ forum.setCreatedBy(user);
+
+ ForumDao forumDao = new ForumDao();
+ forumDao.saveOrUpdate(forum);
+
+ Forum tForum = forumDao.getById(forum.getUid());
+ assertEquals(tForum.getContentId(),new Long(1));
+ assertEquals(tForum.getCreatedBy(),user);
+ }
+
+ public void testDelete(){
+
+ }
+ public void testGetByContentId(){
+ }
}
Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/ForumToolSessionDAOTest.java
===================================================================
diff -u
--- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/ForumToolSessionDAOTest.java (revision 0)
+++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/ForumToolSessionDAOTest.java (revision d3558795f19f456d9caed6ac5dafdb0a71cb0029)
@@ -0,0 +1,47 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.forum.test.dao;
+
+import org.lamsfoundation.lams.tool.forum.test.BaseTest;
+
+public class ForumToolSessionDAOTest extends BaseTest{
+
+ public ForumToolSessionDAOTest(String name) {
+ super(name);
+
+ }
+
+ public void testDelete(){
+
+ }
+
+ public void testSave(){
+
+ }
+
+ public void testGetByContentId(){
+
+ }
+
+ public void testGetBySessionId(){
+
+ }
+}
Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/ForumUserDAOTest.java
===================================================================
diff -u
--- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/ForumUserDAOTest.java (revision 0)
+++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/ForumUserDAOTest.java (revision d3558795f19f456d9caed6ac5dafdb0a71cb0029)
@@ -0,0 +1,38 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.forum.test.dao;
+
+import org.lamsfoundation.lams.tool.forum.test.BaseTest;
+
+public class ForumUserDAOTest extends BaseTest{
+
+ public ForumUserDAOTest(String name) {
+ super(name);
+ }
+ public void testSave(){
+
+ }
+ public void testGetByUserId(){
+
+ }
+
+
+}
Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/MessageDAOTest.java
===================================================================
diff -u
--- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/MessageDAOTest.java (revision 0)
+++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/dao/MessageDAOTest.java (revision d3558795f19f456d9caed6ac5dafdb0a71cb0029)
@@ -0,0 +1,57 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.forum.test.dao;
+
+import org.lamsfoundation.lams.tool.forum.test.BaseTest;
+
+public class MessageDAOTest extends BaseTest{
+
+ public MessageDAOTest(String name) {
+ super(name);
+ }
+
+ public void testSave(){
+
+ }
+ public void testDelete(){
+
+ }
+ public void testGetById(){
+
+ }
+ public void testGetBySession(){
+
+ }
+ public void testGetBySessionAndUser(){
+
+ }
+ public void testGetFromAuthor(){
+
+ }
+ public void testGetRootTopics(){
+
+ }
+ public void testGetChildrenTopics(){
+
+ }
+
+
+}
Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/service/ForumServiceTest.java
===================================================================
diff -u -r80eff1f58f1205ddc908f3eca5ea8706a0c444d2 -rd3558795f19f456d9caed6ac5dafdb0a71cb0029
--- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/service/ForumServiceTest.java (.../ForumServiceTest.java) (revision 80eff1f58f1205ddc908f3eca5ea8706a0c444d2)
+++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/test/service/ForumServiceTest.java (.../ForumServiceTest.java) (revision d3558795f19f456d9caed6ac5dafdb0a71cb0029)
@@ -21,6 +21,7 @@
package org.lamsfoundation.lams.tool.forum.test.service;
import org.lamsfoundation.lams.tool.forum.persistence.Forum;
+import org.lamsfoundation.lams.tool.forum.persistence.ForumUser;
import org.lamsfoundation.lams.tool.forum.service.IForumService;
import org.lamsfoundation.lams.tool.forum.test.BaseTest;
@@ -31,14 +32,26 @@
super(name);
}
public void setUp()throws Exception{
+ super.setUp();
forumService = (IForumService)context.getBean("forumService");
}
public void testUpdateForum(){
+ ForumUser user = new ForumUser();
+ user.setFirstName("Steve");
+ user.setUserId(new Long(1));
+
Forum forum = new Forum();
+
forum.setContentId(new Long(1));
+ forum.setCreatedBy(user);
+
forumService.updateForum(forum);
+ Forum tForum = forumService.getForum(new Long(1));
+
+ assertEquals(tForum.getContentId(),new Long(1));
+ assertEquals(tForum.getCreatedBy(),user);
}
}