# # # # clean_up_report_groups() # # # # # # clean_up_report_groups() # # Populates a new final_report_groups node which is valid for Sawmill # and custom log format plug-ins. The subroutine also separates any # custom report from the source_report_groups node to final_custom_reports # # It further fixes differences between the version 7 and version 8 profile format, # i.e. report field names, etc. # # # IMPORTANT, the difficulty of this setup is to distinguish between # reports in the first level and reports in a group. Some # log format plug-ins have an "items" node for reports in a group # but some have not, they have just the group_name followed by direct report # subnodes! # # include "lib.profile_setup.clean_up_report_groups_util"; subroutine(clean_up_report_groups( node profile, node final_report_groups, node final_custom_reports, bool is_manual_reports_menu, node numerical_report_fields), ( debug_message("\n\n#### clean_up_report_groups() START \n\n"); # # # # Get the source report groups # # # node source_report_groups; if (?(profile . ".create_profile_wizard_options.report_groups")) then ( source_report_groups = profile . ".create_profile_wizard_options.report_groups"; ) else ( # No report_groups in log format plug-in, use the default one # Although the report_groups in "lib.profile_setup.report_groups" # are final we need to run it through this subroutine to add # the overview, log detail and single page summary # in the right order source_report_groups = "lib.profile_setup.report_groups"; ); node default_report_groups = "lib.profile_setup.report_groups"; node report_fields = profile . ".statistics.report_fields"; debug_message("#### is_manual_reports_menu: " . is_manual_reports_menu . "\n"); debug_message("#### final_report_groups:\n" . node_as_string(final_report_groups) . "\n"); debug_message("#### final_custom_reports:\n" . node_as_string(final_custom_reports) . "\n"); debug_message("#### source_report_groups:\n" . node_as_string(source_report_groups) . "\n"); debug_message("#### default_report_groups:\n" . node_as_string(default_report_groups) . "\n"); debug_message("#### report_fields:\n" . node_as_string(report_fields) . "\n"); # # # # Add the overview report as first report in auto mode # # # if (!is_manual_reports_menu) then ( final_report_groups . ".overview.is_group" = false; final_custom_reports . ".overview.type" = "overview"; ); node item; string item_name; int number_of_subitems; bool is_group; node subitem; bool is_all_boolean_nodes; bool is_group_name; bool is_only_group_items; bool is_items_node_in_group; bool item_has_none_boolean_item; node group_node; string group_name; string group_label; node final_group_items_node; foreach item source_report_groups ( # Note, due the plug-in report_group structure we are not able to determine # if the item is a report_group or a single menu item for a report, respectively a custom report. # Some plug-ins contain an items node for grouped reports but some not. item_name = node_name(item); number_of_subitems = num_subnodes(item); if (number_of_subitems == 0) then ( if (item_name eq "date_time_group") then ( # Clone the date_time group default report groups node default_date_time_report_group = default_report_groups{"date_time_group"}; clone_node(default_date_time_report_group, final_report_groups{"date_time_group"}); ) else ( # This must be a single report item, add it. add_report_item(report_fields, final_report_groups, item, final_custom_reports); ); ) else ( # # # This is an item with subnodes # # We have to verify it this item is a report or a report_group # # is_group = false; is_items_node_in_group = if (item?{"items"}) then (true) else (false); if (is_items_node_in_group) then ( is_group = true; ) else ( # Double check for group items in case that the item name does not end with "_group" is_group_name = if (ends_with(item_name, "_group")) then (true) else (false); is_only_group_items = false; item_has_none_boolean_item = false; foreach subitem item ( # ignore any label if (node_name(subitem) ne "label") then ( if (node_type(subitem) ne "bool") then ( item_has_none_boolean_item = true; last; ); ); ); is_only_group_items = !item_has_none_boolean_item; is_group = if (is_group_name or is_only_group_items) then (true) else (false); ); debug_message("\n\n#### item_name: " . item_name . "\n"); debug_message("#### is_items_node_in_group: " . is_items_node_in_group . "\n"); debug_message("#### is_group_name: " . is_group_name . "\n"); debug_message("#### is_only_group_items: " . is_only_group_items . "\n"); debug_message("#### is_group: " . is_group . "\n"); if (is_group) then ( # # # This is a group with report items # # group_node = if (is_items_node_in_group) then (item{"items"}) else (item); group_name = node_name(item); group_label = if (item?{"label"}) then (@item{"label"}) else (""); # Remove label node in item so that we don't have it in the loop in # case that there is no items node if (item?{"label"}) then ( delete_node(item{"label"}); ); # # # Setup the group # # final_report_groups . "." . group_name . ".label" = group_label; final_report_groups . "." . group_name . ".items" = ""; final_group_items_node = final_report_groups . "." . group_name . ".items"; foreach subitem group_node ( add_report_item(report_fields, final_group_items_node, subitem, final_custom_reports); ); ) else ( # # # This is a single item # # add_report_item(report_fields, final_report_groups, item, final_custom_reports); ); ); # item with subnodes ); # foreach item # # # Add missing reports, single page summary and log detail if in auto mode # # # if (!is_manual_reports_menu) then ( # # # Add any report from report_fields if the report_field is not yet covered by # some report because in auto mode a report is created for every report field. # # add_missing_reports_from_report_fields( profile, final_report_groups, numerical_report_fields ); # # # Add single page summary # # final_report_groups . ".single_page_summary" = true; # # # Add log detail # # final_report_groups . ".log_detail" = true; ); # debug_message("#### final_report_groups:\n" . node_as_string(final_report_groups) . "\n\n"); # debug_message("#### final_custom_reports:\n" . node_as_string(final_custom_reports) . "\n\n"); debug_message("\n\n#### clean_up_report_groups() END \n\n"); ));