From 6c8664ada4e0850c78ffec8b7cb4750f09478620 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 9 Jun 2012 15:49:19 -0300 Subject: [PATCH] Rename MindmapUser to Collaboration. --- mindplot/src/main/javascript/widget/Menu.js | 6 +- .../controller/BaseMultiActionController.java | 82 +------------------ .../controller/MindmapSharingController.java | 8 +- .../com/wisemapping/dao/MindmapManager.java | 10 +-- .../wisemapping/dao/MindmapManagerImpl.java | 48 +++++++---- .../com/wisemapping/dao/UserManagerImpl.java | 13 ++- .../{MindmapUser.java => Collaboration.java} | 43 +++++----- .../{UserRole.java => CollaborationRole.java} | 6 +- .../com/wisemapping/model/Collaborator.java | 18 ++-- .../java/com/wisemapping/model/MindMap.java | 38 ++++----- ...va => MindmapCollaborationProperties.java} | 6 +- .../ncontroller/MindmapController.java | 6 +- .../wisemapping/rest/MindmapController.java | 27 +++++- .../rest/model/RestCollaboration.java | 50 +++++++++++ .../rest/model/RestCollaborationList.java | 47 +++++++++++ .../security/aop/UpdateSecurityAdvise.java | 4 +- .../security/aop/ViewBaseSecurityAdvise.java | 4 +- .../wisemapping/service/MindmapService.java | 16 ++-- .../service/MindmapServiceImpl.java | 66 +++++++-------- .../com/wisemapping/view/ColaboratorBean.java | 14 ++-- .../com/wisemapping/view/MindMapBean.java | 12 +-- .../wisemapping/model/Collaborator.hbm.xml | 4 +- .../com/wisemapping/model/MindMap.hbm.xml | 6 +- ...r.hbm.xml => MindmapCollaboration.hbm.xml} | 2 +- ...=> MindmapCollaborationProperties.hbm.xml} | 2 +- .../main/webapp/WEB-INF/wisemapping-dao.xml | 4 +- .../main/webapp/WEB-INF/wisemapping-rest.xml | 2 + .../src/test/sql/hsql/create-schemas.sql | 2 +- .../src/test/sql/hsql/drop-schemas.sql | 2 +- .../src/test/sql/mysql/create-schemas.sql | 2 +- .../src/test/sql/mysql/drop-schemas.sql | 2 +- 31 files changed, 301 insertions(+), 251 deletions(-) rename wise-webapp/src/main/java/com/wisemapping/model/{MindmapUser.java => Collaboration.java} (61%) rename wise-webapp/src/main/java/com/wisemapping/model/{UserRole.java => CollaborationRole.java} (82%) rename wise-webapp/src/main/java/com/wisemapping/model/{CollaboratorProperties.java => MindmapCollaborationProperties.java} (86%) create mode 100644 wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaboration.java create mode 100644 wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java rename wise-webapp/src/main/resources/com/wisemapping/model/{MindmapUser.hbm.xml => MindmapCollaboration.hbm.xml} (86%) rename wise-webapp/src/main/resources/com/wisemapping/model/{CollaboratorProperties.hbm.xml => MindmapCollaborationProperties.hbm.xml} (83%) diff --git a/mindplot/src/main/javascript/widget/Menu.js b/mindplot/src/main/javascript/widget/Menu.js index d94d08c3..bc557203 100644 --- a/mindplot/src/main/javascript/widget/Menu.js +++ b/mindplot/src/main/javascript/widget/Menu.js @@ -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"); } diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java b/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java index 9002815e..7496b0f8 100644 --- a/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java +++ b/wise-webapp/src/main/java/com/wisemapping/controller/BaseMultiActionController.java @@ -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 getMindmapsFromRequest(HttpServletRequest request) { - List result = new ArrayList(); - 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 getMindMapBeanList(User user) { - final List userMindmaps = getMindmapService().getMindmapUserByUser(user); - - final List mindMapBeans = new ArrayList(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"; } diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/MindmapSharingController.java b/wise-webapp/src/main/java/com/wisemapping/controller/MindmapSharingController.java index f5932537..4c618950 100644 --- a/wise-webapp/src/main/java/com/wisemapping/controller/MindmapSharingController.java +++ b/wise-webapp/src/main/java/com/wisemapping/controller/MindmapSharingController.java @@ -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)) { diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java index 842f0ca4..52ca9db4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java @@ -28,11 +28,11 @@ public interface MindmapManager { Collaborator getCollaboratorBy(long id); - List getMindmapUserByCollaborator(final long collaboratorId); + List getMindmapUserByCollaborator(final long collaboratorId); - List getMindmapUserByRole(final UserRole userRole); + List getMindmapUserByRole(final CollaborationRole userRole); - MindmapUser getMindmapUserBy(final int mindmapId, final User user); + Collaboration getMindmapUserBy(final int mindmapId, final User user); List 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 search(MindMapCriteria criteria); diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java index 9df4d0a6..23b7a6bf 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java @@ -34,6 +34,7 @@ public class MindmapManagerImpl extends HibernateDaoSupport implements MindmapManager { + @Override public Collaborator getCollaboratorBy(final String email) { final Collaborator collaborator; final List collaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email); @@ -46,10 +47,12 @@ public class MindmapManagerImpl return collaborator; } + @Override public List search(MindMapCriteria criteria) { return search(criteria, -1); } + @Override public List 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 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 getMindmapUserByCollaborator(final long colaboratorId) { - return getHibernateTemplate().find("from com.wisemapping.model.MindmapUser mindmapUser where colaborator_id=?", colaboratorId); + @Override + public List getMindmapUserByCollaborator(final long colaboratorId) { + return getHibernateTemplate().find("from com.wisemapping.model.Collaboration mindmapUser where colaborator_id=?", colaboratorId); } - public List getMindmapUserByRole(final UserRole userRole) { - return getHibernateTemplate().find("from com.wisemapping.model.MindmapUser mindmapUser where roleId=?", userRole.ordinal()); + @Override + public List 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 mindMaps = getHibernateTemplate().find("from com.wisemapping.model.MindmapUser mindmapUser where mindMap.id=? and colaborator_id=?", new Object[]{mindmapId, user.getId()}); + final List 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 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 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()); diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java index 9789307e..42613772 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java @@ -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 set = col.getMindmapUsers(); - for (MindmapUser mindmapUser : set) { - MindmapUser newMapUser = new MindmapUser(); - newMapUser.setRoleId(mindmapUser.getRole().ordinal()); - newMapUser.setMindMap(mindmapUser.getMindMap()); + final Set 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); } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindmapUser.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java similarity index 61% rename from wise-webapp/src/main/java/com/wisemapping/model/MindmapUser.java rename to wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java index a628b36e..d80fc754 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindmapUser.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java @@ -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; - } + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/UserRole.java b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java similarity index 82% rename from wise-webapp/src/main/java/com/wisemapping/model/UserRole.java rename to wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java index 9b26415c..43174b14 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/UserRole.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java @@ -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; diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java index 725353cd..9a7e0ee3 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java @@ -27,27 +27,27 @@ public class Collaborator { private long id; private String email; private Calendar creationDate; - private Set mindmapUsers = new HashSet(); + private Set collaborations = new HashSet(); public Collaborator() {} - public Collaborator(Set mindmapUsers) { - this.mindmapUsers = mindmapUsers; + public Collaborator(Set collaborations) { + this.collaborations = collaborations; } - public void setMindmapUsers(Set mindmapUsers) + public void setCollaborations(Set 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 getMindmapUsers() + public Set getCollaborations() { - return mindmapUsers; + return collaborations; } public long getId() { diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java index 23a1735a..efe4599c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java @@ -41,8 +41,8 @@ public class MindMap { private Calendar lastModificationTime; private String lastModifierUser; - private Set mindmapUsers = new HashSet(); - private Set collaboratorProperties = new HashSet(); + private Set collaborations = new HashSet(); + private Set collaboratorProperties = new HashSet(); private User owner; private String properties; @@ -55,8 +55,8 @@ public class MindMap { public MindMap() { } - public MindMap(Set mindmapUsers) { - this.mindmapUsers = mindmapUsers; + public MindMap(Set collaborations) { + this.collaborations = collaborations; } //~ Methods .............................................................................................. @@ -111,16 +111,16 @@ public class MindMap { return ret; } - public Set getMindmapUsers() { - return mindmapUsers; + public Set getCollaborations() { + return collaborations; } - public void setMindmapUsers(Set mindmapUsers) { - this.mindmapUsers = mindmapUsers; + public void setCollaborations(Set 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 getCollaboratorProperties() { + public Set getCollaboratorProperties() { return collaboratorProperties; } - public void setCollaboratorProperties(@NotNull Set collaboratorProperties) { + public void setCollaboratorProperties(@NotNull Set collaboratorProperties) { this.collaboratorProperties = collaboratorProperties; } - private CollaboratorProperties findUserProperty(@NotNull Collaborator collaborator) { - final Set collaboratorProperties = this.getCollaboratorProperties(); - CollaboratorProperties result = null; - for (CollaboratorProperties collaboratorProperty : collaboratorProperties) { + private MindmapCollaborationProperties findUserProperty(@NotNull Collaborator collaborator) { + final Set 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(); } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/CollaboratorProperties.java b/wise-webapp/src/main/java/com/wisemapping/model/MindmapCollaborationProperties.java similarity index 86% rename from wise-webapp/src/main/java/com/wisemapping/model/CollaboratorProperties.java rename to wise-webapp/src/main/java/com/wisemapping/model/MindmapCollaborationProperties.java index 1326ce11..918501ba 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/CollaboratorProperties.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindmapCollaborationProperties.java @@ -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(){ } diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java index 2234c95c..da8619ce 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java @@ -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 findMindMapBeanList(@NotNull User user) { - final List userMindmaps = mindmapService.getMindmapUserByUser(user); + final List userMindmaps = mindmapService.getMindmapUserByUser(user); final List mindMapBeans = new ArrayList(userMindmaps.size()); - for (MindmapUser mindmap : userMindmaps) { + for (Collaboration mindmap : userMindmaps) { mindMapBeans.add(new MindMapBean(mindmap.getMindMap())); } return mindMapBeans; diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 693c1eb7..7275f26c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -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 mapsByUser = mindmapService.getMindmapUserByUser(user); + final List mapsByUser = mindmapService.getMindmapUserByUser(user); final List mindmaps = new ArrayList(); - 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 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 { diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaboration.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaboration.java new file mode 100644 index 00000000..1c5e3933 --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaboration.java @@ -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; + } +} diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java new file mode 100644 index 00000000..265b5050 --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java @@ -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 collaborations; + + public RestCollaborationList() { + + } + + public int getCount() { + return this.collaborations.size(); + } + + public void setCount(int count) { + + } + + @XmlElement(name = "collaborate") + public List getCollaborations() { + return collaborations; + } + + public void setCollaborations(@NotNull List collaborations) { + this.collaborations = collaborations; + } +} diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java index dd627030..ff6ee64d 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java @@ -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); diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java index becf50b0..e20a163a 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java @@ -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); diff --git a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java index 68ac46a0..a3fb0b67 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java @@ -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 getMindmapUserByUser(User user); + public List 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 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; } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java index 7949075d..ee9d5939 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java @@ -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 users = map.getMindmapUsers(); - UserRole rol = null; - for (MindmapUser mindmapUser : users) { - if (mindmapUser.getCollaborator().getId() == user.getId()) { - rol = mindmapUser.getRole(); + final Set 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 getMindmapUserByUser(@NotNull User user) { + public List 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 mindmapusers = mindmap.getMindmapUsers(); - MindmapUser mindmapuserToDelete = null; - for (MindmapUser mindmapuser : mindmapusers) { + // remove collaborator association + Set 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 mindmapUsers = mindmap.getMindmapUsers(); + final Set 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 getMindMapHistory(int mindmapId) { return mindmapManager.getHistoryFrom(mindmapId); } @@ -237,19 +233,19 @@ public class MindmapServiceImpl updateMindmap(map, false); } - private MindmapUser getMindmapUserBy(String email, Set mindmapUsers) { - MindmapUser mindmapUser = null; + private Collaboration getMindmapUserBy(String email, Set 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); diff --git a/wise-webapp/src/main/java/com/wisemapping/view/ColaboratorBean.java b/wise-webapp/src/main/java/com/wisemapping/view/ColaboratorBean.java index fd994152..793db3a6 100755 --- a/wise-webapp/src/main/java/com/wisemapping/view/ColaboratorBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/ColaboratorBean.java @@ -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() diff --git a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java index e119dd5e..5c26c97e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java @@ -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 getColaboratorBy(Set source, UserRole role) { + private List getColaboratorBy(Set source, CollaborationRole role) { List col = new ArrayList(); if (source != null) { - for (MindmapUser mu : source) { + for (Collaboration mu : source) { if (mu.getRole() == role) { col.add(new ColaboratorBean(mu.getCollaborator(), mu.getRole())); } diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/Collaborator.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/Collaborator.hbm.xml index ae8b73d2..ba67a873 100755 --- a/wise-webapp/src/main/resources/com/wisemapping/model/Collaborator.hbm.xml +++ b/wise-webapp/src/main/resources/com/wisemapping/model/Collaborator.hbm.xml @@ -12,11 +12,11 @@ - - + diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml index 442ed721..5aaf8ef9 100644 --- a/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml +++ b/wise-webapp/src/main/resources/com/wisemapping/model/MindMap.hbm.xml @@ -22,18 +22,18 @@ - - + - + diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/MindmapUser.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaboration.hbm.xml similarity index 86% rename from wise-webapp/src/main/resources/com/wisemapping/model/MindmapUser.hbm.xml rename to wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaboration.hbm.xml index 7db2c720..806b0bdf 100644 --- a/wise-webapp/src/main/resources/com/wisemapping/model/MindmapUser.hbm.xml +++ b/wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaboration.hbm.xml @@ -5,7 +5,7 @@ - + diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/CollaboratorProperties.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaborationProperties.hbm.xml similarity index 83% rename from wise-webapp/src/main/resources/com/wisemapping/model/CollaboratorProperties.hbm.xml rename to wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaborationProperties.hbm.xml index 5ed22664..b5ded9e2 100644 --- a/wise-webapp/src/main/resources/com/wisemapping/model/CollaboratorProperties.hbm.xml +++ b/wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaborationProperties.hbm.xml @@ -5,7 +5,7 @@ - + diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-dao.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-dao.xml index 0772f391..2be07857 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-dao.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-dao.xml @@ -26,8 +26,8 @@ com/wisemapping/model/Collaborator.hbm.xml com/wisemapping/model/MindMap.hbm.xml - com/wisemapping/model/MindmapUser.hbm.xml - com/wisemapping/model/CollaboratorProperties.hbm.xml + com/wisemapping/model/MindmapCollaboration.hbm.xml + com/wisemapping/model/MindmapCollaborationProperties.hbm.xml com/wisemapping/model/UserLogin.hbm.xml com/wisemapping/model/MindMapHistory.hbm.xml diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-rest.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-rest.xml index 38740f44..ead0e554 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-rest.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-rest.xml @@ -23,6 +23,8 @@ com.wisemapping.rest.model.RestMindmapList com.wisemapping.rest.model.RestUser com.wisemapping.rest.model.RestErrors + com.wisemapping.rest.model.RestCollaboration + com.wisemapping.rest.model.RestCollaborationList diff --git a/wise-webapp/src/test/sql/hsql/create-schemas.sql b/wise-webapp/src/test/sql/hsql/create-schemas.sql index ce6aa8c3..181c54ba 100644 --- a/wise-webapp/src/test/sql/hsql/create-schemas.sql +++ b/wise-webapp/src/test/sql/hsql/create-schemas.sql @@ -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, diff --git a/wise-webapp/src/test/sql/hsql/drop-schemas.sql b/wise-webapp/src/test/sql/hsql/drop-schemas.sql index 5295ad9b..cd247743 100644 --- a/wise-webapp/src/test/sql/hsql/drop-schemas.sql +++ b/wise-webapp/src/test/sql/hsql/drop-schemas.sql @@ -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; diff --git a/wise-webapp/src/test/sql/mysql/create-schemas.sql b/wise-webapp/src/test/sql/mysql/create-schemas.sql index afb1d845..ab5e6d6b 100644 --- a/wise-webapp/src/test/sql/mysql/create-schemas.sql +++ b/wise-webapp/src/test/sql/mysql/create-schemas.sql @@ -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, diff --git a/wise-webapp/src/test/sql/mysql/drop-schemas.sql b/wise-webapp/src/test/sql/mysql/drop-schemas.sql index 8c02fe84..ef704c04 100644 --- a/wise-webapp/src/test/sql/mysql/drop-schemas.sql +++ b/wise-webapp/src/test/sql/mysql/drop-schemas.sql @@ -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;