@@ -66,10 +66,54 @@ public class ExecutionManager {
6666 private static class ChainController {
6767 final Node startNode ;
6868 volatile boolean cancelRequested ;
69+ final Map <String , RuntimeVariable > runtimeVariables ;
6970
7071 ChainController (Node startNode ) {
7172 this .startNode = startNode ;
7273 this .cancelRequested = false ;
74+ this .runtimeVariables = new ConcurrentHashMap <>();
75+ }
76+ }
77+
78+ public static final class RuntimeVariable {
79+ private final NodeType type ;
80+ private final Map <String , String > values ;
81+
82+ public RuntimeVariable (NodeType type , Map <String , String > values ) {
83+ this .type = type ;
84+ this .values = values == null ? Collections .emptyMap () : new HashMap <>(values );
85+ }
86+
87+ public NodeType getType () {
88+ return type ;
89+ }
90+
91+ public Map <String , String > getValues () {
92+ return Collections .unmodifiableMap (values );
93+ }
94+ }
95+
96+ public static final class RuntimeVariableEntry {
97+ private final String startNodeId ;
98+ private final String name ;
99+ private final RuntimeVariable variable ;
100+
101+ public RuntimeVariableEntry (String startNodeId , String name , RuntimeVariable variable ) {
102+ this .startNodeId = startNodeId ;
103+ this .name = name ;
104+ this .variable = variable ;
105+ }
106+
107+ public String getStartNodeId () {
108+ return startNodeId ;
109+ }
110+
111+ public String getName () {
112+ return name ;
113+ }
114+
115+ public RuntimeVariable getVariable () {
116+ return variable ;
73117 }
74118 }
75119
@@ -138,6 +182,49 @@ public static ExecutionManager getInstance() {
138182 return instance ;
139183 }
140184
185+ public boolean setRuntimeVariable (Node startNode , String name , RuntimeVariable value ) {
186+ if (startNode == null || name == null || name .trim ().isEmpty () || value == null ) {
187+ return false ;
188+ }
189+ ChainController controller = activeChains .get (startNode );
190+ if (controller == null ) {
191+ return false ;
192+ }
193+ controller .runtimeVariables .put (name .trim (), value );
194+ return true ;
195+ }
196+
197+ public RuntimeVariable getRuntimeVariable (Node startNode , String name ) {
198+ if (startNode == null || name == null || name .trim ().isEmpty ()) {
199+ return null ;
200+ }
201+ ChainController controller = activeChains .get (startNode );
202+ if (controller == null ) {
203+ return null ;
204+ }
205+ return controller .runtimeVariables .get (name .trim ());
206+ }
207+
208+ public List <RuntimeVariableEntry > getRuntimeVariableEntries () {
209+ if (activeChains .isEmpty ()) {
210+ return Collections .emptyList ();
211+ }
212+ List <RuntimeVariableEntry > entries = new ArrayList <>();
213+ for (ChainController controller : activeChains .values ()) {
214+ if (controller == null || controller .runtimeVariables .isEmpty ()) {
215+ continue ;
216+ }
217+ String startId = controller .startNode != null ? controller .startNode .getId () : "" ;
218+ for (Map .Entry <String , RuntimeVariable > entry : controller .runtimeVariables .entrySet ()) {
219+ if (entry .getKey () == null || entry .getValue () == null ) {
220+ continue ;
221+ }
222+ entries .add (new RuntimeVariableEntry (startId , entry .getKey (), entry .getValue ()));
223+ }
224+ }
225+ return entries ;
226+ }
227+
141228 public void executeGraph (List <Node > nodes , List <NodeConnection > connections ) {
142229 executeGraphInternal (nodes , connections , true );
143230 }
0 commit comments