- JSON/XML/HTML configuration for map rendering

This commit is contained in:
Paulo Gustavo Veiga
2012-02-16 01:16:51 -03:00
parent 826606dc53
commit a786c0de09
4 changed files with 45 additions and 56 deletions

View File

@@ -2,43 +2,32 @@ package com.wisemapping.rest;
import com.wisemapping.model.MindMap;
import com.wisemapping.rest.model.RestMindMap;
import com.wisemapping.service.MindmapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/map")
public class MindmapController {
@Autowired
private MindmapService mindmapService;
public void setMindmapService(MindmapService mindmapService) {
this.mindmapService = mindmapService;
}
@RequestMapping(method = RequestMethod.GET, value = "/map/{id}")
public
@RequestMapping(method = RequestMethod.GET, value = "/{id}")
@ResponseBody
Map<String, Object> getMindmap(@PathVariable int id) throws IOException {
final Map<String, Object> result = new HashMap<String, Object>();
public ModelAndView getMindmap(@PathVariable int id) throws IOException {
final MindMap mindMap = mindmapService.getMindmapById(id);
result.put("xml", mindMap.getNativeXml());
result.put("creationTime", mindMap.getCreationTime());
result.put("description", mindMap.getDescription());
result.put("lastModification", mindMap.getLastModificationDate());
result.put("owner", mindMap.getOwner().getUsername());
return result;
final RestMindMap map = new RestMindMap(mindMap);
return new ModelAndView("mapView", "map", map);
}
@RequestMapping(method = RequestMethod.POST, value = "/map/{id}")
public void updateMindmap(@PathVariable int id) throws IOException {
}
}