Get Collaboration list completed.

This commit is contained in:
Paulo Gustavo Veiga
2012-06-09 22:49:54 -03:00
parent 6c8664ada4
commit aeb0ef0668
26 changed files with 268 additions and 555 deletions

View File

@@ -36,7 +36,7 @@ public class Collaboration {
this.collaborator = collaborator;
// Guarantee referential integrity
mindmap.addMindmapUser(this);
mindmap.addCollaboration(this);
collaborator.addMindmapUser(this);
}
@@ -60,6 +60,10 @@ public class Collaboration {
return role;
}
public void setRole(@NotNull CollaborationRole role) {
this.role = role;
}
public boolean isOwner() {
return getRole() == CollaborationRole.OWNER;
}

View File

@@ -18,12 +18,12 @@
package com.wisemapping.model;
public class ColaborationEmail
public class CollaborationEmail
{
private String subject;
private String message;
public ColaborationEmail(){}
public CollaborationEmail(){}
public String getSubject() {
return subject;

View File

@@ -20,19 +20,19 @@ package com.wisemapping.model;
import org.jetbrains.annotations.NotNull;
public class MindmapCollaborationProperties {
public class CollaborationProperties {
private long id;
private boolean starred;
private Collaborator collaborator;
private MindMap mindmap;
public MindmapCollaborationProperties(@NotNull Collaborator collaborator, @NotNull MindMap mindmap) {
public CollaborationProperties(@NotNull Collaborator collaborator, @NotNull MindMap mindmap) {
this.collaborator = collaborator;
this.mindmap = mindmap;
}
public MindmapCollaborationProperties(){
public CollaborationProperties(){
}

View File

@@ -20,6 +20,7 @@ package com.wisemapping.model;
import com.wisemapping.util.ZipUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -42,7 +43,7 @@ public class MindMap {
private String lastModifierUser;
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
private Set<MindmapCollaborationProperties> collaboratorProperties = new HashSet<MindmapCollaborationProperties>();
private Set<CollaborationProperties> collaborationProperties = new HashSet<CollaborationProperties>();
private User owner;
private String properties;
@@ -55,10 +56,6 @@ public class MindMap {
public MindMap() {
}
public MindMap(Set<Collaboration> collaborations) {
this.collaborations = collaborations;
}
//~ Methods ..............................................................................................
public void setXml(byte[] xml) {
@@ -119,10 +116,26 @@ public class MindMap {
this.collaborations = collaborations;
}
public void addMindmapUser(Collaboration collaboration) {
public void addCollaboration(@NotNull Collaboration collaboration) {
collaborations.add(collaboration);
}
public void removedCollaboration(@NotNull Collaboration collaboration) {
collaborations.add(collaboration);
}
@Nullable
public Collaboration findCollaborationByEmail(@NotNull String email) {
Collaboration result = null;
for (Collaboration collaboration : collaborations) {
if (collaboration.getCollaborator().getEmail().equals(email)) {
result = collaboration;
break;
}
}
return result;
}
public boolean isPublic() {
return isPublic;
}
@@ -222,18 +235,18 @@ public class MindMap {
return owner;
}
public Set<MindmapCollaborationProperties> getCollaboratorProperties() {
return collaboratorProperties;
public Set<CollaborationProperties> getCollaborationProperties() {
return collaborationProperties;
}
public void setCollaboratorProperties(@NotNull Set<MindmapCollaborationProperties> collaboratorProperties) {
this.collaboratorProperties = collaboratorProperties;
public void setCollaborationProperties(@NotNull Set<CollaborationProperties> collaborationProperties) {
this.collaborationProperties = collaborationProperties;
}
private MindmapCollaborationProperties findUserProperty(@NotNull Collaborator collaborator) {
final Set<MindmapCollaborationProperties> collaboratorProperties = this.getCollaboratorProperties();
MindmapCollaborationProperties result = null;
for (MindmapCollaborationProperties collaboratorProperty : collaboratorProperties) {
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;
@@ -244,20 +257,20 @@ public class MindMap {
}
public void setStarred(@NotNull Collaborator collaborator, boolean value) {
if(collaborator==null){
throw new IllegalStateException("Collaborator can not be null");
if (collaborator == null) {
throw new IllegalStateException("Collaborator can not be null");
}
MindmapCollaborationProperties collaboratorProperties = this.findUserProperty(collaborator);
CollaborationProperties collaboratorProperties = this.findUserProperty(collaborator);
if (collaboratorProperties == null) {
collaboratorProperties = new MindmapCollaborationProperties(collaborator, this);
collaboratorProperties = new CollaborationProperties(collaborator, this);
}
collaboratorProperties.setStarred(value);
this.getCollaboratorProperties().add(collaboratorProperties);
this.getCollaborationProperties().add(collaboratorProperties);
}
public boolean isStarred(@NotNull Collaborator collaborator) {
final MindmapCollaborationProperties collaboratorProperty = this.findUserProperty(collaborator);
final CollaborationProperties collaboratorProperty = this.findUserProperty(collaborator);
return collaboratorProperty != null && collaboratorProperty.getStarred();
}