Skip to content

Commit 734df7f

Browse files
committed
refacto stashedNode
Signed-off-by: AAJELLAL <[email protected]>
1 parent 1d4de91 commit 734df7f

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

src/main/java/org/gridsuite/study/server/service/StudyService.java

+36-3
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,24 @@ public void deleteNodeResults(InvalidateNodeInfos invalidateNodeInfos) {
17691769

17701770
}
17711771

1772+
//OldName: invalidateBuild part 2
1773+
// this is used to unbuild the node and its children
1774+
public void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) {
1775+
AtomicReference<Long> startTime = new AtomicReference<>(null);
1776+
startTime.set(System.nanoTime());
1777+
InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos();
1778+
invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid));
1779+
1780+
//TODO: change invalidateBuild methode later
1781+
networkModificationTreeService.invalidateBuild(nodeUuid, rootNetworkUuid, false, invalidateNodeInfos, true);
1782+
deleteNodeResults(invalidateNodeInfos);
1783+
1784+
if (startTime.get() != null) {
1785+
LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid,
1786+
TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get()));
1787+
}
1788+
}
1789+
17721790
private void updateStatuses(UUID studyUuid, UUID nodeUuid) {
17731791
updateStatuses(studyUuid, nodeUuid, true);
17741792
}
@@ -1957,9 +1975,7 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String
19571975
AtomicReference<Long> startTime = new AtomicReference<>(null);
19581976
startTime.set(System.nanoTime());
19591977
boolean invalidateChildrenBuild = stashChildren || networkModificationTreeService.hasModifications(nodeId, false);
1960-
getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity ->
1961-
invalidateBuild(studyUuid, nodeId, rootNetworkEntity.getId(), false, !invalidateChildrenBuild, true)
1962-
);
1978+
unbuildStashedNode(studyUuid, nodeId, invalidateChildrenBuild);
19631979
networkModificationTreeService.doStashNode(nodeId, stashChildren);
19641980

19651981
if (startTime.get() != null) {
@@ -1970,6 +1986,23 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String
19701986
notificationService.emitElementUpdated(studyUuid, userId);
19711987
}
19721988

1989+
public void unbuildStashedNode(UUID studyUuid, UUID nodeId, boolean stashChildren) {
1990+
//two case scenario:
1991+
// one node stashed -> unbuild the node
1992+
// a node and its children are stashed -> unbuild all of them
1993+
boolean invalidateChildrenBuild = stashChildren || networkModificationTreeService.hasModifications(nodeId, false);
1994+
List<RootNetworkEntity> studyRootNetworks = getStudyRootNetworks(studyUuid);
1995+
if (invalidateChildrenBuild) {
1996+
studyRootNetworks.forEach(rootNetworkEntity -> {
1997+
unbuildNodeTree(studyUuid, nodeId, rootNetworkEntity.getId());
1998+
});
1999+
} else {
2000+
studyRootNetworks.forEach(rootNetworkEntity -> {
2001+
unbuildStudyNode(studyUuid, nodeId, rootNetworkEntity.getId());
2002+
});
2003+
}
2004+
}
2005+
19732006
public List<Pair<AbstractNode, Integer>> getStashedNodes(UUID studyId) {
19742007
return networkModificationTreeService.getStashedNodes(studyId);
19752008
}

0 commit comments

Comments
 (0)