- Add support for starred.

- Remove tags temporally.
This commit is contained in:
Paulo Gustavo Veiga
2012-05-29 22:36:32 -03:00
parent 5d1399017f
commit 4f95ad04ca
32 changed files with 368 additions and 72 deletions

View File

@@ -1,3 +1,21 @@
/*
* 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.rest;
@@ -35,8 +53,9 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/json", "text/html", "application/xml"})
@ResponseBody
public ModelAndView getMindmap(@PathVariable int id) throws IOException {
final User user = com.wisemapping.security.Utils.getUser();
final MindMap mindMap = mindmapService.getMindmapById(id);
final RestMindmap map = new RestMindmap(mindMap);
final RestMindmap map = new RestMindmap(mindMap, user);
return new ModelAndView("mapView", "map", map);
}
@@ -54,7 +73,7 @@ public class MindmapController extends BaseController {
mindmaps.add(mindmap);
}
}
final RestMindmapList restMindmapList = new RestMindmapList(mindmaps);
final RestMindmapList restMindmapList = new RestMindmapList(mindmaps, user);
return new ModelAndView("mapsView", "list", restMindmapList);
}
@@ -137,7 +156,7 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/title", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void changeMapTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException {
public void updateMapTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException {
final MindMap mindMap = mindmapService.getMindmapById(id);
final User user = Utils.getUser();
@@ -156,7 +175,7 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/description", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void changeMapDescription(@RequestBody String description, @PathVariable int id) throws WiseMappingException {
public void updateMapDescription(@RequestBody String description, @PathVariable int id) throws WiseMappingException {
final MindMap mindMap = mindmapService.getMindmapById(id);
final User user = Utils.getUser();
@@ -169,7 +188,7 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/publish", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void changeMapPublish(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
public void updatePublishState(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
final MindMap mindMap = mindmapService.getMindmapById(id);
final User user = Utils.getUser();
@@ -184,6 +203,18 @@ public class MindmapController extends BaseController {
}
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/starred", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateStarredState(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
final MindMap mindMap = mindmapService.getMindmapById(id);
final User user = Utils.getUser();
// Update map status ...
mindMap.setStarred(user, Boolean.parseBoolean(value));
updateMindmap(true, mindMap, user);
}
@RequestMapping(method = RequestMethod.DELETE, value = "/maps/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateMap(@PathVariable int id) throws IOException, WiseMappingException {

View File

@@ -1,5 +1,24 @@
package com.wisemapping.rest;
/*
* 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.rest;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.User;
@@ -20,6 +39,12 @@ public enum MindmapFilter {
return mindmap.getOwner().equals(user);
}
},
STARRED("starred") {
@Override
boolean accept(@NotNull MindMap mindmap, @NotNull User user) {
return mindmap.isStarred(user);
}
},
SHARED_WITH_ME("shared_with_me") {
@Override
boolean accept(@NotNull MindMap mindmap, @NotNull User user) {

View File

@@ -1,10 +1,10 @@
package com.wisemapping.rest.model;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.User;
import org.codehaus.jackson.annotate.*;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,7 +27,8 @@ import java.util.TimeZone;
)
@JsonIgnoreProperties(ignoreUnknown = true)
public class RestMindmap {
@JsonIgnore
private Collaborator collaborator;
@JsonIgnore
private MindMap mindmap;
@JsonIgnore
@@ -39,12 +40,13 @@ public class RestMindmap {
}
public RestMindmap() {
this(new MindMap());
this(new MindMap(), null);
}
public RestMindmap(@NotNull MindMap mindmap) {
public RestMindmap(@NotNull MindMap mindmap, @NotNull Collaborator collaborator) {
this.mindmap = mindmap;
this.collaborator = collaborator;
}
public String getCreationTime() {
@@ -147,6 +149,18 @@ public class RestMindmap {
return mindmap.getProperties();
}
public boolean getStarred() {
boolean result = false;
if (collaborator != null) {
result = mindmap.isStarred(collaborator);
}
return result;
}
public void setStarred(boolean value) {
mindmap.setStarred(collaborator, value);
}
@JsonIgnore
public MindMap getDelegated() {
return this.mindmap;

View File

@@ -1,6 +1,7 @@
package com.wisemapping.rest.model;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.User;
import org.codehaus.jackson.annotate.*;
@@ -10,7 +11,6 @@ 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.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@@ -29,6 +29,7 @@ public class RestMindmapInfo {
@JsonIgnore
private MindMap mindmap;
private Collaborator collaborator;
@JsonIgnore
static private SimpleDateFormat sdf;
@@ -38,12 +39,13 @@ public class RestMindmapInfo {
}
public RestMindmapInfo() {
this(new MindMap());
this(new MindMap(), null);
}
public RestMindmapInfo(@NotNull MindMap mindmap) {
public RestMindmapInfo(@NotNull MindMap mindmap, @Nullable Collaborator collaborator) {
this.mindmap = mindmap;
this.collaborator = collaborator;
}
public String getCreationTime() {
@@ -93,7 +95,14 @@ public class RestMindmapInfo {
}
public void setId(int id) {
mindmap.setId(id);
}
public boolean getStarred() {
return mindmap.isStarred(collaborator);
}
public void setStarred(int value) {
}
public void setTitle(String title) {

View File

@@ -1,6 +1,7 @@
package com.wisemapping.rest.model;
import com.wisemapping.model.Collaborator;
import com.wisemapping.model.MindMap;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.jetbrains.annotations.NotNull;
@@ -25,13 +26,13 @@ public class RestMindmapList {
private List<RestMindmapInfo> mindmapsInfo;
public RestMindmapList() {
this(Collections.<MindMap>emptyList());
this(Collections.<MindMap>emptyList(), null);
}
public RestMindmapList(@NotNull List<MindMap> mindmaps) {
public RestMindmapList(@NotNull List<MindMap> mindmaps, @NotNull Collaborator collaborator) {
this.mindmapsInfo = new ArrayList<RestMindmapInfo>();
for (MindMap mindMap : mindmaps) {
this.mindmapsInfo.add(new RestMindmapInfo(mindMap));
this.mindmapsInfo.add(new RestMindmapInfo(mindMap, collaborator));
}
}