Finish collaboration update ...
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||
private Set<CollaborationProperties> collaborationProperties = new HashSet<CollaborationProperties>();
|
||||
|
||||
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<CollaborationProperties> getCollaborationProperties() {
|
||||
return collaborationProperties;
|
||||
}
|
||||
|
||||
public void setCollaborationProperties(@NotNull Set<CollaborationProperties> collaborationProperties) {
|
||||
this.collaborationProperties = collaborationProperties;
|
||||
}
|
||||
|
||||
private CollaborationProperties findUserProperty(@NotNull Collaborator collaborator) {
|
||||
final Set<CollaborationProperties> 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) {
|
||||
|
||||
Reference in New Issue
Block a user