From 94f5b1d07f1533b87797d5d459d4354871cdca91 Mon Sep 17 00:00:00 2001 From: "brian.mulier" Date: Thu, 14 Sep 2023 18:34:44 +0200 Subject: [PATCH] fix(core): added raw setter for app not to override jackson setters --- .../core/models/hierarchies/AbstractGraph.java | 8 ++++++++ .../kestra/core/models/hierarchies/GraphCluster.java | 12 +++++------- .../java/io/kestra/core/services/GraphService.java | 2 +- .../main/java/io/kestra/core/utils/GraphUtils.java | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/io/kestra/core/models/hierarchies/AbstractGraph.java b/core/src/main/java/io/kestra/core/models/hierarchies/AbstractGraph.java index d0b8af1a212..bed8437f434 100644 --- a/core/src/main/java/io/kestra/core/models/hierarchies/AbstractGraph.java +++ b/core/src/main/java/io/kestra/core/models/hierarchies/AbstractGraph.java @@ -33,4 +33,12 @@ public AbstractGraph(String uid) { public String getLabel() { return this.getUid(); } + + public void updateUidWithChildren(String uid) { + this.uid = uid; + } + + public void updateErrorWithChildren(boolean error) { + this.error = error; + } } diff --git a/core/src/main/java/io/kestra/core/models/hierarchies/GraphCluster.java b/core/src/main/java/io/kestra/core/models/hierarchies/GraphCluster.java index f91567856f7..e02e7e332c8 100644 --- a/core/src/main/java/io/kestra/core/models/hierarchies/GraphCluster.java +++ b/core/src/main/java/io/kestra/core/models/hierarchies/GraphCluster.java @@ -69,7 +69,7 @@ public void addNode(AbstractGraph node) { public void addNode(AbstractGraph node, boolean withClusterUidPrefix) { if (withClusterUidPrefix) { - node.setUid(prefixedUid(node.uid)); + node.updateUidWithChildren(prefixedUid(node.uid)); } this.getGraph().addNode(node); } @@ -104,21 +104,19 @@ public String getUid() { } @Override - @JsonIgnore - public void setUid(String uid) { + public void updateUidWithChildren(String uid) { graph.nodes().stream().filter(node -> // filter other clusters' root & end to prevent setting uid multiple times // this is because we need other clusters' root & end to have edges over them, but they are already managed by their own cluster (!(node instanceof GraphClusterRoot) && !(node instanceof GraphClusterEnd)) || node.equals(this.root) || node.equals(this.end)) - .forEach(node -> node.setUid(uid + node.uid.substring(this.uid.length()))); + .forEach(node -> node.updateUidWithChildren(uid + node.uid.substring(this.uid.length()))); - super.setUid(uid); + super.updateUidWithChildren(uid); } @Override - @JsonIgnore - public void setError(boolean error) { + public void updateErrorWithChildren(boolean error) { this.error = error; this.taskNode.error = error; diff --git a/core/src/main/java/io/kestra/core/services/GraphService.java b/core/src/main/java/io/kestra/core/services/GraphService.java index 23e62f8d3a6..cf01e1d596c 100644 --- a/core/src/main/java/io/kestra/core/services/GraphService.java +++ b/core/src/main/java/io/kestra/core/services/GraphService.java @@ -95,7 +95,7 @@ public void replace() { parentCluster.getGraph().removeNode(taskToReplace); if (taskToReplace.isError()) { - clusterForReplacement.setError(true); + clusterForReplacement.updateErrorWithChildren(true); } } } diff --git a/core/src/main/java/io/kestra/core/utils/GraphUtils.java b/core/src/main/java/io/kestra/core/utils/GraphUtils.java index 2018dd64f28..b4b82edd1a8 100644 --- a/core/src/main/java/io/kestra/core/utils/GraphUtils.java +++ b/core/src/main/java/io/kestra/core/utils/GraphUtils.java @@ -280,7 +280,7 @@ private static void fillGraph( graph.addNode(currentGraph); if (relationType == RelationType.ERROR) { - currentGraph.setError(true); + currentGraph.updateErrorWithChildren(true); if (isFirst) { previous = graph.getRoot(); }