Workaround to solve maps visibility problem on missing COLLABORATION entry.
parent
b5e7389e41
commit
704fb1a880
|
@ -29,16 +29,8 @@ public interface MindmapManager {
|
|||
|
||||
Collaborator findCollaborator(@NotNull String email);
|
||||
|
||||
Collaborator findCollaborator(int id);
|
||||
|
||||
List<Collaboration> findCollaboration(final int collaboratorId);
|
||||
|
||||
List<Collaboration> findCollaboration(final CollaborationRole userRole);
|
||||
|
||||
Collaboration findCollaboration(final int mindmapId, final User user);
|
||||
|
||||
List<Mindmap> getAllMindmaps();
|
||||
|
||||
@Nullable
|
||||
Mindmap getMindmapById(int mindmapId);
|
||||
|
||||
|
|
|
@ -116,9 +116,11 @@ public class MindmapManagerImpl
|
|||
|
||||
@Override
|
||||
public List<Mindmap> findMindmapByUser(@NotNull User user) {
|
||||
|
||||
final Mindmap collaborator;
|
||||
// Note: Inconsistency on the COLLABORATION table (m.creator.id=:collabId). Needs to review it.
|
||||
final Query query = currentSession()
|
||||
.createQuery("from com.wisemapping.model.Mindmap m where m.id in (select c.mindMap.id from com.wisemapping.model.Collaboration as c where c.collaborator.id=:collabId )");
|
||||
.createQuery("from com.wisemapping.model.Mindmap m where m.creator.id=:collabId OR m.id in (select c.mindMap.id from com.wisemapping.model.Collaboration as c where c.collaborator.id=:collabId )");
|
||||
query.setParameter("collabId", user.getId());
|
||||
|
||||
return query.getResultList();
|
||||
|
@ -159,11 +161,6 @@ public class MindmapManagerImpl
|
|||
return hibernateCriteria.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collaborator findCollaborator(int id) {
|
||||
return getHibernateTemplate().get(Collaborator.class, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Collaboration> findCollaboration(final int collaboratorId) {
|
||||
Query query = currentSession().createQuery("from com.wisemapping.model.Collaboration c where c.collaborator.id=:collaboratorId");
|
||||
|
@ -171,32 +168,6 @@ public class MindmapManagerImpl
|
|||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Collaboration> findCollaboration(final CollaborationRole collaborationRole) {
|
||||
Query query = currentSession().createQuery("from com.wisemapping.model.Collaboration c where c.role=:roleId");
|
||||
query.setParameter("roleId", collaborationRole.ordinal());
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collaboration findCollaboration(final int mindmapId, final User user) {
|
||||
final Collaboration result;
|
||||
|
||||
Query query = currentSession().createQuery("from com.wisemapping.model.Collaboration c where c.mindMap.id=:mindmapId and c.id=:collaboratorId");
|
||||
query.setParameter("mindmapId", mindmapId);
|
||||
query.setParameter("collaboratorId", user.getId());
|
||||
|
||||
final List<Collaboration> mindMaps = query.getResultList();
|
||||
|
||||
if (mindMaps != null && !mindMaps.isEmpty()) {
|
||||
result = mindMaps.get(0);
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollaborator(@NotNull Collaborator collaborator) {
|
||||
assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!";
|
||||
|
@ -213,12 +184,6 @@ public class MindmapManagerImpl
|
|||
getHibernateTemplate().delete(collaborator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Mindmap> getAllMindmaps() {
|
||||
return currentSession().createQuery("from com.wisemapping.model.Mindmap wisemapping").list();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Mindmap getMindmapById(int id) {
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.model;
|
||||
|
||||
|
@ -36,14 +36,14 @@ import java.util.Set;
|
|||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class Collaborator implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
private String email;
|
||||
|
||||
@Column(name = "creation_date")
|
||||
private Calendar creationDate;
|
||||
|
||||
@OneToMany(mappedBy="collaborator")
|
||||
@OneToMany(mappedBy = "collaborator")
|
||||
private Set<Collaboration> collaborations = new HashSet<>();
|
||||
|
||||
public Collaborator() {
|
||||
|
@ -117,7 +117,6 @@ public class Collaborator implements Serializable {
|
|||
|
||||
if (id != that.getId()) return false;
|
||||
return email != null ? email.equals(that.getEmail()) : that.getEmail() == null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class MindmapController extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/", produces = {"application/json"})
|
||||
public RestMindmapList retrieveList(@RequestParam(required = false) String q) throws IOException {
|
||||
public RestMindmapList retrieveList(@RequestParam(required = false) String q) {
|
||||
final User user = Utils.getUser();
|
||||
|
||||
final MindmapFilter filter = MindmapFilter.parse(q);
|
||||
|
|
Loading…
Reference in New Issue