From 5e67811dcf01bbf24f47004b29e9d6346c7e8cb9 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 17 Jun 2012 02:51:01 -0300 Subject: [PATCH] Finish mindmapHistory rest service. --- mindplot/src/main/javascript/widget/Menu.js | 2 +- .../controller/BaseMultiActionController.java | 71 ------- .../controller/BaseSimpleFormController.java | 16 -- .../controller/HistoryController.java | 82 -------- .../controller/SettingsController.java | 2 +- .../controller/TagsController.java | 2 +- .../com/wisemapping/dao/MindmapManager.java | 2 +- .../ncontroller/MindmapController.java | 177 ++++++------------ .../wisemapping/rest/MindmapController.java | 13 +- .../rest/model/RestMindmapHistory.java | 76 ++++++++ .../rest/model/RestMindmapHistoryList.java | 44 +++++ .../service/MindmapServiceImpl.java | 1 - .../java/com/wisemapping/validator/Utils.java | 2 +- .../com/wisemapping/view/MindMapBean.java | 28 ++- .../main/webapp/WEB-INF/defs/definitions.xml | 39 ++-- .../webapp/WEB-INF/wisemapping-servlet.xml | 5 + wise-webapp/src/main/webapp/js/mymaps.js | 4 + .../main/webapp/jsp/dialogFullTemplate.jsp | 1 + wise-webapp/src/main/webapp/jsp/login.jsp | 2 +- .../src/main/webapp/jsp/mindmapDetail.jsp | 30 +-- .../src/main/webapp/jsp/mindmapEditor.jsp | 2 +- ...keyboard.jsp => mindmapEditorKeyboard.jsp} | 0 .../{toolbar.jsf => mindmapEditorToolbar.jsf} | 17 +- .../src/main/webapp/jsp/mindmapHistory.jsp | 124 ++++++------ .../src/main/webapp/jsp/mindmapList.jsp | 13 ++ .../src/main/webapp/jsp/mindmapPrint.jsp | 4 - .../src/main/webapp/jsp/mindmapShare.jsp | 2 - ...ngePassword.jsp => userChangePassword.jsp} | 0 .../jsp/{setting.jsp => userSetting.jsp} | 0 29 files changed, 342 insertions(+), 419 deletions(-) delete mode 100644 wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java delete mode 100755 wise-webapp/src/main/java/com/wisemapping/controller/HistoryController.java create mode 100644 wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java create mode 100644 wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistoryList.java rename wise-webapp/src/main/webapp/jsp/{keyboard.jsp => mindmapEditorKeyboard.jsp} (100%) rename wise-webapp/src/main/webapp/jsp/{toolbar.jsf => mindmapEditorToolbar.jsf} (88%) rename wise-webapp/src/main/webapp/jsp/{changePassword.jsp => userChangePassword.jsp} (100%) rename wise-webapp/src/main/webapp/jsp/{setting.jsp => userSetting.jsp} (100%) diff --git a/mindplot/src/main/javascript/widget/Menu.js b/mindplot/src/main/javascript/widget/Menu.js index 36ff2c79..def85803 100644 --- a/mindplot/src/main/javascript/widget/Menu.js +++ b/mindplot/src/main/javascript/widget/Menu.js @@ -374,7 +374,7 @@ mindplot.widget.Menu = new Class({ if (historyElem) { this._addButton('history', false, false, function() { - var reqDialog = new MooDialog.Request('c/history?action=list&goToMindmapList&mapId=' + mapId, null, + var reqDialog = new MooDialog.Request('c/iframeWrapper?url=c/maps/' + mapId + "/historyf", null, {'class': 'modalDialog historyModalDialog', closeButton:true, destroyOnClose:true, diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java b/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java deleted file mode 100644 index 7496b0f8..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java +++ /dev/null @@ -1,71 +0,0 @@ -/* -* 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. -*/ - -package com.wisemapping.controller; - -import com.wisemapping.model.MindMap; -import com.wisemapping.service.MindmapService; -import com.wisemapping.service.UserService; -import org.springframework.web.servlet.mvc.multiaction.MultiActionController; - -import javax.servlet.http.HttpServletRequest; - -public abstract class BaseMultiActionController - extends MultiActionController { - - private MindmapService mindmapService; - private UserService userService; - - protected MindMap getMindmapFromRequest(HttpServletRequest request) { - final String mapIdStr = request.getParameter(MAP_ID_PARAMNAME); - assert mapIdStr != null : "mapId parameter can not be null"; - logger.info("MapIdStr:" + mapIdStr); - MindMap map = null; - int mapId; - try { - mapId = Integer.parseInt(mapIdStr); - map = mindmapService.getMindmapById(mapId); - } catch (Exception e) { - logger.debug("An error ocurred trying to get mapId " + mapIdStr + "'", e); - } - - if (map == null) { - throw new IllegalStateException("Map with id '" + mapIdStr + "' can not be found"); - } - return map; - } - - public MindmapService getMindmapService() { - return mindmapService; - } - - public void setMindmapService(MindmapService mindmapService) { - this.mindmapService = mindmapService; - } - - public UserService getUserService() { - return userService; - } - - public void setUserService(UserService userService) { - this.userService = userService; - } - - public static final String MAP_ID_PARAMNAME = "mapId"; - public static final String MINDMAP_EMAILS_PARAMNAME = "userEmails"; -} diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/BaseSimpleFormController.java b/wise-webapp/src/main/java/com/wisemapping/controller/BaseSimpleFormController.java index cd03b85d..34e38e62 100644 --- a/wise-webapp/src/main/java/com/wisemapping/controller/BaseSimpleFormController.java +++ b/wise-webapp/src/main/java/com/wisemapping/controller/BaseSimpleFormController.java @@ -46,17 +46,10 @@ public class BaseSimpleFormController extends SimpleFormController return mindmapService; } - public void setMindmapService(MindmapService mindmapService) { - this.mindmapService = mindmapService; - } - public String getErrorView() { return errorView; } - public void setErrorView(String errorView) { - this.errorView = errorView; - } @Override protected org.springframework.web.servlet.ModelAndView showForm(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, org.springframework.validation.BindException bindException) throws java.lang.Exception { @@ -69,15 +62,6 @@ public class BaseSimpleFormController extends SimpleFormController } return view; } - - /* TODO codigo repetido en BaseMultiActionController */ - protected MindMap getMindmapFromRequest(HttpServletRequest request) { - final String mapIdStr = request.getParameter(BaseMultiActionController.MAP_ID_PARAMNAME); - assert mapIdStr != null : "mapId parameter can not be null"; - logger.info("MapIdStr:" + mapIdStr); - int mapId = Integer.parseInt(mapIdStr); - return mindmapService.getMindmapById(mapId); - } } diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/HistoryController.java b/wise-webapp/src/main/java/com/wisemapping/controller/HistoryController.java deleted file mode 100755 index 57aff50f..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/controller/HistoryController.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -* 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. -*/ - -package com.wisemapping.controller; - -import com.wisemapping.model.MindMap; -import com.wisemapping.model.MindMapHistory; -import com.wisemapping.view.HistoryBean; -import com.wisemapping.view.MindMapBean; -import org.springframework.web.servlet.ModelAndView; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class HistoryController - extends BaseMultiActionController -{ - private static final String HISTORY_ID = "historyId"; - - public ModelAndView list(HttpServletRequest request, HttpServletResponse response) - throws java.lang.Exception { - - final MindMap map = getMindmapFromRequest(request); - final List historyBeanList = createHistoryBeanList(map); - - final Map attr = new HashMap(); - attr.put("minmap",new MindMapBean(map)); - attr.put("goToMindmapList",request.getParameter("goToMindmapList")); - attr.put("historyBeanList",historyBeanList); - return new ModelAndView("mindmapHistory",attr); - } - - public ModelAndView revert(HttpServletRequest request, HttpServletResponse response) - throws java.lang.Exception { - - final MindMap map = getMindmapFromRequest(request); - final int revertId = Integer.parseInt(request.getParameter(HISTORY_ID)); - getMindmapService().revertMapToHistory(map, revertId); - final StringBuilder redirectionTo = new StringBuilder("redirect:"); - - String goToMindmapList = request.getParameter("goToMindmapList"); - if (goToMindmapList != null) - { - redirectionTo.append("maps/"); - } - else - { - redirectionTo.append("editor?mapId="); - redirectionTo.append(map.getId()); - redirectionTo.append("&action=open"); - } - return new ModelAndView(redirectionTo.toString()); - } - - private List createHistoryBeanList(MindMap map) { - final List list = getMindmapService().getMindMapHistory(map.getId()); - final List historyBeanList = new ArrayList(list.size()); - for (MindMapHistory mindMapHistory : list) { - historyBeanList.add(new HistoryBean(mindMapHistory.getMindmapId(),mindMapHistory.getId(),mindMapHistory.getCreator(),mindMapHistory.getCreationTime())); - } - return historyBeanList; - } -} diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/SettingsController.java b/wise-webapp/src/main/java/com/wisemapping/controller/SettingsController.java index 4cc69378..75ec1ee4 100755 --- a/wise-webapp/src/main/java/com/wisemapping/controller/SettingsController.java +++ b/wise-webapp/src/main/java/com/wisemapping/controller/SettingsController.java @@ -24,7 +24,7 @@ import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMeth import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -public class SettingsController extends BaseMultiActionController { +public class SettingsController { public ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/TagsController.java b/wise-webapp/src/main/java/com/wisemapping/controller/TagsController.java index 80f93d98..7d8587d8 100644 --- a/wise-webapp/src/main/java/com/wisemapping/controller/TagsController.java +++ b/wise-webapp/src/main/java/com/wisemapping/controller/TagsController.java @@ -37,7 +37,7 @@ public class TagsController //~ Methods .............................................................................................. protected Object formBackingObject(HttpServletRequest httpServletRequest) throws Exception { - final MindMap mindmap = getMindmapFromRequest(httpServletRequest); + final MindMap mindmap = null; final User user = Utils.getUser(httpServletRequest); final User dbUser = getUserService().getUserBy(user.getId()); diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java index 0790ece2..fb431efd 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java @@ -47,7 +47,7 @@ public interface MindmapManager { void saveMindmap(MindMap mindMap); - void updateMindmap(MindMap mindMap, boolean saveHistory); + void updateMindmap(@NotNull MindMap mindMap, boolean saveHistory); void removeCollaborator(@NotNull Collaborator collaborator); diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java index 06bd9eed..e96bbfcc 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java @@ -1,4 +1,3 @@ - /* * Copyright [2011] [wisemapping] * @@ -20,11 +19,8 @@ package com.wisemapping.ncontroller; -import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.filter.UserAgent; import com.wisemapping.model.MindMap; -import com.wisemapping.model.Collaboration; -import com.wisemapping.model.User; import com.wisemapping.security.Utils; import com.wisemapping.service.MindmapService; import com.wisemapping.view.MindMapBean; @@ -32,77 +28,100 @@ import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; @Controller public class MindmapController { - private String baseUrl; - @Qualifier("mindmapService") @Autowired private MindmapService mindmapService; - @RequestMapping(value = "maps/{id}/export") - public ModelAndView showExportPage(@PathVariable int id) throws IOException { - final MindMapBean modelObject = findMindmapBean(id); - return new ModelAndView("mindmapExport", "mindmap", modelObject); - } - @RequestMapping(value = "maps/import") - public ModelAndView showImportPAge() throws IOException { - return new ModelAndView("mindmapImport"); - } - - @RequestMapping(value = "maps/{id}/exportf") - public ModelAndView showExportPageFull(@PathVariable int id) throws IOException { - final MindMapBean modelObject = findMindmapBean(id); - return new ModelAndView("mindmapExportFull", "mindmap", modelObject); + public String showImportPage() { + return "mindmapImport"; } @RequestMapping(value = "maps/{id}/details") - public ModelAndView showDetails(@PathVariable int id) { - final MindMapBean modelObject = findMindmapBean(id); - final ModelAndView view = new ModelAndView("mindmapDetail", "wisemapDetail", modelObject); - view.addObject("user", Utils.getUser()); - return view; + public String showDetails(@PathVariable int id, @NotNull Model model) { + final MindMapBean mindmap = findMindmapBean(id); + model.addAttribute("mindmap", mindmap); + return "mindmapDetail"; } @RequestMapping(value = "maps/{id}/print") - public ModelAndView showPrintPage(@PathVariable int id) { + public String showPrintPage(@PathVariable int id, @NotNull Model model) { final MindMap mindmap = findMindmap(id); - return new ModelAndView("mindmapPrint", "mindmap", mindmap); + model.addAttribute("mindmap", mindmap); + return "mindmapPrint"; + } + + @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"; + } + + @RequestMapping(value = "maps/{id}/export") + public String showExportPage(@PathVariable int id, @NotNull Model model) throws IOException { + final MindMap mindmap = findMindmap(id); + 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"; } @RequestMapping(value = "maps/{id}/share") - public ModelAndView showSharePage(@PathVariable int id) { + public String showSharePage(@PathVariable int id, @NotNull Model model) { final MindMap mindmap = findMindmap(id); - return new ModelAndView("mindmapShare", "mindmap", mindmap); + model.addAttribute("mindmap", mindmap); + return "mindmapShare"; } @RequestMapping(value = "maps/{id}/sharef") - public ModelAndView showSharePageFull(@PathVariable int id) { - final MindMap mindmap = findMindmap(id); - return new ModelAndView("mindmapShareFull", "mindmap", mindmap); + public String showSharePageFull(@PathVariable int id, @NotNull Model model) { + showSharePage(id, model); + return "mindmapShareFull"; } @RequestMapping(value = "maps/{id}/publish") - public ModelAndView showPublishPage(@PathVariable int id) { + public String showPublishPage(@PathVariable int id, @NotNull Model model) { final MindMap mindmap = findMindmap(id); - return new ModelAndView("mindmapPublish", "mindmap", mindmap); + model.addAttribute("mindmap", mindmap); + return "mindmapPublish"; } @RequestMapping(value = "maps/{id}/publishf") - public ModelAndView showPublishPageFull(@PathVariable int id) { - final MindMap mindmap = findMindmap(id); - return new ModelAndView("mindmapPublishFull", "mindmap", mindmap); + 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"; } @RequestMapping(value = "maps/{id}/edit") @@ -114,7 +133,7 @@ public class MindmapController { // view.addObject(MINDMAP_ID_PARAMETER, mindmapId); } else { - final MindMap mindmap = mindmapService.getMindmapById(id); + final MindMapBean mindmap = findMindmapBean(id); view = new ModelAndView("mindmapEditor", "mindmap", mindmap); view.addObject("editorTryMode", false); final boolean showHelp = isWelcomeMap(mindmap); @@ -125,9 +144,8 @@ public class MindmapController { } @RequestMapping(value = "maps/{id}/embed") - public ModelAndView embeddedView(@PathVariable int id, @RequestParam(required = false) Float zoom, @NotNull HttpServletRequest request) { + public ModelAndView embeddedView(@PathVariable int id, @RequestParam(required = false) Float zoom) { ModelAndView view; - final UserAgent userAgent = UserAgent.create(request); final MindMap mindmap = mindmapService.getMindmapById(id); view = new ModelAndView("mindmapEmbedded", "mindmap", mindmap); view.addObject("user", Utils.getUser()); @@ -135,64 +153,6 @@ public class MindmapController { return view; } - @RequestMapping(value = "collaborator") - public ModelAndView showCollaborator(@RequestParam(required = true) long mapId) { - final MindMapBean modelObject = findMindmapBean(mapId); - return new ModelAndView("mindmapCollaborator", "mindmap", modelObject); - } - - @RequestMapping(value = "viewer") - public ModelAndView viewer(@RequestParam(required = true) long mapId) { - final MindMapBean modelObject = findMindmapBean(mapId); - return new ModelAndView("mindmapViewer", "wisemapsList", modelObject); - } - - @RequestMapping(value = "changeStatus") - public ModelAndView changeStatus(@RequestParam(required = true) long mapId) throws WiseMappingException { - final MindMap mindmap = findMindmap(mapId); - boolean isPublic = !mindmap.isPublic(); - mindmap.setPublic(isPublic); - mindmapService.updateMindmap(mindmap, false); - return new ModelAndView("mindmapDetail", "wisemapDetail", new MindMapBean(mindmap)); - } - - @RequestMapping(value = "maps/") - public ModelAndView list(@NotNull HttpServletRequest request) { - final HttpSession session = request.getSession(false); - - // Try to loaded from the request ... - UserAgent userAgent = null; - if (session != null) { - userAgent = (UserAgent) session.getAttribute(USER_AGENT); - } - - // I could not loaded. I will create a new one... - if (userAgent == null) { - userAgent = UserAgent.create(request); - if (session != null) { - session.setAttribute(USER_AGENT, userAgent); - } - } - - // It's a supported browser ?. - final UserAgent.OS os = userAgent.getOs(); - - final User user = Utils.getUser(); - final ModelAndView view = new ModelAndView("mindmapList", "wisemapsList", findMindMapBeanList(user)); - view.addObject("isMAC", os == UserAgent.OS.MAC); - view.addObject("user", user); - return view; - } - - @RequestMapping(value = "updateMindmap") - public ModelAndView updateMindmap(@RequestParam(required = true) long mapId, @RequestParam(required = true) String title, @RequestParam(required = true) String description, @NotNull HttpServletRequest request) throws WiseMappingException { - final MindMap mindmap = findMindmap(mapId); - mindmap.setTitle(title); - mindmap.setDescription(description); - - mindmapService.updateMindmap(mindmap, false); - return list(request); - } private MindMap findMindmap(long mapId) { final MindMap mindmap = mindmapService.getMindmapById((int) mapId); @@ -202,24 +162,11 @@ public class MindmapController { return mindmap; } - private List findMindMapBeanList(@NotNull User user) { - final List userMindmaps = mindmapService.getCollaborationsBy(user); - - final List mindMapBeans = new ArrayList(userMindmaps.size()); - for (Collaboration mindmap : userMindmaps) { - mindMapBeans.add(new MindMapBean(mindmap.getMindMap())); - } - return mindMapBeans; - } - private MindMapBean findMindmapBean(long mapId) { return new MindMapBean(findMindmap(mapId)); } - private boolean isWelcomeMap(MindMap map) { + private boolean isWelcomeMap(MindMapBean map) { return map.getTitle().startsWith("Welcome "); } - - - private static final String USER_AGENT = "wisemapping.userAgent"; } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 578f1e67..7d5ab6c7 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -105,13 +105,12 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/history", produces = {"application/json", "text/html", "application/xml"}) public ModelAndView retrieveHistory(@PathVariable int id) throws IOException { - final MindMap mindMap = mindmapService.getMindmapById(id); - final Set collaborations = mindMap.getCollaborations(); - final RestCollaborationList result = new RestCollaborationList(); - for (Collaboration collaboration : collaborations) { - result.addCollaboration(new RestCollaboration(collaboration)); + final List histories = mindmapService.getMindMapHistory(id); + final RestMindmapHistoryList result = new RestMindmapHistoryList(); + for (MindMapHistory history : histories) { + result.addHistory(new RestMindmapHistory(history)); } - return new ModelAndView("collabView", "list", result); + return new ModelAndView("historyView", "list", result); } @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"}) @@ -410,7 +409,7 @@ public class MindmapController extends BaseController { final Calendar now = Calendar.getInstance(); mindMap.setLastModificationTime(now); mindMap.setLastModifierUser(user.getUsername()); - mindmapService.updateMindmap(mindMap, minor); + mindmapService.updateMindmap(mindMap, !minor); } private ValidationException buildValidationException(@NotNull String fieldName, @NotNull String message) throws ValidationException { diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java new file mode 100644 index 00000000..ff1eaed9 --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java @@ -0,0 +1,76 @@ +package com.wisemapping.rest.model; + + +import com.wisemapping.model.Collaboration; +import com.wisemapping.model.Collaborator; +import com.wisemapping.model.MindMap; +import com.wisemapping.model.MindMapHistory; +import com.wisemapping.security.Utils; +import org.codehaus.jackson.annotate.JsonAutoDetect; +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +@XmlRootElement(name = "history") +@XmlAccessorType(XmlAccessType.PROPERTY) +@JsonAutoDetect( + fieldVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, + isGetterVisibility = JsonAutoDetect.Visibility.NONE, + getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY +) +@JsonIgnoreProperties(ignoreUnknown = true) +public class RestMindmapHistory { + + static private SimpleDateFormat sdf; + private int id; + private Calendar creation; + private String creator; + + static { + sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); + sdf.setTimeZone(TimeZone.getTimeZone("UTC")); + } + + public RestMindmapHistory(@NotNull MindMapHistory history) { + this.id = history.getId(); + this.creation = history.getCreationTime(); + this.creator = history.getCreator(); + } + + public String getCreationTime() { + return this.toISO8601(creation.getTime()); + } + + public void setCreationTime() { + + } + + public String getCreator() { + return creator; + } + + public void setCreator() { + // Do nothing ... + } + + public void setId(int id) { + } + + private String toISO8601(@NotNull Date date) { + return sdf.format(date) + "Z"; + } + + public int getId() { + return id; + } +} diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistoryList.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistoryList.java new file mode 100644 index 00000000..465cd4ff --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistoryList.java @@ -0,0 +1,44 @@ +package com.wisemapping.rest.model; + + +import org.codehaus.jackson.annotate.JsonAutoDetect; +import org.jetbrains.annotations.NotNull; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "history") +@XmlAccessorType(XmlAccessType.PROPERTY) +@JsonAutoDetect( + fieldVisibility = JsonAutoDetect.Visibility.NONE, + getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, + isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY) +public class RestMindmapHistoryList { + + private List changes; + + public RestMindmapHistoryList() { + changes = new ArrayList(); + } + + public int getCount() { + return this.changes.size(); + } + + public void setCount(int count) { + + } + + @XmlElement(name = "changes") + public List getChanges() { + return changes; + } + + public void addHistory(@NotNull RestMindmapHistory history) { + changes.add(history); + } +} diff --git a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java index 0519cbfb..386f330c 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java @@ -88,7 +88,6 @@ public class MindmapServiceImpl if (mindMap.getTitle() == null || mindMap.getTitle().length() == 0) { throw new WiseMappingException("The tile can not be empty"); } - mindmapManager.updateMindmap(mindMap, saveHistory); } diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/Utils.java b/wise-webapp/src/main/java/com/wisemapping/validator/Utils.java index 8bd2065b..25d3d58d 100644 --- a/wise-webapp/src/main/java/com/wisemapping/validator/Utils.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/Utils.java @@ -26,7 +26,7 @@ import java.util.regex.Matcher; import com.wisemapping.controller.Messages; -public class Utils { +final public class Utils { //Set the email emailPattern string static private Pattern emailPattern = Pattern.compile(".+@.+\\.[a-z]+"); diff --git a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java index f6c24ae1..7b44927b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java @@ -24,6 +24,7 @@ import com.wisemapping.model.MindMap; import com.wisemapping.model.User; import com.wisemapping.security.Utils; +import java.io.IOException; import java.text.DateFormat; import java.util.*; @@ -34,12 +35,8 @@ public class MindMapBean { public MindMapBean(final MindMap mindmap) { this.mindMap = mindmap; - this.colaborators = getColaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR); - this.viewers = getColaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER); - } - - public MindMap getMindMap() { - return mindMap; + this.colaborators = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR); + this.viewers = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER); } public boolean getPublic() { @@ -86,7 +83,7 @@ public class MindMapBean { return mindMap.getTags(); } - private List getColaboratorBy(Set source, CollaborationRole role) { + private List filterCollaboratorBy(Set source, CollaborationRole role) { List col = new ArrayList(); if (source != null) { for (Collaboration mu : source) { @@ -98,7 +95,7 @@ public class MindMapBean { return col; } - public int getCountColaborators() { + public int getCountCollaborators() { return colaborators != null ? colaborators.size() : 0; } @@ -107,7 +104,7 @@ public class MindMapBean { } public int getCountShared() { - return getCountColaborators() + getCountViewers(); + return getCountCollaborators() + getCountViewers(); } public boolean isShared() { @@ -122,7 +119,20 @@ public class MindMapBean { mindMap.setDescription(d); } + public String getXmlAsJsLiteral() throws IOException { + return this.mindMap.getXmlAsJsLiteral(); + } + + public String getProperties() { + return this.mindMap.getProperties(); + } + public User getCreator() { return mindMap.getCreator(); } + + public boolean isOwner() { + return mindMap.hasPermissions(Utils.getUser(), CollaborationRole.OWNER); + } + } diff --git a/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml b/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml index a2f617a1..3116be1f 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/defs/definitions.xml @@ -106,12 +106,6 @@ - - - - - - @@ -148,16 +142,22 @@ - - - - - - + + + + + + + + + + + + @@ -168,9 +168,16 @@ - - - - + + + + + + + + + + + diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml index 57671a0c..fcb6c7a2 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml @@ -3,6 +3,11 @@ + + + + + diff --git a/wise-webapp/src/main/webapp/js/mymaps.js b/wise-webapp/src/main/webapp/js/mymaps.js index 822ede78..1603df9a 100644 --- a/wise-webapp/src/main/webapp/js/mymaps.js +++ b/wise-webapp/src/main/webapp/js/mymaps.js @@ -433,6 +433,10 @@ $(function() { showEmbeddedDialog("c/maps/{mapId}/details", 'info-dialog-modal'); }); + $("#historyBtn").click(function() { + showEmbeddedDialog("c/maps/{mapId}/history", 'history-dialog-modal'); + }); + $("#publishBtn").click(function() { showEmbeddedDialog("c/maps/{mapId}/publish", "publish-dialog-modal"); }); diff --git a/wise-webapp/src/main/webapp/jsp/dialogFullTemplate.jsp b/wise-webapp/src/main/webapp/jsp/dialogFullTemplate.jsp index 5c6a8c9d..b34bc117 100644 --- a/wise-webapp/src/main/webapp/jsp/dialogFullTemplate.jsp +++ b/wise-webapp/src/main/webapp/jsp/dialogFullTemplate.jsp @@ -13,6 +13,7 @@ +
diff --git a/wise-webapp/src/main/webapp/jsp/login.jsp b/wise-webapp/src/main/webapp/jsp/login.jsp index f1d7da4f..50e6b1a5 100644 --- a/wise-webapp/src/main/webapp/jsp/login.jsp +++ b/wise-webapp/src/main/webapp/jsp/login.jsp @@ -15,7 +15,7 @@

What is New:

    -
  • Complerly new UI
  • +
  • New User Interface
  • FreeMind 0.9 Update
  • Improved HTML 5.0 Support
  • Firefox 12 officially supported
  • diff --git a/wise-webapp/src/main/webapp/jsp/mindmapDetail.jsp b/wise-webapp/src/main/webapp/jsp/mindmapDetail.jsp index 75430aa3..dc4ef4f1 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapDetail.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapDetail.jsp @@ -1,5 +1,5 @@ <%@ include file="/jsp/init.jsp" %> -<%--@elvariable id="wisemapDetail" type="com.wisemapping.view.MindMapBean"--%> +<%--@elvariable id="mindmap" type="com.wisemapping.view.MindMapBean"--%>