@@ -59,6 +59,7 @@ def update_nodes(t)
5959 current_node = all_nodes [ node_index ]
6060
6161 update_node ( t , current_node , current_node_input )
62+ update_node_parameters ( t , current_node , current_node_input )
6263
6364 current_node_input = current_node_input . next_node
6465 node_index += 1
@@ -70,19 +71,36 @@ def update_node(t, current_node, current_node_input)
7071 end
7172
7273 def update_node_parameters ( t , current_node , current_node_input )
73- current_node_input . parameters . each do |parameter |
74- node_parameter = current_node . parameters . find_or_initialize_by ( runtime_parameter_definition_id : parameter . runtime_parameter_definition_id )
75- node_parameter . value = parameter . value
76-
77- next if node_parameter . valid?
74+ db_parameters = current_node . node_parameters . first ( current_node_input . parameters . count )
75+ current_node_input . parameters . each_with_index do |parameter , index |
76+ db_parameters [ index ] ||= NodeParameter . new
77+ db_parameters [ index ] . runtime_parameter_definition_id = parameter . runtime_parameter_definition_id . model_id
78+ if parameter . value . function_value
79+ db_parameters [ index ] . function_value = SagittariusSchema . object_from_id ( parameter . value . function_value . runtime_function_id )
80+ db_parameters [ index ] . literal_value = nil
81+ db_parameters [ index ] . reference_value = nil
82+ elsif parameter . value . literal_value
83+ db_parameters [ index ] . literal_value = parameter . value . literal_value
84+ db_parameters [ index ] . function_value = nil
85+ db_parameters [ index ] . reference_value = nil
86+ else
87+ db_parameters [ index ] . reference_value = ReferenceValue . create (
88+ reference_value_id : parameter . value . reference_value . reference_value_id ,
89+ data_type_identifier : get_data_type_identifier ( identifier )
90+ )
91+ db_parameters [ index ] . literal_value = nil
92+ db_parameters [ index ] . function_value = nil
93+ end
94+
95+ next if db_parameters [ index ] . valid?
7896
7997 t . rollback_and_return! ServiceResponse . error (
8098 message : 'Invalid node parameter' ,
81- payload : node_parameter . errors
99+ payload : db_parameters [ index ] . errors
82100 )
83101 end
84102
85- current_node . node_parameters . where . not ( runtime_parameter_id : current_node_input . parameters . map ( & :runtime_parameter_definition_id ) ) . destroy_all
103+ current_node . node_parameters = db_parameters
86104 end
87105
88106 def validate_flow ( t )
0 commit comments