From 249080cc20ad393889ab27afcefd56605e37dc7b Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 9 Jun 2012 22:55:55 -0300 Subject: [PATCH] Finish collaboration update ... --- .../exceptions/NoMapFoundException.java | 26 ----------- .../com/wisemapping/model/Collaboration.java | 15 +++++-- .../model/CollaborationProperties.java | 23 ---------- .../java/com/wisemapping/model/MindMap.java | 44 ++++++++----------- .../ncontroller/MindmapController.java | 18 ++++++++ .../wisemapping/rest/MindmapController.java | 22 +++++----- .../wisemapping/rest/model/RestMindmap.java | 3 +- ...ption.java => CollaborationException.java} | 8 ++-- .../InvalidActivationCodeException.java | 4 +- .../service/InvalidUserEmailException.java | 4 +- .../wisemapping/service/MindmapService.java | 4 +- .../service/MindmapServiceImpl.java | 23 +++++++--- .../com/wisemapping/view/MindMapBean.java | 40 ----------------- ...boration.hbm.xml => Collaboration.hbm.xml} | 9 +++- .../model/CollaborationProperties.hbm.xml | 15 +++++++ .../com/wisemapping/model/MindMap.hbm.xml | 8 ---- .../MindmapCollaborationProperties.hbm.xml | 29 ------------ .../main/webapp/WEB-INF/wisemapping-dao.xml | 4 +- .../src/test/sql/hsql/create-schemas.sql | 20 ++++----- .../src/test/sql/hsql/drop-schemas.sql | 4 +- .../src/test/sql/mysql/create-schemas.sql | 18 ++++---- .../src/test/sql/mysql/drop-schemas.sql | 4 +- 22 files changed, 136 insertions(+), 209 deletions(-) delete mode 100644 wise-webapp/src/main/java/com/wisemapping/exceptions/NoMapFoundException.java rename wise-webapp/src/main/java/com/wisemapping/service/{InvalidCollaborationException.java => CollaborationException.java} (80%) rename wise-webapp/src/main/resources/com/wisemapping/model/{MindmapCollaboration.hbm.xml => Collaboration.hbm.xml} (69%) create mode 100644 wise-webapp/src/main/resources/com/wisemapping/model/CollaborationProperties.hbm.xml delete mode 100644 wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaborationProperties.hbm.xml diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/NoMapFoundException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/NoMapFoundException.java deleted file mode 100644 index b0018bf3..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/NoMapFoundException.java +++ /dev/null @@ -1,26 +0,0 @@ -/* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package com.wisemapping.exceptions; - -public class NoMapFoundException extends WiseMappingException -{ - public NoMapFoundException(final long mapId) { - super("Could not find a mindmap with id '" + mapId + "'"); - } -} diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java index 17ad13b6..3c99e296 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java @@ -22,10 +22,11 @@ import org.jetbrains.annotations.NotNull; public class Collaboration { - private int id; + private long id; private CollaborationRole role; private MindMap mindMap; private Collaborator collaborator; + private CollaborationProperties collaborationProperties; public Collaboration() { } @@ -40,11 +41,11 @@ public class Collaboration { collaborator.addMindmapUser(this); } - public int getId() { + public long getId() { return id; } - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -92,4 +93,12 @@ public class Collaboration { public void setCollaborator(@NotNull Collaborator collaborator) { this.collaborator = collaborator; } + + public CollaborationProperties getCollaborationProperties() { + return collaborationProperties; + } + + public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) { + this.collaborationProperties = collaborationProperties; + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java index c545cb31..c93d5335 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java @@ -23,14 +23,6 @@ import org.jetbrains.annotations.NotNull; public class CollaborationProperties { private long id; private boolean starred; - private Collaborator collaborator; - private MindMap mindmap; - - - public CollaborationProperties(@NotNull Collaborator collaborator, @NotNull MindMap mindmap) { - this.collaborator = collaborator; - this.mindmap = mindmap; - } public CollaborationProperties(){ @@ -43,13 +35,6 @@ public class CollaborationProperties { public void setStarred(boolean starred) { this.starred = starred; } - public Collaborator getCollaborator() { - return collaborator; - } - - public void setCollaborator(Collaborator collaborator) { - this.collaborator = collaborator; - } public long getId() { return id; @@ -58,12 +43,4 @@ public class CollaborationProperties { public void setId(long id) { this.id = id; } - - public MindMap getMindmap() { - return mindmap; - } - - public void setMindmap(@NotNull MindMap mindmap) { - this.mindmap = mindmap; - } } 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 1a806ea6..d30e0d1b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java @@ -18,6 +18,7 @@ package com.wisemapping.model; +import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.util.ZipUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -43,7 +44,6 @@ public class MindMap { private String lastModifierUser; private Set collaborations = new HashSet(); - private Set collaborationProperties = new HashSet(); private User owner; private String properties; @@ -125,7 +125,12 @@ public class MindMap { } @Nullable - public Collaboration findCollaborationByEmail(@NotNull String email) { + public Collaboration findCollaboration(@NotNull Collaborator collaborator) { + return this.findCollaboration(collaborator.getEmail()); + } + + @Nullable + public Collaboration findCollaboration(@NotNull String email) { Collaboration result = null; for (Collaboration collaboration : collaborations) { if (collaboration.getCollaborator().getEmail().equals(email)) { @@ -235,38 +240,25 @@ public class MindMap { return owner; } - public Set getCollaborationProperties() { - return collaborationProperties; - } - - public void setCollaborationProperties(@NotNull Set collaborationProperties) { - this.collaborationProperties = collaborationProperties; - } - private CollaborationProperties findUserProperty(@NotNull Collaborator collaborator) { - final Set collaborationProp = this.getCollaborationProperties(); - CollaborationProperties result = null; - for (CollaborationProperties collaboratorProperty : collaborationProp) { - final Collaborator propCollab = collaboratorProperty.getCollaborator(); - if (propCollab != null && propCollab.getEmail().equals(collaborator.getEmail())) { - result = collaboratorProperty; - break; - } - } - return result; + final Collaboration collaboration = this.findCollaboration(collaborator); + return collaboration != null ? collaboration.getCollaborationProperties() : null; } - public void setStarred(@NotNull Collaborator collaborator, boolean value) { + public void setStarred(@NotNull Collaborator collaborator, boolean value) throws WiseMappingException { if (collaborator == null) { throw new IllegalStateException("Collaborator can not be null"); } - CollaborationProperties collaboratorProperties = this.findUserProperty(collaborator); - if (collaboratorProperties == null) { - collaboratorProperties = new CollaborationProperties(collaborator, this); + final Collaboration collaboration = this.findCollaboration(collaborator); + if(collaboration==null){ + throw new WiseMappingException("User is not collaborator"); } - collaboratorProperties.setStarred(value); - this.getCollaborationProperties().add(collaboratorProperties); + + if (collaboration.getCollaborationProperties() == null) { + collaboration.setCollaborationProperties(new CollaborationProperties()); + } + collaboration.getCollaborationProperties().setStarred(value); } public boolean isStarred(@NotNull Collaborator collaborator) { 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 22e2a17b..7bbd00e1 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java @@ -1,3 +1,21 @@ +/* +* Copyright [2011] [wisemapping] +* +* Licensed under WiseMapping Public License, Version 1.0 (the "License"). +* It is basically the Apache License, Version 2.0 (the "License") plus the +* "powered by wisemapping" text requirement on every single page; +* you may not use this file except in compliance with the License. +* You may obtain a copy of the license at +* +* http://www.wisemapping.org/license +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + package com.wisemapping.ncontroller; 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 e6056200..7274b405 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -27,7 +27,7 @@ import com.wisemapping.importer.ImporterFactory; import com.wisemapping.model.*; import com.wisemapping.rest.model.*; import com.wisemapping.security.Utils; -import com.wisemapping.service.InvalidCollaborationException; +import com.wisemapping.service.CollaborationException; import com.wisemapping.service.MindmapService; import com.wisemapping.validator.MapInfoValidator; import org.jetbrains.annotations.NotNull; @@ -205,7 +205,7 @@ public class MindmapController extends BaseController { @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, @NotNull @RequestBody RestCollaborationList restCollabs) throws InvalidCollaborationException { + public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException { final MindMap mindMap = mindmapService.getMindmapById(id); final User user = Utils.getUser(); if (!mindMap.getOwner().equals(user)) { @@ -215,16 +215,16 @@ public class MindmapController extends BaseController { // Compare one by one if some of the elements has been changed .... final Set collabsToRemove = new HashSet(mindMap.getCollaborations()); for (RestCollaboration restCollab : restCollabs.getCollaborations()) { - final Collaboration collaboration = mindMap.findCollaborationByEmail(restCollab.getEmail()); + final Collaboration collaboration = mindMap.findCollaboration(restCollab.getEmail()); + // Validate role format ... + String roleStr = restCollab.getRole(); + if (roleStr == null) { + throw new IllegalArgumentException(roleStr + " is not a valid role"); + } - if (CollaborationRole.valueOf(restCollab.getRole()) != CollaborationRole.OWNER) { - - // Validate role ... - String roleStr = restCollab.getRole(); - if (roleStr == null) { - throw new IllegalArgumentException(roleStr + " is not a valid role"); - } - final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase()); + // Is owner ? + final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase()); + if (role != CollaborationRole.OWNER) { mindmapService.addCollaboration(mindMap, restCollab.getEmail(), role); } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java index 9861fe78..0b2e36eb 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java @@ -1,6 +1,7 @@ package com.wisemapping.rest.model; +import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.model.Collaborator; import com.wisemapping.model.MindMap; import com.wisemapping.model.User; @@ -161,7 +162,7 @@ public class RestMindmap { return result; } - public void setStarred(boolean value) { + public void setStarred(boolean value) throws WiseMappingException { if (collaborator != null) { mindmap.setStarred(collaborator, value); } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/InvalidCollaborationException.java b/wise-webapp/src/main/java/com/wisemapping/service/CollaborationException.java similarity index 80% rename from wise-webapp/src/main/java/com/wisemapping/service/InvalidCollaborationException.java rename to wise-webapp/src/main/java/com/wisemapping/service/CollaborationException.java index 65579364..8adf3e16 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/InvalidCollaborationException.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/CollaborationException.java @@ -18,10 +18,12 @@ package com.wisemapping.service; -public class InvalidCollaborationException - extends Exception +import com.wisemapping.exceptions.WiseMappingException; + +public class CollaborationException + extends WiseMappingException { - public InvalidCollaborationException(String msg) + public CollaborationException(String msg) { super(msg); } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/InvalidActivationCodeException.java b/wise-webapp/src/main/java/com/wisemapping/service/InvalidActivationCodeException.java index c7dcc20e..fca6c96d 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/InvalidActivationCodeException.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/InvalidActivationCodeException.java @@ -18,8 +18,10 @@ package com.wisemapping.service; +import com.wisemapping.exceptions.WiseMappingException; + public class InvalidActivationCodeException - extends Exception + extends WiseMappingException { public InvalidActivationCodeException(String msg) { diff --git a/wise-webapp/src/main/java/com/wisemapping/service/InvalidUserEmailException.java b/wise-webapp/src/main/java/com/wisemapping/service/InvalidUserEmailException.java index 6964abc5..f47ad052 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/InvalidUserEmailException.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/InvalidUserEmailException.java @@ -18,7 +18,9 @@ package com.wisemapping.service; -public class InvalidUserEmailException extends Exception +import com.wisemapping.exceptions.WiseMappingException; + +public class InvalidUserEmailException extends WiseMappingException { public InvalidUserEmailException(String msg) { 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 75cdba5d..4f9576ed 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java @@ -42,9 +42,9 @@ public interface MindmapService { public void addMindmap(MindMap map, User user) throws WiseMappingException; public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role) - throws InvalidCollaborationException; + throws CollaborationException; - public void removeCollaboration(@NotNull Collaboration collaboration); + public void removeCollaboration(@NotNull Collaboration collaboration) throws CollaborationException; public void addTags(MindMap mindmap, String tags); 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 deca9509..8f3f90f8 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java @@ -114,14 +114,18 @@ public class MindmapServiceImpl } @Override - public void removeCollaboration(@NotNull Collaboration collaboration) { + public void removeCollaboration(@NotNull Collaboration collaboration) throws CollaborationException { // remove collaborator association final MindMap mindMap = collaboration.getMindMap(); - Set collaborations = mindMap.getCollaborations(); + final Set collaborations = mindMap.getCollaborations(); // When you delete an object from hibernate you have to delete it from *all* collections it exists in... - collaborations.remove(collaboration); + if (mindMap.getOwner().getEmail().equals(collaboration.getCollaborator().getEmail())) { + throw new CollaborationException("User is the creator and must have ownership permissions"); + } + mindmapManager.removeCollaboration(collaboration); + collaborations.remove(collaboration); } @Override @@ -129,7 +133,7 @@ public class MindmapServiceImpl if (mindmap.getOwner().equals(user)) { mindmapManager.removeMindmap(mindmap); } else { - final Collaboration collaboration = mindmap.findCollaborationByEmail(user.getEmail()); + final Collaboration collaboration = mindmap.findCollaboration(user); if (collaboration != null) { this.removeCollaboration(collaboration); } @@ -157,7 +161,7 @@ public class MindmapServiceImpl map.setLastModificationTime(creationTime); map.setOwner(user); - // Hack to reload dbuser ... + // Add map creator with owner permissions ... final User dbUser = userService.getUserBy(user.getId()); final Collaboration collaboration = new Collaboration(CollaborationRole.OWNER, dbUser, map); map.getCollaborations().add(collaboration); @@ -167,13 +171,18 @@ public class MindmapServiceImpl @Override public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role) - throws InvalidCollaborationException { + throws CollaborationException { // Validate final Collaborator owner = mindmap.getOwner(); final Set collaborations = mindmap.getCollaborations(); if (owner.getEmail().equals(email)) { - throw new InvalidCollaborationException("The user " + owner.getEmail() + " is the owner"); + throw new CollaborationException("The user " + owner.getEmail() + " is the owner"); + } + + if (role == CollaborationRole.OWNER) { + throw new CollaborationException("Ownership can not be modified"); + } Collaboration collaboration = getCollaborationBy(email, collaborations); 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 5c26c97e..0b1a8b8f 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java @@ -74,20 +74,6 @@ public class MindMapBean { return mindMap.getLastModifierUser(); } - public String getLastEditDate() { - String result = ""; - Calendar lastEditTime = Calendar.getInstance(); - lastEditTime.setTime(mindMap.getLastModificationTime().getTime()); - Calendar now = Calendar.getInstance(); - int dayDiff = getDaysBetween(now, lastEditTime); - if (dayDiff > 0) { - result = dayDiff + " days ago"; - } else if (dayDiff == 0) { - result = "today"; - } - return result; - } - public String getLastEditTime() { return DateFormat.getInstance().format(mindMap.getLastModificationTime().getTime()); } @@ -116,32 +102,6 @@ public class MindMapBean { return col; } - private static int getDaysBetween(java.util.Calendar d1, java.util.Calendar d2) { - if (d1.after(d2)) { // swap dates so that d1 is start and d2 is end - java.util.Calendar swap = d1; - d1 = d2; - d2 = swap; - } - int days = d2.get(java.util.Calendar.DAY_OF_YEAR) - - d1.get(java.util.Calendar.DAY_OF_YEAR); - int y2 = d2.get(java.util.Calendar.YEAR); - if (d1.get(java.util.Calendar.YEAR) != y2) { - d1 = (java.util.Calendar) d1.clone(); - do { - days += d1.getActualMaximum(java.util.Calendar.DAY_OF_YEAR); - d1.add(java.util.Calendar.YEAR, 1); - } while (d1.get(java.util.Calendar.YEAR) != y2); - } - return days; - } - - public static class MindMapBeanComparator implements Comparator { - - public int compare(MindMapBean o1, MindMapBean o2) { - return o1.getLastEditTime().compareTo(o2.getLastEditTime()); - } - } - public int getCountColaborators() { return colaborators != null ? colaborators.size() : 0; } diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaboration.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/Collaboration.hbm.xml similarity index 69% rename from wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaboration.hbm.xml rename to wise-webapp/src/main/resources/com/wisemapping/model/Collaboration.hbm.xml index 806b0bdf..3b00d82c 100644 --- a/wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaboration.hbm.xml +++ b/wise-webapp/src/main/resources/com/wisemapping/model/Collaboration.hbm.xml @@ -5,7 +5,7 @@ - + @@ -17,13 +17,18 @@ column="MINDMAP_ID" not-null="true" class="com.wisemapping.model.MindMap" - /> + /> + + + + \ No newline at end of file diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/CollaborationProperties.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/CollaborationProperties.hbm.xml new file mode 100644 index 00000000..e8430b3b --- /dev/null +++ b/wise-webapp/src/main/resources/com/wisemapping/model/CollaborationProperties.hbm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file 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 31e3df32..76d965d9 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 @@ -28,14 +28,6 @@ - - - - - - \ No newline at end of file diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaborationProperties.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaborationProperties.hbm.xml deleted file mode 100644 index 108cb089..00000000 --- a/wise-webapp/src/main/resources/com/wisemapping/model/MindmapCollaborationProperties.hbm.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file 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 2be07857..4bddf1a8 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/MindmapCollaboration.hbm.xml - com/wisemapping/model/MindmapCollaborationProperties.hbm.xml + com/wisemapping/model/Collaboration.hbm.xml + com/wisemapping/model/CollaborationProperties.hbm.xml com/wisemapping/model/UserLogin.hbm.xml com/wisemapping/model/MindMapHistory.hbm.xml diff --git a/wise-webapp/src/test/sql/hsql/create-schemas.sql b/wise-webapp/src/test/sql/hsql/create-schemas.sql index 181c54ba..75e0a486 100644 --- a/wise-webapp/src/test/sql/hsql/create-schemas.sql +++ b/wise-webapp/src/test/sql/hsql/create-schemas.sql @@ -32,14 +32,6 @@ editor_properties varchar(512) --FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id) ); -CREATE TABLE MINDMAP_COLLABORATION_PROPERTIES -(id INTEGER NOT NULL IDENTITY, -mindmap_id INTEGER NOT NULL, -collaborator_id INTEGER NOT NULL, -starred BOOLEAN NOT NULL, -FOREIGN KEY(collaborator_id) REFERENCES COLABORATOR(id), -FOREIGN KEY(mindmap_id) REFERENCES MINDMAP(id) -); CREATE TABLE MINDMAP_HISTORY (id INTEGER NOT NULL IDENTITY, @@ -48,15 +40,23 @@ mindmap_id INTEGER NOT NULL, creation_date DATETIME, creator_user varchar(255)); -CREATE TABLE MINDMAP_COLABORATOR +CREATE TABLE COLLABORATION_PROPERTIES +(id INTEGER NOT NULL IDENTITY, +starred BOOLEAN NOT NULL, +); + +CREATE TABLE COLLABORATION (id INTEGER NOT NULL IDENTITY, colaborator_id INTEGER NOT NULL, +properties_id INTEGER, mindmap_id INTEGER NOT NULL, role_id INTEGER NOT NULL, FOREIGN KEY(colaborator_id) REFERENCES COLABORATOR(id), -FOREIGN KEY(mindmap_id) REFERENCES MINDMAP(id) +FOREIGN KEY(mindmap_id) REFERENCES MINDMAP(id), +FOREIGN KEY(properties_id) REFERENCES COLLABORATION_PROPERTIES(id) ); + CREATE TABLE TAG (id INTEGER NOT NULL IDENTITY, name varchar(255) 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 cd247743..75793b5c 100644 --- a/wise-webapp/src/test/sql/hsql/drop-schemas.sql +++ b/wise-webapp/src/test/sql/hsql/drop-schemas.sql @@ -1,6 +1,6 @@ DROP TABLE TAG; -DROP TABLE MINDMAP_COLLABORATION_PROPERTIES; -DROP TABLE MINDMAP_COLABORATOR; +DROP TABLE COLLABORATION_PROPERTIES; +DROP TABLE COLLABORATION; DROP TABLE MINDMAP_HISTORY; DROP TABLE MINDMAP; DROP TABLE USER; diff --git a/wise-webapp/src/test/sql/mysql/create-schemas.sql b/wise-webapp/src/test/sql/mysql/create-schemas.sql index ab5e6d6b..fcb9fb88 100644 --- a/wise-webapp/src/test/sql/mysql/create-schemas.sql +++ b/wise-webapp/src/test/sql/mysql/create-schemas.sql @@ -34,15 +34,6 @@ FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id) ) CHARACTER SET utf8 ; -CREATE TABLE MINDMAP_COLLABORATION_PROPERTIES( -id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, -mindmap_id INTEGER NOT NULL, -collaborator_id INTEGER NOT NULL, -starred BOOL NOT NULL default 0, -FOREIGN KEY(collaborator_id) REFERENCES COLABORATOR(id), -FOREIGN KEY(mindmap_id) REFERENCES MINDMAP(id) -) CHARACTER SET utf8; - CREATE TABLE MINDMAP_HISTORY (id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, xml blob NOT NULL, @@ -51,13 +42,20 @@ creation_date datetime, creator_user varchar(255) CHARACTER SET utf8 ) CHARACTER SET utf8 ; -CREATE TABLE MINDMAP_COLABORATOR ( +CREATE TABLE COLLABORATION_PROPERTIES( +id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, +starred BOOL NOT NULL default 0, +) CHARACTER SET utf8; + +CREATE TABLE COLLABORATION ( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, colaborator_id INTEGER NOT NULL, +properties_id INTEGER NOT NULL, mindmap_id INTEGER NOT NULL, role_id INTEGER NOT NULL, FOREIGN KEY(colaborator_id) REFERENCES COLABORATOR(id), FOREIGN KEY(mindmap_id) REFERENCES MINDMAP(id) +FOREIGN KEY(properties_id) REFERENCES COLLABORATION_PROPERTIES(id), ) CHARACTER SET utf8 ; CREATE TABLE TAG( diff --git a/wise-webapp/src/test/sql/mysql/drop-schemas.sql b/wise-webapp/src/test/sql/mysql/drop-schemas.sql index ef704c04..d69fd571 100644 --- a/wise-webapp/src/test/sql/mysql/drop-schemas.sql +++ b/wise-webapp/src/test/sql/mysql/drop-schemas.sql @@ -1,6 +1,6 @@ DROP TABLE TAG; -DROP TABLE MINDMAP_COLLABORATION_PROPERTIES; -DROP TABLE MINDMAP_COLABORATOR; +DROP TABLE COLLABORATION_PROPERTIES; +DROP TABLE COLLABORATION; DROP TABLE MINDMAP_HISTORY; DROP TABLE MINDMAP; DROP TABLE USER;