Index: lams_tool_mindmap/db/model/mindmap_tool.clay =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/db/model/mindmap_tool.clay,v diff -u -r1.2 -r1.2.2.1 --- lams_tool_mindmap/db/model/mindmap_tool.clay 20 Apr 2009 05:03:05 -0000 1.2 +++ lams_tool_mindmap/db/model/mindmap_tool.clay 6 May 2009 05:36:33 -0000 1.2.2.1 @@ -19,8 +19,8 @@ - + @@ -32,8 +32,8 @@ - + @@ -59,8 +59,8 @@ - + @@ -78,8 +78,8 @@ - + @@ -117,8 +117,8 @@ - + @@ -142,8 +142,8 @@ - + @@ -210,8 +210,8 @@ - + @@ -220,17 +220,10 @@ - + - - - - - - - - - + + @@ -261,8 +254,8 @@ - + @@ -274,8 +267,8 @@ - + @@ -287,8 +280,8 @@ - + @@ -314,8 +307,8 @@ - + @@ -327,8 +320,8 @@ - + @@ -388,8 +381,8 @@ - + @@ -401,8 +394,8 @@ - + @@ -414,8 +407,8 @@ - + @@ -427,11 +420,11 @@ + - @@ -440,8 +433,8 @@ - + @@ -453,8 +446,8 @@ - + @@ -466,8 +459,8 @@ - + @@ -479,8 +472,8 @@ - + @@ -529,8 +522,8 @@ - + @@ -554,8 +547,8 @@ - + @@ -567,8 +560,8 @@ - + @@ -587,8 +580,8 @@ - + @@ -626,8 +619,8 @@ - + @@ -639,8 +632,8 @@ - + @@ -679,8 +672,8 @@ - + @@ -692,8 +685,8 @@ - + Index: lams_tool_mindmap/db/sql/create_lams_tool_mindmap.sql =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/db/sql/create_lams_tool_mindmap.sql,v diff -u -r1.1 -r1.1.2.1 --- lams_tool_mindmap/db/sql/create_lams_tool_mindmap.sql 3 Apr 2009 00:00:31 -0000 1.1 +++ lams_tool_mindmap/db/sql/create_lams_tool_mindmap.sql 6 May 2009 05:36:45 -0000 1.1.2.1 @@ -9,7 +9,7 @@ drop table if exists tl_lamind10_request; create table tl_lamind10_attachment (uid bigint not null auto_increment, file_version_id bigint, file_type varchar(255), file_name varchar(255), file_uuid bigint, create_date datetime, mindmap_uid bigint, primary key (uid))type=innodb; -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, last_action_id bigint, reflect_on_activity bit, reflect_instructions text, primary key (uid))type=innodb; +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; Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/model/Mindmap.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/model/Mindmap.java,v diff -u -r1.1 -r1.1.2.1 --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/model/Mindmap.java 3 Apr 2009 00:00:36 -0000 1.1 +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/model/Mindmap.java 6 May 2009 05:35:57 -0000 1.1.2.1 @@ -27,7 +27,7 @@ import java.util.Date; import java.util.HashSet; import java.util.Iterator; -import java.util.Set; //import java.util.TreeSet; +import java.util.Set; import org.apache.log4j.Logger; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; //import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; @@ -56,7 +56,7 @@ private boolean contentInUse; private boolean defineLater; private Long toolContentId; - private Long lastActionId; + private String mindmapExportContent; private Set mindmapAttachments; private Set mindmapSessions; @@ -260,20 +260,16 @@ public void setToolContentId(Long toolContentId) { this.toolContentId = toolContentId; } - + /** - * @hibernate.property column="last_action_id" length="20" + * @hibernate.property column="export_content" */ - public Long getLastActionId() { - return lastActionId; + public String getMindmapExportContent() { + return mindmapExportContent; } - - /** - * @param lastActionId - * the lastActionId to set - */ - public void setLastActionId(Long lastActionId) { - this.lastActionId = lastActionId; + + public void setMindmapExportContent(String mindmapExportContent) { + this.mindmapExportContent = mindmapExportContent; } /** Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java,v diff -u -r1.4 -r1.4.2.1 --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java 4 May 2009 03:14:28 -0000 1.4 +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java 6 May 2009 05:36:12 -0000 1.4.2.1 @@ -86,6 +86,8 @@ import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.util.audit.IAuditService; +import com.thoughtworks.xstream.XStream; + /** * An implementation of the IMindmapService interface. As a requirement, all LAMS tool's service bean must implement * ToolContentManager and ToolSessionManager. @@ -94,7 +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; @@ -402,20 +406,16 @@ 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); if (mindmap == null) { @@ -424,16 +424,36 @@ 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()); + if (mindmapNodeList != null && mindmapNodeList.size() > 0) { + MindmapNode rootMindmapNode = (MindmapNode) mindmapNodeList.get(0); - // set ResourceToolContentHandler as null to avoid copy file node in - // repository again. + String rootMindmapUser = getMindmapMessageService().getMessage("node.instructor.label"); + + NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), rootMindmapNode + .getText(), rootMindmapNode.getColor(), rootMindmapUser, 1)); + 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"); @@ -445,9 +465,7 @@ /** * 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 { @@ -461,13 +479,33 @@ throw new ImportToolContentException("Import Mindmap tool content failed. Deserialized object is " + toolPOJO); } + Mindmap mindmap = (Mindmap) toolPOJO; + + String mindmapContent = mindmap.getMindmapExportContent(); + MindmapUser mindmapUser = null; + XStream xstream = new XStream(); + xstream.alias("branch", NodeModel.class); + 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); + + // saving child Nodes into database + if (branches != null) { + getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap); + } + // 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); }