-
Notifications
You must be signed in to change notification settings - Fork 2
remove stash data when un loading study #1062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
1c1ab83
04142d7
3f5a430
d060f1d
2290562
d5b70f5
8a8714e
8f875dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -445,6 +445,41 @@ public void doDeleteTree(UUID studyId) { | |
| } | ||
| } | ||
|
|
||
| @Transactional | ||
| public void deleteAllStashedElements(UUID studyId) { | ||
| List<NodeEntity> nodes = nodesRepository.findAllByStudyId(studyId); | ||
| List<NodeEntity> stashedNodes = new ArrayList<>(); | ||
| List<NodeEntity> notStashedNodes = new ArrayList<>(); | ||
| for (NodeEntity nodeEntity : nodes) { | ||
| if (nodeEntity.isStashed()) { | ||
| stashedNodes.add(nodeEntity); | ||
| } else { | ||
| notStashedNodes.add(nodeEntity); | ||
| } | ||
| } | ||
|
|
||
| // remove stashed modification on not stashed nodes | ||
| List<NetworkModificationNode> networkModificationNodeInfos = networkModificationNodeInfoRepository | ||
| .findAllById(notStashedNodes.stream().map(NodeEntity::getIdNode).toList()) | ||
| .stream().map(NetworkModificationNodeInfoEntity::toDto).toList(); | ||
| List<UUID> stashedModificationGroupUuids = networkModificationNodeInfos.stream() | ||
| .map(NetworkModificationNode::getModificationGroupUuid) | ||
| .toList(); | ||
| networkModificationService.deleteStashedModificationsGroups(stashedModificationGroupUuids); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does a stashed modification exists in a group which contain a non stashed modification in a non stashed node ? |
||
|
|
||
| // remove modification on stashed nodes | ||
| List<NetworkModificationNode> networkModificationNodeInfosToDelete = networkModificationNodeInfoRepository | ||
| .findAllById(stashedNodes.stream().map(NodeEntity::getIdNode).toList()) | ||
| .stream().map(NetworkModificationNodeInfoEntity::toDto).toList(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same remark here |
||
| List<UUID> modificationGroupUuidsToDelete = networkModificationNodeInfosToDelete.stream() | ||
| .map(NetworkModificationNode::getModificationGroupUuid) | ||
| .toList(); | ||
| networkModificationService.deleteModificationsGroups(modificationGroupUuidsToDelete); | ||
| // remove stashed nodes | ||
| networkModificationNodeInfoRepository.deleteAllById(stashedNodes.stream().map(NodeEntity::getIdNode).toList()); | ||
| nodesRepository.deleteAll(stashedNodes); | ||
| } | ||
|
|
||
| @Transactional | ||
| public NodeEntity createRoot(StudyEntity study) { | ||
| NodeEntity node = nodesRepository.save(new NodeEntity(null, null, NodeType.ROOT, study, false, null, new ArrayList<>())); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to pass throught the DTO, this is strange,
NetworkModificationNodeInfoEntityalready has themodificationGroupUuidmember