# # # # # 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), ( # debug_message("\n" . node_as_string(report_fields) . "\n"); string report_item_name = node_name(report_item); 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 ( 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 ( 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") 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; 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), ( # Adds any missing report if the non-aggregating report field does not yet exist as report. # It does not add any missing session report because the sessions group handling should cover the session reports # # # 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); debug_message("\n" . node_as_string(covered_reports) . "\n"); 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 ( 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; covered_reports{report_field_name} = ""; ); ); ); ); ));