- 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

@@ -140,10 +140,10 @@ public class FreemindExporter
final String shape = mindmapTopic.getShape();
if (shape != null && !shape.isEmpty()) {
if (isRoot && !ShapeStyle.ROUNDED_RETAGLE.getStyle().endsWith(shape) || !isRoot && !ShapeStyle.LINE.getStyle().endsWith(shape)) {
if (isRoot && !ShapeStyle.ROUNDED_RECTANGLE.getStyle().endsWith(shape) || !isRoot && !ShapeStyle.LINE.getStyle().endsWith(shape)) {
String style = shape;
if (ShapeStyle.ROUNDED_RETAGLE.getStyle().equals(shape)) {
if (ShapeStyle.ROUNDED_RECTANGLE.getStyle().equals(shape)) {
style = "bubble";
}
freemindNode.setSTYLE(style);

View File

@@ -128,7 +128,7 @@ public class FreemindImporter
convertNodeProperties(freeNode, wiseTopic);
wiseTopic.setShape(ShapeStyle.ROUNDED_RETAGLE.getStyle());
wiseTopic.setShape(ShapeStyle.ROUNDED_RECTANGLE.getStyle());
mindmapMap.getTopic().add(wiseTopic);
mindmapMap.setName(mapName);
@@ -631,7 +631,7 @@ public class FreemindImporter
String result = node.getSTYLE();
// In freemind a node without style is a line
if ("bubble".equals(result)) {
result = ShapeStyle.ROUNDED_RETAGLE.getStyle();
result = ShapeStyle.ROUNDED_RECTANGLE.getStyle();
} else {
result = ShapeStyle.LINE.getStyle();
}

View File

@@ -0,0 +1,69 @@
/*
* 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.model;
import org.jetbrains.annotations.NotNull;
public class CollaboratorProperties {
private long id;
private boolean starred;
private Collaborator collaborator;
private MindMap mindmap;
public CollaboratorProperties(@NotNull Collaborator collaborator, @NotNull MindMap mindmap) {
this.collaborator = collaborator;
this.mindmap = mindmap;
}
public CollaboratorProperties(){
}
public boolean getStarred() {
return starred;
}
public void setStarred(boolean starred) {
this.starred = starred;
}
public Collaborator getCollaborator() {
return collaborator;
}
public void setCollaborator(Collaborator collaborator) {
this.collaborator = collaborator;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public MindMap getMindmap() {
return mindmap;
}
public void setMindmap(@NotNull MindMap mindmap) {
this.mindmap = mindmap;
}
}

View File

@@ -19,7 +19,6 @@
package com.wisemapping.model;
import com.wisemapping.util.ZipUtils;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -33,17 +32,18 @@ public class MindMap {
private static final String UTF_8 = "UTF-8";
//~ Instance fields ......................................................................................
private int id;
private Calendar creationTime;
private String creator;
private String description;
private int id;
private boolean isPublic;
private Calendar lastModificationTime;
private String lastModifierUser;
private Set<MindmapUser> mindmapUsers = new HashSet<MindmapUser>();
private Set<CollaboratorProperties> collaboratorProperties = new HashSet<CollaboratorProperties>();
private User owner;
private String properties;
private String tags;
@@ -86,7 +86,7 @@ public class MindMap {
throws IOException {
byte[] result = this.xml;
if (result != null) {
result = ZipUtils.stringToZip(new String(result, UTF_8));
result = ZipUtils.stringToZip(new String(result, UTF_8));
}
return result;
}
@@ -219,6 +219,41 @@ public class MindMap {
return owner;
}
public Set<CollaboratorProperties> getCollaboratorProperties() {
return collaboratorProperties;
}
public void setCollaboratorProperties(@NotNull Set<CollaboratorProperties> collaboratorProperties) {
this.collaboratorProperties = collaboratorProperties;
}
private CollaboratorProperties findUserProperty(@NotNull Collaborator collaborator) {
final Set<CollaboratorProperties> collaboratorProperties = this.getCollaboratorProperties();
CollaboratorProperties result = null;
for (CollaboratorProperties collaboratorProperty : collaboratorProperties) {
final Collaborator propCollab = collaboratorProperty.getCollaborator();
if (propCollab != null && propCollab.getEmail().equals(collaborator.getEmail())) {
result = collaboratorProperty;
break;
}
}
return result;
}
public void setStarred(@NotNull Collaborator collaborator, boolean value) {
CollaboratorProperties collaboratorProperties = this.findUserProperty(collaborator);
if (collaboratorProperties == null) {
collaboratorProperties = new CollaboratorProperties(collaborator, this);
}
collaboratorProperties.setStarred(value);
this.getCollaboratorProperties().add(collaboratorProperties);
}
public boolean isStarred(@NotNull Collaborator collaborator) {
final CollaboratorProperties collaboratorProperty = this.findUserProperty(collaborator);
return collaboratorProperty != null && collaboratorProperty.getStarred();
}
public static String getDefaultMindmapXml(@NotNull final String title) {
final StringBuilder result = new StringBuilder();

View File

@@ -21,9 +21,9 @@ package com.wisemapping.model;
public enum ShapeStyle
{
LINE("line"),
ROUNDED_RETAGLE("rounded rectagle"),
RECTAGLE("rectagle"),
ELIPSE("elipse");
ROUNDED_RECTANGLE("rounded rectagle"),
RECTANGLE("rectagle"),
ELLIPSE("elipse");
private String style;

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));
}
}