Rename MindmapUser to Collaboration.

This commit is contained in:
Paulo Gustavo Veiga
2012-06-09 15:49:19 -03:00
parent 6f923656ee
commit 6c8664ada4
31 changed files with 301 additions and 251 deletions

View File

@@ -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;
}
}
}

View File

@@ -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;

View File

@@ -27,27 +27,27 @@ public class Collaborator {
private long id;
private String email;
private Calendar creationDate;
private Set<MindmapUser> mindmapUsers = new HashSet<MindmapUser>();
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
public Collaborator() {}
public Collaborator(Set<MindmapUser> mindmapUsers) {
this.mindmapUsers = mindmapUsers;
public Collaborator(Set<Collaboration> collaborations) {
this.collaborations = collaborations;
}
public void setMindmapUsers(Set<MindmapUser> mindmapUsers)
public void setCollaborations(Set<Collaboration> 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<MindmapUser> getMindmapUsers()
public Set<Collaboration> getCollaborations()
{
return mindmapUsers;
return collaborations;
}
public long getId() {

View File

@@ -41,8 +41,8 @@ public class MindMap {
private Calendar lastModificationTime;
private String lastModifierUser;
private Set<MindmapUser> mindmapUsers = new HashSet<MindmapUser>();
private Set<CollaboratorProperties> collaboratorProperties = new HashSet<CollaboratorProperties>();
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
private Set<MindmapCollaborationProperties> collaboratorProperties = new HashSet<MindmapCollaborationProperties>();
private User owner;
private String properties;
@@ -55,8 +55,8 @@ public class MindMap {
public MindMap() {
}
public MindMap(Set<MindmapUser> mindmapUsers) {
this.mindmapUsers = mindmapUsers;
public MindMap(Set<Collaboration> collaborations) {
this.collaborations = collaborations;
}
//~ Methods ..............................................................................................
@@ -111,16 +111,16 @@ public class MindMap {
return ret;
}
public Set<MindmapUser> getMindmapUsers() {
return mindmapUsers;
public Set<Collaboration> getCollaborations() {
return collaborations;
}
public void setMindmapUsers(Set<MindmapUser> mindmapUsers) {
this.mindmapUsers = mindmapUsers;
public void setCollaborations(Set<Collaboration> 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<CollaboratorProperties> getCollaboratorProperties() {
public Set<MindmapCollaborationProperties> getCollaboratorProperties() {
return collaboratorProperties;
}
public void setCollaboratorProperties(@NotNull Set<CollaboratorProperties> collaboratorProperties) {
public void setCollaboratorProperties(@NotNull Set<MindmapCollaborationProperties> collaboratorProperties) {
this.collaboratorProperties = collaboratorProperties;
}
private CollaboratorProperties findUserProperty(@NotNull Collaborator collaborator) {
final Set<CollaboratorProperties> collaboratorProperties = this.getCollaboratorProperties();
CollaboratorProperties result = null;
for (CollaboratorProperties collaboratorProperty : collaboratorProperties) {
private MindmapCollaborationProperties findUserProperty(@NotNull Collaborator collaborator) {
final Set<MindmapCollaborationProperties> 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();
}

View File

@@ -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(){
}