Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.java,v diff -u -r1.28 -r1.29 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.java 15 Jun 2006 04:04:37 -0000 1.28 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.java 4 Aug 2006 07:22:43 -0000 1.29 @@ -92,20 +92,21 @@ try{ msg = (Message) super.clone(); msg.setUid(null); - if(parent != null){ - msg.parent = (Message) parent.clone(); - //try to keep parent uid, so avoid persistant a new instance in database for parent message - msg.parent.uid = parent.uid; - } - if(toolSession != null){ - msg.toolSession = (ForumToolSession) toolSession.clone(); - } + //it is not necessary to deep clone following comment fields. //don't deep clone forum to avoid dead loop in clone - if(createdBy != null){ - msg.createdBy = (ForumUser) createdBy.clone(); - } - if(modifiedBy != null) - msg.modifiedBy = (ForumUser) modifiedBy.clone(); +// if(parent != null){ +// msg.parent = (Message) parent.clone(); +// //try to keep parent uid, so avoid persistant a new instance in database for parent message +// msg.parent.uid = parent.uid; +// } +// if(toolSession != null){ +// msg.toolSession = (ForumToolSession) toolSession.clone(); +// } +// if(createdBy != null){ +// msg.createdBy = (ForumUser) createdBy.clone(); +// } +// if(modifiedBy != null) +// msg.modifiedBy = (ForumUser) modifiedBy.clone(); //clone attachment if(attachments != null){ Iterator iter = attachments.iterator(); Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java,v diff -u -r1.58 -r1.59 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java 2 Aug 2006 02:46:17 -0000 1.58 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java 4 Aug 2006 07:22:43 -0000 1.59 @@ -338,7 +338,6 @@ log.error("Failed on getting session by given sessionID:" + sessionId); throw new ForumException("Failed on getting session by given sessionID:" + sessionId); } - List topicsFromAuthor = messageDao.getTopicsFromAuthor(session.getForum().getUid()); //sorted by last post date Message msg; @@ -348,11 +347,6 @@ msg = (Message) iter.next(); map.put(msg.getLastReplyDate(),msg); } - iter = topicsFromAuthor.iterator(); - while(iter.hasNext()){ - msg = (Message) iter.next(); - map.put(msg.getLastReplyDate(),msg); - } return MessageDTO.getMessageDTO(new ArrayList(map.values())); } @@ -695,6 +689,34 @@ Forum forum = forumDao.getByContentId(toolContentId); session.setForum(forum); forumToolSessionDao.saveOrUpdate(session); + + //also clone author created topic from this forum tool content!!! + //this can avoid topic record information conflict when multiple sessions are against same tool content + //for example, the reply number maybe various for different sessions. + List topicsFromAuthor = messageDao.getTopicsFromAuthor(session.getForum().getUid()); + + //sorted by last post date + Message msg; + SortedMap map = new TreeMap(new DateComparator()); + Iterator iter = topicsFromAuthor.iterator(); + while(iter.hasNext()){ + msg = (Message) iter.next(); + //Don't copy other session's topic, only from tool content!!!. + if(msg.getToolSession() != null) + continue; + //set this message forum Uid as toContent + if(!msg.getIsAuthored()) + continue; + Message newMsg = (Message) msg.clone(); + //reset some value. + newMsg.setReplyNumber(0); + newMsg.setHideFlag(false); + //it should be new message + newMsg.setUid(null); + //!!! set current session to authored message + newMsg.setToolSession(session); + createRootTopic(toolContentId,null,newMsg); + } } public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException {