diff --git a/installer/build.sh b/installer/build.sh index 8f258bb3..4723d5b2 100755 --- a/installer/build.sh +++ b/installer/build.sh @@ -1,8 +1,9 @@ #!/bin/bash set -e +set -u -WISE_VERSION=0.96 +WISE_VERSION=$1 BASE_DIR=`pwd` TARGET_DIR=$BASE_DIR/target JETTY_DIR=$TARGET_DIR/wisemapping-$WISE_VERSION @@ -12,12 +13,12 @@ JETTY_ZIP=${JETTY_DIST_DIR}.zip # Clean ... mvn -f $BASE_DIR/../pom.xml clean -[ ! -e target ] && mkdir target +[ ! -e target ] && mkdir target rm -fr ${JETTY_DIR} rm -fr ${TARGET_DIR}/jetty-distribution-7.3.0.v20110203 # Prepare resources .. -mvn -f $BASE_DIR/../pom.xml install +mvn -f $BASE_DIR/../pom.xml install -Dmaven.test.skip=true if [ ! -f ./target/${JETTY_ZIP} ] then @@ -29,7 +30,6 @@ echo "Unzip Jetty ...:" unzip ${TARGET_DIR}/${JETTY_ZIP} -d ${TARGET_DIR}/ > /dev/null mv ${TARGET_DIR}/${JETTY_DIST_DIR} ${JETTY_DIR} - # Clean unsed files ... rm -r $JETTY_DIR/webapps/* rm -r $JETTY_DIR/contexts/* @@ -48,7 +48,11 @@ cp $BASE_DIR/wisemapping.xml $JETTY_DIR/contexts/ sed 's/target\/db\/wisemapping/webapps\/wisemapping\/WEB-INF\/database\/wisemapping/' $WISE_WEBAPP_DIR/WEB-INF/app.properties > $WISE_WEBAPP_DIR/WEB-INF/app.properties2 mv $WISE_WEBAPP_DIR/WEB-INF/app.properties2 $WISE_WEBAPP_DIR/WEB-INF/app.properties -#Build final Zip + +# Distribute scripts +cp -r $BASE_DIR/../wise-webapp/src/test/sql $TARGET_DIR/wisemapping-$WISE_VERSION/config + +# Zip all ... cd $TARGET_DIR zip -r wisemapping-$WISE_VERSION.zip wisemapping-$WISE_VERSION cd .. diff --git a/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java b/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java index 6fb5c042..24fcfd94 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java @@ -18,13 +18,11 @@ package com.wisemapping.exporter; -import com.wisemapping.exporter.ExportException; -import com.wisemapping.exporter.Exporter; + import com.wisemapping.importer.freemind.FreemindIconConverter; import com.wisemapping.model.MindMap; import com.wisemapping.model.ShapeStyle; import com.wisemapping.util.JAXBUtils; -import com.wisemapping.xml.Style; import com.wisemapping.xml.freemind.*; import com.wisemapping.xml.mindmap.RelationshipType; import com.wisemapping.xml.mindmap.TopicType; @@ -140,7 +138,7 @@ public class FreemindExporter final String shape = mindmapTopic.getShape(); if (shape != null && !shape.isEmpty()) { - if ( isRoot && !ShapeStyle.ROUNDED_RETAGLE.getStyle().endsWith(shape) || !isRoot && !ShapeStyle.LINE.getStyle().endsWith(shape) ) { + if (isRoot && !ShapeStyle.ROUNDED_RETAGLE.getStyle().endsWith(shape) || !isRoot && !ShapeStyle.LINE.getStyle().endsWith(shape)) { String style = shape; if (ShapeStyle.ROUNDED_RETAGLE.getStyle().equals(shape)) { @@ -156,6 +154,16 @@ public class FreemindExporter addEdgeNode(freemindNode, mindmapTopic); addNote(freemindNode, mindmapTopic); + final String position = mindmapTopic.getPosition(); + if (position != null && !position.isEmpty()) { + freemindNode.setWcoords(position); + } + + final Integer order = mindmapTopic.getOrder(); + if (order != null) { + freemindNode.setWorder(BigInteger.valueOf(order)); + } + Boolean shrink = mindmapTopic.isShrink(); if (shrink != null && shrink) freemindNode.setFOLDED(String.valueOf(shrink)); diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/Importer.java b/wise-webapp/src/main/java/com/wisemapping/importer/Importer.java index 9416e337..61f064ad 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/Importer.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/Importer.java @@ -20,6 +20,7 @@ package com.wisemapping.importer; import com.wisemapping.model.MindMap; +import java.io.IOException; import java.io.InputStream; public interface Importer diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java index a136e6fa..a0c375f2 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java @@ -45,6 +45,8 @@ import java.math.BigInteger; public class FreemindImporter implements Importer { + public static final String CODE_VERSION = "pela"; + public static final int HALF_ROOT_TOPICS_SEPARATION = 25; private com.wisemapping.xml.mindmap.ObjectFactory mindmapObjectFactory; private static final String POSITION_LEFT = "left"; private static final String BOLD = "bold"; @@ -53,45 +55,80 @@ public class FreemindImporter private java.util.Map nodesMap = null; private List relationships = null; private static final String EMPTY_FONT_STYLE = ";;;;;"; + private final static Charset UTF_8_CHARSET = Charset.forName("UTF-8"); + private final static int ORDER_SEPARATION_FACTOR = 2; private int currentId; + public static void main(String argv[]) { + + + // Now, calculate the order it belongs to ... + // 3 = -100 0 + // 1 = -50 1 + // 0 = 0 2 + // 2 = 50 3 + // 4 = 100 4 + + int total = 2; + int center = (total - 1) / 2; + + + for (int i = 0; i < total; i++) { + + int result = i - center + ((total % 2 == 0) ? 0 : 1); + if (result > 0) { + result = (result - 1) * 2; + } else { + result = (result * -2) + 1; + } + + System.out.println(i + "->" + result); + } + + } + public MindMap importMap(String mapName, String description, InputStream input) throws ImporterException { - final MindMap map; + final MindMap result = new MindMap(); + nodesMap = new HashMap(); + relationships = new ArrayList(); mindmapObjectFactory = new com.wisemapping.xml.mindmap.ObjectFactory(); + try { + String wiseXml; final Map freemindMap = (Map) JAXBUtils.getMapObject(input, "com.wisemapping.xml.freemind"); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final com.wisemapping.xml.mindmap.Map mindmapMap = mindmapObjectFactory.createMap(); - mindmapMap.setVersion("pela"); + mindmapMap.setVersion(CODE_VERSION); currentId = 0; - final Node centralNode = freemindMap.getNode(); - final TopicType centralTopic = mindmapObjectFactory.createTopicType(); - centralTopic.setId(String.valueOf(currentId++)); - centralTopic.setCentral(true); + final Node freeNode = freemindMap.getNode(); + final TopicType wiseTopic = mindmapObjectFactory.createTopicType(); + wiseTopic.setId(String.valueOf(currentId++)); + wiseTopic.setCentral(true); - setNodePropertiesToTopic(centralTopic, centralNode); - centralTopic.setShape(ShapeStyle.ROUNDED_RETAGLE.getStyle()); - mindmapMap.getTopic().add(centralTopic); + convertNodeProperties(freeNode, wiseTopic); + + wiseTopic.setShape(ShapeStyle.ROUNDED_RETAGLE.getStyle()); + mindmapMap.getTopic().add(wiseTopic); mindmapMap.setName(mapName); - nodesMap = new HashMap(); - relationships = new ArrayList(); - nodesMap.put(centralNode.getID(), centralTopic); - addTopicFromNode(centralNode, centralTopic); - fixCentralTopicChildOrder(centralTopic); + nodesMap.put(freeNode.getID(), wiseTopic); + + convertChildNodes(freeNode, wiseTopic, 1); addRelationships(mindmapMap); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - JAXBUtils.saveMap(mindmapMap, out, "com.wisemapping.xml.mindmap"); + JAXBUtils.saveMap(mindmapMap, baos, "com.wisemapping.xml.mindmap"); - map = new MindMap(); - map.setNativeXml(new String(out.toByteArray(), Charset.forName("UTF-8"))); - map.setTitle(mapName); - map.setDescription(description); + wiseXml = new String(baos.toByteArray(), UTF_8_CHARSET); + + + result.setNativeXml(wiseXml); + result.setTitle(mapName); + result.setDescription(description); } catch (JAXBException e) { throw new ImporterException(e); @@ -99,7 +136,7 @@ public class FreemindImporter throw new ImporterException(e); } - return map; + return result; } private void addRelationships(@NotNull com.wisemapping.xml.mindmap.Map mindmapMap) { @@ -122,7 +159,7 @@ public class FreemindImporter } } - private void fixRelationshipControlPoints(RelationshipType relationship) { + private void fixRelationshipControlPoints(@NotNull RelationshipType relationship) { //Both relationship node's ids should be freemind ones at this point. TopicType srcTopic = nodesMap.get(relationship.getSrcTopicId()); TopicType destTopicType = nodesMap.get(relationship.getDestTopicId()); @@ -139,7 +176,7 @@ public class FreemindImporter relationship.setDestCtrlPoint(x + "," + destCtrlPoint[1]); } - //Fix y coord + //Fix coord if (srcTopic.getOrder() % 2 != 0) { //Odd order. String[] srcCtrlPoint = relationship.getSrcCtrlPoint().split(","); int y = Integer.valueOf(srcCtrlPoint[1]) * -1; @@ -153,168 +190,110 @@ public class FreemindImporter } - private void fixCentralTopicChildOrder(@NotNull TopicType centralTopic) { - List topics = centralTopic.getTopic(); - List leftTopics = new ArrayList(); - List rightTopics = new ArrayList(); - - for (TopicType topic : topics) { - if (isOnLeftSide(topic)) { - leftTopics.add(topic); - } else { - rightTopics.add(topic); - } - } - - if (leftTopics.size() > 0) { - int size = leftTopics.size(); - int index = 0; - int center = size / 2; - if (size % 2 == 0) { //Even number, then place middle point in 1 index - index = 1; - center--; - } - int index2 = index; - - leftTopics.get(center).setOrder(index); - for (int i = center - 1; i >= 0; i--) { - if (index == 0) { - index++; - } else { - index += 2; - } - leftTopics.get(i).setOrder(index); - } - index = index2; - for (int i = center + 1; i < size; i++) { - if (index == 1) { - index++; - } else { - index += 2; - } - leftTopics.get(i).setOrder(index); - } - } - if (rightTopics.size() > 0) { - int size = rightTopics.size(); - int index = 0; - int center = size / 2; - if (size % 2 == 0) { //Even number, then place middle point in 1 index - index = 1; - center--; - } - int index2 = index; - rightTopics.get(center).setOrder(index); - for (int i = center - 1; i >= 0; i--) { - if (index == 0) { - index++; - } else { - index += 2; - } - rightTopics.get(i).setOrder(index); - } - index = index2; - for (int i = center + 1; i < size; i++) { - if (index == 1) { - index++; - } else { - index += 2; - } - rightTopics.get(i).setOrder(index); - } - } - } - private boolean isOnLeftSide(TopicType topic) { String[] position = topic.getPosition().split(","); int x = Integer.parseInt(position[0]); return x < 0; } - private void addTopicFromNode(@NotNull Node mainNode, @NotNull TopicType topic) { - final List freemindNodes = mainNode.getArrowlinkOrCloudOrEdge(); - TopicType currentTopic = topic; + private boolean isOnLeftSide(@NotNull String pos) { + String[] position = pos.split(","); + int x = Integer.parseInt(position[0]); + return x < 0; + } + + private void convertChildNodes(@NotNull Node freeParent, @NotNull TopicType wiseParent, final int depth) { + final List freeChilden = freeParent.getArrowlinkOrCloudOrEdge(); + TopicType currentWiseTopic = wiseParent; + int order = 0; - for (Object freemindNode : freemindNodes) { + for (Object element : freeChilden) { - if (freemindNode instanceof Node) { - final Node node = (Node) freemindNode; - TopicType newTopic = mindmapObjectFactory.createTopicType(); - newTopic.setId(String.valueOf(currentId++)); - nodesMap.put(node.getID(), newTopic); //Lets use freemind id temporarily. This will be fixed when adding relationship to the map. - newTopic.setOrder(order++); + if (element instanceof Node) { + final Node freeChild = (Node) element; + final TopicType wiseChild = mindmapObjectFactory.createTopicType(); - // Is there any link ? - final String url = node.getLINK(); - if (url != null) { - final Link link = new Link(); - link.setUrl(url); - newTopic.setLink(link); + // Set an incremental id ... + wiseChild.setId(String.valueOf(currentId++)); + + // Lets use freemind id temporarily. This will be fixed when adding relationship to the map. + nodesMap.put(freeChild.getID(), wiseChild); + + // Set node order ... + int norder; + if (depth != 1) { + norder = order++; + } else { + norder = calcFirstLevelOrder(freeChilden, freeChild); } + wiseChild.setOrder(norder); - if (POSITION_LEFT.equals(mainNode.getPOSITION())) { - node.setPOSITION(POSITION_LEFT); + // Convert node position ... + final String position = convertPosition(wiseParent, freeChild, depth, norder); + wiseChild.setPosition(position); + + // Convert the rest of the node properties ... + convertNodeProperties(freeChild, wiseChild); + + convertChildNodes(freeChild, wiseChild, depth + 1); + + if (!wiseChild.equals(wiseParent)) { + wiseParent.getTopic().add(wiseChild); } + currentWiseTopic = wiseChild; - setNodePropertiesToTopic(newTopic, node); - addTopicFromNode(node, newTopic); - if (!newTopic.equals(topic)) { - topic.getTopic().add(newTopic); - } - currentTopic = newTopic; - - } else if (freemindNode instanceof Font) { - final Font font = (Font) freemindNode; - final String fontStyle = generateFontStyle(mainNode, font); + } else if (element instanceof Font) { + final Font font = (Font) element; + final String fontStyle = generateFontStyle(freeParent, font); if (fontStyle != null) { - currentTopic.setFontStyle(fontStyle); + currentWiseTopic.setFontStyle(fontStyle); } - } else if (freemindNode instanceof Edge) { - final Edge edge = (Edge) freemindNode; - currentTopic.setBrColor(edge.getCOLOR()); - } else if (freemindNode instanceof Icon) { - final Icon freemindIcon = (Icon) freemindNode; + } else if (element instanceof Edge) { + final Edge edge = (Edge) element; + currentWiseTopic.setBrColor(edge.getCOLOR()); + } else if (element instanceof Icon) { + final Icon freemindIcon = (Icon) element; String iconId = freemindIcon.getBUILTIN(); final String wiseIconId = FreemindIconConverter.toWiseId(iconId); if (wiseIconId != null) { final com.wisemapping.xml.mindmap.Icon mindmapIcon = new com.wisemapping.xml.mindmap.Icon(); mindmapIcon.setId(wiseIconId); - currentTopic.getIcon().add(mindmapIcon); + currentWiseTopic.getIcon().add(mindmapIcon); } - } else if (freemindNode instanceof Hook) { - final Hook hook = (Hook) freemindNode; + } else if (element instanceof Hook) { + final Hook hook = (Hook) element; final com.wisemapping.xml.mindmap.Note mindmapNote = new com.wisemapping.xml.mindmap.Note(); String textNote = hook.getText(); if (textNote == null) // It is not a note is a BlinkingNodeHook or AutomaticLayout Hook { textNote = EMPTY_NOTE; mindmapNote.setText(textNote); - currentTopic.setNote(mindmapNote); + currentWiseTopic.setNote(mindmapNote); } - } else if (freemindNode instanceof Richcontent) { - final Richcontent content = (Richcontent) freemindNode; + } else if (element instanceof Richcontent) { + final Richcontent content = (Richcontent) element; final String type = content.getTYPE(); if (type.equals("NODE")) { String text = getText(content); text = text.replaceAll("\n", ""); text = text.trim(); - currentTopic.setText(text); + currentWiseTopic.setText(text); } else { String text = getRichContent(content); final com.wisemapping.xml.mindmap.Note mindmapNote = new com.wisemapping.xml.mindmap.Note(); text = text != null ? text.replaceAll("\n", "%0A") : EMPTY_NOTE; mindmapNote.setText(text); - currentTopic.setNote(mindmapNote); + currentWiseTopic.setNote(mindmapNote); } - } else if (freemindNode instanceof Arrowlink) { - final Arrowlink arrow = (Arrowlink) freemindNode; + } else if (element instanceof Arrowlink) { + final Arrowlink arrow = (Arrowlink) element; RelationshipType relationship = mindmapObjectFactory.createRelationshipType(); String destId = arrow.getDESTINATION(); - relationship.setSrcTopicId(mainNode.getID()); + relationship.setSrcTopicId(freeParent.getID()); relationship.setDestTopicId(destId); String[] inclination = arrow.getENDINCLINATION().split(";"); relationship.setDestCtrlPoint(inclination[0] + "," + inclination[1]); @@ -329,6 +308,91 @@ public class FreemindImporter } } + private int calcFirstLevelOrder(@NotNull List freeChilden, @NotNull Node freeChild) { + final List nodes = new ArrayList(); + int result; + if (freeChild.getWorder() != null) { + result = freeChild.getWorder().intValue(); + } else { + for (Object child : freeChilden) { + if (child instanceof Node) { + Node node = (Node) child; + + final String side = node.getPOSITION(); + if (freeChild.getPOSITION().equals(side)) { + nodes.add(node); + } + } + } + + // What is the index of the current node ? + int nodeIndex = 0; + for (Node node : nodes) { + if (node == freeChild) { + break; + } + nodeIndex++; + } + + int size = ORDER_SEPARATION_FACTOR * nodes.size(); + int center = (size - 1) / 2; + result = (nodeIndex * ORDER_SEPARATION_FACTOR) - center + ((size % 2 == 0) ? 0 : 1); + + if (result > 0) { + result = (result - 1) * 2; + } else { + result = (result * -2) + 1; + } + + } + return result; + } + + /** + * Position is (x,y). + * x values greater than 0 are right axis + * x values lower than 0 are left axis + */ + private + @NotNull + String convertPosition(@NotNull TopicType wiseParent, @NotNull Node freeChild, final int depth, int order) { + + // Which side must be the node be positioned ? + String result = freeChild.getWcoords(); + if (result == null) { + + final int xaxis; + int y; + if (depth == 1) { + + final String side = freeChild.getPOSITION(); + assert side != null : "This should not happen"; + xaxis = POSITION_LEFT.equals(side) ? -1 : 1; + + // 3 = -100 1 + // 1 = -50 2 + // 0 = 0 3 + // 2 = 50 4 + // 4 = 100 5 + if (order % 2 == 0) { + y = HALF_ROOT_TOPICS_SEPARATION * order; + } else { + y = -HALF_ROOT_TOPICS_SEPARATION * (order + 1); + } + + } else { + final String position = wiseParent.getPosition(); + xaxis = isOnLeftSide(position) ? -1 : 1; + y = 100 * depth; // Todo: This is not right at all. This must be changed. Position must be calculated based on the parent position + + } + int x = xaxis * 200 * depth; + result = x + "," + y; + + } + return result; + } + private String getRichContent(Richcontent content) { String result = null; List elementList = content.getHtml().getAny(); @@ -346,6 +410,7 @@ public class FreemindImporter return result; } + @NotNull private String getText(Richcontent content) { String result = ""; List elementList = content.getHtml().getAny(); @@ -384,34 +449,30 @@ public class FreemindImporter return text.toString(); } - private void setNodePropertiesToTopic(@NotNull com.wisemapping.xml.mindmap.TopicType wiseTopic, @NotNull com.wisemapping.xml.freemind.Node freemindNode) { - wiseTopic.setText(freemindNode.getTEXT()); - wiseTopic.setBgColor(freemindNode.getBACKGROUNDCOLOR()); + private void convertNodeProperties(@NotNull com.wisemapping.xml.freemind.Node freeNode, @NotNull com.wisemapping.xml.mindmap.TopicType wiseTopic) { + final String text = freeNode.getTEXT(); + wiseTopic.setText(text); - final String shape = getShapeFormFromNode(freemindNode); + final String bgcolor = freeNode.getBACKGROUNDCOLOR(); + wiseTopic.setBgColor(bgcolor); + + final String shape = getShapeFormFromNode(freeNode); wiseTopic.setShape(shape); - int pos = 1; - if (POSITION_LEFT.equals(freemindNode.getPOSITION())) { - pos = -1; - } - Integer orderPosition = wiseTopic.getOrder() != null ? wiseTopic.getOrder() : 0; - int position = pos * 200 + (orderPosition + 1) * 10; - wiseTopic.setPosition(position + "," + 200 * orderPosition); - final String fontStyle = generateFontStyle(freemindNode, null); + final String fontStyle = generateFontStyle(freeNode, null); if (fontStyle != null) { wiseTopic.setFontStyle(fontStyle); } // Is there any link ? - final String url = freemindNode.getLINK(); + final String url = freeNode.getLINK(); if (url != null) { final Link link = new Link(); link.setUrl(url); wiseTopic.setLink(link); } - final Boolean folded = Boolean.valueOf(freemindNode.getFOLDED()); + final Boolean folded = Boolean.valueOf(freeNode.getFOLDED()); if (folded) { wiseTopic.setShrink(folded); } @@ -477,7 +538,9 @@ public class FreemindImporter return result; } - private @NotNull String getShapeFormFromNode(@NotNull Node node) { + private + @NotNull + String getShapeFormFromNode(@NotNull Node node) { String result = node.getSTYLE(); // In freemind a node without style is a line if ("bubble".equals(result)) { diff --git a/wise-webapp/src/main/java/com/wisemapping/util/JAXBUtils.java b/wise-webapp/src/main/java/com/wisemapping/util/JAXBUtils.java index 634dd2d9..937beb7d 100755 --- a/wise-webapp/src/main/java/com/wisemapping/util/JAXBUtils.java +++ b/wise-webapp/src/main/java/com/wisemapping/util/JAXBUtils.java @@ -18,28 +18,47 @@ package com.wisemapping.util; +import org.jetbrains.annotations.NotNull; + import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import java.io.InputStream; import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; public class JAXBUtils { - public static Object getMapObject(InputStream stream,String pakage) throws JAXBException { + private final static Map context = new HashMap(); - final JAXBContext context = JAXBContext.newInstance(pakage); - final Unmarshaller unmarshaller = context.createUnmarshaller() ; + public static Object getMapObject(@NotNull InputStream stream, @NotNull final String pakage) throws JAXBException { - return unmarshaller.unmarshal (stream) ; + final JAXBContext context = getInstance(pakage); + final Unmarshaller unmarshaller = context.createUnmarshaller(); + + return unmarshaller.unmarshal(stream); } - public static void saveMap(Object obj, OutputStream out,String pakage) throws JAXBException { + private static JAXBContext getInstance(@NotNull String pakage) throws JAXBException { - final JAXBContext context = JAXBContext.newInstance(pakage); - final Marshaller marshaller = context.createMarshaller(); + JAXBContext result = context.get(pakage); + if (result == null) { + synchronized (context) { + result = JAXBContext.newInstance(pakage); + context.put(pakage, result); + } + } + return result; - marshaller.marshal(obj, out) ; + } + + public static void saveMap(@NotNull Object obj, @NotNull OutputStream out, String pachage) throws JAXBException { + + final JAXBContext context = getInstance(pachage); + final Marshaller marshaller = context.createMarshaller(); + + marshaller.marshal(obj, out); } } diff --git a/wise-webapp/src/main/java/com/wisemapping/xml/freemind/Node.java b/wise-webapp/src/main/java/com/wisemapping/xml/freemind/Node.java index fd2b9428..14fe003c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/xml/freemind/Node.java +++ b/wise-webapp/src/main/java/com/wisemapping/xml/freemind/Node.java @@ -26,9 +26,9 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -75,25 +75,23 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "arrowlinkOrCloudOrEdge" + "arrowlinkOrCloudOrEdge" }) @XmlRootElement(name = "node") public class Node { @XmlElements({ - @XmlElement(name = "icon", type = Icon.class), - @XmlElement(name = "node", type = Node.class), - @XmlElement(name = "edge", type = Edge.class), - @XmlElement(name = "arrowlink", type = Arrowlink.class), - @XmlElement(name = "font", type = Font.class), - @XmlElement(name = "hook", type = Hook.class), - @XmlElement(name = "richcontent", type = Richcontent.class), - @XmlElement(name = "cloud", type = Cloud.class) + @XmlElement(name = "icon", type = Icon.class), + @XmlElement(name = "node", type = Node.class), + @XmlElement(name = "edge", type = Edge.class), + @XmlElement(name = "arrowlink", type = Arrowlink.class), + @XmlElement(name = "font", type = Font.class), + @XmlElement(name = "hook", type = Hook.class), + @XmlElement(name = "richcontent", type = Richcontent.class), + @XmlElement(name = "cloud", type = Cloud.class) }) protected List arrowlinkOrCloudOrEdge; @XmlAttribute(name = "BACKGROUND_COLOR") @@ -123,28 +121,35 @@ public class Node { protected BigInteger hgap; @XmlAttribute(name = "VGAP") protected BigInteger vgap; + @XmlAttribute(name = "VSHIFT") protected BigInteger vshift; @XmlAttribute(name = "ENCRYPTED_CONTENT") protected String encryptedcontent; + // Wise Extensions + @XmlAttribute(name = "wCOORDS") + protected String wcoords; + @XmlAttribute(name = "WORDER") + protected BigInteger worder; + /** * Gets the value of the arrowlinkOrCloudOrEdge property. - * - *

