129 lines
3.6 KiB
Java
Raw Normal View History

/*
* 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
* "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
import java.text.DateFormat;
import java.util.*;
public class MindMapBean {
private MindMap mindMap;
private List<ColaboratorBean> viewers;
private List<ColaboratorBean> colaborators;
public MindMapBean(final MindMap mindmap) {
this.mindMap = mindmap;
2012-06-09 15:49:19 -03:00
this.colaborators = getColaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR);
this.viewers = getColaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER);
2009-06-07 18:59:43 +00:00
}
public MindMap getMindMap() {
return mindMap;
}
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());
}
2009-06-07 18:59:43 +00:00
public List<ColaboratorBean> getViewers() {
return viewers;
}
public List<ColaboratorBean> getCollaborators() {
return colaborators;
}
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-09 15:49:19 -03:00
private List<ColaboratorBean> getColaboratorBy(Set<Collaboration> source, CollaborationRole role) {
2009-06-07 18:59:43 +00:00
List<ColaboratorBean> col = new ArrayList<ColaboratorBean>();
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) {
col.add(new ColaboratorBean(mu.getCollaborator(), mu.getRole()));
2009-06-07 18:59:43 +00:00
}
}
}
return col;
}
public int getCountColaborators() {
return colaborators != null ? colaborators.size() : 0;
}
public int getCountViewers() {
return viewers != null ? viewers.size() : 0;
}
public int getCountShared() {
return getCountColaborators() + getCountViewers();
}
public boolean isShared() {
return getCountShared() > 0;
}
public void setTitle(String t) {
mindMap.setTitle(t);
}
public void setDescription(String d) {
mindMap.setDescription(d);
}
2012-06-12 11:23:47 -03:00
public User getCreator() {
return mindMap.getCreator();
2009-06-07 18:59:43 +00:00
}
}