mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Finish collaboration update ...
This commit is contained in:
parent
aeb0ef0668
commit
249080cc20
@ -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 + "'");
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,10 +22,11 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class Collaboration {
|
public class Collaboration {
|
||||||
|
|
||||||
private int id;
|
private long id;
|
||||||
private CollaborationRole role;
|
private CollaborationRole role;
|
||||||
private MindMap mindMap;
|
private MindMap mindMap;
|
||||||
private Collaborator collaborator;
|
private Collaborator collaborator;
|
||||||
|
private CollaborationProperties collaborationProperties;
|
||||||
|
|
||||||
public Collaboration() {
|
public Collaboration() {
|
||||||
}
|
}
|
||||||
@ -40,11 +41,11 @@ public class Collaboration {
|
|||||||
collaborator.addMindmapUser(this);
|
collaborator.addMindmapUser(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,4 +93,12 @@ public class Collaboration {
|
|||||||
public void setCollaborator(@NotNull Collaborator collaborator) {
|
public void setCollaborator(@NotNull Collaborator collaborator) {
|
||||||
this.collaborator = collaborator;
|
this.collaborator = collaborator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CollaborationProperties getCollaborationProperties() {
|
||||||
|
return collaborationProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) {
|
||||||
|
this.collaborationProperties = collaborationProperties;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
public class CollaborationProperties {
|
public class CollaborationProperties {
|
||||||
private long id;
|
private long id;
|
||||||
private boolean starred;
|
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(){
|
public CollaborationProperties(){
|
||||||
|
|
||||||
@ -43,13 +35,6 @@ public class CollaborationProperties {
|
|||||||
public void setStarred(boolean starred) {
|
public void setStarred(boolean starred) {
|
||||||
this.starred = starred;
|
this.starred = starred;
|
||||||
}
|
}
|
||||||
public Collaborator getCollaborator() {
|
|
||||||
return collaborator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCollaborator(Collaborator collaborator) {
|
|
||||||
this.collaborator = collaborator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
@ -58,12 +43,4 @@ public class CollaborationProperties {
|
|||||||
public void setId(long id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MindMap getMindmap() {
|
|
||||||
return mindmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMindmap(@NotNull MindMap mindmap) {
|
|
||||||
this.mindmap = mindmap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.wisemapping.model;
|
package com.wisemapping.model;
|
||||||
|
|
||||||
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.util.ZipUtils;
|
import com.wisemapping.util.ZipUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -43,7 +44,6 @@ public class MindMap {
|
|||||||
private String lastModifierUser;
|
private String lastModifierUser;
|
||||||
|
|
||||||
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||||
private Set<CollaborationProperties> collaborationProperties = new HashSet<CollaborationProperties>();
|
|
||||||
|
|
||||||
private User owner;
|
private User owner;
|
||||||
private String properties;
|
private String properties;
|
||||||
@ -125,7 +125,12 @@ public class MindMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@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;
|
Collaboration result = null;
|
||||||
for (Collaboration collaboration : collaborations) {
|
for (Collaboration collaboration : collaborations) {
|
||||||
if (collaboration.getCollaborator().getEmail().equals(email)) {
|
if (collaboration.getCollaborator().getEmail().equals(email)) {
|
||||||
@ -235,38 +240,25 @@ public class MindMap {
|
|||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<CollaborationProperties> getCollaborationProperties() {
|
|
||||||
return collaborationProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCollaborationProperties(@NotNull Set<CollaborationProperties> collaborationProperties) {
|
|
||||||
this.collaborationProperties = collaborationProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CollaborationProperties findUserProperty(@NotNull Collaborator collaborator) {
|
private CollaborationProperties findUserProperty(@NotNull Collaborator collaborator) {
|
||||||
final Set<CollaborationProperties> collaborationProp = this.getCollaborationProperties();
|
final Collaboration collaboration = this.findCollaboration(collaborator);
|
||||||
CollaborationProperties result = null;
|
return collaboration != null ? collaboration.getCollaborationProperties() : null;
|
||||||
for (CollaborationProperties collaboratorProperty : collaborationProp) {
|
|
||||||
final Collaborator propCollab = collaboratorProperty.getCollaborator();
|
|
||||||
if (propCollab != null && propCollab.getEmail().equals(collaborator.getEmail())) {
|
|
||||||
result = collaboratorProperty;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStarred(@NotNull Collaborator collaborator, boolean value) {
|
public void setStarred(@NotNull Collaborator collaborator, boolean value) throws WiseMappingException {
|
||||||
if (collaborator == null) {
|
if (collaborator == null) {
|
||||||
throw new IllegalStateException("Collaborator can not be null");
|
throw new IllegalStateException("Collaborator can not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
CollaborationProperties collaboratorProperties = this.findUserProperty(collaborator);
|
final Collaboration collaboration = this.findCollaboration(collaborator);
|
||||||
if (collaboratorProperties == null) {
|
if(collaboration==null){
|
||||||
collaboratorProperties = new CollaborationProperties(collaborator, this);
|
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) {
|
public boolean isStarred(@NotNull Collaborator collaborator) {
|
||||||
|
@ -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;
|
package com.wisemapping.ncontroller;
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import com.wisemapping.importer.ImporterFactory;
|
|||||||
import com.wisemapping.model.*;
|
import com.wisemapping.model.*;
|
||||||
import com.wisemapping.rest.model.*;
|
import com.wisemapping.rest.model.*;
|
||||||
import com.wisemapping.security.Utils;
|
import com.wisemapping.security.Utils;
|
||||||
import com.wisemapping.service.InvalidCollaborationException;
|
import com.wisemapping.service.CollaborationException;
|
||||||
import com.wisemapping.service.MindmapService;
|
import com.wisemapping.service.MindmapService;
|
||||||
import com.wisemapping.validator.MapInfoValidator;
|
import com.wisemapping.validator.MapInfoValidator;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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"})
|
@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)
|
@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 MindMap mindMap = mindmapService.getMindmapById(id);
|
||||||
final User user = Utils.getUser();
|
final User user = Utils.getUser();
|
||||||
if (!mindMap.getOwner().equals(user)) {
|
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 ....
|
// Compare one by one if some of the elements has been changed ....
|
||||||
final Set<Collaboration> collabsToRemove = new HashSet<Collaboration>(mindMap.getCollaborations());
|
final Set<Collaboration> collabsToRemove = new HashSet<Collaboration>(mindMap.getCollaborations());
|
||||||
for (RestCollaboration restCollab : restCollabs.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) {
|
// Is owner ?
|
||||||
|
final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase());
|
||||||
// Validate role ...
|
if (role != CollaborationRole.OWNER) {
|
||||||
String roleStr = restCollab.getRole();
|
|
||||||
if (roleStr == null) {
|
|
||||||
throw new IllegalArgumentException(roleStr + " is not a valid role");
|
|
||||||
}
|
|
||||||
final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase());
|
|
||||||
mindmapService.addCollaboration(mindMap, restCollab.getEmail(), role);
|
mindmapService.addCollaboration(mindMap, restCollab.getEmail(), role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.wisemapping.rest.model;
|
package com.wisemapping.rest.model;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
import com.wisemapping.model.Collaborator;
|
import com.wisemapping.model.Collaborator;
|
||||||
import com.wisemapping.model.MindMap;
|
import com.wisemapping.model.MindMap;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
@ -161,7 +162,7 @@ public class RestMindmap {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStarred(boolean value) {
|
public void setStarred(boolean value) throws WiseMappingException {
|
||||||
if (collaborator != null) {
|
if (collaborator != null) {
|
||||||
mindmap.setStarred(collaborator, value);
|
mindmap.setStarred(collaborator, value);
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,12 @@
|
|||||||
|
|
||||||
package com.wisemapping.service;
|
package com.wisemapping.service;
|
||||||
|
|
||||||
public class InvalidCollaborationException
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
extends Exception
|
|
||||||
|
public class CollaborationException
|
||||||
|
extends WiseMappingException
|
||||||
{
|
{
|
||||||
public InvalidCollaborationException(String msg)
|
public CollaborationException(String msg)
|
||||||
{
|
{
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
@ -18,8 +18,10 @@
|
|||||||
|
|
||||||
package com.wisemapping.service;
|
package com.wisemapping.service;
|
||||||
|
|
||||||
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
|
|
||||||
public class InvalidActivationCodeException
|
public class InvalidActivationCodeException
|
||||||
extends Exception
|
extends WiseMappingException
|
||||||
{
|
{
|
||||||
public InvalidActivationCodeException(String msg)
|
public InvalidActivationCodeException(String msg)
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
package com.wisemapping.service;
|
package com.wisemapping.service;
|
||||||
|
|
||||||
public class InvalidUserEmailException extends Exception
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
|
|
||||||
|
public class InvalidUserEmailException extends WiseMappingException
|
||||||
{
|
{
|
||||||
public InvalidUserEmailException(String msg)
|
public InvalidUserEmailException(String msg)
|
||||||
{
|
{
|
||||||
|
@ -42,9 +42,9 @@ public interface MindmapService {
|
|||||||
public void addMindmap(MindMap map, User user) throws WiseMappingException;
|
public void addMindmap(MindMap map, User user) throws WiseMappingException;
|
||||||
|
|
||||||
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role)
|
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);
|
public void addTags(MindMap mindmap, String tags);
|
||||||
|
|
||||||
|
@ -114,14 +114,18 @@ public class MindmapServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeCollaboration(@NotNull Collaboration collaboration) {
|
public void removeCollaboration(@NotNull Collaboration collaboration) throws CollaborationException {
|
||||||
// remove collaborator association
|
// remove collaborator association
|
||||||
final MindMap mindMap = collaboration.getMindMap();
|
final MindMap mindMap = collaboration.getMindMap();
|
||||||
Set<Collaboration> collaborations = mindMap.getCollaborations();
|
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
||||||
|
|
||||||
// When you delete an object from hibernate you have to delete it from *all* collections it exists in...
|
// 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);
|
mindmapManager.removeCollaboration(collaboration);
|
||||||
|
collaborations.remove(collaboration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -129,7 +133,7 @@ public class MindmapServiceImpl
|
|||||||
if (mindmap.getOwner().equals(user)) {
|
if (mindmap.getOwner().equals(user)) {
|
||||||
mindmapManager.removeMindmap(mindmap);
|
mindmapManager.removeMindmap(mindmap);
|
||||||
} else {
|
} else {
|
||||||
final Collaboration collaboration = mindmap.findCollaborationByEmail(user.getEmail());
|
final Collaboration collaboration = mindmap.findCollaboration(user);
|
||||||
if (collaboration != null) {
|
if (collaboration != null) {
|
||||||
this.removeCollaboration(collaboration);
|
this.removeCollaboration(collaboration);
|
||||||
}
|
}
|
||||||
@ -157,7 +161,7 @@ public class MindmapServiceImpl
|
|||||||
map.setLastModificationTime(creationTime);
|
map.setLastModificationTime(creationTime);
|
||||||
map.setOwner(user);
|
map.setOwner(user);
|
||||||
|
|
||||||
// Hack to reload dbuser ...
|
// Add map creator with owner permissions ...
|
||||||
final User dbUser = userService.getUserBy(user.getId());
|
final User dbUser = userService.getUserBy(user.getId());
|
||||||
final Collaboration collaboration = new Collaboration(CollaborationRole.OWNER, dbUser, map);
|
final Collaboration collaboration = new Collaboration(CollaborationRole.OWNER, dbUser, map);
|
||||||
map.getCollaborations().add(collaboration);
|
map.getCollaborations().add(collaboration);
|
||||||
@ -167,13 +171,18 @@ public class MindmapServiceImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role)
|
public void addCollaboration(@NotNull MindMap mindmap, @NotNull String email, @NotNull CollaborationRole role)
|
||||||
throws InvalidCollaborationException {
|
throws CollaborationException {
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
final Collaborator owner = mindmap.getOwner();
|
final Collaborator owner = mindmap.getOwner();
|
||||||
final Set<Collaboration> collaborations = mindmap.getCollaborations();
|
final Set<Collaboration> collaborations = mindmap.getCollaborations();
|
||||||
if (owner.getEmail().equals(email)) {
|
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);
|
Collaboration collaboration = getCollaborationBy(email, collaborations);
|
||||||
|
@ -74,20 +74,6 @@ public class MindMapBean {
|
|||||||
return mindMap.getLastModifierUser();
|
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() {
|
public String getLastEditTime() {
|
||||||
return DateFormat.getInstance().format(mindMap.getLastModificationTime().getTime());
|
return DateFormat.getInstance().format(mindMap.getLastModificationTime().getTime());
|
||||||
}
|
}
|
||||||
@ -116,32 +102,6 @@ public class MindMapBean {
|
|||||||
return col;
|
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<MindMapBean> {
|
|
||||||
|
|
||||||
public int compare(MindMapBean o1, MindMapBean o2) {
|
|
||||||
return o1.getLastEditTime().compareTo(o2.getLastEditTime());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCountColaborators() {
|
public int getCountColaborators() {
|
||||||
return colaborators != null ? colaborators.size() : 0;
|
return colaborators != null ? colaborators.size() : 0;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<hibernate-mapping>
|
<hibernate-mapping>
|
||||||
|
|
||||||
<class name="com.wisemapping.model.Collaboration" table="MINDMAP_COLABORATOR">
|
<class name="com.wisemapping.model.Collaboration" table="COLLABORATION">
|
||||||
<id name="id">
|
<id name="id">
|
||||||
<generator class="increment"/>
|
<generator class="increment"/>
|
||||||
</id>
|
</id>
|
||||||
@ -17,13 +17,18 @@
|
|||||||
column="MINDMAP_ID"
|
column="MINDMAP_ID"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
class="com.wisemapping.model.MindMap"
|
class="com.wisemapping.model.MindMap"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<many-to-one name="collaborator"
|
<many-to-one name="collaborator"
|
||||||
column="COLABORATOR_ID"
|
column="COLABORATOR_ID"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
class="com.wisemapping.model.Collaborator"
|
class="com.wisemapping.model.Collaborator"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<many-to-one name="collaborationProperties" class="com.wisemapping.model.CollaborationProperties"
|
||||||
|
column="properties_id" not-null="false" cascade="all" unique="true"/>
|
||||||
|
|
||||||
</class>
|
</class>
|
||||||
|
|
||||||
</hibernate-mapping>
|
</hibernate-mapping>
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE hibernate-mapping PUBLIC
|
||||||
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||||
|
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||||
|
|
||||||
|
<hibernate-mapping>
|
||||||
|
|
||||||
|
<class name="com.wisemapping.model.CollaborationProperties" table="COLLABORATION_PROPERTIES">
|
||||||
|
<id name="id">
|
||||||
|
<generator class="increment"/>
|
||||||
|
</id>
|
||||||
|
<property name="starred" column="starred" unique="false" not-null="true"/>
|
||||||
|
</class>
|
||||||
|
|
||||||
|
</hibernate-mapping>
|
@ -28,14 +28,6 @@
|
|||||||
<key column="MINDMAP_ID" not-null="true"/>
|
<key column="MINDMAP_ID" not-null="true"/>
|
||||||
<one-to-many class="com.wisemapping.model.Collaboration"/>
|
<one-to-many class="com.wisemapping.model.Collaboration"/>
|
||||||
</set>
|
</set>
|
||||||
|
|
||||||
<set name="collaborationProperties"
|
|
||||||
cascade="all, delete-orphan"
|
|
||||||
inverse="true">
|
|
||||||
<key column="MINDMAP_ID" not-null="true"/>
|
|
||||||
<one-to-many class="com.wisemapping.model.CollaborationProperties"/>
|
|
||||||
</set>
|
|
||||||
|
|
||||||
</class>
|
</class>
|
||||||
|
|
||||||
</hibernate-mapping>
|
</hibernate-mapping>
|
@ -1,29 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE hibernate-mapping PUBLIC
|
|
||||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
|
||||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
|
||||||
|
|
||||||
<hibernate-mapping>
|
|
||||||
|
|
||||||
<class name="com.wisemapping.model.CollaborationProperties" table="MINDMAP_COLLABORATION_PROPERTIES">
|
|
||||||
<id name="id">
|
|
||||||
<generator class="increment"/>
|
|
||||||
</id>
|
|
||||||
|
|
||||||
<property name="starred" column="starred" unique="false" not-null="true"/>
|
|
||||||
|
|
||||||
<!-- Read-only association property -->
|
|
||||||
<many-to-one name="mindmap"
|
|
||||||
column="MINDMAP_ID"
|
|
||||||
not-null="true"
|
|
||||||
class="com.wisemapping.model.MindMap"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<many-to-one name="collaborator"
|
|
||||||
column="COLLABORATOR_ID"
|
|
||||||
not-null="true"
|
|
||||||
class="com.wisemapping.model.Collaborator"
|
|
||||||
/>
|
|
||||||
</class>
|
|
||||||
|
|
||||||
</hibernate-mapping>
|
|
@ -26,8 +26,8 @@
|
|||||||
<list>
|
<list>
|
||||||
<value>com/wisemapping/model/Collaborator.hbm.xml</value>
|
<value>com/wisemapping/model/Collaborator.hbm.xml</value>
|
||||||
<value>com/wisemapping/model/MindMap.hbm.xml</value>
|
<value>com/wisemapping/model/MindMap.hbm.xml</value>
|
||||||
<value>com/wisemapping/model/MindmapCollaboration.hbm.xml</value>
|
<value>com/wisemapping/model/Collaboration.hbm.xml</value>
|
||||||
<value>com/wisemapping/model/MindmapCollaborationProperties.hbm.xml</value>
|
<value>com/wisemapping/model/CollaborationProperties.hbm.xml</value>
|
||||||
<value>com/wisemapping/model/UserLogin.hbm.xml</value>
|
<value>com/wisemapping/model/UserLogin.hbm.xml</value>
|
||||||
<value>com/wisemapping/model/MindMapHistory.hbm.xml</value>
|
<value>com/wisemapping/model/MindMapHistory.hbm.xml</value>
|
||||||
</list>
|
</list>
|
||||||
|
@ -32,14 +32,6 @@ editor_properties varchar(512)
|
|||||||
--FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id)
|
--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
|
CREATE TABLE MINDMAP_HISTORY
|
||||||
(id INTEGER NOT NULL IDENTITY,
|
(id INTEGER NOT NULL IDENTITY,
|
||||||
@ -48,15 +40,23 @@ mindmap_id INTEGER NOT NULL,
|
|||||||
creation_date DATETIME,
|
creation_date DATETIME,
|
||||||
creator_user varchar(255));
|
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,
|
(id INTEGER NOT NULL IDENTITY,
|
||||||
colaborator_id INTEGER NOT NULL,
|
colaborator_id INTEGER NOT NULL,
|
||||||
|
properties_id INTEGER,
|
||||||
mindmap_id INTEGER NOT NULL,
|
mindmap_id INTEGER NOT NULL,
|
||||||
role_id INTEGER NOT NULL,
|
role_id INTEGER NOT NULL,
|
||||||
FOREIGN KEY(colaborator_id) REFERENCES COLABORATOR(id),
|
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
|
CREATE TABLE TAG
|
||||||
(id INTEGER NOT NULL IDENTITY,
|
(id INTEGER NOT NULL IDENTITY,
|
||||||
name varchar(255) NOT NULL,
|
name varchar(255) NOT NULL,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
DROP TABLE TAG;
|
DROP TABLE TAG;
|
||||||
DROP TABLE MINDMAP_COLLABORATION_PROPERTIES;
|
DROP TABLE COLLABORATION_PROPERTIES;
|
||||||
DROP TABLE MINDMAP_COLABORATOR;
|
DROP TABLE COLLABORATION;
|
||||||
DROP TABLE MINDMAP_HISTORY;
|
DROP TABLE MINDMAP_HISTORY;
|
||||||
DROP TABLE MINDMAP;
|
DROP TABLE MINDMAP;
|
||||||
DROP TABLE USER;
|
DROP TABLE USER;
|
||||||
|
@ -34,15 +34,6 @@ FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id)
|
|||||||
) CHARACTER SET utf8 ;
|
) 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
|
CREATE TABLE MINDMAP_HISTORY
|
||||||
(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
xml blob NOT NULL,
|
xml blob NOT NULL,
|
||||||
@ -51,13 +42,20 @@ creation_date datetime,
|
|||||||
creator_user varchar(255) CHARACTER SET utf8
|
creator_user varchar(255) CHARACTER SET utf8
|
||||||
) 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,
|
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
colaborator_id INTEGER NOT NULL,
|
colaborator_id INTEGER NOT NULL,
|
||||||
|
properties_id INTEGER NOT NULL,
|
||||||
mindmap_id INTEGER NOT NULL,
|
mindmap_id INTEGER NOT NULL,
|
||||||
role_id INTEGER NOT NULL,
|
role_id INTEGER NOT NULL,
|
||||||
FOREIGN KEY(colaborator_id) REFERENCES COLABORATOR(id),
|
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),
|
||||||
) CHARACTER SET utf8 ;
|
) CHARACTER SET utf8 ;
|
||||||
|
|
||||||
CREATE TABLE TAG(
|
CREATE TABLE TAG(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
DROP TABLE TAG;
|
DROP TABLE TAG;
|
||||||
DROP TABLE MINDMAP_COLLABORATION_PROPERTIES;
|
DROP TABLE COLLABORATION_PROPERTIES;
|
||||||
DROP TABLE MINDMAP_COLABORATOR;
|
DROP TABLE COLLABORATION;
|
||||||
DROP TABLE MINDMAP_HISTORY;
|
DROP TABLE MINDMAP_HISTORY;
|
||||||
DROP TABLE MINDMAP;
|
DROP TABLE MINDMAP;
|
||||||
DROP TABLE USER;
|
DROP TABLE USER;
|
||||||
|
Loading…
Reference in New Issue
Block a user