+ *

+ *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the arrowlinkOrCloudOrEdge property. - * - *

+ *

+ *

* For example, to add a new item, do as follows: *

      *    getArrowlinkOrCloudOrEdge().add(newItem);
      * 
- * - * - *

+ *

+ *

+ *

* Objects of the following type(s) are allowed in the list * {@link Icon } * {@link Node } @@ -154,8 +159,6 @@ public class Node { * {@link Hook } * {@link Richcontent } * {@link Cloud } - * - * */ public List getArrowlinkOrCloudOrEdge() { if (arrowlinkOrCloudOrEdge == null) { @@ -166,11 +169,9 @@ public class Node { /** * Gets the value of the backgroundcolor property. - * - * @return - * possible object is - * {@link String } - * + * + * @return possible object is + * {@link String } */ public String getBACKGROUNDCOLOR() { return backgroundcolor; @@ -178,11 +179,9 @@ public class Node { /** * Sets the value of the backgroundcolor property. - * - * @param value - * allowed object is - * {@link String } - * + * + * @param value allowed object is + * {@link String } */ public void setBACKGROUNDCOLOR(String value) { this.backgroundcolor = value; @@ -190,23 +189,27 @@ public class Node { /** * Gets the value of the color property. - * - * @return - * possible object is - * {@link String } - * + * + * @return possible object is + * {@link String } */ public String getCOLOR() { return color; } + public BigInteger getWorder() { + return worder; + } + + public void setWorder(BigInteger worder) { + this.worder = worder; + } + /** * Sets the value of the color property. - * - * @param value - * allowed object is - * {@link String } - * + * + * @param value allowed object is + * {@link String } */ public void setCOLOR(String value) { this.color = value; @@ -214,11 +217,9 @@ public class Node { /** * Gets the value of the folded property. - * - * @return - * possible object is - * {@link String } - * + * + * @return possible object is + * {@link String } */ public String getFOLDED() { return folded; @@ -226,11 +227,9 @@ public class Node { /** * Sets the value of the folded property. - * - * @param value - * allowed object is - * {@link String } - * + * + * @param value allowed object is + * {@link String } */ public void setFOLDED(String value) { this.folded = value; @@ -238,11 +237,9 @@ public class Node { /** * Gets the value of the id property. - * - * @return - * possible object is - * {@link String } - * + * + * @return possible object is + * {@link String } */ public String getID() { return id; @@ -250,11 +247,9 @@ public class Node { /** * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link String } - * + * + * @param value allowed object is + * {@link String } */ public void setID(String value) { this.id = value; @@ -262,11 +257,9 @@ public class Node { /** * Gets the value of the link property. - * - * @return - * possible object is - * {@link String } - * + * + * @return possible object is + * {@link String } */ public String getLINK() { return link; @@ -274,11 +267,9 @@ public class Node { /** * Sets the value of the link property. - * - * @param value - * allowed object is - * {@link String } - * + * + * @param value allowed object is + * {@link String } */ public void setLINK(String value) { this.link = value; @@ -286,11 +277,9 @@ public class Node { /** * Gets the value of the position property. - * - * @return - * possible object is - * {@link String } - * + * + * @return possible object is + * {@link String } */ public String getPOSITION() { return position; @@ -298,11 +287,9 @@ public class Node { /** * Sets the value of the position property. - * - * @param value - * allowed object is - * {@link String } - * + * + * @param value allowed object is + * {@link String } */ public void setPOSITION(String value) { this.position = value; @@ -310,11 +297,9 @@ public class Node { /** * Gets the value of the style property. - * - * @return - * possible object is - * {@link String } - * + * + * @return possible object is + * {@link String } */ public String getSTYLE() { return style; @@ -322,11 +307,9 @@ public class Node { /** * Sets the value of the style property. - * - * @param value - * allowed object is - * {@link String } - * + * + * @param value allowed object is + * {@link String } */ public void setSTYLE(String value) { this.style = value; @@ -334,11 +317,9 @@ public class Node { /** * Gets the value of the text property. - * - * @return - * possible object is - * {@link String } - * + * + * @return possible object is + * {@link String } */ public String getTEXT() { return text; @@ -346,11 +327,9 @@ public class Node { /** * Sets the value of the text property. - * - * @param value - * allowed object is - * {@link String } - * + * + * @param value allowed object is + * {@link String } */ public void setTEXT(String value) { this.text = value; @@ -358,11 +337,9 @@ public class Node { /** * Gets the value of the created property. - * - * @return - * possible object is - * {@link BigInteger } - * + * + * @return possible object is + * {@link BigInteger } */ public BigInteger getCREATED() { return created; @@ -370,11 +347,9 @@ public class Node { /** * Sets the value of the created property. - * - * @param value - * allowed object is - * {@link BigInteger } - * + * + * @param value allowed object is + * {@link BigInteger } */ public void setCREATED(BigInteger value) { this.created = value; @@ -382,23 +357,27 @@ public class Node { /** * Gets the value of the modified property. - * - * @return - * possible object is - * {@link BigInteger } - * + * + * @return possible object is + * {@link BigInteger } */ public BigInteger getMODIFIED() { return modified; } + public String getWcoords() { + return wcoords; + } + + public void setWcoords(String wcoords) { + this.wcoords = wcoords; + } + /** * Sets the value of the modified property. - * - * @param value - * allowed object is - * {@link BigInteger } - * + * + * @param value allowed object is + * {@link BigInteger } */ public void setMODIFIED(BigInteger value) { this.modified = value; @@ -406,11 +385,9 @@ public class Node { /** * Gets the value of the hgap property. - * - * @return - * possible object is - * {@link BigInteger } - * + * + * @return possible object is + * {@link BigInteger } */ public BigInteger getHGAP() { return hgap; @@ -418,11 +395,9 @@ public class Node { /** * Sets the value of the hgap property. - * - * @param value - * allowed object is - * {@link BigInteger } - * + * + * @param value allowed object is + * {@link BigInteger } */ public void setHGAP(BigInteger value) { this.hgap = value; @@ -430,11 +405,9 @@ public class Node { /** * Gets the value of the vgap property. - * - * @return - * possible object is - * {@link BigInteger } - * + * + * @return possible object is + * {@link BigInteger } */ public BigInteger getVGAP() { return vgap; @@ -442,11 +415,9 @@ public class Node { /** * Sets the value of the vgap property. - * - * @param value - * allowed object is - * {@link BigInteger } - * + * + * @param value allowed object is + * {@link BigInteger } */ public void setVGAP(BigInteger value) { this.vgap = value; @@ -454,11 +425,9 @@ public class Node { /** * Gets the value of the vshift property. - * - * @return - * possible object is - * {@link BigInteger } - * + * + * @return possible object is + * {@link BigInteger } */ public BigInteger getVSHIFT() { return vshift; @@ -466,11 +435,9 @@ public class Node { /** * Sets the value of the vshift property. - * - * @param value - * allowed object is - * {@link BigInteger } - * + * + * @param value allowed object is + * {@link BigInteger } */ public void setVSHIFT(BigInteger value) { this.vshift = value; @@ -478,11 +445,9 @@ public class Node { /** * Gets the value of the encryptedcontent property. - * - * @return - * possible object is - * {@link String } - * + * + * @return possible object is + * {@link String } */ public String getENCRYPTEDCONTENT() { return encryptedcontent; @@ -490,11 +455,9 @@ public class Node { /** * Sets the value of the encryptedcontent property. - * - * @param value - * allowed object is - * {@link String } - * + * + * @param value allowed object is + * {@link String } */ public void setENCRYPTEDCONTENT(String value) { this.encryptedcontent = value; diff --git a/wise-webapp/src/main/java/com/wisemapping/xml/freemind_0_9_0.xsd b/wise-webapp/src/main/java/com/wisemapping/xml/freemind_0_9_0.xsd index 809a2e8a..7de99d23 100755 --- a/wise-webapp/src/main/java/com/wisemapping/xml/freemind_0_9_0.xsd +++ b/wise-webapp/src/main/java/com/wisemapping/xml/freemind_0_9_0.xsd @@ -149,6 +149,9 @@ + + + diff --git a/wise-webapp/src/main/webapp/WEB-INF/app.properties b/wise-webapp/src/main/webapp/WEB-INF/app.properties index c4cff7ce..62882278 100755 --- a/wise-webapp/src/main/webapp/WEB-INF/app.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/app.properties @@ -3,8 +3,8 @@ #database.url=jdbc:mysql://localhost/wisemapping #database.driver=com.mysql.jdbc.Driver #database.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect -#database.username=root -#database.password= +#database.username=wisemapping +#database.password=password # HSQL Configuration properties database.url=jdbc:hsqldb:file:target/db/wisemapping @@ -23,4 +23,4 @@ mail.host=localhost mail.user=user mail.password=password mail.registrationEmail=root@localhost -mail.siteEmail=root@localhost \ No newline at end of file +mail.siteEmail=root@localhost diff --git a/wise-webapp/src/test/data/freemind/basic.mmr b/wise-webapp/src/test/data/freemind/basic.mmr index c145329e..5752731b 100644 --- a/wise-webapp/src/test/data/freemind/basic.mmr +++ b/wise-webapp/src/test/data/freemind/basic.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/basic.wxml b/wise-webapp/src/test/data/freemind/basic.wxml new file mode 100644 index 00000000..8eff41b9 --- /dev/null +++ b/wise-webapp/src/test/data/freemind/basic.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/fonts.mmr b/wise-webapp/src/test/data/freemind/fonts.mmr index 2bed53a3..1d1c5afd 100644 --- a/wise-webapp/src/test/data/freemind/fonts.mmr +++ b/wise-webapp/src/test/data/freemind/fonts.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/fonts.wxml b/wise-webapp/src/test/data/freemind/fonts.wxml new file mode 100644 index 00000000..1e80d593 --- /dev/null +++ b/wise-webapp/src/test/data/freemind/fonts.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/icons.mmr b/wise-webapp/src/test/data/freemind/icons.mmr index 1d464f26..775c63f8 100644 --- a/wise-webapp/src/test/data/freemind/icons.mmr +++ b/wise-webapp/src/test/data/freemind/icons.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/icons.wxml b/wise-webapp/src/test/data/freemind/icons.wxml new file mode 100644 index 00000000..d7ee93ae --- /dev/null +++ b/wise-webapp/src/test/data/freemind/icons.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/links.mmr b/wise-webapp/src/test/data/freemind/links.mmr index 050ce1d3..1a15b29c 100644 --- a/wise-webapp/src/test/data/freemind/links.mmr +++ b/wise-webapp/src/test/data/freemind/links.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/links.wxml b/wise-webapp/src/test/data/freemind/links.wxml new file mode 100644 index 00000000..dfcbab9a --- /dev/null +++ b/wise-webapp/src/test/data/freemind/links.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/node-styles.mmr b/wise-webapp/src/test/data/freemind/node-styles.mmr index 41a26b82..353d40b0 100644 --- a/wise-webapp/src/test/data/freemind/node-styles.mmr +++ b/wise-webapp/src/test/data/freemind/node-styles.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/node-styles.wxml b/wise-webapp/src/test/data/freemind/node-styles.wxml new file mode 100644 index 00000000..ce69fddd --- /dev/null +++ b/wise-webapp/src/test/data/freemind/node-styles.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java index 69d6af94..015a972e 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java @@ -29,45 +29,65 @@ public class ImportExportTest { @Test(dataProvider = "Data-Provider-Function") - public void exportImportExportTest(@NotNull final File freeMindFile, @NotNull final File recFile) throws ImporterException, IOException, ExportException { + public void exportImportExportTest(@NotNull final File freeMindFile, @NotNull final File wiseFile, @NotNull final File freeRecFile) throws ImporterException, IOException, ExportException { - FileInputStream fileInputStream = new FileInputStream(freeMindFile.getAbsolutePath()); + final FileInputStream fileInputStream = new FileInputStream(freeMindFile.getAbsolutePath()); final MindMap mindMap = importer.importMap("basic", "basic", fileInputStream); - if (recFile.exists()) { + + // Compare mindmap output ... + if (wiseFile.exists()) { // Compare rec and file ... + final String recContent = readFile(wiseFile); - // Load rec file co - final FileInputStream fis = new FileInputStream(recFile); - final InputStreamReader isr = new InputStreamReader(fis); - final BufferedReader br = new BufferedReader(isr); + // Export mile content ... + Assert.assertEquals(mindMap.getUnzippedXml(), recContent); - final StringBuilder recContent = new StringBuilder(); - String line = br.readLine(); - while (line != null) { - recContent.append(line); - line = br.readLine(); + } else { + final FileOutputStream fos = new FileOutputStream(wiseFile); + fos.write(mindMap.getUnzippedXml().getBytes()); + fos.close(); + } - } - - fis.close(); + // Compare freemind output ... + if (freeRecFile.exists()) { + // Compare rec and file ... + final String recContent = readFile(freeRecFile); // Export mile content ... final ByteArrayOutputStream bos = new ByteArrayOutputStream(); exporter.export(mindMap, bos); final String exportContent = new String(bos.toByteArray()); - Assert.assertEquals(recContent.toString(), exportContent); + Assert.assertEquals(exportContent, recContent); } else { - final FileOutputStream fos = new FileOutputStream(recFile); + final FileOutputStream fos = new FileOutputStream(freeRecFile); exporter.export(mindMap, fos); fos.close(); } } + private String readFile(@NotNull File file) throws IOException { + // Load rec file co + final FileInputStream fis = new FileInputStream(file); + final InputStreamReader isr = new InputStreamReader(fis); + final BufferedReader br = new BufferedReader(isr); + + final StringBuilder result = new StringBuilder(); + String line = br.readLine(); + while (line != null) { + result.append(line); + line = br.readLine(); + + } + + fis.close(); + return result.toString(); + } + //This function will provide the parameter data @DataProvider(name = "Data-Provider-Function") public Object[][] parameterIntTestProvider() { @@ -84,7 +104,8 @@ public class ImportExportTest { for (int i = 0; i < freeMindFiles.length; i++) { File freeMindFile = freeMindFiles[i]; final String name = freeMindFile.getName(); - result[i] = new Object[]{freeMindFile, new File(DATA_DIR_PATH, name.substring(0, name.lastIndexOf(".")) + ".mmr")}; + String testName = name.substring(0, name.lastIndexOf(".")); + result[i] = new Object[]{freeMindFile, new File(DATA_DIR_PATH, testName + ".wxml"), new File(DATA_DIR_PATH, testName + ".mmr")}; } return result; diff --git a/wise-webapp/src/test/sql/mysql/create-database.sql b/wise-webapp/src/test/sql/mysql/create-database.sql new file mode 100644 index 00000000..a90872ed --- /dev/null +++ b/wise-webapp/src/test/sql/mysql/create-database.sql @@ -0,0 +1,3 @@ +CREATE DATABASE wisemapping CHARACTER SET='utf8' COLLATE='utf8_unicode_ci'; +CREATE USER 'wisemapping'@'localhost' IDENTIFIED BY 'password'; +GRANT ALL ON wisemapping.* TO 'wisemapping'@'localhost'; diff --git a/wise-webapp/src/test/sql/mysql/test-data.sql b/wise-webapp/src/test/sql/mysql/test-data.sql index 9958efa5..5121071c 100644 --- a/wise-webapp/src/test/sql/mysql/test-data.sql +++ b/wise-webapp/src/test/sql/mysql/test-data.sql @@ -1,4 +1,4 @@ -INSERT INTO COLABORATOR(id,email,creation_date) values (1,'test@wisemapping.com',CURRENT_DATE()); +INSERT INTO COLABORATOR(id,email,creation_date) values (1,'test@wisemapping.org',CURRENT_DATE()); INSERT INTO USER (colaborator_id,username,firstname, lastname, password, activationCode,activation_date,allowSendEmail) values(1,'Wise Mapping Test User','Wise','Test', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',1237,CURRENT_DATE(),1); COMMIT;