2012-06-09 22:55:55 -03:00
|
|
|
/*
|
|
|
|
* Copyright [2011] [wisemapping]
|
|
|
|
*
|
|
|
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
|
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
|
|
* "powered by wisemapping" text requirement on every single page;
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the license at
|
|
|
|
*
|
|
|
|
* http://www.wisemapping.org/license
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-04-02 14:11:28 -03:00
|
|
|
package com.wisemapping.ncontroller;
|
|
|
|
|
|
|
|
|
|
|
|
import com.wisemapping.filter.UserAgent;
|
|
|
|
import com.wisemapping.model.MindMap;
|
|
|
|
import com.wisemapping.security.Utils;
|
|
|
|
import com.wisemapping.service.MindmapService;
|
|
|
|
import com.wisemapping.view.MindMapBean;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2012-06-09 22:49:54 -03:00
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
2012-04-02 14:11:28 -03:00
|
|
|
import org.springframework.stereotype.Controller;
|
2012-06-17 02:51:01 -03:00
|
|
|
import org.springframework.ui.Model;
|
2012-04-02 14:11:28 -03:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
public class MindmapController {
|
2012-06-03 20:23:31 -03:00
|
|
|
|
2012-06-09 22:49:54 -03:00
|
|
|
@Qualifier("mindmapService")
|
2012-04-02 14:11:28 -03:00
|
|
|
@Autowired
|
|
|
|
private MindmapService mindmapService;
|
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
@RequestMapping(value = "maps/import")
|
|
|
|
public String showImportPage() {
|
|
|
|
return "mindmapImport";
|
2012-04-02 14:11:28 -03:00
|
|
|
}
|
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
@RequestMapping(value = "maps/{id}/details")
|
|
|
|
public String showDetails(@PathVariable int id, @NotNull Model model) {
|
|
|
|
final MindMapBean mindmap = findMindmapBean(id);
|
|
|
|
model.addAttribute("mindmap", mindmap);
|
|
|
|
return "mindmapDetail";
|
2012-06-03 19:19:48 -03:00
|
|
|
}
|
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
@RequestMapping(value = "maps/{id}/print")
|
|
|
|
public String showPrintPage(@PathVariable int id, @NotNull Model model) {
|
|
|
|
final MindMap mindmap = findMindmap(id);
|
|
|
|
model.addAttribute("mindmap", mindmap);
|
|
|
|
return "mindmapPrint";
|
2012-06-03 11:16:38 -03:00
|
|
|
}
|
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
@RequestMapping(value = "maps/{id}/view")
|
|
|
|
public String showViewPage(@PathVariable int id, @NotNull Model model) {
|
|
|
|
final MindMap mindmap = findMindmap(id);
|
|
|
|
model.addAttribute("mindmap", mindmap);
|
|
|
|
return "mindmapPrint";
|
2012-04-14 18:46:07 -03:00
|
|
|
}
|
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
@RequestMapping(value = "maps/{id}/export")
|
|
|
|
public String showExportPage(@PathVariable int id, @NotNull Model model) throws IOException {
|
2012-04-14 18:46:07 -03:00
|
|
|
final MindMap mindmap = findMindmap(id);
|
2012-06-17 02:51:01 -03:00
|
|
|
model.addAttribute("mindmap", mindmap);
|
|
|
|
return "mindmapExport";
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "maps/{id}/exportf")
|
|
|
|
public String showExportPageFull(@PathVariable int id, @NotNull Model model) throws IOException {
|
|
|
|
showExportPage(id, model);
|
|
|
|
return "mindmapExportFull";
|
2012-04-14 18:46:07 -03:00
|
|
|
}
|
|
|
|
|
2012-06-03 11:16:38 -03:00
|
|
|
@RequestMapping(value = "maps/{id}/share")
|
2012-06-17 02:51:01 -03:00
|
|
|
public String showSharePage(@PathVariable int id, @NotNull Model model) {
|
2012-06-03 11:16:38 -03:00
|
|
|
final MindMap mindmap = findMindmap(id);
|
2012-06-17 02:51:01 -03:00
|
|
|
model.addAttribute("mindmap", mindmap);
|
|
|
|
return "mindmapShare";
|
2012-06-03 11:16:38 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "maps/{id}/sharef")
|
2012-06-17 02:51:01 -03:00
|
|
|
public String showSharePageFull(@PathVariable int id, @NotNull Model model) {
|
|
|
|
showSharePage(id, model);
|
|
|
|
return "mindmapShareFull";
|
2012-06-03 11:16:38 -03:00
|
|
|
}
|
|
|
|
|
2012-05-27 18:15:46 -03:00
|
|
|
@RequestMapping(value = "maps/{id}/publish")
|
2012-06-17 02:51:01 -03:00
|
|
|
public String showPublishPage(@PathVariable int id, @NotNull Model model) {
|
2012-05-20 21:46:55 -03:00
|
|
|
final MindMap mindmap = findMindmap(id);
|
2012-06-17 02:51:01 -03:00
|
|
|
model.addAttribute("mindmap", mindmap);
|
|
|
|
return "mindmapPublish";
|
2012-05-27 18:15:46 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "maps/{id}/publishf")
|
2012-06-17 02:51:01 -03:00
|
|
|
public String showPublishPageFull(@PathVariable int id, @NotNull Model model) {
|
|
|
|
showPublishPage(id, model);
|
|
|
|
return "mindmapPublishFull";
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "maps/{id}/history", method = RequestMethod.GET)
|
|
|
|
public String showHistoryPage(@PathVariable int id, @NotNull Model model) {
|
|
|
|
model.addAttribute("mindmapId", id);
|
|
|
|
return "mindmapHistory";
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "maps/{id}/historyf", method = RequestMethod.GET)
|
|
|
|
public String showHistoryPageFull(@PathVariable int id, @NotNull Model model) {
|
|
|
|
showHistoryPage(id, model);
|
|
|
|
return "mindmapHistoryFull";
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(value = "maps/")
|
|
|
|
public String showListPage() {
|
|
|
|
return "mindmapList";
|
2012-05-20 21:46:55 -03:00
|
|
|
}
|
|
|
|
|
2012-05-27 18:15:46 -03:00
|
|
|
@RequestMapping(value = "maps/{id}/edit")
|
2012-05-20 21:46:55 -03:00
|
|
|
public ModelAndView editMap(@PathVariable int id, @NotNull HttpServletRequest request) {
|
2012-04-14 18:46:07 -03:00
|
|
|
ModelAndView view;
|
|
|
|
final UserAgent userAgent = UserAgent.create(request);
|
|
|
|
if (userAgent.needsGCF()) {
|
|
|
|
view = new ModelAndView("gcfPluginNeeded");
|
|
|
|
// view.addObject(MINDMAP_ID_PARAMETER, mindmapId);
|
|
|
|
} else {
|
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
final MindMapBean mindmap = findMindmapBean(id);
|
2012-04-14 18:46:07 -03:00
|
|
|
view = new ModelAndView("mindmapEditor", "mindmap", mindmap);
|
|
|
|
view.addObject("editorTryMode", false);
|
|
|
|
final boolean showHelp = isWelcomeMap(mindmap);
|
|
|
|
view.addObject("showHelp", showHelp);
|
|
|
|
view.addObject("user", Utils.getUser());
|
|
|
|
}
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
2012-06-03 20:23:31 -03:00
|
|
|
@RequestMapping(value = "maps/{id}/embed")
|
2012-06-17 02:51:01 -03:00
|
|
|
public ModelAndView embeddedView(@PathVariable int id, @RequestParam(required = false) Float zoom) {
|
2012-06-03 20:23:31 -03:00
|
|
|
ModelAndView view;
|
|
|
|
final MindMap mindmap = mindmapService.getMindmapById(id);
|
|
|
|
view = new ModelAndView("mindmapEmbedded", "mindmap", mindmap);
|
|
|
|
view.addObject("user", Utils.getUser());
|
|
|
|
view.addObject("zoom", zoom == null ? 1 : zoom);
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
2012-04-02 14:11:28 -03:00
|
|
|
|
|
|
|
private MindMap findMindmap(long mapId) {
|
|
|
|
final MindMap mindmap = mindmapService.getMindmapById((int) mapId);
|
|
|
|
if (mindmap == null) {
|
|
|
|
throw new IllegalArgumentException("Mindmap could not be found");
|
|
|
|
}
|
|
|
|
return mindmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
private MindMapBean findMindmapBean(long mapId) {
|
|
|
|
return new MindMapBean(findMindmap(mapId));
|
|
|
|
}
|
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
private boolean isWelcomeMap(MindMapBean map) {
|
2012-04-14 18:46:07 -03:00
|
|
|
return map.getTitle().startsWith("Welcome ");
|
|
|
|
}
|
2012-04-02 14:11:28 -03:00
|
|
|
}
|