mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-21 21:57:56 +01:00
Optimize to avoid single selects on OnToMany in mindmap.
This commit is contained in:
parent
86964febc1
commit
708a42c560
@ -19,6 +19,9 @@
|
||||
package com.wisemapping.model;
|
||||
|
||||
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
@ -23,6 +23,8 @@ import com.wisemapping.exceptions.InvalidMindmapException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.util.ZipUtils;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -64,9 +66,11 @@ public class Mindmap implements Serializable {
|
||||
private boolean isPublic;
|
||||
|
||||
@OneToMany(mappedBy = "mindMap", orphanRemoval = true, cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private Set<Collaboration> collaborations = new HashSet<>();
|
||||
|
||||
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE})
|
||||
@Fetch(FetchMode.JOIN)
|
||||
@JoinTable(
|
||||
name = "R_LABEL_MINDMAP",
|
||||
joinColumns = @JoinColumn(name = "mindmap_id"),
|
||||
|
@ -134,15 +134,8 @@ public class RestMindmapInfo {
|
||||
public String getRole() {
|
||||
final User user = Utils.getUser();
|
||||
String result;
|
||||
if (mindmap.isCreator(user)) {
|
||||
// Performance hack. In case that the person is the creator, assume that the role is owner.
|
||||
// This is to avoid loading all the collaboration maps per map.
|
||||
result = CollaborationRole.OWNER.getLabel();
|
||||
} else {
|
||||
final Optional<Collaboration> collaboration = mindmap.findCollaboration(user);
|
||||
result = collaboration.map(value -> value.getRole().getLabel()).orElse(ROLE_NONE);
|
||||
}
|
||||
return result;
|
||||
final Optional<Collaboration> collaboration = mindmap.findCollaboration(user);
|
||||
return collaboration.map(value -> value.getRole().getLabel()).orElse(ROLE_NONE);
|
||||
}
|
||||
|
||||
public void setRole(String value) {
|
||||
|
Loading…
Reference in New Issue
Block a user