Index: lams_tool_mindmap/.settings/org.eclipse.core.resources.prefs =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/.settings/org.eclipse.core.resources.prefs (.../org.eclipse.core.resources.prefs) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/.settings/org.eclipse.core.resources.prefs (.../org.eclipse.core.resources.prefs) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -1,5 +1,4 @@ -#Tue Mar 24 14:05:02 EST 2009 +#Thu May 07 17:18:58 GMT+10:00 2009 eclipse.preferences.version=1 -encoding//conf/language/lams/ApplicationResources_ru_RU.properties=UTF-8 encoding//conf/xdoclet/web-settings.xml=UTF-8 encoding//web/WEB-INF/web.xml=UTF-8 Index: lams_tool_mindmap/db/model/mindmap_tool.clay =================================================================== diff -u -r844ff3b43d22c544d3da7bf5aadf2ae33e48f9d4 -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/db/model/mindmap_tool.clay (.../mindmap_tool.clay) (revision 844ff3b43d22c544d3da7bf5aadf2ae33e48f9d4) +++ lams_tool_mindmap/db/model/mindmap_tool.clay (.../mindmap_tool.clay) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -249,7 +249,7 @@ - + @@ -304,6 +304,19 @@ + + + + + + + + + + + + + Index: lams_tool_mindmap/db/sql/create_lams_tool_mindmap.sql =================================================================== diff -u -r844ff3b43d22c544d3da7bf5aadf2ae33e48f9d4 -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/db/sql/create_lams_tool_mindmap.sql (.../create_lams_tool_mindmap.sql) (revision 844ff3b43d22c544d3da7bf5aadf2ae33e48f9d4) +++ lams_tool_mindmap/db/sql/create_lams_tool_mindmap.sql (.../create_lams_tool_mindmap.sql) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -12,7 +12,7 @@ create table tl_lamind10_mindmap (uid bigint not null auto_increment, create_date datetime, update_date datetime, create_by bigint, title varchar(255), instructions text, run_offline bit, lock_on_finished bit, multiuser_mode bit, online_instructions text, offline_instructions text, content_in_use bit, define_later bit, tool_content_id bigint, export_content text, reflect_on_activity bit, reflect_instructions text, primary key (uid))type=innodb; create table tl_lamind10_session (uid bigint not null auto_increment, session_end_date datetime, session_start_date datetime, status integer, session_id bigint, session_name varchar(250), mindmap_uid bigint, primary key (uid))type=innodb; create table tl_lamind10_user (uid bigint not null auto_increment, user_id bigint, last_name varchar(255), login_name varchar(255), first_name varchar(255), finishedActivity bit, mindmap_session_uid bigint, entry_uid bigint, primary key (uid))type=innodb; -create table tl_lamind10_node (node_id bigint not null auto_increment, unique_id bigint, parent_id bigint, node_text varchar(100), node_color varchar(6), user_id bigint, mindmap_id bigint, primary key (node_id))TYPE=InnoDB; +create table tl_lamind10_node (node_id bigint not null auto_increment, unique_id bigint, parent_id bigint, node_text varchar(100), node_color varchar(6), session_id bigint, user_id bigint, mindmap_id bigint, primary key (node_id))TYPE=InnoDB; CREATE TABLE tl_lamind10_request (`uid` BIGINT(20) NOT NULL AUTO_INCREMENT, `unique_id` BIGINT(20) DEFAULT NULL, `global_id` BIGINT(20) DEFAULT NULL, `request_type` TINYINT(4) DEFAULT NULL, `node_id` BIGINT(20) DEFAULT NULL, `node_child_id` BIGINT(20) DEFAULT NULL, `user_id` BIGINT(20) DEFAULT NULL, `mindmap_id` BIGINT(20) DEFAULT NULL, PRIMARY KEY (`uid`), KEY `mindmap_id` (`mindmap_id`), KEY `user_id` (`user_id`), CONSTRAINT `tl_lamind10_request_fk` FOREIGN KEY (`mindmap_id`) REFERENCES `tl_lamind10_mindmap` (`uid`), CONSTRAINT `tl_lamind10_request_fk1` FOREIGN KEY (`user_id`) REFERENCES `tl_lamind10_user` (`uid`))ENGINE=InnoDB; alter table tl_lamind10_attachment add index FK_NEW_972920762_12090F57FC940906 (mindmap_uid), add constraint FK_NEW_972920762_12090F57FC940906 foreign key (mindmap_uid) references tl_lamind10_mindmap (uid); Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/IMindmapNodeDAO.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/IMindmapNodeDAO.java (.../IMindmapNodeDAO.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/IMindmapNodeDAO.java (.../IMindmapNodeDAO.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -35,29 +35,31 @@ */ public interface IMindmapNodeDAO extends IBaseDAO { - public void deleteNodeByUniqueMindmapUser(Long uniqueId, Long mindmapId, Long userId); + public void deleteNodeByUniqueMindmapUser(Long uniqueId, Long mindmapId, Long userId, Long sessionId); public void deleteNodes(String deletedNodesQuery); public void saveOrUpdate(MindmapNode mindmapNode); public List getAuthorRootNodeByMindmapId(Long mindmapId); - public List getAuthorRootNodeByMindmapIdMulti(Long mindmapId); + public List getAuthorRootNodeBySessionId(Long sessionId); + public List getAuthorRootNodeByMindmapSession(Long mindmapId, Long toolSessionId); + public List getRootNodeByMindmapIdAndUserId(Long mindmapId, Long userId); - public List getUserRootNodeByUserId(Long userId); - public List getMindmapNodeByParentId(Long parentId, Long mindmapId); + public List getMindmapNodeByParentIdMindmapIdSessionId(Long parentId, Long mindmapId, Long sessionId); + public List getMindmapNodeByUniqueId(Long uniqueId, Long mindmapId); + public List getMindmapNodeByUniqueIdSessionId(Long uniqueId, Long mindmapId, Long sessionId); + public List getMindmapNodeByUniqueIdMindmapIdUserId(Long uniqueId, Long mindmapId, Long userId); - public Long getLastUniqueIdByMindmapIdUserId(Long mindmapId, Long userId); + public Long getNodeLastUniqueIdByMindmapUidSessionId(Long mindmapUid, Long sessionId); - public Long getLastUniqueIdByMindmapId(Long mindmapId); - public int getNumNodesByUserAndSession(Long userId, Long sessionId); } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/IMindmapRequestDAO.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/IMindmapRequestDAO.java (.../IMindmapRequestDAO.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/IMindmapRequestDAO.java (.../IMindmapRequestDAO.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -37,9 +37,9 @@ public void saveOrUpdate(MindmapRequest mindmapRequest); - public List getLastRequestsAfterGlobalId(Long globalId, Long mindmapId, Long userId); + public List getLastRequestsAfterGlobalId(Long globalId, Long mindmapId, Long userId, Long sessionId); public MindmapRequest getRequestByUniqueId(Long uniqueId, Long userId, Long mindmapId, Long globalId); - public Long getLastGlobalIdByMindmapId(Long mindmapId); + public Long getLastGlobalIdByMindmapId(Long mindmapId, Long sessionId); } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/IMindmapSessionDAO.java =================================================================== diff -u -r4dac3505ba7605adf1bc770010861260e2b91c1b -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/IMindmapSessionDAO.java (.../IMindmapSessionDAO.java) (revision 4dac3505ba7605adf1bc770010861260e2b91c1b) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/IMindmapSessionDAO.java (.../IMindmapSessionDAO.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -28,16 +28,14 @@ import org.lamsfoundation.lams.tool.mindmap.model.MindmapSession; /** - * DAO for accessing the MindmapSession objects - interface defining - * methods to be implemented by the Hibernate or other implementation. + * DAO for accessing the MindmapSession objects - interface defining methods to be implemented by the Hibernate or other + * implementation. */ public interface IMindmapSessionDAO extends IBaseDAO { - void saveOrUpdate(MindmapSession session); + void saveOrUpdate(MindmapSession session); - MindmapSession getBySessionId(Long toolSessionId); + MindmapSession getBySessionId(Long toolSessionId); - void deleteBySessionID(Long toolSessionID); - - public MindmapSession getSessionByMindmapId(Long mindmapId); + void deleteBySessionID(Long toolSessionID); } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/hibernate/MindmapNodeDAO.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/hibernate/MindmapNodeDAO.java (.../MindmapNodeDAO.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/hibernate/MindmapNodeDAO.java (.../MindmapNodeDAO.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -38,48 +38,59 @@ * @author Ruslan Kazakov */ public class MindmapNodeDAO extends BaseDAO implements IMindmapNodeDAO { + private static final String SQL_QUERY_FIND_ROOT_NODE_BY_MINDMAP_ID = "from " + MindmapNode.class.getName() + " mn where mn.parent is null and mn.mindmap.uid = ? and mn.user is null "; - private static final String SQL_QUERY_FIND_ROOT_NODE_BY_MINDMAP_ID_MULTI = "from " + MindmapNode.class.getName() - + " mn where mn.parent is null and mn.mindmap.uid = ? "; + private static final String SQL_QUERY_FIND_ROOT_NODE_BY_MINDMAP_SESSION = "from " + MindmapNode.class.getName() + + " mn where mn.parent is null and mn.mindmap.uid = ? and mn.session.sessionId = ? "; private static final String SQL_QUERY_FIND_ROOT_NODE_BY_MINDMAP_ID_USER_ID = "from " + MindmapNode.class.getName() + " mn where mn.parent is null and mn.mindmap.uid = ? and mn.user.uid = ? "; + + private static final String SQL_QUERY_FIND_ROOT_NODE_BY_MINDMAP_ID_SESSION_ID = "from " + MindmapNode.class.getName() + + " mn where mn.parent is null and mn.mindmap.uid = ? and mn.session.sessionId = ? "; + + private static final String SQL_QUERY_FIND_ROOT_NODE_BY_SESSION_ID = "from " + MindmapNode.class.getName() + + " mn where mn.parent is null and mn.session.sessionId = ? "; - private static final String SQL_QUERY_FIND_ROOT_NODE_BY_USER_ID = "from " + MindmapNode.class.getName() - + " mn where mn.parent is null and mn.user.uid = ? "; + private static final String SQL_QUERY_FIND_NODE_BY_PARENT_ID_MINDMAP_ID = "from " + + MindmapNode.class.getName() + " mn where mn.parent.nodeId = ? and mn.mindmap.uid = ? "; - private static final String SQL_QUERY_FIND_NODE_BY_PARENT_ID_MINDMAP_ID = "from " + MindmapNode.class.getName() - + " mn where mn.parent.nodeId = ? and mn.mindmap.uid = ? "; - + private static final String SQL_QUERY_FIND_NODE_BY_PARENT_ID_MINDMAP_ID_SESSION_ID = "from " + + MindmapNode.class.getName() + " mn where mn.parent.nodeId = ? and mn.mindmap.uid = ? and mn.session.sessionId = ? "; + private static final String SQL_QUERY_FIND_NODE_BY_UNIQUE_ID_MINDMAP_ID = "from " + MindmapNode.class.getName() + " mn where mn.uniqueId = ? and mn.mindmap.uid = ? "; + + private static final String SQL_QUERY_FIND_NODE_BY_UNIQUE_ID_SESSION_ID = "from " + MindmapNode.class.getName() + + " mn where mn.uniqueId = ? and mn.mindmap.uid = ? and mn.session.sessionId = ? "; private static final String SQL_QUERY_FIND_NODE_BY_UNIQUE_MINDMAP_ID_AND_USER_ID = "from " + MindmapNode.class.getName() + " mn where mn.uniqueId = ? and mn.mindmap.uid = ? and mn.user.uid = ? "; - private static final String SQL_QUERY_FIND_UNIQUE_ID_BY_MINDMAP_ID_AND_USER_ID = " select mn.uniqueId from " - + MindmapNode.class.getName() + " mn where mn.mindmap.uid = ? and mn.user.uid = ? " + private static final String SQL_QUERY_FIND_NODE_LAST_UNIQUEID_BY_MINDMAPUID_SESSIONID = " select mn.uniqueId from " + + MindmapNode.class.getName() + " mn where mn.mindmap.uid = ? and mn.session.sessionId = ? " + " order by mn.uniqueId desc "; - private static final String SQL_QUERY_FIND_UNIQUE_ID_BY_MINDMAP_ID = " select mn.uniqueId from " - + MindmapNode.class.getName() + " mn where mn.mindmap.uid = ? " + " order by mn.uniqueId desc "; - - private static final String SQL_QUERY_NODES_NUMBER_BY_USER_SESSION = " select count(*) from " + private static final String SQL_QUERY_FIND_NODES_NUMBER_BY_USERUID_SESSIONID = " select count(*) from " + MindmapNode.class.getName() + " mn where mn.user.uid = ? "; - - public void deleteNodeByUniqueMindmapUser(Long uniqueId, Long mindmapId, Long userId) { + + /* Functions Implementations */ + + // deleting Mindmap nodes in singleuser mode + public void deleteNodes(String deletedNodesQuery) { Session session = getSessionFactory().getCurrentSession(); - String hql = "delete from " + MindmapNode.class.getName() + " where unique_id = " + uniqueId - + " and mindmap_id = " + mindmapId + " and user_id = " + userId; + String hql = "delete from " + MindmapNode.class.getName() + deletedNodesQuery; Query query = session.createQuery(hql); query.executeUpdate(); } - - public void deleteNodes(String deletedNodesQuery) { + + // deleting Mindmap nodes in Multiuser mode + public void deleteNodeByUniqueMindmapUser(Long uniqueId, Long mindmapId, Long userId, Long sessionId) { Session session = getSessionFactory().getCurrentSession(); - String hql = "delete from " + MindmapNode.class.getName() + deletedNodesQuery; + String hql = "delete from " + MindmapNode.class.getName() + " where unique_id = " + uniqueId + + " and mindmap_id = " + mindmapId + " and user_id = " + userId + " and session_id = " + sessionId; Query query = session.createQuery(hql); query.executeUpdate(); } @@ -91,55 +102,65 @@ public List getAuthorRootNodeByMindmapId(Long mindmapId) { return this.getHibernateTemplate().find(SQL_QUERY_FIND_ROOT_NODE_BY_MINDMAP_ID, mindmapId); } + + public List getAuthorRootNodeBySessionId(Long sessionId) { + return this.getHibernateTemplate().find(SQL_QUERY_FIND_ROOT_NODE_BY_SESSION_ID, sessionId); + } - public List getAuthorRootNodeByMindmapIdMulti(Long mindmapId) { - return this.getHibernateTemplate().find(SQL_QUERY_FIND_ROOT_NODE_BY_MINDMAP_ID_MULTI, mindmapId); + public List getAuthorRootNodeByMindmapSession(Long mindmapId, Long toolSessionId) { + return this.getHibernateTemplate().find(SQL_QUERY_FIND_ROOT_NODE_BY_MINDMAP_SESSION, + new Object[] { mindmapId, toolSessionId }); } public List getRootNodeByMindmapIdAndUserId(Long mindmapId, Long userId) { return this.getHibernateTemplate().find(SQL_QUERY_FIND_ROOT_NODE_BY_MINDMAP_ID_USER_ID, new Object[] { mindmapId, userId }); } - - public List getUserRootNodeByUserId(Long userId) { - return this.getHibernateTemplate().find(SQL_QUERY_FIND_ROOT_NODE_BY_USER_ID, userId); + + public List getRootNodeByMindmapIdAndSessionId(Long mindmapId, Long sessionId) { + return this.getHibernateTemplate().find(SQL_QUERY_FIND_ROOT_NODE_BY_MINDMAP_ID_SESSION_ID, + new Object[] { mindmapId, sessionId }); } public List getMindmapNodeByParentId(Long parentId, Long mindmapId) { return this.getHibernateTemplate().find(SQL_QUERY_FIND_NODE_BY_PARENT_ID_MINDMAP_ID, new Object[] { parentId, mindmapId }); } - + + public List getMindmapNodeByParentIdMindmapIdSessionId(Long parentId, Long mindmapId, Long sessionId) { + return this.getHibernateTemplate().find(SQL_QUERY_FIND_NODE_BY_PARENT_ID_MINDMAP_ID_SESSION_ID, + new Object[] { parentId, mindmapId, sessionId }); + } + public List getMindmapNodeByUniqueId(Long uniqueId, Long mindmapId) { return this.getHibernateTemplate().find(SQL_QUERY_FIND_NODE_BY_UNIQUE_ID_MINDMAP_ID, new Object[] { uniqueId, mindmapId }); } + + public List getMindmapNodeByUniqueIdSessionId(Long uniqueId, Long mindmapId, Long sessionId) { + return this.getHibernateTemplate().find(SQL_QUERY_FIND_NODE_BY_UNIQUE_ID_SESSION_ID, + new Object[] { uniqueId, mindmapId, sessionId }); + } public List getMindmapNodeByUniqueIdMindmapIdUserId(Long uniqueId, Long mindmapId, Long userId) { return this.getHibernateTemplate().find(SQL_QUERY_FIND_NODE_BY_UNIQUE_MINDMAP_ID_AND_USER_ID, new Object[] { uniqueId, mindmapId, userId }); } - - public Long getLastUniqueIdByMindmapIdUserId(Long mindmapId, Long userId) { - List list = this.getHibernateTemplate().find(SQL_QUERY_FIND_UNIQUE_ID_BY_MINDMAP_ID_AND_USER_ID, - new Object[] { mindmapId, userId }); + + // Node Unique ID + public Long getNodeLastUniqueIdByMindmapUidSessionId(Long mindmapUid, Long sessionId) { + List list = this.getHibernateTemplate().find(SQL_QUERY_FIND_NODE_LAST_UNIQUEID_BY_MINDMAPUID_SESSIONID, + new Object[] { mindmapUid, sessionId }); if (list != null && list.size() > 0) return ((Number) list.get(0)).longValue(); else return null; } - - public Long getLastUniqueIdByMindmapId(Long mindmapId) { - List list = this.getHibernateTemplate().find(SQL_QUERY_FIND_UNIQUE_ID_BY_MINDMAP_ID, mindmapId); - if (list != null && list.size() > 0) - return ((Number) list.get(0)).longValue(); - else - return null; - } /** Outputs */ public int getNumNodesByUserAndSession(Long userId, Long sessionId) { - List list = this.getHibernateTemplate().find(SQL_QUERY_NODES_NUMBER_BY_USER_SESSION, new Object[] { userId }); + List list = this.getHibernateTemplate().find(SQL_QUERY_FIND_NODES_NUMBER_BY_USERUID_SESSIONID, + new Object[] { userId }); if (list != null && list.size() > 0) return ((Number) list.get(0)).intValue(); else Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/hibernate/MindmapRequestDAO.java =================================================================== diff -u -r74f1da43432cc3cdefe3db657852ec79723ae3e7 -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/hibernate/MindmapRequestDAO.java (.../MindmapRequestDAO.java) (revision 74f1da43432cc3cdefe3db657852ec79723ae3e7) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/hibernate/MindmapRequestDAO.java (.../MindmapRequestDAO.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -36,23 +36,23 @@ public class MindmapRequestDAO extends BaseDAO implements IMindmapRequestDAO { private static final String SQL_QUERY_FIND_REQUESTS_AFTER_GLOBAL_ID = " from " + MindmapRequest.class.getName() + " mr where mr.globalId > ? and " + - " mr.mindmap.uid = ? and mr.user.uid <> ? order by mr.globalId "; + " mr.mindmap.uid = ? and mr.user.uid <> ? and mr.user.mindmapSession.sessionId = ? order by mr.globalId "; private static final String SQL_QUERY_FIND_REQUEST_BY_UNIQUE_ID = " from " + MindmapRequest.class.getName() + " mr where mr.uniqueId = ? and mr.user.uid = ? and " + " mr.mindmap.uid = ? and mr.globalId > ? "; private static final String SQL_QUERY_FIND_LAST_GLOBAL_ID_BY_MINDMAP = - " select mr.globalId from " + MindmapRequest.class.getName() + " mr where mr.mindmap.uid = ? " + - " order by mr.globalId desc limit 1 "; + " select mr.globalId from " + MindmapRequest.class.getName() + " mr where mr.mindmap.uid = ? and " + + " mr.user.mindmapSession.sessionId = ? order by mr.globalId desc limit 1 "; public void saveOrUpdate(MindmapRequest mindmapRequest) { this.getHibernateTemplate().saveOrUpdate(mindmapRequest); } - public List getLastRequestsAfterGlobalId(Long globalId, Long mindmapId, Long userId) { + public List getLastRequestsAfterGlobalId(Long globalId, Long mindmapId, Long userId, Long sessionId) { return this.getHibernateTemplate().find(SQL_QUERY_FIND_REQUESTS_AFTER_GLOBAL_ID, - new Object[]{globalId, mindmapId, userId}); + new Object[]{globalId, mindmapId, userId, sessionId}); } public MindmapRequest getRequestByUniqueId(Long uniqueId, Long userId, Long mindmapId, Long globalId) { @@ -64,8 +64,9 @@ return null; } - public Long getLastGlobalIdByMindmapId(Long mindmapId) { - List list = this.getHibernateTemplate().find(SQL_QUERY_FIND_LAST_GLOBAL_ID_BY_MINDMAP, mindmapId); + public Long getLastGlobalIdByMindmapId(Long mindmapId, Long sessionId) { + List list = this.getHibernateTemplate().find(SQL_QUERY_FIND_LAST_GLOBAL_ID_BY_MINDMAP, + new Object[]{mindmapId, sessionId}); if (list != null && list.size() > 0) return ((Number) list.get(0)).longValue(); else Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/hibernate/MindmapSessionDAO.java =================================================================== diff -u -r4dac3505ba7605adf1bc770010861260e2b91c1b -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/hibernate/MindmapSessionDAO.java (.../MindmapSessionDAO.java) (revision 4dac3505ba7605adf1bc770010861260e2b91c1b) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dao/hibernate/MindmapSessionDAO.java (.../MindmapSessionDAO.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -35,39 +35,30 @@ */ public class MindmapSessionDAO extends BaseDAO implements IMindmapSessionDAO { - public static final String SQL_QUERY_FIND_BY_SESSION_ID = "from " - + MindmapSession.class.getName() + " where session_id = ?"; + public static final String SQL_QUERY_FIND_BY_SESSION_ID = "from " + MindmapSession.class.getName() + + " where session_id = ?"; - public static final String SQL_QUERY_FIND_BY_MINDMAP_ID = "from " - + MindmapSession.class.getName() + " ms where ms.mindmap.uid = ?"; - - public void saveOrUpdate(MindmapSession session) { - this.getHibernateTemplate().saveOrUpdate(session); - this.getHibernateTemplate().flush(); - } + public static final String SQL_QUERY_FIND_BY_MINDMAP_ID = "from " + MindmapSession.class.getName() + + " ms where ms.mindmap.uid = ?"; - public MindmapSession getBySessionId(Long toolSessionId) { - List list = this.getHibernateTemplate().find( - SQL_QUERY_FIND_BY_SESSION_ID, toolSessionId); - if (list == null || list.isEmpty()) - return null; - return (MindmapSession) list.get(0); - } + public void saveOrUpdate(MindmapSession session) { + this.getHibernateTemplate().saveOrUpdate(session); + this.getHibernateTemplate().flush(); + } - public void deleteBySessionID(Long toolSessionID) { - MindmapSession session = getBySessionId(toolSessionID); - if(session != null){ - this.getHibernateTemplate().delete(session); - this.getHibernateTemplate().flush(); - } + public MindmapSession getBySessionId(Long toolSessionId) { + List list = this.getHibernateTemplate().find(SQL_QUERY_FIND_BY_SESSION_ID, toolSessionId); + if (list == null || list.isEmpty()) + return null; + return (MindmapSession) list.get(0); + } + + public void deleteBySessionID(Long toolSessionID) { + MindmapSession session = getBySessionId(toolSessionID); + if (session != null) { + this.getHibernateTemplate().delete(session); + this.getHibernateTemplate().flush(); } - - public MindmapSession getSessionByMindmapId(Long mindmapId) { - List list = this.getHibernateTemplate().find(SQL_QUERY_FIND_BY_MINDMAP_ID, mindmapId); - if (list == null || list.isEmpty()) - return null; - - return (MindmapSession) list.get(0); - } - + } + } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/model/MindmapNode.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/model/MindmapNode.java (.../MindmapNode.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/model/MindmapNode.java (.../MindmapNode.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -32,13 +32,14 @@ */ public class MindmapNode implements Cloneable { - //private static Logger log = Logger.getLogger(MindmapNode.class); + private static Logger log = Logger.getLogger(MindmapNode.class); private Long nodeId; private Long uniqueId; private MindmapNode parent; private String text; private String color; + private MindmapSession session; private MindmapUser user; private Mindmap mindmap; @@ -132,8 +133,23 @@ public void setColor(String color) { this.color = color; } + + /** + * @return Returns the sessionid of the session in Mindmap. + * @hibernate.many-to-one column="session_id" cascade="all" + */ + public MindmapSession getSession() { + return session; + } /** + * @param session the session to set + */ + public void setSession(MindmapSession session) { + this.session = session; + } + + /** * @return Returns the userid of the user who created the Mindmap. * @hibernate.many-to-one column="user_id" cascade="all" */ Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/IMindmapService.java =================================================================== diff -u -r4dac3505ba7605adf1bc770010861260e2b91c1b -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/IMindmapService.java (.../IMindmapService.java) (revision 4dac3505ba7605adf1bc770010861260e2b91c1b) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/IMindmapService.java (.../IMindmapService.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -42,187 +42,102 @@ * Defines the services available to the web layer from the Mindmap Service */ public interface IMindmapService { - /** - * Makes a copy of the default content and assigns it a newContentID - * @param newContentID - * @return - */ + public Mindmap copyDefaultContent(Long newContentID); - /** - * Returns an instance of the Mindmap tools default content. - * @return - */ public Mindmap getDefaultContent(); - /** - * @param toolSignature - * @return - */ public Long getDefaultContentIdBySignature(String toolSignature); - /** - * @param toolContentID - * @return - */ public Mindmap getMindmapByContentId(Long toolContentID); - /** - * @param Uid - * @return - */ public Mindmap getMindmapByUid(Long Uid); - - /** - * @param toolContentId - * @param file - * @param type - * @return - */ + public MindmapAttachment uploadFileToContent(Long toolContentId, FormFile file, String type); - /** - * @param uuid - * @param versionID - */ public void deleteFromRepository(Long uuid, Long versionID) throws MindmapException; - /** - * @param contentID - * @param uuid - * @param versionID - * @param type - */ public void deleteInstructionFile(Long contentID, Long uuid, Long versionID, String type); - /** - * @param mindmap - */ public void saveOrUpdateMindmap(Mindmap mindmap); - /** - * @param toolSessionId - * @return - */ public MindmapSession getSessionBySessionId(Long toolSessionId); - /** - * @param mindmapSession - */ public void saveOrUpdateMindmapSession(MindmapSession mindmapSession); - /** - * - * @param userId - * @param toolSessionId - * @return - */ public MindmapUser getUserByUserIdAndSessionId(Long userId, Long toolSessionId); - /** - * - * @param uid - * @return - */ public MindmapUser getUserByUID(Long uid); - /** - * - * @param mindmapUser - */ public void saveOrUpdateMindmapUser(MindmapUser mindmapUser); - /** - * - * @param user - * @param mindmapSession - * @return - */ public MindmapUser createMindmapUser(UserDTO user, MindmapSession mindmapSession); - /** - * - * @param id - * @param idType - * @param signature - * @param userID - * @param title - * @param entry - * @return - */ Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry); - /** - * - * @param uid - * @return - */ NotebookEntry getEntry(Long uid); - /** - * - * @param uid - * @param title - * @param entry - */ void updateEntry(Long uid, String entry); - + public void updateEntry(NotebookEntry notebookEntry); - + boolean isGroupedActivity(long toolContentID); - + public void setMindmapMessageService(MessageService mindmapMessageService); public MessageService getMindmapMessageService(); - - /** Outputs */ - public int getNumNodes(Long learnerId, Long toolSessionId); - + public String getLanguageXML(); - - public void deleteNodeByUniqueMindmapUser(Long uniqueId, Long mindmapId, Long userId); - + + public void deleteNodeByUniqueMindmapUser(Long uniqueId, Long mindmapId, Long userId, Long sessionId); + public void deleteNodes(String nodesToDeleteCondition); - + public String getNodesToDeleteCondition(); - + public void setNodesToDeleteCondition(String nodesToDeleteCondition); - + public void saveOrUpdateMindmapNode(MindmapNode mindmapNode); - + public List getAuthorRootNodeByMindmapId(Long mindmapId); + + public List getAuthorRootNodeBySessionId(Long sessionId); - public List getAuthorRootNodeByMindmapIdMulti(Long mindmapId); - + public List getAuthorRootNodeByMindmapSession(Long mindmapId, Long toolSessionId); + public List getRootNodeByMindmapIdAndUserId(Long mindmapId, Long userId); - - public List getUserRootNodeByUserId(Long userId); - + + public List getRootNodeByMindmapIdAndSessionId(Long mindmapId, Long sessionId); + public List getMindmapNodeByParentId(Long parentId, Long mindmapId); + public List getMindmapNodeByParentIdMindmapIdSessionId(Long parentId, Long mindmapId, Long sessionId); + public List getMindmapNodeByUniqueId(Long uniqueId, Long mindmapId); - + + public List getMindmapNodeByUniqueIdSessionId(Long uniqueId, Long mindmapId, Long sessionId); + public List getMindmapNodeByUniqueIdMindmapIdUserId(Long uniqueId, Long mindmapId, Long userId); - - public MindmapNode saveMindmapNode(MindmapNode currentMindmapNode, MindmapNode parentMindmapNode, Long uniqueId, - String text, String color, MindmapUser mindmapUser, Mindmap mindmap); - - public NodeModel getMindmapXMLFromDatabase(Long rootNodeId, Long mindmapId, NodeModel rootNodeModel, MindmapUser mindmapUser); - - public void getChildMindmapNodes(List branches, MindmapNode rootMindmapNode, MindmapUser mindmapUser, - Mindmap mindmap); - + + public MindmapNode saveMindmapNode(MindmapNode currentMindmapNode, MindmapNode parentMindmapNode, Long uniqueId, + String text, String color, MindmapUser mindmapUser, Mindmap mindmap, MindmapSession session); + + public NodeModel getMindmapXMLFromDatabase(Long rootNodeId, Long mindmapId, NodeModel rootNodeModel, + MindmapUser mindmapUser); + + public void getChildMindmapNodes(List branches, MindmapNode rootMindmapNode, MindmapUser mindmapUser, + Mindmap mindmap, MindmapSession mindmapSession); + public void saveOrUpdateMindmapRequest(MindmapRequest mindmapRequest); - - public Long getLastUniqueIdByMindmapIdUserId(Long mindmapId, Long userId); - - public Long getLastUniqueIdByMindmapId(Long mindmapId); - - public List getLastRequestsAfterGlobalId(Long globalId, Long mindmapId, Long userId); - + + public Long getNodeLastUniqueIdByMindmapUidSessionId(Long mindmapUid, Long sessionId); + + public List getLastRequestsAfterGlobalId(Long globalId, Long mindmapId, Long userId, Long sessionId); + public MindmapRequest getRequestByUniqueId(Long uniqueId, Long userId, Long mindmapId, Long globalId); + + public Long getLastGlobalIdByMindmapId(Long mindmapId, Long sessionId); - public Long getLastGlobalIdByMindmapId(Long mindmapId); - - public MindmapSession getSessionByMindmapId(Long mindmapId); + // Outputs + public int getNumNodes(Long learnerId, Long toolSessionId); } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapOutputFactory.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapOutputFactory.java (.../MindmapOutputFactory.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapOutputFactory.java (.../MindmapOutputFactory.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -39,7 +39,7 @@ public class MindmapOutputFactory extends OutputFactory { /** The number of nodes the learner has created in one Mindmap activity. */ - protected final static String OUTPUT_NAME_LEARNER_NUM_NODES = "output.learner.number.of.nodes"; + protected final static String OUTPUT_NAME_LEARNER_NUM_NODES = "number.of.nodes"; @Override public SortedMap getToolOutputDefinitions(Object toolContentObject) @@ -77,101 +77,4 @@ return new ToolOutput(OUTPUT_NAME_LEARNER_NUM_NODES, getI18NText(OUTPUT_NAME_LEARNER_NUM_NODES, true), new Long(num)); } - - - /* - - public SortedMap getToolOutput(List names, IMindmapService mindmapService, - Long toolSessionId, Long learnerId) { - - TreeMap outputs = new TreeMap(); - // cached tool output for all text search conditions - ToolOutput mindmapEntryOutput = null; - if (names == null) { - // output will be set for all the existing conditions - Mindmap mindmap = mindmapService.getSessionBySessionId(toolSessionId).getMindmap(); - - /* - Set conditions = mindmap.getConditions(); - for (MindmapCondition condition : conditions) { - String name = condition.getName(); - if (isTextSearchConditionName(name) && mindmapEntryOutput != null) { - outputs.put(name, mindmapEntryOutput); - } else { - ToolOutput output = getToolOutput(name, mindmapService, toolSessionId, learnerId); - if (output != null) { - outputs.put(name, output); - if (isTextSearchConditionName(name)) { - mindmapEntryOutput = output; - } - } - } - } - } else { - for (String name : names) { - if (isTextSearchConditionName(name) && mindmapEntryOutput != null) { - outputs.put(name, mindmapEntryOutput); - } else { - ToolOutput output = getToolOutput(name, mindmapService, toolSessionId, learnerId); - if (output != null) { - outputs.put(name, output); - if (isTextSearchConditionName(name)) { - mindmapEntryOutput = output; - } - } - } - }*/ - -/* } - - - return outputs; - - } - - public ToolOutput getToolOutput(String name, IMindmapService chatService, Long toolSessionId, Long learnerId) { - if (isTextSearchConditionName(name)) { - - // entry is loaded from DB - Mindmap mindmap = chatService.getSessionBySessionId(toolSessionId).getMindmap(); - - MindmapUser user = chatService.getUserByUserIdAndSessionId(learnerId, toolSessionId); - - // NotebookEntry entry = chatService.getEntry(user.getEntryUID()); - //String value = entry == null ? null : entry.getEntry(); - String value = ""; - - return new ToolOutput(name, getI18NText(MindmapConstants.TEXT_SEARCH_DEFINITION_NAME, true), value); - - } - return null; - } -/* - @Override - protected String[] splitConditionName(String conditionName) { - return super.splitConditionName(conditionName); - } - - protected String buildConditionName(String uniquePart) { - return super.buildConditionName(MindmapConstants.TEXT_SEARCH_DEFINITION_NAME, uniquePart); - } - - private boolean isTextSearchConditionName(String name) { - return name != null && name.startsWith(MindmapConstants.TEXT_SEARCH_DEFINITION_NAME); - } - - /* - * Creates a default condition so teachers know how to use complex conditions for this tool. - * - * @param mindmap - * content of the tool - * @return default mindmap condition - */ -/* protected MindmapCondition createDefaultComplexCondition(Mindmap mindmap) { - String name = buildConditionName(MindmapConstants.TEXT_SEARCH_DEFINITION_NAME, mindmap.getToolContentId() - .toString()); - // Default condition checks if the text contains word "LAMS" - return new MindmapCondition(null, null, 1, name, getI18NText( - MindmapConstants.TEXT_SEARCH_DEFAULT_CONDITION_DISPLAY_NAME_KEY, false), "LAMS", null, null, null); - }*/ } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java =================================================================== diff -u -r844ff3b43d22c544d3da7bf5aadf2ae33e48f9d4 -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java (.../MindmapService.java) (revision 844ff3b43d22c544d3da7bf5aadf2ae33e48f9d4) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java (.../MindmapService.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -96,9 +96,9 @@ ToolContentImport102Manager { static Logger logger = Logger.getLogger(MindmapService.class.getName()); - + boolean exp = false; - + private IMindmapDAO mindmapDAO = null; private IMindmapSessionDAO mindmapSessionDAO = null; private IMindmapUserDAO mindmapUserDAO = null; @@ -115,12 +115,12 @@ private MindmapOutputFactory mindmapOutputFactory; private String nodesToDeleteCondition = null; // string to accumulate nodes to delete private MessageService mindmapMessageService; - + public MindmapService() { super(); } - /* Methods from ToolSessionManager */ + /* Methods from ToolSessionManager */ public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { if (MindmapService.logger.isDebugEnabled()) { MindmapService.logger.debug("entering method createToolSession:" + " toolSessionId = " + toolSessionId @@ -176,7 +176,7 @@ public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { return getMindmapOutputFactory().getToolOutput(name, this, toolSessionId, learnerId); } - + /** * Get number of nodes created by particular user * @@ -186,14 +186,14 @@ */ public int getNumNodes(Long learnerId, Long toolSessionId) { MindmapUser mindmapUser = getUserByUserIdAndSessionId(learnerId, toolSessionId); - //MindmapSession mindmapSession = getSessionBySessionId(toolSessionId); + // MindmapSession mindmapSession = getSessionBySessionId(toolSessionId); return mindmapNodeDAO.getNumNodesByUserAndSession(mindmapUser.getUid(), toolSessionId); } - - - /* Methods from ToolContentManager */ + /* + * Methods from ToolContentManager Called on adding lesson. + */ public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { if (MindmapService.logger.isDebugEnabled()) { @@ -214,49 +214,49 @@ // create the fromContent using the default tool content fromContent = getDefaultContent(); } + Mindmap toContent = Mindmap.newInstance(fromContent, toContentId, mindmapToolContentHandler); mindmapDAO.saveOrUpdate(toContent); /* Copying Mindmap Nodes */ - + // creating default nodes for current mindmap String rootNodeName = getMindmapMessageService().getMessage("node.root.defaultName"); String childNodeName1 = getMindmapMessageService().getMessage("node.child1.defaultName"); String childNodeName2 = getMindmapMessageService().getMessage("node.child2.defaultName"); - + List rootNode = getAuthorRootNodeByMindmapId(fromContent.getUid()); - + MindmapNode rootMindmapNode = null; - if (rootNode == null || rootNode.size() == 0) - { + if (rootNode == null || rootNode.size() == 0) { // Create default content - rootMindmapNode = saveMindmapNode(null, null, 1l, rootNodeName, "ffffff", null, toContent); + rootMindmapNode = saveMindmapNode(null, null, 1l, rootNodeName, "ffffff", null, fromContent, null); saveOrUpdateMindmapNode(rootMindmapNode); - saveMindmapNode(null, rootMindmapNode, 2l, childNodeName1, "ffffff", null, toContent); - saveMindmapNode(null, rootMindmapNode, 3l, childNodeName2, "ffffff", null, toContent); - } - else { + saveMindmapNode(null, rootMindmapNode, 2l, childNodeName1, "ffffff", null, fromContent, null); + saveMindmapNode(null, rootMindmapNode, 3l, childNodeName2, "ffffff", null, fromContent, null); + } else { rootMindmapNode = (MindmapNode) getAuthorRootNodeByMindmapId(fromContent.getUid()).get(0); } - - //MindmapNode fromMindmapNode = (MindmapNode) getAuthorRootNodeByMindmapId(fromContent.getUid()).get(0); + + // MindmapNode fromMindmapNode = (MindmapNode) getAuthorRootNodeByMindmapId(fromContent.getUid()).get(0); cloneMindmapNodesForRuntime(rootMindmapNode, null, fromContent, toContent); + } - + /** - * Makes a runtime copy of Mindmap Nodes for single-user mode. - * Makes a shared copy of Mindmap Nodes for multi-user mode. + * Makes a runtime copy of Mindmap Nodes for single-user mode. Makes a shared copy of Mindmap Nodes for multi-user + * mode. * * @param fromMindmapNode * @param toMindmapNode * @param fromContent * @param toContent - * @return + * @return */ public void cloneMindmapNodesForRuntime(MindmapNode fromMindmapNode, MindmapNode toMindmapNode, Mindmap fromContent, Mindmap toContent) { toMindmapNode = saveMindmapNode(null, toMindmapNode, fromMindmapNode.getUniqueId(), fromMindmapNode.getText(), - fromMindmapNode.getColor(), fromMindmapNode.getUser(), toContent); + fromMindmapNode.getColor(), fromMindmapNode.getUser(), toContent, null); List childMindmapNodes = getMindmapNodeByParentId(fromMindmapNode.getNodeId(), fromContent.getUid()); @@ -267,7 +267,7 @@ } } } - + /** * Saves Mindmap Node to database. * @@ -281,21 +281,22 @@ * @return null */ public MindmapNode saveMindmapNode(MindmapNode currentMindmapNode, MindmapNode parentMindmapNode, Long uniqueId, - String text, String color, MindmapUser mindmapUser, Mindmap mindmap) { + String text, String color, MindmapUser mindmapUser, Mindmap mindmap, MindmapSession session) { if (currentMindmapNode == null) { currentMindmapNode = new MindmapNode(); } currentMindmapNode.setParent(parentMindmapNode); currentMindmapNode.setUniqueId(uniqueId); currentMindmapNode.setText(text); currentMindmapNode.setColor(color); + currentMindmapNode.setSession(session); currentMindmapNode.setUser(mindmapUser); currentMindmapNode.setMindmap(mindmap); saveOrUpdateMindmapNode(currentMindmapNode); return currentMindmapNode; } - + /** * Makes a runtime copy of Mindmap Nodes for single-user mode. * @@ -343,7 +344,7 @@ } public void getChildMindmapNodes(List branches, MindmapNode rootMindmapNode, MindmapUser mindmapUser, - Mindmap mindmap) { + Mindmap mindmap, MindmapSession mindmapSession) { for (Iterator iterator = branches.iterator(); iterator.hasNext();) { NodeModel nodeModel = (NodeModel) iterator.next(); NodeConceptModel nodeConceptModel = nodeModel.getConcept(); @@ -361,30 +362,30 @@ } this.nodesToDeleteCondition += " and uniqueId <> " + nodeConceptModel.getId(); currentMindmapNode = saveMindmapNode(currentMindmapNode, rootMindmapNode, nodeConceptModel.getId(), - nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap); + nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap, mindmapSession); // if there are child nodes, redo for every child if (nodeModel.getBranch() != null) - getChildMindmapNodes(nodeModel.getBranch(), currentMindmapNode, mindmapUser, mindmap); + getChildMindmapNodes(nodeModel.getBranch(), currentMindmapNode, mindmapUser, mindmap, mindmapSession); } } - + public String getLanguageXML() { - ArrayList languageCollection = new ArrayList(); + ArrayList languageCollection = new ArrayList(); languageCollection.add(new String("local.title")); languageCollection.add(new String("local.delete_question")); languageCollection.add(new String("local.yes")); languageCollection.add(new String("local.no")); languageCollection.add(new String("local.node_creator")); - + String languageOutput = ""; - - for(int i=0; i < languageCollection.size(); i++) { - languageOutput += "" + - mindmapMessageService.getMessage(languageCollection.get(i)) + ""; + + for (int i = 0; i < languageCollection.size(); i++) { + languageOutput += "" + + mindmapMessageService.getMessage(languageCollection.get(i)) + ""; } - + languageOutput += ""; - + return languageOutput; } @@ -406,15 +407,18 @@ mindmapDAO.saveOrUpdate(mindmap); } - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, + ToolException { // TODO Auto-generated method stub } /** * Export the XML fragment for the tool's content, along with any files needed for the content. - * @throws DataMissingException if no tool content matches the toolSessionId - * @throws ToolException if any other error occurs + * + * @throws DataMissingException + * if no tool content matches the toolSessionId + * @throws ToolException + * if any other error occurs */ public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { Mindmap mindmap = mindmapDAO.getByContentId(toolContentId); @@ -424,7 +428,7 @@ if (mindmap == null) { throw new DataMissingException("Unable to find default content for the mindmap tool"); } - + // generating Mindmap XML to export String mindmapContent = null; List mindmapNodeList = getAuthorRootNodeByMindmapId(mindmap.getUid()); @@ -435,25 +439,25 @@ NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), rootMindmapNode .getText(), rootMindmapNode.getColor(), rootMindmapUser, 1)); - NodeModel currentNodeModel = getMindmapXMLFromDatabase(rootMindmapNode.getNodeId(), - mindmap.getUid(), rootNodeModel, null); + NodeModel currentNodeModel = getMindmapXMLFromDatabase(rootMindmapNode.getNodeId(), mindmap.getUid(), + rootNodeModel, null); XStream xstream = new XStream(); xstream.alias("branch", NodeModel.class); mindmapContent = xstream.toXML(currentNodeModel); } - + // set ResourceToolContentHandler as null to avoid copy file node in repository again. mindmap = Mindmap.newInstance(mindmap, toolContentId, null); - + mindmap.setMindmapExportContent(mindmapContent); mindmap.setToolContentHandler(null); mindmap.setMindmapSessions(null); Set atts = mindmap.getMindmapAttachments(); for (MindmapAttachment att : atts) { att.setMindmap(null); } - + try { exportContentService.registerFileClassForExport(MindmapAttachment.class.getName(), "fileUuid", "fileVersionId"); @@ -465,7 +469,9 @@ /** * Import the XML fragment for the tool's content, along with any files needed for the content. - * @throws ToolException if any other error occurs + * + * @throws ToolException + * if any other error occurs */ public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, String toVersion) throws ToolException { @@ -481,7 +487,7 @@ } Mindmap mindmap = (Mindmap) toolPOJO; - + String mindmapContent = mindmap.getMindmapExportContent(); MindmapUser mindmapUser = null; @@ -490,22 +496,22 @@ NodeModel rootNodeModel = (NodeModel) xstream.fromXML(mindmapContent); NodeConceptModel nodeConceptModel = rootNodeModel.getConcept(); List branches = rootNodeModel.getBranch(); - + MindmapNode rootMindmapNode = null; - rootMindmapNode = saveMindmapNode(rootMindmapNode, null, nodeConceptModel.getId(), - nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap); - + rootMindmapNode = saveMindmapNode(rootMindmapNode, null, nodeConceptModel.getId(), nodeConceptModel + .getText(), nodeConceptModel.getColor(), mindmapUser, mindmap, null); + // saving child Nodes into database if (branches != null) { - getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap); + getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap, null); } // reset it to new toolContentId mindmap.setToolContentId(toolContentId); - //mindmap.setCreateBy(new Long(newUserUid.longValue())); - + // mindmap.setCreateBy(new Long(newUserUid.longValue())); + mindmapDAO.saveOrUpdate(mindmap); - + } catch (ImportToolContentException e) { throw new ToolException(e); } @@ -527,7 +533,7 @@ return getMindmapOutputFactory().getToolOutputDefinitions(mindmap); } - /* IMindmapService Methods */ + /* IMindmapService Methods */ public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) { return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); @@ -540,11 +546,11 @@ public void updateEntry(Long uid, String entry) { coreNotebookService.updateEntry(uid, "", entry); } - + public void updateEntry(NotebookEntry notebookEntry) { coreNotebookService.updateEntry(notebookEntry); } - + public Long getDefaultContentIdBySignature(String toolSignature) { Long toolContentId = null; toolContentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); @@ -626,8 +632,8 @@ } NodeKey nodeKey = processFile(file, type); - MindmapAttachment attachment = new MindmapAttachment(nodeKey.getVersion(), type, file.getFileName(), - nodeKey.getUuid(), new Date()); + MindmapAttachment attachment = new MindmapAttachment(nodeKey.getVersion(), type, file.getFileName(), nodeKey + .getUuid(), new Date()); return attachment; } @@ -636,7 +642,8 @@ try { repositoryService.deleteVersion(ticket, uuid, versionID); } catch (Exception e) { - throw new MindmapException("Exception occured while deleting files from" + " the repository " + e.getMessage()); + throw new MindmapException("Exception occured while deleting files from" + " the repository " + + e.getMessage()); } } @@ -734,15 +741,16 @@ mindmap.setCreateBy(new Long(user.getUserID().longValue())); mindmap.setCreateDate(now); mindmap.setDefineLater(Boolean.FALSE); - mindmap.setInstructions(WebUtil.convertNewlines((String) importValues.get(ToolContentImport102Manager.CONTENT_BODY))); + mindmap.setInstructions(WebUtil.convertNewlines((String) importValues + .get(ToolContentImport102Manager.CONTENT_BODY))); mindmap.setLockOnFinished(Boolean.TRUE); mindmap.setOfflineInstructions(null); mindmap.setOnlineInstructions(null); mindmap.setRunOffline(Boolean.FALSE); mindmap.setTitle((String) importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); mindmap.setToolContentId(toolContentId); mindmap.setUpdateDate(now); - //mindmap.setAllowRichEditor(Boolean.FALSE); + // mindmap.setAllowRichEditor(Boolean.FALSE); // leave as empty, no need to set them to anything. // setMindmapAttachments(Set mindmapAttachments); // setMindmapSessions(Set mindmapSessions); @@ -765,7 +773,7 @@ } // ========================================================================================= - /* Used by Spring to "inject" the linked objects */ + /* Used by Spring to "inject" the linked objects */ public IRepositoryService getRepositoryService() { return repositoryService; @@ -875,32 +883,44 @@ return mindmapNodeDAO.getAuthorRootNodeByMindmapId(mindmapId); } - public List getAuthorRootNodeByMindmapIdMulti(Long mindmapId) { - return mindmapNodeDAO.getAuthorRootNodeByMindmapIdMulti(mindmapId); + public List getAuthorRootNodeBySessionId(Long sessionId) { + return mindmapNodeDAO.getAuthorRootNodeBySessionId(sessionId); } + public List getAuthorRootNodeByMindmapSession(Long mindmapId, Long toolSessionId) { + return mindmapNodeDAO.getAuthorRootNodeByMindmapSession(mindmapId, toolSessionId); + } + public List getRootNodeByMindmapIdAndUserId(Long mindmapId, Long userId) { return mindmapNodeDAO.getRootNodeByMindmapIdAndUserId(mindmapId, userId); } - public List getUserRootNodeByUserId(Long userId) { - return mindmapNodeDAO.getUserRootNodeByUserId(userId); + public List getRootNodeByMindmapIdAndSessionId(Long mindmapId, Long sessionId) { + return mindmapNodeDAO.getRootNodeByMindmapIdAndUserId(mindmapId, sessionId); } public List getMindmapNodeByParentId(Long parentId, Long mindmapId) { return mindmapNodeDAO.getMindmapNodeByParentId(parentId, mindmapId); } - + + public List getMindmapNodeByParentIdMindmapIdSessionId(Long parentId, Long mindmapId, Long sessionId) { + return mindmapNodeDAO.getMindmapNodeByParentIdMindmapIdSessionId(parentId, mindmapId, sessionId); + } + public List getMindmapNodeByUniqueId(Long uniqueId, Long mindmapId) { return mindmapNodeDAO.getMindmapNodeByUniqueId(uniqueId, mindmapId); } + public List getMindmapNodeByUniqueIdSessionId(Long uniqueId, Long mindmapId, Long sessionId) { + return mindmapNodeDAO.getMindmapNodeByUniqueIdSessionId(uniqueId, mindmapId, sessionId); + } + public List getMindmapNodeByUniqueIdMindmapIdUserId(Long uniqueId, Long mindmapId, Long userId) { return mindmapNodeDAO.getMindmapNodeByUniqueIdMindmapIdUserId(uniqueId, mindmapId, userId); } - public void deleteNodeByUniqueMindmapUser(Long uniqueId, Long mindmapId, Long userId) { - mindmapNodeDAO.deleteNodeByUniqueMindmapUser(uniqueId, mindmapId, userId); + public void deleteNodeByUniqueMindmapUser(Long uniqueId, Long mindmapId, Long userId, Long sessionId) { + mindmapNodeDAO.deleteNodeByUniqueMindmapUser(uniqueId, mindmapId, userId, sessionId); } public void deleteNodes(String nodesToDeleteCondition) { @@ -915,66 +935,35 @@ this.nodesToDeleteCondition = nodesToDeleteCondition; } - public Long getLastUniqueIdByMindmapIdUserId(Long mindmapId, Long userId) { - return this.mindmapNodeDAO.getLastUniqueIdByMindmapIdUserId(mindmapId, userId); - } - - /** - * @param mindmapRequestDAO - * the mindmapRequestDAO to set - */ public void setMindmapRequestDAO(IMindmapRequestDAO mindmapRequestDAO) { this.mindmapRequestDAO = mindmapRequestDAO; } - /** - * @return mindmapRequestDAO - */ public IMindmapRequestDAO getMindmapRequestDAO() { return mindmapRequestDAO; } - public List getLastRequestsAfterGlobalId(Long globalId, Long mindmapId, Long userId) { - return mindmapRequestDAO.getLastRequestsAfterGlobalId(globalId, mindmapId, userId); + public List getLastRequestsAfterGlobalId(Long globalId, Long mindmapId, Long userId, Long sessionId) { + return mindmapRequestDAO.getLastRequestsAfterGlobalId(globalId, mindmapId, userId, sessionId); } public MindmapRequest getRequestByUniqueId(Long uniqueId, Long userId, Long mindmapId, Long globalId) { return mindmapRequestDAO.getRequestByUniqueId(uniqueId, userId, mindmapId, globalId); } - - /** - * @param mindmapMessageService - * @return mindmapRequestDAO.getLastGlobalIdByMindmapId(mindmapId) - */ - public Long getLastGlobalIdByMindmapId(Long mindmapId) { - return mindmapRequestDAO.getLastGlobalIdByMindmapId(mindmapId); + + public Long getLastGlobalIdByMindmapId(Long mindmapId, Long sessionId) { + return mindmapRequestDAO.getLastGlobalIdByMindmapId(mindmapId, sessionId); } - - /** - * @param mindmapMessageService - * @return mindmapNodeDAO.getLastUniqueIdByMindmapId(mindmapId) - */ - public Long getLastUniqueIdByMindmapId(Long mindmapId) { - return mindmapNodeDAO.getLastUniqueIdByMindmapId(mindmapId); + + public Long getNodeLastUniqueIdByMindmapUidSessionId(Long mindmapUid, Long sessionId) { + return mindmapNodeDAO.getNodeLastUniqueIdByMindmapUidSessionId(mindmapUid, sessionId); } - /** - * @param mindmapMessageService - * @return - */ public void setMindmapMessageService(MessageService mindmapMessageService) { this.mindmapMessageService = mindmapMessageService; } - /** - * @return mindmapMessageService - */ public MessageService getMindmapMessageService() { return mindmapMessageService; } - - public MindmapSession getSessionByMindmapId(Long mindmapId) - { - return mindmapSessionDAO.getSessionByMindmapId(mindmapId); - } } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/AuthoringAction.java =================================================================== diff -u -r4060c9d9376555e5c015b4d20656d121069f4f0d -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision 4060c9d9376555e5c015b4d20656d121069f4f0d) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -120,10 +120,11 @@ String childNodeName1 = mindmapService.getMindmapMessageService().getMessage("node.child1.defaultName"); String childNodeName2 = mindmapService.getMindmapMessageService().getMessage("node.child2.defaultName"); - MindmapNode rootMindmapNode = mindmapService.saveMindmapNode(null, null, 1l, rootNodeName, "ffffff", null, mindmap); + MindmapNode rootMindmapNode = + mindmapService.saveMindmapNode(null, null, 1l, rootNodeName, "ffffff", null, mindmap, null); mindmapService.saveOrUpdateMindmapNode(rootMindmapNode); - mindmapService.saveMindmapNode(null, rootMindmapNode, 2l, childNodeName1, "ffffff", null, mindmap); - mindmapService.saveMindmapNode(null, rootMindmapNode, 3l, childNodeName2, "ffffff", null, mindmap); + mindmapService.saveMindmapNode(null, rootMindmapNode, 2l, childNodeName1, "ffffff", null, mindmap, null); + mindmapService.saveMindmapNode(null, rootMindmapNode, 3l, childNodeName2, "ffffff", null, mindmap, null); } if (mode != null && mode.isTeacher()) { @@ -300,15 +301,15 @@ // saving root Node into database MindmapNode rootMindmapNode = (MindmapNode) mindmapService.getAuthorRootNodeByMindmapId(mindmap.getUid()).get(0); rootMindmapNode = mindmapService.saveMindmapNode(rootMindmapNode, null, nodeConceptModel.getId(), - nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap); + nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap, null); // string to accumulate deleted nodes for query String nodesToDeleteCondition = " where uniqueId <> " + rootMindmapNode.getUniqueId(); // saving child Nodes into database if (branches != null) { mindmapService.setNodesToDeleteCondition(""); - mindmapService.getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap); + mindmapService.getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap, null); } nodesToDeleteCondition += mindmapService.getNodesToDeleteCondition() + " and mindmap_id = " + mindmap.getUid(); Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/LearningAction.java =================================================================== diff -u -r844ff3b43d22c544d3da7bf5aadf2ae33e48f9d4 -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/LearningAction.java (.../LearningAction.java) (revision 844ff3b43d22c544d3da7bf5aadf2ae33e48f9d4) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/LearningAction.java (.../LearningAction.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -165,7 +165,7 @@ // mindmapContentPath Parameter String mindmapContentPath = Configuration.get(ConfigurationKeys.SERVER_URL) + "tool/lamind10/learning.do?dispatch=setMindmapContent%26mindmapId=" + mindmap.getUid() + "%26userId=" - + mindmapUser.getUid(); + + mindmapUser.getUid() + "%26sessionId=" + mindmapSession.getSessionId(); request.setAttribute("mindmapContentPath", mindmapContentPath); // currentMindmapUser Parameter @@ -187,13 +187,13 @@ // pollServer Parameter String pollServerParam = Configuration.get(ConfigurationKeys.SERVER_URL) + "tool/lamind10/learning.do?dispatch=pollServerAction%26mindmapId=" + mindmap.getUid() + "%26userId=" - + mindmapUser.getUid(); + + mindmapUser.getUid() + "%26sessionId=" + mindmapSession.getSessionId(); request.setAttribute("pollServerParam", pollServerParam); // notifyServer Parameter String notifyServerParam = Configuration.get(ConfigurationKeys.SERVER_URL) + "tool/lamind10/learning.do?dispatch=notifyServerAction%26mindmapId=" + mindmap.getUid() - + "%26userId=" + mindmapUser.getUid(); + + "%26userId=" + mindmapUser.getUid() + "%26sessionId=" + mindmapSession.getSessionId(); request.setAttribute("notifyServerParam", notifyServerParam); String localizationPath = Configuration.get(ConfigurationKeys.SERVER_URL) @@ -210,20 +210,31 @@ request.setAttribute("dispatch", "saveLastMindmapChanges"); request.setAttribute("mindmapId", mindmap.getUid()); request.setAttribute("userId", mindmapUser.getUid()); + request.setAttribute("sessionId", toolSessionID); request.setAttribute("multiMode", mindmap.isMultiUserMode()); // if not multi-user mode if (!mindmap.isMultiUserMode()) { - // clonning Mindmap Nodes for current user + // clonning Mindmap Nodes for every new user List rootNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), mindmapUser.getUid()); if (rootNodeList == null || rootNodeList.size() == 0) { MindmapNode fromMindmapNode = (MindmapNode) mindmapService.getAuthorRootNodeByMindmapId( mindmap.getUid()).get(0); - cloneMindmapNodesForRuntime(fromMindmapNode, null, mindmap, mindmap, mindmapUser); + cloneMindmapNodesForRuntime(fromMindmapNode, null, mindmap, mindmap, mindmapUser, mindmapSession); } } else { + // clonning Mindmap Nodes for every new session + List rootNodeList = mindmapService.getAuthorRootNodeBySessionId(toolSessionID); + + if (rootNodeList == null || rootNodeList.size() == 0) { + MindmapNode fromMindmapNode = + (MindmapNode) mindmapService.getAuthorRootNodeByMindmapId(mindmap.getUid()).get(0); + cloneMindmapNodesForRuntime(fromMindmapNode, null, mindmap, mindmap, null, mindmapSession); + } + + // Using Learner in Monitor mode (for Teachers to participate in multimode) boolean isMonitor = WebUtil.readBooleanParam(request, "monitor", false); request.setAttribute("isMonitor", isMonitor); } @@ -241,17 +252,17 @@ * @param user */ public void cloneMindmapNodesForRuntime(MindmapNode fromMindmapNode, MindmapNode toMindmapNode, - Mindmap fromContent, Mindmap toContent, MindmapUser user) { + Mindmap fromContent, Mindmap toContent, MindmapUser user, MindmapSession session) { toMindmapNode = mindmapService.saveMindmapNode(null, toMindmapNode, fromMindmapNode.getUniqueId(), - fromMindmapNode.getText(), fromMindmapNode.getColor(), user, toContent); + fromMindmapNode.getText(), fromMindmapNode.getColor(), user, toContent, session); - List childMindmapNodes = mindmapService.getMindmapNodeByParentId(fromMindmapNode.getNodeId(), fromContent - .getUid()); + List childMindmapNodes = mindmapService.getMindmapNodeByParentIdMindmapIdSessionId(fromMindmapNode.getNodeId(), + fromContent.getUid(), session.getSessionId()); if (childMindmapNodes != null && childMindmapNodes.size() > 0) { for (Iterator iterator = childMindmapNodes.iterator(); iterator.hasNext();) { MindmapNode childMindmapNode = (MindmapNode) iterator.next(); - cloneMindmapNodesForRuntime(childMindmapNode, toMindmapNode, fromContent, toContent, user); + cloneMindmapNodesForRuntime(childMindmapNode, toMindmapNode, fromContent, toContent, user, session); } } } @@ -270,7 +281,10 @@ Long userId = WebUtil.readLongParam(request, "userId", false); Long mindmapId = WebUtil.readLongParam(request, "mindmapId", false); + Long toolSessionId = WebUtil.readLongParam(request, "sessionId", false); String requestAction = WebUtil.readStrParam(request, "actionXML", false); + + MindmapSession mindmapSession = mindmapService.getSessionBySessionId(toolSessionId); XStream xstream = new XStream(); xstream.alias("action", NotifyRequestModel.class); @@ -289,7 +303,8 @@ if (mindmapRequest == null) { // getting node to which changes will be applied MindmapNode mindmapNode = null; - List mindmapNodeList = mindmapService.getMindmapNodeByUniqueId(notifyRequestModel.getNodeID(), mindmapId); + List mindmapNodeList = + mindmapService.getMindmapNodeByUniqueIdSessionId(notifyRequestModel.getNodeID(), mindmapId, toolSessionId); if (mindmapNodeList != null && mindmapNodeList.size() > 0) { mindmapNode = (MindmapNode) mindmapNodeList.get(0); } else { @@ -301,13 +316,26 @@ if (requestType == 0) { // if node is created not by author or by other user... cannot delete if (mindmapNode.getUser() == mindmapService.getUserByUID(userId)) { - List childNodes = mindmapService.getMindmapNodeByParentId(notifyRequestModel.getNodeID(), mindmapId); - if (childNodes == null || childNodes.size() == 0) // check for Father + + List nodes = mindmapService.getMindmapNodeByUniqueIdSessionId(notifyRequestModel.getNodeID(), + mindmapId, toolSessionId); + + if (nodes != null && nodes.size() > 0) // check if node exists { - mindmapService.deleteNodeByUniqueMindmapUser(notifyRequestModel.getNodeID(), mindmapId, userId); - mindmapRequest = saveMindmapRequest(mindmapRequest, requestType, notifyRequestModel, userId, - mindmapId, null); - notifyResponse = generateNotifyResponse(1, mindmapRequest.getGlobalId(), null); + MindmapNode curNode = (MindmapNode) nodes.get(0); + List childNodes = mindmapService.getMindmapNodeByParentIdMindmapIdSessionId(curNode.getNodeId(), + mindmapId, toolSessionId); + + if (childNodes == null || childNodes.size() == 0) // check if node has any children + { + mindmapService.deleteNodeByUniqueMindmapUser(notifyRequestModel.getNodeID(), + mindmapId, userId, toolSessionId); + mindmapRequest = saveMindmapRequest(mindmapRequest, requestType, notifyRequestModel, userId, + mindmapId, null, toolSessionId); + notifyResponse = generateNotifyResponse(1, mindmapRequest.getGlobalId(), null); + } else { + notifyResponse = generateNotifyResponse(0, null, null); + } } else notifyResponse = generateNotifyResponse(0, null, null); } else { @@ -319,13 +347,15 @@ // no checking... users can create nodes everywhere NodeConceptModel nodeConceptModel = notifyRequestModel.getConcept(); - Long uniqueId = mindmapService.getLastUniqueIdByMindmapId(mindmapId) + 1; // node unique ID - + Long uniqueId = // node unique ID + mindmapService.getNodeLastUniqueIdByMindmapUidSessionId(mindmapId, toolSessionId) + 1; + mindmapService.saveMindmapNode(null, mindmapNode, uniqueId, nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapService.getUserByUID(userId), mindmapService - .getMindmapByUid(mindmapId)); + .getMindmapByUid(mindmapId), mindmapSession); + mindmapRequest = saveMindmapRequest(mindmapRequest, requestType, notifyRequestModel, userId, mindmapId, - uniqueId); + uniqueId, toolSessionId); notifyResponse = generateNotifyResponse(1, mindmapRequest.getGlobalId(), uniqueId); } // change color @@ -335,7 +365,7 @@ mindmapNode.setUser(mindmapService.getUserByUID(userId)); mindmapService.saveOrUpdateMindmapNode(mindmapNode); mindmapRequest = saveMindmapRequest(mindmapRequest, requestType, notifyRequestModel, userId, - mindmapId, null); + mindmapId, null, toolSessionId); notifyResponse = generateNotifyResponse(1, mindmapRequest.getGlobalId(), null); } else { notifyResponse = generateNotifyResponse(0, null, null); @@ -348,7 +378,7 @@ mindmapNode.setUser(mindmapService.getUserByUID(userId)); mindmapService.saveOrUpdateMindmapNode(mindmapNode); mindmapRequest = saveMindmapRequest(mindmapRequest, requestType, notifyRequestModel, userId, - mindmapId, null); + mindmapId, null, toolSessionId); notifyResponse = generateNotifyResponse(1, mindmapRequest.getGlobalId(), null); } else { notifyResponse = generateNotifyResponse(0, null, null); @@ -383,12 +413,12 @@ * @param nodeChildId */ private MindmapRequest saveMindmapRequest(MindmapRequest mindmapRequest, int requestType, - NotifyRequestModel notifyRequestModel, Long userId, Long mindmapId, Long nodeChildId) { + NotifyRequestModel notifyRequestModel, Long userId, Long mindmapId, Long nodeChildId, Long sessionId) { mindmapRequest = new MindmapRequest(); mindmapRequest.setType(requestType); mindmapRequest.setUniqueId(notifyRequestModel.getID()); // incrementing lastRequestId - mindmapRequest.setGlobalId(mindmapService.getLastGlobalIdByMindmapId(mindmapId) + 1); + mindmapRequest.setGlobalId(mindmapService.getLastGlobalIdByMindmapId(mindmapId, sessionId) + 1); mindmapRequest.setUser(mindmapService.getUserByUID(userId)); mindmapRequest.setMindmap(mindmapService.getMindmapByUid(mindmapId)); mindmapRequest.setNodeId(notifyRequestModel.getNodeID()); @@ -431,11 +461,12 @@ Long mindmapId = WebUtil.readLongParam(request, "mindmapId", false); Long userId = WebUtil.readLongParam(request, "userId", false); + Long toolSessionId = WebUtil.readLongParam(request, "sessionId", false); Long lastActionId = WebUtil.readLongParam(request, "lastActionID", false); PollResponseModel pollResponseModel = new PollResponseModel(); - List requestsList = mindmapService.getLastRequestsAfterGlobalId(lastActionId, mindmapId, userId); + List requestsList = mindmapService.getLastRequestsAfterGlobalId(lastActionId, mindmapId, userId, toolSessionId); for (Iterator iterator = requestsList.iterator(); iterator.hasNext();) { MindmapRequest mindmapRequest = (MindmapRequest) iterator.next(); int requestType = mindmapRequest.getType(); @@ -525,12 +556,13 @@ Long mindmapId = WebUtil.readLongParam(request, "mindmapId", false); Long userId = WebUtil.readLongParam(request, "userId", false); + Long toolSessionId = WebUtil.readLongParam(request, "sessionId", true); Mindmap mindmap = mindmapService.getMindmapByUid(mindmapId); MindmapUser mindmapUser = mindmapService.getUserByUID(userId); List mindmapNodeList = null; if (mindmap.isMultiUserMode()) // is multi-user - mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapIdMulti(mindmapId); + mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapSession(mindmapId, toolSessionId); else mindmapNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmapId, userId); @@ -545,10 +577,11 @@ + rootMindmapNode.getUser().getLastName(); int edit = 1; - if (rootMindmapNode.getUser() == mindmapUser) + if (rootMindmapNode.getUser() == mindmapUser) { edit = 1; - else + } else { edit = 0; + } NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), rootMindmapNode .getText(), rootMindmapNode.getColor(), mindmapUserName, edit)); @@ -561,7 +594,7 @@ String mindmapContent = xstream.toXML(currentNodeModel); // Saving lastActionID - Long lastActionId = mindmapService.getLastGlobalIdByMindmapId(mindmap.getUid()); + Long lastActionId = mindmapService.getLastGlobalIdByMindmapId(mindmap.getUid(), toolSessionId); //mindmap.setLastActionId(lastActionId); // adding lastActionId @@ -590,22 +623,25 @@ Long userId = WebUtil.readLongParam(request, "userId", false); Long toolContentId = WebUtil.readLongParam(request, "mindmapId", false); + Long toolSessionId = WebUtil.readLongParam(request, "sessionId", true); MindmapUser mindmapUser = mindmapService.getUserByUID(userId); Mindmap mindmap = mindmapService.getMindmapByUid(toolContentId); + MindmapSession mindmapSession = mindmapService.getSessionBySessionId(toolSessionId); // Saving Mindmap Nodes if (!mindmap.isMultiUserMode()) { // getting xml data from SWF String mindmapContent = WebUtil.readStrParam(request, "content", false); // learningForm.getMindmapContent(); - saveMindmapXML(mindmap, mindmapUser, mindmapContent); + saveMindmapXML(mindmap, mindmapUser, mindmapContent, mindmapSession); } return null; } - public void saveMindmapXML(Mindmap mindmap, MindmapUser mindmapUser, String mindmapContent) { + public void saveMindmapXML(Mindmap mindmap, MindmapUser mindmapUser, String mindmapContent, + MindmapSession mindmapSession) { // Saving Mindmap data to XML XStream xstream = new XStream(); xstream.alias("branch", NodeModel.class); @@ -617,15 +653,15 @@ MindmapNode rootMindmapNode = (MindmapNode) mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), mindmapUser.getUid()).get(0); rootMindmapNode = mindmapService.saveMindmapNode(rootMindmapNode, null, nodeConceptModel.getId(), - nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap); + nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap, mindmapSession); // string to accumulate deleted nodes for query String nodesToDeleteCondition = " where uniqueId <> " + rootMindmapNode.getUniqueId(); // saving child Nodes into database if (branches != null) { mindmapService.setNodesToDeleteCondition(""); - mindmapService.getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap); + mindmapService.getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap, mindmapSession); } nodesToDeleteCondition += mindmapService.getNodesToDeleteCondition() + " and mindmap_id = " + mindmap.getUid() @@ -693,9 +729,10 @@ Long userId = WebUtil.readLongParam(request, "userId", false); Long toolContentId = WebUtil.readLongParam(request, "toolContentId", false); - + MindmapUser mindmapUser = mindmapService.getUserByUID(userId); Mindmap mindmap = mindmapService.getMindmapByUid(toolContentId); + MindmapSession mindmapSession = mindmapUser.getMindmapSession(); request.setAttribute("reflectTitle", mindmap.getTitle()); request.setAttribute("reflectInstructions", mindmap.getReflectInstructions()); @@ -707,7 +744,7 @@ // Saving Mindmap Nodes if (!mindmap.isMultiUserMode()) - saveMindmapXML(mindmap, mindmapUser, learningForm.getMindmapContent()); + saveMindmapXML(mindmap, mindmapUser, learningForm.getMindmapContent(), mindmapSession); // Reflection NotebookEntry entry = mindmapService.getEntry(mindmapUser.getEntryUID()); @@ -764,15 +801,15 @@ } } else { if (!mindmap.isMultiUserMode()) - saveMindmapXML(mindmap, mindmapUser, learningForm.getMindmapContent()); + saveMindmapXML(mindmap, mindmapUser, learningForm.getMindmapContent(), mindmapSession); } } else { log.error("finishActivity(): couldn't find MindmapUser is null " + " and toolSessionID: " + toolSessionID); } - ToolSessionManager sessionMgrService = MindmapServiceProxy.getMindmapSessionManager(getServlet() - .getServletContext()); + ToolSessionManager sessionMgrService = + MindmapServiceProxy.getMindmapSessionManager(getServlet().getServletContext()); String nextActivityUrl; try { Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/MonitoringAction.java =================================================================== diff -u -r74f1da43432cc3cdefe3db657852ec79723ae3e7 -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision 74f1da43432cc3cdefe3db657852ec79723ae3e7) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -35,7 +35,6 @@ import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.mindmap.dto.MindmapDTO; -import org.lamsfoundation.lams.tool.mindmap.dto.MindmapSessionDTO; import org.lamsfoundation.lams.tool.mindmap.dto.MindmapUserDTO; import org.lamsfoundation.lams.tool.mindmap.model.Mindmap; import org.lamsfoundation.lams.tool.mindmap.model.MindmapNode; @@ -82,7 +81,6 @@ Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); - MindmapSession session = mindmapService.getSessionByMindmapId(mindmap.getUid()); if (mindmap == null) { log.error("unspecified(): Mindmap is not found!"); @@ -95,14 +93,9 @@ Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true); mindmapDTO.setCurrentTab(currentTab); - Object[] users = ((MindmapSessionDTO) mindmapDTO.getSessionDTOs().toArray()[0]).getUserDTOs().toArray(); - if (users != null && users.length > 0) - request.setAttribute("mindmapUser", ((MindmapUserDTO) users[0])); - request.setAttribute("mindmapDTO", mindmapDTO); request.setAttribute("contentFolderID", contentFolderID); request.setAttribute("isGroupedActivity", isGroupedActivity); - request.setAttribute("toolSessionID", session.getSessionId()); return mapping.findForward("success"); } @@ -124,9 +117,7 @@ Mindmap mindmap = mindmapService.getMindmapByUid(mindmapId); List mindmapNodeList = null; - if (mindmap.isMultiUserMode()) // is multi-user - mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapIdMulti(mindmapId); - else + if (!mindmap.isMultiUserMode()) // is single-user mindmapNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmapId, userId); if (mindmapNodeList != null && mindmapNodeList.size() > 0) { @@ -200,7 +191,7 @@ String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); MindmapUser mindmapUser = mindmapService.getUserByUID(userId); - + MindmapUserDTO userDTO = new MindmapUserDTO(mindmapUser); request.setAttribute("userDTO", userDTO); @@ -282,6 +273,8 @@ Long userId = WebUtil.readLongParam(request, "userId", false); MindmapUser mindmapUser = mindmapService.getUserByUID(userId); + MindmapSession mindmapSession = mindmapUser.getMindmapSession(); + String mindmapContent = WebUtil.readStrParam(request, "content", false); if (!mindmap.isMultiUserMode()) { @@ -293,18 +286,19 @@ List branches = rootNodeModel.getBranch(); // saving root Node into database - MindmapNode rootMindmapNode = (MindmapNode) mindmapService.getRootNodeByMindmapIdAndUserId( - mindmap.getUid(), userId).get(0); + MindmapNode rootMindmapNode = + (MindmapNode) mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), userId).get(0); + rootMindmapNode = mindmapService.saveMindmapNode(rootMindmapNode, null, nodeConceptModel.getId(), - nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap); + nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap, mindmapSession); // string to accumulate deleted nodes for query String nodesToDeleteCondition = " where uniqueId <> " + rootMindmapNode.getUniqueId(); // saving child Nodes into database if (branches != null) { mindmapService.setNodesToDeleteCondition(""); - mindmapService.getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap); + mindmapService.getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap, mindmapSession); } nodesToDeleteCondition += mindmapService.getNodesToDeleteCondition() + " and mindmap_id = " Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/servlets/ExportServlet.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/servlets/ExportServlet.java (.../ExportServlet.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/servlets/ExportServlet.java (.../ExportServlet.java) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -49,6 +49,8 @@ import org.lamsfoundation.lams.tool.mindmap.util.MindmapException; import org.lamsfoundation.lams.tool.mindmap.util.xmlmodel.NodeConceptModel; import org.lamsfoundation.lams.tool.mindmap.util.xmlmodel.NodeModel; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.servlet.AbstractExportPortfolioServlet; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -156,10 +158,13 @@ + request.getContextPath(); writeResponseToFile(basePath + "/images/mindmap_locked.swf", directoryName, "mindmap.swf", cookies); writeResponseToFile(basePath + "/includes/javascript/swfobject.js", directoryName, "swfobject.js", cookies); - + writeResponseToFile(basePath + "/includes/javascript/mindmap.resize.js", directoryName, "resize.js", cookies); + writeResponseToFile(Configuration.get(ConfigurationKeys.SERVER_URL) + + "includes/javascript/jquery-latest.pack.js", directoryName, "jquery.js", cookies); + List mindmapNodeList = null; if (mindmap.isMultiUserMode()) // is multi-user - mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapIdMulti(mindmap.getUid()); + mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapSession(mindmap.getUid(), toolSessionID); else mindmapNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), mindmapUser.getUid()); @@ -215,8 +220,90 @@ throw new MindmapException(error); } + + //Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); + //MindmapDTO mindmapDTO = new MindmapDTO(mindmap); + + + MindmapSession mindmapSession = mindmapService.getSessionBySessionId(toolSessionID); + //Mindmap mindmap = mindmapSession.getMindmap(); Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); + //Long userID = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID); + MindmapUser mindmapUser = null; //mindmapService.getUserByUserIdAndSessionId(userID, toolSessionID); + + // construct dto's MindmapDTO mindmapDTO = new MindmapDTO(mindmap); + mindmapDTO.setTitle(mindmap.getTitle()); + mindmapDTO.setInstructions(mindmap.getInstructions()); + + //MindmapSessionDTO sessionDTO = new MindmapSessionDTO(); + //sessionDTO.setSessionName(mindmapSession.getSessionName()); + //sessionDTO.setSessionID(mindmapSession.getSessionId()); + + //MindmapUserDTO userDTO = new MindmapUserDTO(mindmapUser); + + //sessionDTO.getUserDTOs().add(userDTO); + //mindmapDTO.getSessionDTOs().add(sessionDTO); + + // adding Mindmap files to archive + request.getSession().setAttribute("mindmapContentPath", "mindmap.xml"); + + //String currentMindmapUser = mindmapUser.getFirstName() + " " + mindmapUser.getLastName(); + //request.getSession().setAttribute("currentMindmapUser", currentMindmapUser); + + request.getSession().setAttribute("localizationPath", "locale.xml"); + + String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + + request.getContextPath(); + writeResponseToFile(basePath + "/images/mindmap_locked.swf", directoryName, "mindmap.swf", cookies); + writeResponseToFile(basePath + "/includes/javascript/swfobject.js", directoryName, "swfobject.js", cookies); + writeResponseToFile(basePath + "/includes/javascript/mindmap.resize.js", directoryName, "resize.js", cookies); + writeResponseToFile(Configuration.get(ConfigurationKeys.SERVER_URL) + + "includes/javascript/jquery-latest.pack.js", directoryName, "jquery.js", cookies); + + List mindmapNodeList = null; + if (mindmap.isMultiUserMode()) // is multi-user + mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapSession(mindmap.getUid(), toolSessionID); + else + mindmapNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), mindmapUser.getUid()); + + if (mindmapNodeList != null && mindmapNodeList.size() > 0) { + MindmapNode rootMindmapNode = (MindmapNode) mindmapNodeList.get(0); + + String mindmapUserName = null; + if (rootMindmapNode.getUser() == null) + mindmapUserName = mindmapService.getMindmapMessageService().getMessage("node.instructor.label"); + else + mindmapUserName = rootMindmapNode.getUser().getFirstName() + " " + + rootMindmapNode.getUser().getLastName(); + + NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), rootMindmapNode + .getText(), rootMindmapNode.getColor(), mindmapUserName)); + + NodeModel currentNodeModel = mindmapService.getMindmapXMLFromDatabase(rootMindmapNode.getNodeId(), + mindmap.getUid(), rootNodeModel, mindmapUser); + + XStream xstream = new XStream(); + xstream.alias("branch", NodeModel.class); + String mindmapContent = xstream.toXML(currentNodeModel); + + try { + File mindmapFile = new File(directoryName + "/mindmap.xml"); + FileOutputStream fop = new FileOutputStream(mindmapFile); + fop.write(mindmapContent.getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + try { + File localeFile = new File(directoryName + "/locale.xml"); + FileOutputStream fop = new FileOutputStream(localeFile); + fop.write(mindmapService.getLanguageXML().getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } + request.getSession().setAttribute("mindmapDTO", mindmapDTO); } } Index: lams_tool_mindmap/web/pages/export/exportPortfolio.jsp =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/web/pages/export/exportPortfolio.jsp (.../exportPortfolio.jsp) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/web/pages/export/exportPortfolio.jsp (.../exportPortfolio.jsp) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -4,16 +4,20 @@ <%@ include file="/common/taglibs.jsp"%> + + @@ -70,11 +74,11 @@ Index: lams_tool_mindmap/web/pages/learning/mindmap.jsp =================================================================== diff -u -r490538b019293e777795484a0ca53b09e2e053c8 -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/web/pages/learning/mindmap.jsp (.../mindmap.jsp) (revision 490538b019293e777795484a0ca53b09e2e053c8) +++ lams_tool_mindmap/web/pages/learning/mindmap.jsp (.../mindmap.jsp) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -26,7 +26,7 @@ $.timer(60000, function (timer) { if (!multiMode) $.post("${get}", { dispatch: "${dispatch}", mindmapId: "${mindmapId}", userId: "${userId}", - content: document['flashContent'].getMindmap() } ); + sessionId: "${sessionId}", content: document['flashContent'].getMindmap() } ); }); function validateForm() { Index: lams_tool_mindmap/web/pages/monitoring/summary.jsp =================================================================== diff -u -r4dac3505ba7605adf1bc770010861260e2b91c1b -reaa5be9d92dd1414e8279f492f86077ca02c494d --- lams_tool_mindmap/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision 4dac3505ba7605adf1bc770010861260e2b91c1b) +++ lams_tool_mindmap/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision eaa5be9d92dd1414e8279f492f86077ca02c494d) @@ -125,32 +125,50 @@ - - - + + + + + + + + + + + + + - + + + - + - + + + + + + @@ -166,7 +184,7 @@ - + @@ -179,7 +197,7 @@ - + @@ -189,6 +207,7 @@ +
-
+
message.enableJavaScript
-
+
- -
+ ${user.firstName} ${user.lastName} + + + + + + + + +
- - - -
+ + - - - - - - + + - - -
+ +