mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
Rename MindmapUser to Collaboration.
This commit is contained in:
parent
6f923656ee
commit
6c8664ada4
@ -333,7 +333,7 @@ mindplot.widget.Menu = new Class({
|
||||
var shareElem = $('shareIt');
|
||||
if (shareElem) {
|
||||
this._addButton('shareIt', false, false, function() {
|
||||
var reqDialog = new MooDialog.Request('c/mymaps.htm?action=collaborator&mapId=' + mapId, null,
|
||||
var reqDialog = new MooDialog.Request('c/iframeWrapper.htm?url=c/maps/' + mapId + "/publishf", null,
|
||||
{'class': 'modalDialog shareItModalDialog',
|
||||
closeButton:true,
|
||||
destroyOnClose:true,
|
||||
@ -344,9 +344,9 @@ mindplot.widget.Menu = new Class({
|
||||
reqDialog.setContent('loading...');
|
||||
}
|
||||
});
|
||||
|
||||
MooDialog.Request.active = reqDialog;
|
||||
});
|
||||
this._registerTooltip('shareIt', "Collaborators");
|
||||
this._registerTooltip('shareIt', "Share");
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,18 +19,11 @@
|
||||
package com.wisemapping.controller;
|
||||
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.MindMapCriteria;
|
||||
import com.wisemapping.model.MindmapUser;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.UserService;
|
||||
import com.wisemapping.view.MindMapBean;
|
||||
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BaseMultiActionController
|
||||
extends MultiActionController {
|
||||
@ -38,78 +31,17 @@ public abstract class BaseMultiActionController
|
||||
private MindmapService mindmapService;
|
||||
private UserService userService;
|
||||
|
||||
|
||||
protected List<MindMap> getMindmapsFromRequest(HttpServletRequest request) {
|
||||
List<MindMap> result = new ArrayList<MindMap>();
|
||||
final String mindmapIds = request.getParameter("mindmapIds");
|
||||
|
||||
final String ids[] = mindmapIds.split(",");
|
||||
for (String id : ids) {
|
||||
MindMap map = mindmapService.getMindmapById(Integer.parseInt(id));
|
||||
result.add(map);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected List<MindMapBean> getMindMapBeanList(User user) {
|
||||
final List<MindmapUser> userMindmaps = getMindmapService().getMindmapUserByUser(user);
|
||||
|
||||
final List<MindMapBean> mindMapBeans = new ArrayList<MindMapBean>(userMindmaps.size());
|
||||
for (MindmapUser mindmap : userMindmaps) {
|
||||
mindMapBeans.add(new MindMapBean(mindmap.getMindMap()));
|
||||
}
|
||||
return mindMapBeans;
|
||||
}
|
||||
|
||||
protected MindMapCriteria getMindMapCriteriaFromRequest(HttpServletRequest request) {
|
||||
final MindMapCriteria criteria = new MindMapCriteria();
|
||||
|
||||
final String titleOrTags = request.getParameter("titleOrTags");
|
||||
if (titleOrTags != null && titleOrTags.length() != 0) {
|
||||
criteria.orCriteria();
|
||||
criteria.setTitle(titleOrTags);
|
||||
final String tag[] = titleOrTags.split(MindmapService.TAG_SEPARATOR);
|
||||
// Add new Tags to User
|
||||
for (String searchTag : tag) {
|
||||
criteria.getTags().add(searchTag);
|
||||
}
|
||||
}
|
||||
|
||||
final String title = request.getParameter("name");
|
||||
if (title != null && title.length() != 0) {
|
||||
criteria.setTitle(title);
|
||||
}
|
||||
final String description = request.getParameter("description");
|
||||
if (description != null && description.length() != 0) {
|
||||
criteria.setDescription(description);
|
||||
}
|
||||
|
||||
final String tags = request.getParameter("tags");
|
||||
if (tags != null && tags.length() != 0) {
|
||||
final String tag[] = tags.split(MindmapService.TAG_SEPARATOR);
|
||||
// Add new Tags to User
|
||||
for (String searchTag : tag) {
|
||||
criteria.getTags().add(searchTag);
|
||||
}
|
||||
}
|
||||
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected MindMap getMindmapFromRequest(HttpServletRequest request) {
|
||||
final String mapIdStr = request.getParameter(MAP_ID_PARAMNAME);
|
||||
assert mapIdStr != null : "mapId parameter can not be null";
|
||||
logger.info("MapIdStr:" + mapIdStr);
|
||||
MindMap map = null;
|
||||
int mapId;
|
||||
try
|
||||
{
|
||||
try {
|
||||
mapId = Integer.parseInt(mapIdStr);
|
||||
map = mindmapService.getMindmapById(mapId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.debug("An error ocurred trying to get mapId "+ mapIdStr + "'",e);
|
||||
} catch (Exception e) {
|
||||
logger.debug("An error ocurred trying to get mapId " + mapIdStr + "'", e);
|
||||
}
|
||||
|
||||
if (map == null) {
|
||||
@ -118,13 +50,6 @@ public abstract class BaseMultiActionController
|
||||
return map;
|
||||
}
|
||||
|
||||
private MindmapUser getMindmapUser(Integer mapId, HttpServletRequest request) {
|
||||
assert mapId != null : "EDIT action: mindmapId is required!";
|
||||
assert request != null : "EDIT action: request is required!";
|
||||
final User user = Utils.getUser(request);
|
||||
return mindmapService.getMindmapUserBy(mapId, user);
|
||||
}
|
||||
|
||||
public MindmapService getMindmapService() {
|
||||
return mindmapService;
|
||||
}
|
||||
@ -143,5 +68,4 @@ public abstract class BaseMultiActionController
|
||||
|
||||
public static final String MAP_ID_PARAMNAME = "mapId";
|
||||
public static final String MINDMAP_EMAILS_PARAMNAME = "userEmails";
|
||||
public static final String MINDMAP_EMAIL_PARAMNAME = "userEmail";
|
||||
}
|
||||
|
@ -19,9 +19,9 @@
|
||||
package com.wisemapping.controller;
|
||||
|
||||
import com.wisemapping.model.ColaborationEmail;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.UserRole;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.InvalidColaboratorException;
|
||||
import com.wisemapping.view.MindMapBean;
|
||||
@ -36,14 +36,14 @@ public class MindmapSharingController extends BaseMultiActionController {
|
||||
public ModelAndView addCollaborator(HttpServletRequest request, HttpServletResponse response)
|
||||
throws InvalidColaboratorException {
|
||||
logger.info("Sharing Controller: add collaborators action");
|
||||
addColaborator(request, UserRole.COLLABORATOR);
|
||||
addColaborator(request, CollaborationRole.EDITOR);
|
||||
return new ModelAndView("closeDialog");
|
||||
}
|
||||
|
||||
public ModelAndView addViewer(HttpServletRequest request, HttpServletResponse response)
|
||||
throws InvalidColaboratorException {
|
||||
logger.info("Sharing Controller: add viewer action");
|
||||
addColaborator(request, UserRole.VIEWER);
|
||||
addColaborator(request, CollaborationRole.VIEWER);
|
||||
return new ModelAndView("closeDialog");
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class MindmapSharingController extends BaseMultiActionController {
|
||||
return result;
|
||||
}
|
||||
|
||||
private MindMapBean addColaborator(HttpServletRequest request, UserRole role) throws InvalidColaboratorException {
|
||||
private MindMapBean addColaborator(HttpServletRequest request, CollaborationRole role) throws InvalidColaboratorException {
|
||||
final MindMap mindMap = getMindmapFromRequest(request);
|
||||
User user = Utils.getUser();
|
||||
if (!mindMap.getOwner().equals(user)) {
|
||||
|
@ -28,11 +28,11 @@ public interface MindmapManager {
|
||||
|
||||
Collaborator getCollaboratorBy(long id);
|
||||
|
||||
List<MindmapUser> getMindmapUserByCollaborator(final long collaboratorId);
|
||||
List<Collaboration> getMindmapUserByCollaborator(final long collaboratorId);
|
||||
|
||||
List<MindmapUser> getMindmapUserByRole(final UserRole userRole);
|
||||
List<Collaboration> getMindmapUserByRole(final CollaborationRole userRole);
|
||||
|
||||
MindmapUser getMindmapUserBy(final int mindmapId, final User user);
|
||||
Collaboration getMindmapUserBy(final int mindmapId, final User user);
|
||||
|
||||
List<MindMap> getAllMindmaps();
|
||||
|
||||
@ -44,8 +44,6 @@ public interface MindmapManager {
|
||||
|
||||
void addMindmap(User user, MindMap mindMap);
|
||||
|
||||
public void addView(int mapId);
|
||||
|
||||
void saveMindmap(MindMap mindMap);
|
||||
|
||||
void updateMindmap(MindMap mindMap, boolean saveHistory);
|
||||
@ -54,7 +52,7 @@ public interface MindmapManager {
|
||||
|
||||
void removeMindmap(MindMap mindap);
|
||||
|
||||
void removeMindmapUser(MindmapUser mindmapUser);
|
||||
void removeMindmapUser(Collaboration collaboration);
|
||||
|
||||
public List<MindMap> search(MindMapCriteria criteria);
|
||||
|
||||
|
@ -34,6 +34,7 @@ public class MindmapManagerImpl
|
||||
extends HibernateDaoSupport
|
||||
implements MindmapManager {
|
||||
|
||||
@Override
|
||||
public Collaborator getCollaboratorBy(final String email) {
|
||||
final Collaborator collaborator;
|
||||
final List<Collaborator> collaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email);
|
||||
@ -46,10 +47,12 @@ public class MindmapManagerImpl
|
||||
return collaborator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MindMap> search(MindMapCriteria criteria) {
|
||||
return search(criteria, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MindMapHistory> getHistoryFrom(int mindmapId) {
|
||||
final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class);
|
||||
hibernateCriteria.add(Restrictions.eq("mindmapId", mindmapId));
|
||||
@ -61,10 +64,12 @@ public class MindmapManagerImpl
|
||||
return list.subList(0, (10 < list.size() ? 10 : list.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MindMapHistory getHistory(int historyId) {
|
||||
return (MindMapHistory) getHibernateTemplate().get(MindMapHistory.class, historyId);
|
||||
return getHibernateTemplate().get(MindMapHistory.class, historyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MindMap> search(MindMapCriteria criteria, int maxResult) {
|
||||
final Criteria hibernateCriteria = getSession().createCriteria(MindMap.class);
|
||||
//always search public maps
|
||||
@ -103,22 +108,25 @@ public class MindmapManagerImpl
|
||||
return hibernateCriteria.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collaborator getCollaboratorBy(long id) {
|
||||
return (Collaborator) getHibernateTemplate().get(Collaborator.class, id);
|
||||
return getHibernateTemplate().get(Collaborator.class, id);
|
||||
}
|
||||
|
||||
public List<MindmapUser> getMindmapUserByCollaborator(final long colaboratorId) {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.MindmapUser mindmapUser where colaborator_id=?", colaboratorId);
|
||||
@Override
|
||||
public List<Collaboration> getMindmapUserByCollaborator(final long colaboratorId) {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.Collaboration mindmapUser where colaborator_id=?", colaboratorId);
|
||||
}
|
||||
|
||||
public List<MindmapUser> getMindmapUserByRole(final UserRole userRole) {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.MindmapUser mindmapUser where roleId=?", userRole.ordinal());
|
||||
@Override
|
||||
public List<Collaboration> getMindmapUserByRole(final CollaborationRole collaborationRole) {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.Collaboration mindmapUser where roleId=?", collaborationRole.ordinal());
|
||||
}
|
||||
@Override
|
||||
public Collaboration getMindmapUserBy(final int mindmapId, final User user) {
|
||||
final Collaboration result;
|
||||
|
||||
public MindmapUser getMindmapUserBy(final int mindmapId, final User user) {
|
||||
final MindmapUser result;
|
||||
|
||||
final List<MindmapUser> mindMaps = getHibernateTemplate().find("from com.wisemapping.model.MindmapUser mindmapUser where mindMap.id=? and colaborator_id=?", new Object[]{mindmapId, user.getId()});
|
||||
final List<Collaboration> mindMaps = getHibernateTemplate().find("from com.wisemapping.model.Collaboration mindmapUser where mindMap.id=? and colaborator_id=?", new Object[]{mindmapId, user.getId()});
|
||||
if (mindMaps != null && !mindMaps.isEmpty()) {
|
||||
result = mindMaps.get(0);
|
||||
} else {
|
||||
@ -128,27 +136,33 @@ public class MindmapManagerImpl
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollaborator(Collaborator collaborator) {
|
||||
assert collaborator != null : "ADD MINDMAP COLABORATOR: Collaborator is required!";
|
||||
getHibernateTemplate().save(collaborator);
|
||||
}
|
||||
|
||||
public void removeMindmapUser(MindmapUser mindmapUser) {
|
||||
getHibernateTemplate().delete(mindmapUser);
|
||||
@Override
|
||||
public void removeMindmapUser(Collaboration collaboration) {
|
||||
getHibernateTemplate().delete(collaboration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCollaborator(Collaborator collaborator) {
|
||||
getHibernateTemplate().delete(collaborator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MindMap> getAllMindmaps() {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.MindMap wisemapping");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MindMap getMindmapById(int mindmapId) {
|
||||
return getHibernateTemplate().get(MindMap.class, mindmapId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MindMap getMindmapByTitle(final String title, final User user) {
|
||||
final MindMap result;
|
||||
List<MindMap> mindMaps = getHibernateTemplate().find("from com.wisemapping.model.MindMap wisemapping where title=? and creator=?", new Object[]{title, user.getUsername()});
|
||||
@ -160,19 +174,18 @@ public class MindmapManagerImpl
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addView(int mapId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMindmap(User user, MindMap mindMap) {
|
||||
saveMindmap(mindMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveMindmap(MindMap mindMap) {
|
||||
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
||||
getSession().save(mindMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMindmap(@NotNull MindMap mindMap, boolean saveHistory) {
|
||||
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
||||
getHibernateTemplate().saveOrUpdate(mindMap);
|
||||
@ -181,11 +194,12 @@ public class MindmapManagerImpl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMindmap(MindMap mindMap) {
|
||||
getHibernateTemplate().delete(mindMap);
|
||||
}
|
||||
|
||||
public void saveHistory(MindMap mindMap) {
|
||||
private void saveHistory(MindMap mindMap) {
|
||||
final MindMapHistory history = new MindMapHistory();
|
||||
|
||||
history.setXml(mindMap.getXml());
|
||||
|
@ -18,11 +18,10 @@
|
||||
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.MindmapUser;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.UserLogin;
|
||||
import com.wisemapping.security.CustomPasswordEncoder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
import org.springframework.security.authentication.encoding.PasswordEncoder;
|
||||
@ -110,11 +109,11 @@ public class UserManagerImpl
|
||||
user.setPassword(passwordEncoder.encodePassword(user.getPassword(),null));
|
||||
assert user != null : "Trying to store a null user";
|
||||
|
||||
final Set<MindmapUser> set = col.getMindmapUsers();
|
||||
for (MindmapUser mindmapUser : set) {
|
||||
MindmapUser newMapUser = new MindmapUser();
|
||||
newMapUser.setRoleId(mindmapUser.getRole().ordinal());
|
||||
newMapUser.setMindMap(mindmapUser.getMindMap());
|
||||
final Set<Collaboration> set = col.getCollaborations();
|
||||
for (Collaboration collaboration : set) {
|
||||
Collaboration newMapUser = new Collaboration();
|
||||
newMapUser.setRoleId(collaboration.getRole().ordinal());
|
||||
newMapUser.setMindMap(collaboration.getMindMap());
|
||||
newMapUser.setCollaborator(user);
|
||||
user.addMindmapUser(newMapUser);
|
||||
}
|
||||
|
@ -18,24 +18,26 @@
|
||||
|
||||
package com.wisemapping.model;
|
||||
|
||||
public class MindmapUser {
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Collaboration {
|
||||
|
||||
private int id;
|
||||
private int roleId;
|
||||
private MindMap mindMap;
|
||||
private CollaborationRole role;
|
||||
private MindMap mindMap;
|
||||
private Collaborator collaborator;
|
||||
|
||||
public MindmapUser(){ }
|
||||
public Collaboration() {
|
||||
}
|
||||
|
||||
public MindmapUser(int role, Collaborator collaborator, MindMap mindmap)
|
||||
{
|
||||
this.roleId = role;
|
||||
this.mindMap =mindmap;
|
||||
public Collaboration(@NotNull CollaborationRole role, @NotNull Collaborator collaborator, @NotNull MindMap mindmap) {
|
||||
this.role = role;
|
||||
this.mindMap = mindmap;
|
||||
this.collaborator = collaborator;
|
||||
|
||||
// Guarantee referential integrity
|
||||
mindmap.addMindmapUser(this);
|
||||
collaborator.addMindmapUser(this);
|
||||
mindmap.addMindmapUser(this);
|
||||
collaborator.addMindmapUser(this);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@ -47,27 +49,27 @@ public class MindmapUser {
|
||||
}
|
||||
|
||||
public int getRoleId() {
|
||||
return roleId;
|
||||
return role.ordinal();
|
||||
}
|
||||
|
||||
public void setRoleId(int roleId) {
|
||||
this.roleId = roleId;
|
||||
this.role = CollaborationRole.values()[roleId];
|
||||
}
|
||||
|
||||
public UserRole getRole() {
|
||||
return UserRole.values()[roleId];
|
||||
public CollaborationRole getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public boolean isOwner() {
|
||||
return getRole() == UserRole.OWNER;
|
||||
return getRole() == CollaborationRole.OWNER;
|
||||
}
|
||||
|
||||
public boolean isColaborator() {
|
||||
return getRole() == UserRole.COLLABORATOR;
|
||||
public boolean isEditor() {
|
||||
return getRole() == CollaborationRole.EDITOR;
|
||||
}
|
||||
|
||||
public boolean isViewer() {
|
||||
return getRole() == UserRole.VIEWER;
|
||||
return getRole() == CollaborationRole.VIEWER;
|
||||
}
|
||||
|
||||
public MindMap getMindMap() {
|
||||
@ -78,11 +80,12 @@ public class MindmapUser {
|
||||
this.mindMap = mindMap;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collaborator getCollaborator() {
|
||||
return collaborator;
|
||||
}
|
||||
|
||||
public void setCollaborator(Collaborator collaborator) {
|
||||
public void setCollaborator(@NotNull Collaborator collaborator) {
|
||||
this.collaborator = collaborator;
|
||||
}
|
||||
}
|
||||
}
|
@ -18,14 +18,14 @@
|
||||
|
||||
package com.wisemapping.model;
|
||||
|
||||
public enum UserRole {
|
||||
OWNER(true, true, true), COLLABORATOR(true, true, false), VIEWER(false, true, false);
|
||||
public enum CollaborationRole {
|
||||
OWNER(true, true, true), EDITOR(true, true, false), VIEWER(false, true, false);
|
||||
|
||||
private final boolean hasEditPermission;
|
||||
private final boolean hasViewPermission;
|
||||
private final boolean hasDeletePermission;
|
||||
|
||||
private UserRole(boolean hasEditPermission, boolean hasViewPermission, boolean hasDeletePermission) {
|
||||
private CollaborationRole(boolean hasEditPermission, boolean hasViewPermission, boolean hasDeletePermission) {
|
||||
this.hasEditPermission = hasEditPermission;
|
||||
this.hasViewPermission = hasViewPermission;
|
||||
this.hasDeletePermission = hasDeletePermission;
|
@ -27,27 +27,27 @@ public class Collaborator {
|
||||
private long id;
|
||||
private String email;
|
||||
private Calendar creationDate;
|
||||
private Set<MindmapUser> mindmapUsers = new HashSet<MindmapUser>();
|
||||
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||
|
||||
public Collaborator() {}
|
||||
|
||||
public Collaborator(Set<MindmapUser> mindmapUsers) {
|
||||
this.mindmapUsers = mindmapUsers;
|
||||
public Collaborator(Set<Collaboration> collaborations) {
|
||||
this.collaborations = collaborations;
|
||||
}
|
||||
|
||||
public void setMindmapUsers(Set<MindmapUser> mindmapUsers)
|
||||
public void setCollaborations(Set<Collaboration> collaborations)
|
||||
{
|
||||
this.mindmapUsers = mindmapUsers;
|
||||
this.collaborations = collaborations;
|
||||
}
|
||||
|
||||
public void addMindmapUser(MindmapUser mindmaUser)
|
||||
public void addMindmapUser(Collaboration mindmaUser)
|
||||
{
|
||||
mindmapUsers.add(mindmaUser);
|
||||
collaborations.add(mindmaUser);
|
||||
}
|
||||
|
||||
public Set<MindmapUser> getMindmapUsers()
|
||||
public Set<Collaboration> getCollaborations()
|
||||
{
|
||||
return mindmapUsers;
|
||||
return collaborations;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
|
@ -41,8 +41,8 @@ public class MindMap {
|
||||
private Calendar lastModificationTime;
|
||||
private String lastModifierUser;
|
||||
|
||||
private Set<MindmapUser> mindmapUsers = new HashSet<MindmapUser>();
|
||||
private Set<CollaboratorProperties> collaboratorProperties = new HashSet<CollaboratorProperties>();
|
||||
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||
private Set<MindmapCollaborationProperties> collaboratorProperties = new HashSet<MindmapCollaborationProperties>();
|
||||
|
||||
private User owner;
|
||||
private String properties;
|
||||
@ -55,8 +55,8 @@ public class MindMap {
|
||||
public MindMap() {
|
||||
}
|
||||
|
||||
public MindMap(Set<MindmapUser> mindmapUsers) {
|
||||
this.mindmapUsers = mindmapUsers;
|
||||
public MindMap(Set<Collaboration> collaborations) {
|
||||
this.collaborations = collaborations;
|
||||
}
|
||||
|
||||
//~ Methods ..............................................................................................
|
||||
@ -111,16 +111,16 @@ public class MindMap {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Set<MindmapUser> getMindmapUsers() {
|
||||
return mindmapUsers;
|
||||
public Set<Collaboration> getCollaborations() {
|
||||
return collaborations;
|
||||
}
|
||||
|
||||
public void setMindmapUsers(Set<MindmapUser> mindmapUsers) {
|
||||
this.mindmapUsers = mindmapUsers;
|
||||
public void setCollaborations(Set<Collaboration> collaborations) {
|
||||
this.collaborations = collaborations;
|
||||
}
|
||||
|
||||
public void addMindmapUser(MindmapUser mindmapUser) {
|
||||
mindmapUsers.add(mindmapUser);
|
||||
public void addMindmapUser(Collaboration collaboration) {
|
||||
collaborations.add(collaboration);
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
@ -222,18 +222,18 @@ public class MindMap {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public Set<CollaboratorProperties> getCollaboratorProperties() {
|
||||
public Set<MindmapCollaborationProperties> getCollaboratorProperties() {
|
||||
return collaboratorProperties;
|
||||
}
|
||||
|
||||
public void setCollaboratorProperties(@NotNull Set<CollaboratorProperties> collaboratorProperties) {
|
||||
public void setCollaboratorProperties(@NotNull Set<MindmapCollaborationProperties> collaboratorProperties) {
|
||||
this.collaboratorProperties = collaboratorProperties;
|
||||
}
|
||||
|
||||
private CollaboratorProperties findUserProperty(@NotNull Collaborator collaborator) {
|
||||
final Set<CollaboratorProperties> collaboratorProperties = this.getCollaboratorProperties();
|
||||
CollaboratorProperties result = null;
|
||||
for (CollaboratorProperties collaboratorProperty : collaboratorProperties) {
|
||||
private MindmapCollaborationProperties findUserProperty(@NotNull Collaborator collaborator) {
|
||||
final Set<MindmapCollaborationProperties> collaboratorProperties = this.getCollaboratorProperties();
|
||||
MindmapCollaborationProperties result = null;
|
||||
for (MindmapCollaborationProperties collaboratorProperty : collaboratorProperties) {
|
||||
final Collaborator propCollab = collaboratorProperty.getCollaborator();
|
||||
if (propCollab != null && propCollab.getEmail().equals(collaborator.getEmail())) {
|
||||
result = collaboratorProperty;
|
||||
@ -248,16 +248,16 @@ public class MindMap {
|
||||
throw new IllegalStateException("Collaborator can not be null");
|
||||
}
|
||||
|
||||
CollaboratorProperties collaboratorProperties = this.findUserProperty(collaborator);
|
||||
MindmapCollaborationProperties collaboratorProperties = this.findUserProperty(collaborator);
|
||||
if (collaboratorProperties == null) {
|
||||
collaboratorProperties = new CollaboratorProperties(collaborator, this);
|
||||
collaboratorProperties = new MindmapCollaborationProperties(collaborator, this);
|
||||
}
|
||||
collaboratorProperties.setStarred(value);
|
||||
this.getCollaboratorProperties().add(collaboratorProperties);
|
||||
}
|
||||
|
||||
public boolean isStarred(@NotNull Collaborator collaborator) {
|
||||
final CollaboratorProperties collaboratorProperty = this.findUserProperty(collaborator);
|
||||
final MindmapCollaborationProperties collaboratorProperty = this.findUserProperty(collaborator);
|
||||
return collaboratorProperty != null && collaboratorProperty.getStarred();
|
||||
}
|
||||
|
||||
|
@ -20,19 +20,19 @@ package com.wisemapping.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CollaboratorProperties {
|
||||
public class MindmapCollaborationProperties {
|
||||
private long id;
|
||||
private boolean starred;
|
||||
private Collaborator collaborator;
|
||||
private MindMap mindmap;
|
||||
|
||||
|
||||
public CollaboratorProperties(@NotNull Collaborator collaborator, @NotNull MindMap mindmap) {
|
||||
public MindmapCollaborationProperties(@NotNull Collaborator collaborator, @NotNull MindMap mindmap) {
|
||||
this.collaborator = collaborator;
|
||||
this.mindmap = mindmap;
|
||||
}
|
||||
|
||||
public CollaboratorProperties(){
|
||||
public MindmapCollaborationProperties(){
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ package com.wisemapping.ncontroller;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.filter.UserAgent;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.MindmapUser;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
@ -186,10 +186,10 @@ public class MindmapController {
|
||||
}
|
||||
|
||||
private List<MindMapBean> findMindMapBeanList(@NotNull User user) {
|
||||
final List<MindmapUser> userMindmaps = mindmapService.getMindmapUserByUser(user);
|
||||
final List<Collaboration> userMindmaps = mindmapService.getMindmapUserByUser(user);
|
||||
|
||||
final List<MindMapBean> mindMapBeans = new ArrayList<MindMapBean>(userMindmaps.size());
|
||||
for (MindmapUser mindmap : userMindmaps) {
|
||||
for (Collaboration mindmap : userMindmaps) {
|
||||
mindMapBeans.add(new MindMapBean(mindmap.getMindMap()));
|
||||
}
|
||||
return mindMapBeans;
|
||||
|
@ -24,8 +24,8 @@ import com.wisemapping.importer.ImportFormat;
|
||||
import com.wisemapping.importer.Importer;
|
||||
import com.wisemapping.importer.ImporterException;
|
||||
import com.wisemapping.importer.ImporterFactory;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.MindmapUser;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestMindmap;
|
||||
import com.wisemapping.rest.model.RestMindmapInfo;
|
||||
@ -92,10 +92,10 @@ public class MindmapController extends BaseController {
|
||||
|
||||
final MindmapFilter filter = MindmapFilter.parse(q);
|
||||
|
||||
final List<MindmapUser> mapsByUser = mindmapService.getMindmapUserByUser(user);
|
||||
final List<Collaboration> mapsByUser = mindmapService.getMindmapUserByUser(user);
|
||||
final List<MindMap> mindmaps = new ArrayList<MindMap>();
|
||||
for (MindmapUser mindmapUser : mapsByUser) {
|
||||
final MindMap mindmap = mindmapUser.getMindMap();
|
||||
for (Collaboration collaboration : mapsByUser) {
|
||||
final MindMap mindmap = collaboration.getMindMap();
|
||||
if (filter.accept(mindmap, user)) {
|
||||
mindmaps.add(mindmap);
|
||||
}
|
||||
@ -201,6 +201,25 @@ public class MindmapController extends BaseController {
|
||||
saveMindmap(true, mindMap, user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs", consumes = {"application/json", "application/xml"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateCollabs(@PathVariable int id) throws WiseMappingException {
|
||||
|
||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/collabs", produces = {"application/json", "text/html", "application/xml"})
|
||||
public ModelAndView retrieveList(@PathVariable int id) throws IOException {
|
||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
||||
|
||||
return new ModelAndView("mapsView", "list", collaborations);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/description", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateDescription(@RequestBody String description, @PathVariable int id) throws WiseMappingException {
|
||||
|
@ -0,0 +1,50 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "collaborators")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
public class RestCollaboration {
|
||||
|
||||
@JsonIgnore
|
||||
private String email;
|
||||
|
||||
@JsonIgnore
|
||||
private CollaborationRole role;
|
||||
|
||||
public RestCollaboration() {
|
||||
|
||||
}
|
||||
|
||||
public void setRole(@NotNull final String value) {
|
||||
if (value == null) {
|
||||
throw new IllegalStateException("role can not be null");
|
||||
}
|
||||
|
||||
role = CollaborationRole.valueOf(value.toUpperCase());
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role.toString().toLowerCase();
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "collaboration")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
public class RestCollaborationList {
|
||||
|
||||
private List<RestCollaboration> collaborations;
|
||||
|
||||
public RestCollaborationList() {
|
||||
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.collaborations.size();
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "collaborate")
|
||||
public List<RestCollaboration> getCollaborations() {
|
||||
return collaborations;
|
||||
}
|
||||
|
||||
public void setCollaborations(@NotNull List<RestCollaboration> collaborations) {
|
||||
this.collaborations = collaborations;
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
|
||||
package com.wisemapping.security.aop;
|
||||
|
||||
import com.wisemapping.model.UserRole;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.MindMap;
|
||||
|
||||
@ -30,7 +30,7 @@ public class UpdateSecurityAdvise
|
||||
extends BaseSecurityAdvice
|
||||
implements MethodInterceptor {
|
||||
|
||||
private UserRole grantedRole = UserRole.COLLABORATOR;
|
||||
private CollaborationRole grantedRole = CollaborationRole.EDITOR;
|
||||
|
||||
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
|
||||
checkRole(methodInvocation);
|
||||
|
@ -20,7 +20,7 @@ package com.wisemapping.security.aop;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import com.wisemapping.model.UserRole;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -28,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ViewBaseSecurityAdvise
|
||||
extends BaseSecurityAdvice
|
||||
implements MethodInterceptor {
|
||||
private UserRole grantedRole = UserRole.VIEWER;
|
||||
private CollaborationRole grantedRole = CollaborationRole.VIEWER;
|
||||
|
||||
public Object invoke(@NotNull MethodInvocation methodInvocation) throws Throwable {
|
||||
checkRole(methodInvocation);
|
||||
|
@ -29,19 +29,19 @@ public interface MindmapService {
|
||||
|
||||
public static final String TAG_SEPARATOR = " ";
|
||||
|
||||
public MindmapUser getMindmapUserBy(int mindmapId, User user);
|
||||
public Collaboration getMindmapUserBy(int mindmapId, User user);
|
||||
|
||||
public MindMap getMindmapById(int mindmapId);
|
||||
|
||||
public MindMap getMindmapByTitle(String title, User user);
|
||||
|
||||
public List<MindmapUser> getMindmapUserByUser(User user);
|
||||
public List<Collaboration> getMindmapUserByUser(User user);
|
||||
|
||||
public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException;
|
||||
|
||||
public void addMindmap(MindMap map, User user) throws WiseMappingException;
|
||||
|
||||
public void addCollaborators(MindMap mindmap, String[] collaboratorEmails, UserRole role, ColaborationEmail email)
|
||||
public void addCollaborators(MindMap mindmap, String[] collaboratorEmails, CollaborationRole role, ColaborationEmail email)
|
||||
throws InvalidColaboratorException;
|
||||
|
||||
public void addTags(MindMap mindmap, String tags);
|
||||
@ -56,17 +56,15 @@ public interface MindmapService {
|
||||
|
||||
public List<MindMapHistory> getMindMapHistory(int mindmapId);
|
||||
|
||||
public boolean isAllowedToView(User user, MindMap map, UserRole allowedRole);
|
||||
public boolean isAllowedToView(User user, MindMap map, CollaborationRole allowedRole);
|
||||
|
||||
public boolean isAllowedToView(User user, int mapId, UserRole allowedRole);
|
||||
public boolean isAllowedToView(User user, int mapId, CollaborationRole allowedRole);
|
||||
|
||||
public boolean isAllowedToCollaborate(User user, int mapId, UserRole grantedRole);
|
||||
public boolean isAllowedToCollaborate(User user, int mapId, CollaborationRole grantedRole);
|
||||
|
||||
public boolean isAllowedToCollaborate(User user, MindMap map, UserRole grantedRole);
|
||||
public boolean isAllowedToCollaborate(User user, MindMap map, CollaborationRole grantedRole);
|
||||
|
||||
public void addWelcomeMindmap(User user) throws WiseMappingException;
|
||||
|
||||
public void addView(int mapId);
|
||||
|
||||
public void revertMapToHistory(MindMap map, int historyId) throws IOException, WiseMappingException;
|
||||
}
|
||||
|
@ -36,17 +36,17 @@ public class MindmapServiceImpl
|
||||
private UserService userService;
|
||||
private Mailer mailer;
|
||||
|
||||
public boolean isAllowedToCollaborate(@NotNull User user, int mapId, @NotNull UserRole grantedRole) {
|
||||
public boolean isAllowedToCollaborate(@NotNull User user, int mapId, @NotNull CollaborationRole grantedRole) {
|
||||
final MindMap map = mindmapManager.getMindmapById(mapId);
|
||||
return isAllowedToCollaborate(user, map, grantedRole);
|
||||
}
|
||||
|
||||
public boolean isAllowedToView(User user, int mapId, UserRole grantedRole) {
|
||||
public boolean isAllowedToView(User user, int mapId, CollaborationRole grantedRole) {
|
||||
final MindMap map = mindmapManager.getMindmapById(mapId);
|
||||
return isAllowedToView(user, map, grantedRole);
|
||||
}
|
||||
|
||||
public boolean isAllowedToView(@NotNull User user, @NotNull MindMap map, @NotNull UserRole grantedRole) {
|
||||
public boolean isAllowedToView(@NotNull User user, @NotNull MindMap map, @NotNull CollaborationRole grantedRole) {
|
||||
boolean result = false;
|
||||
if (map != null) {
|
||||
if (map.isPublic()) {
|
||||
@ -58,17 +58,17 @@ public class MindmapServiceImpl
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isAllowedToCollaborate(@NotNull User user, @Nullable MindMap map, UserRole grantedRole) {
|
||||
public boolean isAllowedToCollaborate(@NotNull User user, @Nullable MindMap map, CollaborationRole grantedRole) {
|
||||
boolean isAllowed = false;
|
||||
if (map != null) {
|
||||
if (map.getOwner().getId() == user.getId()) {
|
||||
isAllowed = true;
|
||||
} else {
|
||||
final Set<MindmapUser> users = map.getMindmapUsers();
|
||||
UserRole rol = null;
|
||||
for (MindmapUser mindmapUser : users) {
|
||||
if (mindmapUser.getCollaborator().getId() == user.getId()) {
|
||||
rol = mindmapUser.getRole();
|
||||
final Set<Collaboration> users = map.getCollaborations();
|
||||
CollaborationRole rol = null;
|
||||
for (Collaboration collaboration : users) {
|
||||
if (collaboration.getCollaborator().getId() == user.getId()) {
|
||||
rol = collaboration.getRole();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,7 @@ public class MindmapServiceImpl
|
||||
return isAllowed;
|
||||
}
|
||||
|
||||
public MindmapUser getMindmapUserBy(int mindmapId, User user) {
|
||||
public Collaboration getMindmapUserBy(int mindmapId, User user) {
|
||||
return mindmapManager.getMindmapUserBy(mindmapId, user);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class MindmapServiceImpl
|
||||
return mindmapManager.getMindmapById(mindmapId);
|
||||
}
|
||||
|
||||
public List<MindmapUser> getMindmapUserByUser(@NotNull User user) {
|
||||
public List<Collaboration> getMindmapUserByUser(@NotNull User user) {
|
||||
return mindmapManager.getMindmapUserByCollaborator(user.getId());
|
||||
}
|
||||
|
||||
@ -113,10 +113,10 @@ public class MindmapServiceImpl
|
||||
}
|
||||
|
||||
public void removeCollaboratorFromMindmap(@NotNull MindMap mindmap, long userId) {
|
||||
// remove colaborator association
|
||||
Set<MindmapUser> mindmapusers = mindmap.getMindmapUsers();
|
||||
MindmapUser mindmapuserToDelete = null;
|
||||
for (MindmapUser mindmapuser : mindmapusers) {
|
||||
// remove collaborator association
|
||||
Set<Collaboration> mindmapusers = mindmap.getCollaborations();
|
||||
Collaboration mindmapuserToDelete = null;
|
||||
for (Collaboration mindmapuser : mindmapusers) {
|
||||
if (mindmapuser.getCollaborator().getId() == userId) {
|
||||
mindmapuserToDelete = mindmapuser;
|
||||
break;
|
||||
@ -159,28 +159,28 @@ public class MindmapServiceImpl
|
||||
|
||||
// Hack to reload dbuser ...
|
||||
final User dbUser = userService.getUserBy(user.getId());
|
||||
final MindmapUser mindmapUser = new MindmapUser(UserRole.OWNER.ordinal(), dbUser, map);
|
||||
map.getMindmapUsers().add(mindmapUser);
|
||||
final Collaboration collaboration = new Collaboration(CollaborationRole.OWNER, dbUser, map);
|
||||
map.getCollaborations().add(collaboration);
|
||||
|
||||
mindmapManager.addMindmap(dbUser, map);
|
||||
}
|
||||
|
||||
public void addCollaborators(MindMap mindmap, String[] collaboratorEmails, UserRole role, ColaborationEmail email)
|
||||
public void addCollaborators(MindMap mindmap, String[] collaboratorEmails, CollaborationRole role, ColaborationEmail email)
|
||||
throws InvalidColaboratorException {
|
||||
if (collaboratorEmails != null && collaboratorEmails.length > 0) {
|
||||
final Collaborator owner = mindmap.getOwner();
|
||||
final Set<MindmapUser> mindmapUsers = mindmap.getMindmapUsers();
|
||||
final Set<Collaboration> collaborations = mindmap.getCollaborations();
|
||||
|
||||
for (String colaboratorEmail : collaboratorEmails) {
|
||||
if (owner.getEmail().equals(colaboratorEmail)) {
|
||||
throw new InvalidColaboratorException("The user " + owner.getEmail() + " is the owner");
|
||||
}
|
||||
MindmapUser mindmapUser = getMindmapUserBy(colaboratorEmail, mindmapUsers);
|
||||
if (mindmapUser == null) {
|
||||
Collaboration collaboration = getMindmapUserBy(colaboratorEmail, collaborations);
|
||||
if (collaboration == null) {
|
||||
addCollaborator(colaboratorEmail, role, mindmap, email);
|
||||
} else if (mindmapUser.getRole() != role) {
|
||||
} else if (collaboration.getRole() != role) {
|
||||
// If the relationship already exists and the role changed then only update the role
|
||||
mindmapUser.setRoleId(role.ordinal());
|
||||
collaboration.setRoleId(role.ordinal());
|
||||
mindmapManager.updateMindmap(mindmap, false);
|
||||
}
|
||||
}
|
||||
@ -222,10 +222,6 @@ public class MindmapServiceImpl
|
||||
}
|
||||
}
|
||||
|
||||
public void addView(int mapId) {
|
||||
mindmapManager.addView(mapId);
|
||||
}
|
||||
|
||||
public List<MindMapHistory> getMindMapHistory(int mindmapId) {
|
||||
return mindmapManager.getHistoryFrom(mindmapId);
|
||||
}
|
||||
@ -237,19 +233,19 @@ public class MindmapServiceImpl
|
||||
updateMindmap(map, false);
|
||||
}
|
||||
|
||||
private MindmapUser getMindmapUserBy(String email, Set<MindmapUser> mindmapUsers) {
|
||||
MindmapUser mindmapUser = null;
|
||||
private Collaboration getMindmapUserBy(String email, Set<Collaboration> collaborations) {
|
||||
Collaboration collaboration = null;
|
||||
|
||||
for (MindmapUser user : mindmapUsers) {
|
||||
for (Collaboration user : collaborations) {
|
||||
if (user.getCollaborator().getEmail().equals(email)) {
|
||||
mindmapUser = user;
|
||||
collaboration = user;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mindmapUser;
|
||||
return collaboration;
|
||||
}
|
||||
|
||||
private void addCollaborator(String colaboratorEmail, UserRole role, MindMap mindmap, ColaborationEmail email) {
|
||||
private void addCollaborator(String colaboratorEmail, CollaborationRole role, MindMap mindmap, ColaborationEmail email) {
|
||||
|
||||
Collaborator collaborator = mindmapManager.getCollaboratorBy(colaboratorEmail);
|
||||
if (collaborator == null) {
|
||||
@ -259,8 +255,8 @@ public class MindmapServiceImpl
|
||||
mindmapManager.addCollaborator(collaborator);
|
||||
}
|
||||
|
||||
final MindmapUser newMindmapUser = new MindmapUser(role.ordinal(), collaborator, mindmap);
|
||||
mindmap.getMindmapUsers().add(newMindmapUser);
|
||||
final Collaboration newCollaboration = new Collaboration(role, collaborator, mindmap);
|
||||
mindmap.getCollaborations().add(newCollaboration);
|
||||
|
||||
mindmapManager.saveMindmap(mindmap);
|
||||
|
||||
|
@ -18,27 +18,27 @@
|
||||
|
||||
package com.wisemapping.view;
|
||||
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.UserRole;
|
||||
import com.wisemapping.model.User;
|
||||
|
||||
public class ColaboratorBean
|
||||
{
|
||||
private UserRole userRole;
|
||||
private CollaborationRole collaborationRole;
|
||||
private boolean isUser;
|
||||
private Collaborator collaborator;
|
||||
|
||||
public ColaboratorBean(Collaborator collaborator, UserRole role)
|
||||
public ColaboratorBean(Collaborator collaborator, CollaborationRole role)
|
||||
{
|
||||
this.collaborator = collaborator;
|
||||
this.userRole = role;
|
||||
this.collaborationRole = role;
|
||||
this.isUser = false;
|
||||
}
|
||||
|
||||
public ColaboratorBean(User user, UserRole role)
|
||||
public ColaboratorBean(User user, CollaborationRole role)
|
||||
{
|
||||
this.collaborator = user;
|
||||
this.userRole = role;
|
||||
this.collaborationRole = role;
|
||||
this.isUser = true;
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ public class ColaboratorBean
|
||||
|
||||
public String getRole()
|
||||
{
|
||||
return userRole.name();
|
||||
return collaborationRole.name();
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
|
@ -18,9 +18,9 @@
|
||||
|
||||
package com.wisemapping.view;
|
||||
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.MindmapUser;
|
||||
import com.wisemapping.model.UserRole;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.Utils;
|
||||
|
||||
@ -34,8 +34,8 @@ public class MindMapBean {
|
||||
|
||||
public MindMapBean(final MindMap mindmap) {
|
||||
this.mindMap = mindmap;
|
||||
this.colaborators = getColaboratorBy(mindmap.getMindmapUsers(), UserRole.COLLABORATOR);
|
||||
this.viewers = getColaboratorBy(mindmap.getMindmapUsers(), UserRole.VIEWER);
|
||||
this.colaborators = getColaboratorBy(mindmap.getCollaborations(), CollaborationRole.EDITOR);
|
||||
this.viewers = getColaboratorBy(mindmap.getCollaborations(), CollaborationRole.VIEWER);
|
||||
}
|
||||
|
||||
public MindMap getMindMap() {
|
||||
@ -104,10 +104,10 @@ public class MindMapBean {
|
||||
return mindMap.getTags();
|
||||
}
|
||||
|
||||
private List<ColaboratorBean> getColaboratorBy(Set<MindmapUser> source, UserRole role) {
|
||||
private List<ColaboratorBean> getColaboratorBy(Set<Collaboration> source, CollaborationRole role) {
|
||||
List<ColaboratorBean> col = new ArrayList<ColaboratorBean>();
|
||||
if (source != null) {
|
||||
for (MindmapUser mu : source) {
|
||||
for (Collaboration mu : source) {
|
||||
if (mu.getRole() == role) {
|
||||
col.add(new ColaboratorBean(mu.getCollaborator(), mu.getRole()));
|
||||
}
|
||||
|
@ -12,11 +12,11 @@
|
||||
<property name="email"/>
|
||||
<property name="creationDate" column="creation_date"/>
|
||||
|
||||
<set name="mindmapUsers"
|
||||
<set name="collaborations"
|
||||
cascade="all, delete-orphan"
|
||||
inverse="true">
|
||||
<key column="COLABORATOR_ID" not-null="true"/>
|
||||
<one-to-many class="com.wisemapping.model.MindmapUser"/>
|
||||
<one-to-many class="com.wisemapping.model.Collaboration"/>
|
||||
</set>
|
||||
|
||||
<joined-subclass name="com.wisemapping.model.User" table="USER">
|
||||
|
@ -22,18 +22,18 @@
|
||||
|
||||
<many-to-one name="owner" column="owner_id" unique="true" not-null="true"/>
|
||||
|
||||
<set name="mindmapUsers"
|
||||
<set name="collaborations"
|
||||
cascade="all, delete-orphan"
|
||||
inverse="true">
|
||||
<key column="MINDMAP_ID" not-null="true"/>
|
||||
<one-to-many class="com.wisemapping.model.MindmapUser"/>
|
||||
<one-to-many class="com.wisemapping.model.Collaboration"/>
|
||||
</set>
|
||||
|
||||
<set name="collaboratorProperties"
|
||||
cascade="all, delete-orphan"
|
||||
inverse="true">
|
||||
<key column="MINDMAP_ID" not-null="true"/>
|
||||
<one-to-many class="com.wisemapping.model.CollaboratorProperties"/>
|
||||
<one-to-many class="com.wisemapping.model.MindmapCollaborationProperties"/>
|
||||
</set>
|
||||
|
||||
</class>
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
<hibernate-mapping>
|
||||
|
||||
<class name="com.wisemapping.model.MindmapUser" table="MINDMAP_COLABORATOR">
|
||||
<class name="com.wisemapping.model.Collaboration" table="MINDMAP_COLABORATOR">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
@ -5,7 +5,7 @@
|
||||
|
||||
<hibernate-mapping>
|
||||
|
||||
<class name="com.wisemapping.model.CollaboratorProperties" table="MINDMAP_COLLABORATOR_PROPERTIES">
|
||||
<class name="com.wisemapping.model.MindmapCollaborationProperties" table="MINDMAP_COLLABORATION_PROPERTIES">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
@ -26,8 +26,8 @@
|
||||
<list>
|
||||
<value>com/wisemapping/model/Collaborator.hbm.xml</value>
|
||||
<value>com/wisemapping/model/MindMap.hbm.xml</value>
|
||||
<value>com/wisemapping/model/MindmapUser.hbm.xml</value>
|
||||
<value>com/wisemapping/model/CollaboratorProperties.hbm.xml</value>
|
||||
<value>com/wisemapping/model/MindmapCollaboration.hbm.xml</value>
|
||||
<value>com/wisemapping/model/MindmapCollaborationProperties.hbm.xml</value>
|
||||
<value>com/wisemapping/model/UserLogin.hbm.xml</value>
|
||||
<value>com/wisemapping/model/MindMapHistory.hbm.xml</value>
|
||||
</list>
|
||||
|
@ -23,6 +23,8 @@
|
||||
<value>com.wisemapping.rest.model.RestMindmapList</value>
|
||||
<value>com.wisemapping.rest.model.RestUser</value>
|
||||
<value>com.wisemapping.rest.model.RestErrors</value>
|
||||
<value>com.wisemapping.rest.model.RestCollaboration</value>
|
||||
<value>com.wisemapping.rest.model.RestCollaborationList</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
@ -32,7 +32,7 @@ editor_properties varchar(512)
|
||||
--FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP_COLLABORATOR_PROPERTIES
|
||||
CREATE TABLE MINDMAP_COLLABORATION_PROPERTIES
|
||||
(id INTEGER NOT NULL IDENTITY,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
collaborator_id INTEGER NOT NULL,
|
||||
|
@ -1,5 +1,5 @@
|
||||
DROP TABLE TAG;
|
||||
DROP TABLE MINDMAP_COLLABORATOR_PROPERTIES;
|
||||
DROP TABLE MINDMAP_COLLABORATION_PROPERTIES;
|
||||
DROP TABLE MINDMAP_COLABORATOR;
|
||||
DROP TABLE MINDMAP_HISTORY;
|
||||
DROP TABLE MINDMAP;
|
||||
|
@ -34,7 +34,7 @@ FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id)
|
||||
) CHARACTER SET utf8 ;
|
||||
|
||||
|
||||
CREATE TABLE MINDMAP_COLLABORATOR_PROPERTIES(
|
||||
CREATE TABLE MINDMAP_COLLABORATION_PROPERTIES(
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
collaborator_id INTEGER NOT NULL,
|
||||
|
@ -1,5 +1,5 @@
|
||||
DROP TABLE TAG;
|
||||
DROP TABLE MINDMAP_COLLABORATOR_PROPERTIES;
|
||||
DROP TABLE MINDMAP_COLLABORATION_PROPERTIES;
|
||||
DROP TABLE MINDMAP_COLABORATOR;
|
||||
DROP TABLE MINDMAP_HISTORY;
|
||||
DROP TABLE MINDMAP;
|
||||
|
Loading…
Reference in New Issue
Block a user