Optimize mindmap list query.
This commit is contained in:
@@ -15,7 +15,7 @@ public interface LabelService {
|
||||
@NotNull List<Label> getAll(@NotNull final User user);
|
||||
|
||||
@Nullable
|
||||
Label getLabelById(int id, @NotNull final User user);
|
||||
Label findLabelById(int id, @NotNull final User user);
|
||||
|
||||
Label getLabelByTitle(@NotNull String title, @NotNull final User user);
|
||||
|
||||
|
@@ -31,7 +31,7 @@ public class LabelServiceImpl implements LabelService {
|
||||
}
|
||||
|
||||
@Override @Nullable
|
||||
public Label getLabelById(int id, @NotNull final User user) {
|
||||
public Label findLabelById(int id, @NotNull final User user) {
|
||||
return labelManager.getLabelById(id, user);
|
||||
}
|
||||
|
||||
|
@@ -20,9 +20,9 @@ package com.wisemapping.service;
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@@ -31,6 +31,9 @@ public interface MindmapService {
|
||||
@Nullable
|
||||
Mindmap findMindmapById(int id);
|
||||
|
||||
@NotNull
|
||||
List<Mindmap> findMindmapsByUser(@NotNull User user);
|
||||
|
||||
Mindmap getMindmapByTitle(@NotNull String title, User user);
|
||||
|
||||
List<Collaboration> findCollaborations(@NotNull User user);
|
||||
@@ -65,8 +68,4 @@ public interface MindmapService {
|
||||
boolean isAdmin(@Nullable User user);
|
||||
|
||||
void purgeHistory(int mapId) throws IOException;
|
||||
|
||||
void linkLabel(@NotNull final Mindmap mindmap, @NotNull final Label label);
|
||||
|
||||
void removeLabel(@NotNull final Mindmap mindmap, @NotNull final Label label);
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@@ -68,9 +69,11 @@ public class MindmapServiceImpl
|
||||
if ((map.isPublic() && role == CollaborationRole.VIEWER) || isAdmin(user)) {
|
||||
result = true;
|
||||
} else if (user != null) {
|
||||
final Collaboration collaboration = map.findCollaboration(user);
|
||||
if (collaboration != null) {
|
||||
result = collaboration.hasPermissions(role);
|
||||
final Optional<Collaboration> collaboration = map.findCollaboration(user);
|
||||
if (collaboration .isPresent()) {
|
||||
result = collaboration
|
||||
.get()
|
||||
.hasPermissions(role);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,16 +90,6 @@ public class MindmapServiceImpl
|
||||
mindmapManager.purgeHistory(mapId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void linkLabel(@NotNull Mindmap mindmap, @NotNull final Label label) {
|
||||
mindmap.addLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLabel(@NotNull Mindmap mindmap, @NotNull Label label) {
|
||||
mindmap.removeLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mindmap getMindmapByTitle(String title, User user) {
|
||||
return mindmapManager.getMindmapByTitle(title, user);
|
||||
@@ -108,6 +101,12 @@ public class MindmapServiceImpl
|
||||
return mindmapManager.getMindmapById(id);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Mindmap> findMindmapsByUser(@NotNull User user) {
|
||||
return mindmapManager.findMindmapByUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Collaboration> findCollaborations(@NotNull User user) {
|
||||
return mindmapManager.findCollaboration(user.getId());
|
||||
@@ -160,9 +159,9 @@ public class MindmapServiceImpl
|
||||
if (mindmap.getCreator().identityEquality(user) || isAdmin(user)) {
|
||||
mindmapManager.removeMindmap(mindmap);
|
||||
} else {
|
||||
final Collaboration collaboration = mindmap.findCollaboration(user);
|
||||
if (collaboration != null) {
|
||||
this.removeCollaboration(mindmap, collaboration);
|
||||
final Optional<Collaboration> collaboration = mindmap.findCollaboration(user);
|
||||
if (collaboration.isPresent()) {
|
||||
this.removeCollaboration(mindmap, collaboration.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user