2011-01-23 20:34:05 -03:00
|
|
|
/*
|
|
|
|
* Copyright [2011] [wisemapping]
|
|
|
|
*
|
2011-01-23 21:03:12 -03:00
|
|
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
|
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
2011-01-23 20:34:05 -03:00
|
|
|
* "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.
|
|
|
|
*/
|
|
|
|
|
2009-06-07 18:59:43 +00:00
|
|
|
package com.wisemapping.view;
|
|
|
|
|
2012-06-09 15:49:19 -03:00
|
|
|
import com.wisemapping.model.Collaboration;
|
|
|
|
import com.wisemapping.model.CollaborationRole;
|
2009-06-07 18:59:43 +00:00
|
|
|
import com.wisemapping.model.MindMap;
|
|
|
|
import com.wisemapping.model.User;
|
2012-06-06 00:48:46 -03:00
|
|
|
import com.wisemapping.security.Utils;
|
2009-06-07 18:59:43 +00:00
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
import java.io.IOException;
|
2009-06-07 18:59:43 +00:00
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
public class MindMapBean {
|
|
|
|
private MindMap mindMap;
|
2012-06-16 19:27:22 -03:00
|
|
|
private List<CollaboratorBean> viewers;
|
2012-06-17 12:24:09 -03:00
|
|
|
private List<CollaboratorBean> collaborators;
|
2009-06-07 18:59:43 +00:00
|
|
|
|
|
|
|
public MindMapBean(final MindMap mindmap) {
|
|
|
|
this.mindMap = mindmap;
|
2012-06-17 12:24:09 -03:00
|
|
|
this.collaborators = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR);
|
2012-06-17 02:51:01 -03:00
|
|
|
this.viewers = filterCollaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER);
|
2009-06-07 18:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean getPublic() {
|
|
|
|
return mindMap.isPublic();
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTitle() {
|
|
|
|
return mindMap.getTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
return mindMap.getDescription();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getId() {
|
|
|
|
return mindMap.getId();
|
|
|
|
}
|
|
|
|
|
2012-06-06 00:48:46 -03:00
|
|
|
public boolean isStarred() {
|
|
|
|
return mindMap.isStarred(Utils.getUser());
|
|
|
|
}
|
|
|
|
|
2012-06-16 19:27:22 -03:00
|
|
|
public List<CollaboratorBean> getViewers() {
|
2009-06-07 18:59:43 +00:00
|
|
|
return viewers;
|
|
|
|
}
|
|
|
|
|
2012-06-16 19:27:22 -03:00
|
|
|
public List<CollaboratorBean> getCollaborators() {
|
2012-06-17 12:24:09 -03:00
|
|
|
return collaborators;
|
2009-06-07 18:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getLastEditor() {
|
|
|
|
return mindMap.getLastModifierUser();
|
|
|
|
}
|
|
|
|
|
2012-05-20 02:25:54 -03:00
|
|
|
public String getLastEditTime() {
|
|
|
|
return DateFormat.getInstance().format(mindMap.getLastModificationTime().getTime());
|
2009-06-07 18:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getCreationTime() {
|
|
|
|
return DateFormat.getInstance().format(mindMap.getCreationTime().getTime());
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTags() {
|
|
|
|
return mindMap.getTags();
|
|
|
|
}
|
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
private List<CollaboratorBean> filterCollaboratorBy(Set<Collaboration> source, CollaborationRole role) {
|
2012-06-16 19:27:22 -03:00
|
|
|
List<CollaboratorBean> col = new ArrayList<CollaboratorBean>();
|
2009-06-07 18:59:43 +00:00
|
|
|
if (source != null) {
|
2012-06-09 15:49:19 -03:00
|
|
|
for (Collaboration mu : source) {
|
2009-06-07 18:59:43 +00:00
|
|
|
if (mu.getRole() == role) {
|
2012-06-16 19:27:22 -03:00
|
|
|
col.add(new CollaboratorBean(mu.getCollaborator(), mu.getRole()));
|
2009-06-07 18:59:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return col;
|
|
|
|
}
|
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
public int getCountCollaborators() {
|
2012-06-17 12:24:09 -03:00
|
|
|
return collaborators != null ? collaborators.size() : 0;
|
2009-06-07 18:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getCountViewers() {
|
|
|
|
return viewers != null ? viewers.size() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCountShared() {
|
2012-06-17 02:51:01 -03:00
|
|
|
return getCountCollaborators() + getCountViewers();
|
2009-06-07 18:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isShared() {
|
|
|
|
return getCountShared() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTitle(String t) {
|
|
|
|
mindMap.setTitle(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDescription(String d) {
|
|
|
|
mindMap.setDescription(d);
|
|
|
|
}
|
|
|
|
|
2012-06-17 02:51:01 -03:00
|
|
|
public String getXmlAsJsLiteral() throws IOException {
|
|
|
|
return this.mindMap.getXmlAsJsLiteral();
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getProperties() {
|
|
|
|
return this.mindMap.getProperties();
|
|
|
|
}
|
|
|
|
|
2012-06-12 11:23:47 -03:00
|
|
|
public User getCreator() {
|
|
|
|
return mindMap.getCreator();
|
2009-06-07 18:59:43 +00:00
|
|
|
}
|
2012-06-17 02:51:01 -03:00
|
|
|
|
|
|
|
public boolean isOwner() {
|
|
|
|
return mindMap.hasPermissions(Utils.getUser(), CollaborationRole.OWNER);
|
|
|
|
}
|
|
|
|
|
2012-06-17 12:24:09 -03:00
|
|
|
public boolean isEditor() {
|
|
|
|
return mindMap.hasPermissions(Utils.getUser(), CollaborationRole.EDITOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
public MindMap getDelegated(){
|
|
|
|
return mindMap;
|
|
|
|
}
|
|
|
|
|
2009-06-07 18:59:43 +00:00
|
|
|
}
|