# # # # # clean_up_report_groups_util.cfv # # # add_report_item() # # # get_reports_already_covered_in_final_report_groups() # add_missing_reports_from_report_fields() # # # # # # # # add_report_item() # # # subroutine(add_report_item( node report_fields, node the_root, # the root of final_report_groups or "items" if the report is part of a group node report_item, node final_custom_reports, bool add_geo_location_reports), ( # debug_message("\n" . node_as_string(report_fields) . "\n"); string report_item_name = node_name(report_item); #echo("add_report_item(); report_item_name=" . report_item_name); bool is_item_with_subnodes = (num_subnodes(report_item) > 0); # # Check if we have a hierarchical page field # string hierachical_page_field_source_field_name; string hierachical_page_field_name; if (?("v.temp_hierarchical_page_field_info.hierarchical_field_name")) then ( hierachical_page_field_source_field_name = @("v.temp_hierarchical_page_field_info.source_field_name"); hierachical_page_field_name = @("v.temp_hierarchical_page_field_info.hierarchical_field_name"); # We have to check report_groups for an item with hierachical_page_field_source_field_name, # if we find it we have to insert the hierarchical field before the none-hierarchical field! ); if (report_item_name ne "date_time" and report_item_name ne "days" and report_item_name ne "location") then ( # # Check if we need to insert a hierarchical page field # if (hierachical_page_field_source_field_name ne "" and (hierachical_page_field_source_field_name eq report_item_name)) then ( # Add the hirearchical field set_subnode_value(the_root, hierachical_page_field_name, true); ); # # Add the item # set_subnode_value(the_root, report_item_name, true); # if this item has any subnodes it must be a custom report, # clone it to final_custom_reports if (is_item_with_subnodes) then ( clone_node(report_item, final_custom_reports{report_item_name}); ) else ( # Check if this is a X_by_Y report, i.e. search_phrase_by_search_engine, # though which has no columns node defined yet. If this report name # contains two valid report fields then we create the columns node here # and add the report to final_custom_reports if (matches_regular_expression(report_item_name, '^(.*)_by_(.*)$')) then ( string report_field_1 = $1; string report_field_2 = $2; if (report_fields?{report_field_1} and report_fields?{report_field_2}) then ( debug_message("Adding '" . report_field_1 . " by " . report_field_2 . "' report\n"); # debug_message("\n" . node_as_string(report_fields{report_field_1}) . "\n"); # debug_message("\n" . node_as_string(report_fields{report_field_2}) . "\n"); string field_label_1; string field_label_2; if (?("lang_stats.field_labels." . report_field_1)) then ( field_label_1 = "capitalize(expand(lang_stats.field_labels." . report_field_1 . "))"; ) else ( field_label_1 = '"' . capitalize(expand(@report_fields{report_field_1}{"label"})) . '"'; ); if (?("lang_stats.field_labels." . report_field_2)) then ( field_label_2 = "capitalize(expand(lang_stats.field_labels." . report_field_2 . "))"; ) else ( field_label_2 = '"' . capitalize(expand(@report_fields{report_field_2}{"label"})) . '"'; ); # Set the columns node and subtable node like # in apache_combined.cfg for search_phrase_by_search_engine # @report_item{"label"} = capitalize(expand(@report_fields{report_field_1}{"label"})) . lang_stats.multi_column_report_divider . expand(@report_fields{report_field_2}{"label"}); @report_item{"label"} = "{=" . field_label_1 . " . lang_stats.multi_column_report_divider . " . field_label_2 . "=}"; @report_item{"columns"}{"0"}{"field_name"} = report_field_2; @report_item{"columns"}{"1"}{"field_name"} = report_field_1; @report_item{"subtable"} = true; clone_node(report_item, final_custom_reports{report_item_name}); ); ); ); ) else ( # # Convert report item and any subnode # # We need to convert the item_name and any report subnodes # to reflect the report_field changes in version 8. # Note, we add three new date_time reports in case of date_time # but ignore the orginal days report if (report_item_name eq "date_time") then ( # 2012-08-16 - GMF - wowza has a manual date_time_group, which includes date_time; the section below didn't include a date_time report, causing date_time to be added to the bottom of the menu. Adding it back. set_subnode_value(the_root, "date_time", true); set_subnode_value(the_root, "year", true); set_subnode_value(the_root, "month", true); set_subnode_value(the_root, "day", true); if (is_item_with_subnodes) then ( # If this item has a label it must be out of date, remove it if (report_item?{"label"}) then ( delete_node(report_item{"label"}); ); # if report_item has still subnodes (after removing the label) clone it # over to final_custom_reports if (num_subnodes(report_item) > 0) then ( # 2012-08-16 - GMF - wowza has a manual date_time_group, which includes date_time; the section below didn't include a date_time report, causing date_time to be added to the bottom of the menu. Adding it back. clone_node(report_item, final_custom_reports{"date_time"}); clone_node(report_item, final_custom_reports{"year"}); clone_node(report_item, final_custom_reports{"month"}); clone_node(report_item, final_custom_reports{"day"}); ); ); ) else if ((report_item_name eq "location") and (add_geo_location_reports)) then ( set_subnode_value(the_root, "country", true); set_subnode_value(the_root, "region", true); set_subnode_value(the_root, "city", true); if (is_item_with_subnodes) then ( # If this item has a label it must be out of date, remove it if (report_item?{"label"}) then ( delete_node(report_item{"label"}); ); # if report_item has still subnodes (after removing the label) clone it # over to final_custom_reports if (num_subnodes(report_item) > 0) then ( clone_node(report_item, final_custom_reports{"country"}); clone_node(report_item, final_custom_reports{"region"}); clone_node(report_item, final_custom_reports{"city"}); ); ); ); ); )); # add_report_item # # # # get_reports_already_covered_in_final_report_groups() # # # subroutine(get_reports_already_covered_in_final_report_groups( node final_report_groups, node covered_reports), ( node item; string report_name; #echo("get_reports_already_covered_in_final_report_groups()"); #echo("final_report_groups: " . node_as_string(final_report_groups)); foreach item final_report_groups ( if (!item?{"items"}) then ( # This must be a single menu item for a reeport report_name = node_name(item); covered_reports{report_name} = ""; ) else ( # This must be a report group get_reports_already_covered_in_final_report_groups(item{"items"}, covered_reports); ); ); )); # # # # add_missing_reports_from_report_fields() # # # subroutine(add_missing_reports_from_report_fields( node profile, node final_report_groups, node numerical_report_fields), ( #echo("profile: " . profile); # Adds any missing report if the non-aggregating report field does not yet exist as report. #echo("add_missing_reports_from_report_fields()"); # # # Get all existing reports from final_report_groups # # delete_node("v.covered_reports"); v.covered_reports = ""; node covered_reports = "v.covered_reports"; get_reports_already_covered_in_final_report_groups(final_report_groups, covered_reports); # 2012-08-08 - GMF - If a profile has added the report manually already, e.g. via snapon, consider it "covered" node reports_menu = profile{"statistics.reports_menu"}; node reports_menu_group; foreach reports_menu_group reports_menu ( #echo("reports_menu_group: " . node_as_string(reports_menu_group)); if (reports_menu_group?{"items"}) then ( node report; foreach report (reports_menu_group{"items"}) ( #echo("report: " . report); @covered_reports{node_name(report)} = ""; ); # foreach report ); # if group # else # @covered_reports{node_name(reports_menu_group)} = ""; ); # foreach reports_menu_group debug_message("\n" . node_as_string(covered_reports) . "\n"); # 2012-11-14 - GMF - If a report is listed in omit_reports, add it to "covered" to indicate that it should not be added below if (?(profile . '.create_profile_wizard_options.omit_reports')) then ( node omit_report; foreach omit_report (profile{'create_profile_wizard_options'}{'omit_reports'}) ( @covered_reports{node_name(omit_report)} = ""; ); # foreach report ); # if omit_reports #echo("covered_reports: " . node_as_string(covered_reports)); node report_field; node report_fields = profile{"statistics"}{"report_fields"}; string report_field_name; node database_fields = profile{"database"}{"fields"}; string db_field_name; node db_field; string derivation_method; foreach report_field report_fields ( #echo("OMIT? report_field: " . report_field); db_field = profile{"database"}{"fields"}{@report_field{"database_field"}}; #echo("OMIT? database_field: " . db_field); if ((report_field?{"omit_automatic_report"}) and (@report_field{"omit_automatic_report"})) then ( @covered_reports{node_name(report_field)} = ""; #echo("OMITTING " . report_field); ); ); # 2012-12-07 - GMF - If a report field has omit_reports=true, add it to "covered" to indicate that it should not be added below foreach report_field report_fields ( report_field_name = node_name(report_field); if (!numerical_report_fields?{report_field_name} and report_field?{"database_field"} and (report_field_name ne "date_time_timestamp") and (report_field_name ne "location")) then ( db_field_name = @report_field{"database_field"}; if (database_fields?{db_field_name}) then ( db_field = database_fields{db_field_name}; derivation_method = @db_field{"derivation_method"}; if ((derivation_method eq "log_field") and !covered_reports?{report_field_name}) then ( # The report_field_name does not yet exist as report. # Add it to final_report_groups now final_report_groups . "." . report_field_name . ".is_group" = false; #echo("Adding: " . (final_report_groups . "." . report_field_name . ".is_group")); covered_reports{report_field_name} = ""; ); ); ); ); #echo("final_report_groups: " . node_as_string(final_report_groups)); ));