2012-10-04 20:48:01 -03:00
|
|
|
/*
|
2022-02-22 14:16:50 -08:00
|
|
|
* Copyright [2015] [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-10-04 20:48:01 -03:00
|
|
|
|
2012-02-17 10:42:20 -03:00
|
|
|
package com.wisemapping.rest.model;
|
|
|
|
|
|
|
|
|
2020-11-06 21:35:54 -08:00
|
|
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
2022-02-22 14:16:50 -08:00
|
|
|
import com.wisemapping.exceptions.InvalidMindmapException;
|
2012-06-09 22:55:55 -03:00
|
|
|
import com.wisemapping.exceptions.WiseMappingException;
|
2021-12-24 18:03:23 -08:00
|
|
|
import com.wisemapping.model.*;
|
2012-09-15 11:35:53 -03:00
|
|
|
import com.wisemapping.util.TimeUtils;
|
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
|
|
|
|
2014-01-25 03:13:51 -03:00
|
|
|
import javax.xml.bind.annotation.XmlAccessType;
|
|
|
|
import javax.xml.bind.annotation.XmlAccessorType;
|
|
|
|
import javax.xml.bind.annotation.XmlRootElement;
|
2012-02-17 10:42:20 -03:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
|
|
|
@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
|
2021-12-24 18:03:23 -08:00
|
|
|
private final Collaborator collaborator;
|
2012-02-21 14:22:43 -03:00
|
|
|
@JsonIgnore
|
2021-12-24 18:03:23 -08:00
|
|
|
private final Mindmap mindmap;
|
2012-09-15 11:35:53 -03:00
|
|
|
@Nullable
|
2012-06-17 21:43:34 -03:00
|
|
|
private String properties;
|
2012-04-07 21:35:01 -03:00
|
|
|
|
2012-06-17 21:43:34 -03:00
|
|
|
public RestMindmap() throws WiseMappingException {
|
2012-08-15 21:28:51 -03:00
|
|
|
this(new Mindmap(), null);
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
2012-08-15 21:28:51 -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-09-15 11:35:53 -03:00
|
|
|
final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(collaborator, false);
|
|
|
|
if (collaborationProperties != null) {
|
|
|
|
this.properties = collaborationProperties.getMindmapProperties();
|
|
|
|
}
|
2012-06-17 21:43:34 -03:00
|
|
|
}
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
2022-02-22 14:16:50 -08:00
|
|
|
public void setCreationTime(final String creationTime) {
|
2014-01-25 03:13:51 -03:00
|
|
|
// Ignore
|
|
|
|
}
|
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) {
|
2012-09-15 11:35:53 -03:00
|
|
|
result = TimeUtils.toISO8601(creationTime.getTime());
|
2012-04-07 21:35:01 -03:00
|
|
|
}
|
|
|
|
return result;
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
return mindmap.getDescription();
|
|
|
|
}
|
|
|
|
|
2014-01-25 03:13:51 -03:00
|
|
|
public void setDescription(String description) {
|
|
|
|
mindmap.setDescription(description);
|
|
|
|
}
|
|
|
|
|
2012-02-17 10:42:20 -03:00
|
|
|
public String getTitle() {
|
|
|
|
return mindmap.getTitle();
|
|
|
|
}
|
|
|
|
|
2014-01-25 03:13:51 -03:00
|
|
|
public void setTitle(String title) {
|
|
|
|
mindmap.setTitle(title);
|
|
|
|
}
|
|
|
|
|
2012-02-17 10:42:20 -03:00
|
|
|
public int getId() {
|
|
|
|
return mindmap.getId();
|
|
|
|
}
|
|
|
|
|
2014-01-25 03:13:51 -03:00
|
|
|
public void setId(int id) {
|
|
|
|
mindmap.setId(id);
|
|
|
|
}
|
|
|
|
|
2012-02-17 10:42:20 -03:00
|
|
|
public String getCreator() {
|
2014-01-25 03:13:51 -03:00
|
|
|
final User creator = mindmap.getCreator();
|
|
|
|
return creator != null ? creator.getEmail() : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCreator(String creatorUser) {
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
2014-01-25 03:13:51 -03:00
|
|
|
|
2012-09-15 11:35:53 -03:00
|
|
|
public RestCollaborator getLastModifierUser() {
|
|
|
|
final User lastEditor = mindmap.getLastEditor();
|
|
|
|
|
|
|
|
RestCollaborator result = null;
|
|
|
|
if (lastEditor != null && mindmap.hasPermissions(collaborator, CollaborationRole.EDITOR)) {
|
|
|
|
result = new RestCollaborator(lastEditor);
|
|
|
|
}
|
|
|
|
return result;
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
2014-01-25 03:13:51 -03:00
|
|
|
public void setLastModifierUser(RestUser lastModifierUser) {
|
|
|
|
}
|
|
|
|
|
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) {
|
2012-09-15 11:35:53 -03:00
|
|
|
result = TimeUtils.toISO8601(date.getTime());
|
2012-05-23 21:54:03 -03:00
|
|
|
}
|
|
|
|
return result;
|
2012-02-17 10:42:20 -03:00
|
|
|
}
|
|
|
|
|
2014-01-25 03:13:51 -03:00
|
|
|
public void setLastModificationTime(final String value) {
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-02-22 14:16:50 -08:00
|
|
|
public void setXml(@Nullable String xml) throws IOException, InvalidMindmapException {
|
|
|
|
if (xml != null) {
|
2012-03-14 01:49:05 -03:00
|
|
|
mindmap.setXmlStr(xml);
|
2022-02-22 14:16:50 -08:00
|
|
|
}
|
2012-02-17 10:42:20 -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
|
|
|
}
|
|
|
|
|
2014-01-25 03:13:51 -03:00
|
|
|
public void setOwner(String owner) {
|
2012-02-17 10:42:20 -03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-09-15 11:35:53 -03:00
|
|
|
@Nullable
|
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
|
|
|
}
|
|
|
|
|
2014-01-25 03:13:51 -03:00
|
|
|
public void setProperties(@Nullable String properties) {
|
|
|
|
this.properties = properties;
|
|
|
|
}
|
|
|
|
|
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
|
2012-08-15 21:28:51 -03:00
|
|
|
public Mindmap getDelegated() {
|
2012-02-17 10:42:20 -03:00
|
|
|
return this.mindmap;
|
|
|
|
}
|
|
|
|
}
|