# # # # save_re_data_util.cfv # # # override_existing_report_element_with_new_report_element_data() # # # # # # override_existing_report_element_with_new_report_element_data() # # # subroutine(override_existing_report_element_with_new_report_element_data( node existing_report_element, node new_report_element), ( debug_message("#### override_existing_report_element_with_new_report_element_data() START \n"); debug_message("#### existing_report_element:\n" . node_as_string(existing_report_element) . "\n\n"); debug_message("#### new_report_element:\n" . node_as_string(new_report_element) . "\n\n"); node item; string item_name; foreach item new_report_element ( item_name = node_name(item); # The new_report_element does not contain all report element properties, # so we only override properties which exists in the new_report_element # and the existing report_element. if (num_subnodes(item) == 0) then ( if (item_name ne "label" and existing_report_element?{item_name}) then ( if (@item ne @existing_report_element{item_name}) then ( # Override node value set_subnode_value(existing_report_element, item_name, @item); ); ); ) else ( # This is a node with subnodes, such as "graphs" or "columns". # We don't check for differences, we simply replace them. # Note, we have to maintain the node order due checksum generation for caching issues, # we do that by restructure_report_element() # Delete any existing node (graphs may not exist, so we have to check for node existence) if (existing_report_element?{item_name}) then ( delete_node(existing_report_element{item_name}); ); # Clone the new node to the existing report element, # it will put into the right order via restructure_report_element() clone_node(item, existing_report_element . "." . item_name); ); ); # KHP 9/Apr/2010 # Handle sort_by and sort_direction of log_detail reports because # the sort_by and sort_direction node may not yet exist in the existing_report_element, # so we need to add it here. if (@existing_report_element{"type"} eq "log_detail" and (!existing_report_element?{"sort_by"} or !existing_report_element?{"sort_direction"})) then ( @existing_report_element{"sort_by"} = @new_report_element{"sort_by"}; @existing_report_element{"sort_direction"} = @new_report_element{"sort_direction"}; ); # # # Restructure the report_element to have a consistent node order # # restructure_report_element(existing_report_element); ));