169 lines
4.6 KiB
Java
Raw Normal View History

2012-10-04 20:48:01 -03:00
/*
* Copyright [2012] [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-03-15 01:21:46 -03:00
package com.wisemapping.rest.model;
2012-06-12 11:23:47 -03:00
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Collaborator;
2014-01-29 02:56:09 -03:00
import com.wisemapping.model.Label;
import com.wisemapping.model.Mindmap;
2012-03-15 01:21:46 -03:00
import com.wisemapping.model.User;
2012-06-12 11:23:47 -03:00
import com.wisemapping.security.Utils;
2012-09-15 11:35:53 -03:00
import com.wisemapping.util.TimeUtils;
2014-01-25 03:13:51 -03:00
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
2012-03-15 01:21:46 -03:00
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.util.Calendar;
2014-01-29 02:56:09 -03:00
import java.util.HashSet;
import java.util.Set;
2012-03-15 01:21:46 -03:00
@XmlRootElement(name = "map")
@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 RestMindmapInfo {
@JsonIgnore
private Mindmap mindmap;
private Collaborator collaborator;
2012-03-15 01:21:46 -03:00
public RestMindmapInfo() {
this(new Mindmap(), null);
2012-03-15 01:21:46 -03:00
}
public RestMindmapInfo(@NotNull Mindmap mindmap, @Nullable Collaborator collaborator) {
2012-03-15 01:21:46 -03:00
this.mindmap = mindmap;
this.collaborator = collaborator;
2012-03-15 01:21:46 -03:00
}
2014-01-25 04:21:59 -03:00
public void setCreationTime(String value){
// Ignore
}
public String getCreationTime() {
2014-01-25 03:13:51 -03:00
final Calendar creationTime = mindmap.getCreationTime();
return creationTime != null ? TimeUtils.toISO8601(creationTime.getTime()) : null;
2012-03-15 01:21:46 -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-03-15 01:21:46 -03:00
public String getTags() {
return mindmap.getTags();
}
2014-01-25 03:13:51 -03:00
public void setTags(String tags) {
mindmap.setTags(tags);
}
2012-03-15 01:21:46 -03:00
public String getTitle() {
return mindmap.getTitle();
}
2014-01-25 03:13:51 -03:00
public void setTitle(String title) {
mindmap.setTitle(title);
}
2014-01-29 02:56:09 -03:00
public Set<RestLabel> getLabels() {
final Set<RestLabel> result = new HashSet<>();
for (Label label : mindmap.getLabels()) {
result.add(new RestLabel(label));
}
return result;
}
2014-01-25 03:13:51 -03:00
2012-03-15 01:21:46 -03:00
public int getId() {
return mindmap.getId();
}
2014-01-25 03:13:51 -03:00
public void setId(int id) {
}
2012-03-15 01:21:46 -03:00
public String getCreator() {
2014-01-25 03:13:51 -03:00
final User creator = mindmap.getCreator();
return creator!=null?creator.getFullName():null;
}
public void setCreator(String email) {
2012-03-15 01:21:46 -03:00
}
2012-06-12 11:23:47 -03:00
public void setCreator() {
// Do nothing ...
2012-05-20 21:46:55 -03:00
}
2012-06-12 11:23:47 -03:00
public String getRole() {
final Collaboration collaboration = mindmap.findCollaboration(Utils.getUser());
return collaboration != null ? collaboration.getRole().getLabel() : "none";
}
2014-01-25 04:21:59 -03:00
public void setRole(String value) {
2012-06-12 11:23:47 -03:00
// Do nothing ...
2012-05-20 21:46:55 -03:00
}
2012-03-15 01:21:46 -03:00
public String getLastModifierUser() {
2012-07-15 00:57:44 -03:00
final User user = mindmap.getLastEditor();
return user != null ? user.getFullName() : "unknown";
2012-03-15 01:21:46 -03:00
}
2014-01-25 03:13:51 -03:00
public void setLastModifierUser(String value) {
}
public String getLastModificationTime() {
final Calendar calendar = mindmap.getLastModificationTime();
2014-01-25 03:13:51 -03:00
return calendar!=null?TimeUtils.toISO8601(calendar.getTime()):null;
2012-03-15 01:21:46 -03:00
}
2014-01-25 03:13:51 -03:00
public void setLastModificationTime(String value) {
2012-03-15 01:21:46 -03:00
}
2014-01-25 03:13:51 -03:00
public boolean isPublic() {
return mindmap.isPublic();
}
public boolean getStarred() {
return mindmap.isStarred(collaborator);
}
2014-01-25 04:21:59 -03:00
public void setStarred(boolean value) {
2012-03-15 01:21:46 -03:00
}
2012-03-15 21:13:47 -03:00
@JsonIgnore
public Mindmap getDelegated() {
2012-03-15 21:13:47 -03:00
return this.mindmap;
}
2012-03-15 01:21:46 -03:00
}