Clean up dependencies on map delete

This commit is contained in:
Paulo Gustavo Veiga 2022-09-27 18:47:56 -07:00
parent 599bc9ec00
commit 5f26874b47
3 changed files with 14 additions and 7 deletions

View File

@ -227,15 +227,18 @@ public class MindmapManagerImpl
}
@Override
public void removeMindmap(@NotNull final Mindmap mindMap) {
public void removeMindmap(@NotNull final Mindmap mindmap) {
// Delete history first ...
final Criteria hibernateCriteria = currentSession().createCriteria(MindMapHistory.class);
hibernateCriteria.add(Restrictions.eq("mindmapId", mindMap.getId()));
List list = hibernateCriteria.list();
hibernateCriteria.add(Restrictions.eq("mindmapId", mindmap.getId()));
final List list = hibernateCriteria.list();
getHibernateTemplate().deleteAll(list);
// Remove collaborations ...
mindmap.removedCollaboration(mindmap.getCollaborations());
// Delete mindmap ....
getHibernateTemplate().delete(mindMap);
getHibernateTemplate().delete(mindmap);
}
private void saveHistory(@NotNull final Mindmap mindMap) {

View File

@ -146,7 +146,11 @@ public class Mindmap implements Serializable {
}
public void removedCollaboration(@NotNull Collaboration collaboration) {
collaborations.add(collaboration);
collaborations.remove(collaboration);
}
public void removedCollaboration(@NotNull Set<Collaboration> collaborations) {
this.collaborations.removeAll(collaborations);
}
@NotNull
@ -182,7 +186,7 @@ public class Mindmap implements Serializable {
}
public boolean isCreator(@NotNull User user) {
return this.getCreator()!=null && this.getCreator().identityEquality(user);
return this.getCreator() != null && this.getCreator().identityEquality(user);
}
public boolean isPublic() {

View File

@ -129,7 +129,7 @@ public class AccountController extends BaseController {
}
// Delete labels ....
List<Label> labels = labelService.getAll(user);
final List<Label> labels = labelService.getAll(user);
labels.forEach(l -> {
try {
labelService.removeLabel(l, user);