support both export versions for freemind (old and new 1.0.1)

This commit is contained in:
Claudio Barril
2014-09-07 16:06:58 -03:00
parent 369f015af2
commit 26a18ae7d0
16 changed files with 68 additions and 26 deletions

View File

@@ -21,6 +21,7 @@ package com.wisemapping.exporter;
public class ExportProperties {
private ExportFormat format;
private String baseImgPath;
private String version;
public ExportFormat getFormat() {
return format;
@@ -40,6 +41,14 @@ public class ExportProperties {
return result;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
static public class GenericProperties extends ExportProperties {
private GenericProperties(ExportFormat format) {
super(format);

View File

@@ -142,6 +142,7 @@ public class ExporterFactory {
}
case FREEMIND: {
final FreemindExporter exporter = new FreemindExporter();
exporter.setVersion(properties.getVersion());
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output);
break;
}

View File

@@ -49,12 +49,12 @@ import java.util.Map;
public class FreemindExporter
implements Exporter {
private static final String FREE_MIND_VERSION = "0.9.0";
private static final String POSITION_LEFT = "left";
private static final String POSITION_RIGHT = "right";
private com.wisemapping.jaxb.freemind.ObjectFactory objectFactory;
private static final String EMPTY_FONT_STYLE = ";;;;;";
private Map<String, Node> nodesMap = null;
private String version;
public void export(Mindmap map, OutputStream outputStream) throws ExportException {
export(map.getUnzipXml(), outputStream);
@@ -71,7 +71,7 @@ public class FreemindExporter
mindmapMap = (com.wisemapping.jaxb.wisemap.Map) JAXBUtils.getMapObject(stream, "com.wisemapping.jaxb.wisemap");
final com.wisemapping.jaxb.freemind.Map freemindMap = objectFactory.createMap();
freemindMap.setVersion(FREE_MIND_VERSION);
freemindMap.setVersion(this.getVersion());
final List<TopicType> topics = mindmapMap.getTopic();
@@ -342,4 +342,11 @@ public class FreemindExporter
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}

View File

@@ -114,13 +114,14 @@ public class MindmapController extends BaseController {
return new ModelAndView("transformViewWise", values);
}
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/freemind"}, params = {"download=mm"})
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/freemind"}, params = {"download=mm","version"})
@ResponseBody
public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id) throws IOException, MapCouldNotFoundException {
public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id, @RequestParam(value = "version") String version) throws IOException, MapCouldNotFoundException {
final Mindmap mindMap = findMindmapById(id);
final Map<String, Object> values = new HashMap<String, Object>();
values.put("content", mindMap.getXmlStr());
values.put("filename", mindMap.getTitle());
values.put("version", version);
return new ModelAndView("transformViewFreemind", values);
}

View File

@@ -56,6 +56,7 @@ public class TransformView extends AbstractView {
final String content = (String) viewMap.get("content");
final String filename = (String) viewMap.get("filename");
final String version = (String) viewMap.get("version");
// Build format properties ...
final ExportProperties properties = ExportProperties.create(exportFormat);
@@ -63,6 +64,9 @@ public class TransformView extends AbstractView {
final ExportProperties.ImageProperties imageProperties = (ExportProperties.ImageProperties) properties;
imageProperties.setSize(ExportProperties.ImageProperties.Size.LARGE);
}
if (version != null) {
properties.setVersion(version);
}
// Set format content type...
final String contentType = exportFormat.getContentType();