2012-02-17 10:42:20 -03:00
|
|
|
package com.wisemapping.rest.model;
|
|
|
|
|
|
|
|
|
2012-06-09 22:55:55 -03:00
|
|
|
import com.wisemapping.exceptions.WiseMappingException;
|
2012-06-17 21:43:34 -03:00
|
|
|
import com.wisemapping.model.*;
|
2012-02-21 14:22:43 -03:00
|
|
|
import org.codehaus.jackson.annotate.*;
|
2012-02-17 10:42:20 -03:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2012-03-14 01:49:05 -03:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2012-02-17 10:42:20 -03:00
|
|
|
|
2012-06-03 11:16:38 -03:00
|
|
|
import javax.xml.bind.annotation.*;
|
2012-02-17 10:42:20 -03:00
|
|
|
import java.io.IOException;
|
2012-04-07 21:35:01 -03:00
|
|
|
import java.text.SimpleDateFormat;
|
2012-02-17 10:42:20 -03:00
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Date;
|
2012-04-07 21:35:01 -03:00
|
|
|
import java.util.TimeZone;
|
2012-02-17 10:42:20 -03:00
|
|
|
|
|
|
|
@XmlRootElement(name = "map")
|
|
|
|
@XmlAccessorType(XmlAccessType.PROPERTY)
|
2012-02-21 14:22:43 -03:00
|
|
|
@JsonAutoDetect(
|
|
|
|
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
|
|
|
setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
|
|
|
isGetterVisibility = JsonAutoDetect.Visibility.NONE,
|
|
|
|
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY
|
|
|
|
)
|
2012-03-14 01:49:05 -03:00
|
|
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
2012-02-19 21:07:24 -03:00
|
|
|
public class RestMindmap {
|
2012-05-29 22:36:32 -03:00
|
|
|
@JsonIgnore
|
|
|
|
private Collaborator collaborator;
|
2012-02-21 14:22:43 -03:00
|
|
|
@JsonIgnore
|
2012-02-17 10:42:20 -03:00
|
|
|
private MindMap mindmap;
|
2012-04-07 21:35:01 -03:00
|
|
|
@JsonIgnore
|
|
|
|
static private SimpleDateFormat sdf;
|
2012-06-17 21:43:34 -03:00
|
|
|
private String properties;
|
2012-04-07 21:35:01 -03:00
|
|
|
|
|
|
|
static {
|
|
|
|
sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
|
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
|
|
}
|
2012-02-17 10:42:20 -03:00
|
|
|
|
2012-06-17 21:43:34 -03:00
|
|
|
public RestMindmap() throws WiseMappingException {
|
2012-06-09 22:49:54 -03:00
|
|
|
this(new MindMap(), null);
|
2012-02-17 10:42:20 -03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-17 21:43:34 -03:00
|
|
|
public RestMindmap(@NotNull MindMap mindmap, @Nullable Collaborator collaborator) throws WiseMappingException {
|
2012-02-17 10:42:20 -03:00
|
|
|
this.mindmap = mindmap;
|
2012-05-29 22:36:32 -03:00
|
|
|
this.collaborator = collaborator;
|
2012-06-17 21:43:34 -03:00
|
|
|
if (collaborator != null) {
|
2012-06-17 23:21:02 -03:00
|
|
|
final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(collaborator);
|
2012-06-17 21:43:34 -03:00
|
|
|
this.properties = collaborationProperties.getMindmapProperties();
|
|
|
|
}
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
2012-06-17 21:43:34 -03:00
|
|
|
|
2012-04-07 21:35:01 -03:00
|
|
|
public String getCreationTime() {
|
|
|
|
final Calendar creationTime = mindmap.getCreationTime();
|
|
|
|
String result = null;
|
|
|
|
if (creationTime != null) {
|
|
|
|
result = this.toISO8601(creationTime.getTime());
|
|
|
|
}
|
|
|
|
return result;
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
return mindmap.getDescription();
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTags() {
|
|
|
|
return mindmap.getTags();
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTitle() {
|
|
|
|
return mindmap.getTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getId() {
|
|
|
|
return mindmap.getId();
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getCreator() {
|
2012-06-12 11:23:47 -03:00
|
|
|
return mindmap.getCreator().getEmail();
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getLastModifierUser() {
|
|
|
|
return mindmap.getLastModifierUser();
|
|
|
|
}
|
|
|
|
|
2012-04-07 21:35:01 -03:00
|
|
|
public String getLastModificationTime() {
|
|
|
|
final Calendar date = mindmap.getLastModificationTime();
|
2012-05-23 21:54:03 -03:00
|
|
|
String result = null;
|
|
|
|
if (date != null) {
|
|
|
|
result = toISO8601(date.getTime());
|
|
|
|
}
|
|
|
|
return result;
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isPublic() {
|
|
|
|
return mindmap.isPublic();
|
|
|
|
}
|
|
|
|
|
2012-04-06 17:05:42 -03:00
|
|
|
|
|
|
|
public void setPublic(boolean value) {
|
2012-04-07 21:35:01 -03:00
|
|
|
// return mindmap.isPublic();
|
2012-04-06 17:05:42 -03:00
|
|
|
}
|
|
|
|
|
2012-02-17 10:42:20 -03:00
|
|
|
public String getXml() throws IOException {
|
2012-02-21 14:22:43 -03:00
|
|
|
return mindmap.getXmlStr();
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
2012-06-03 11:16:38 -03:00
|
|
|
|
2012-03-14 01:49:05 -03:00
|
|
|
public void setXml(@Nullable String xml) throws IOException {
|
2012-02-17 10:42:20 -03:00
|
|
|
|
2012-03-14 01:49:05 -03:00
|
|
|
if (xml != null)
|
|
|
|
mindmap.setXmlStr(xml);
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setId(int id) {
|
|
|
|
mindmap.setId(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTitle(String title) {
|
|
|
|
mindmap.setTitle(title);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTags(String tags) {
|
|
|
|
mindmap.setTags(tags);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDescription(String description) {
|
|
|
|
mindmap.setDescription(description);
|
|
|
|
}
|
|
|
|
|
2012-06-03 11:16:38 -03:00
|
|
|
public void setOwner(String owner) {
|
|
|
|
|
|
|
|
}
|
2012-03-14 01:49:05 -03:00
|
|
|
|
2012-06-03 11:16:38 -03:00
|
|
|
public String getOwner() {
|
2012-06-12 11:23:47 -03:00
|
|
|
final User owner = mindmap.getCreator();
|
2012-06-09 22:49:54 -03:00
|
|
|
return owner != null ? owner.getEmail() : null;
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setCreator(String creatorUser) {
|
|
|
|
}
|
|
|
|
|
2012-02-21 14:22:43 -03:00
|
|
|
|
2012-06-17 21:43:34 -03:00
|
|
|
public void setProperties(@Nullable String properties) {
|
|
|
|
this.properties = properties;
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
2012-04-07 21:35:01 -03:00
|
|
|
public void setLastModificationTime(final String value) {
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setLastModifierUser(String lastModifierUser) {
|
|
|
|
}
|
|
|
|
|
2012-02-21 14:22:43 -03:00
|
|
|
public String getProperties() {
|
2012-06-17 21:43:34 -03:00
|
|
|
return properties;
|
2012-02-21 14:22:43 -03:00
|
|
|
}
|
|
|
|
|
2012-05-29 22:36:32 -03:00
|
|
|
public boolean getStarred() {
|
|
|
|
boolean result = false;
|
|
|
|
if (collaborator != null) {
|
|
|
|
result = mindmap.isStarred(collaborator);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-06-09 22:55:55 -03:00
|
|
|
public void setStarred(boolean value) throws WiseMappingException {
|
2012-06-06 00:48:46 -03:00
|
|
|
if (collaborator != null) {
|
|
|
|
mindmap.setStarred(collaborator, value);
|
|
|
|
}
|
2012-05-29 22:36:32 -03:00
|
|
|
}
|
|
|
|
|
2012-02-17 10:42:20 -03:00
|
|
|
@JsonIgnore
|
|
|
|
public MindMap getDelegated() {
|
|
|
|
return this.mindmap;
|
|
|
|
}
|
2012-04-07 21:35:01 -03:00
|
|
|
|
|
|
|
private String toISO8601(@Nullable Date date) {
|
|
|
|
String result = "";
|
|
|
|
if (date != null) {
|
|
|
|
result = sdf.format(date) + "Z";
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|