# # # # create_report_job() # # # include "templates.util.date_filter.get_date_filter_info"; include "templates.util.user_agent"; include "templates.util.get_dash_breaks"; include "templates.util.get_break_entity"; include "templates.util.get_web_server_root_path"; include "templates.statistics.filters.check_filter_expression"; include "templates.statistics.filters.get_combined_filters"; include "templates.statistics.filters.create_filter_expression"; include "templates.statistics.filters.filters_util"; include "templates.statistics.util.create_report_job_util"; include "templates.statistics.util.get_html_rep_element_exists"; subroutine(create_report_job( string session_id, bool is_root_admin, node basic_ids, string current_language, string profile_name, string date_filter, string command_line_filter, string command_line_filter_comment, string filter_id, string report_info_id, bool is_calendar, string output_format, node db_state_node, node expanded_menu_groups), ( # # The output_format is required to check whether # a ready html report element already exists. # The output_format can be of type: # # "dynamic" # "static" (For static html files) # "static_print" (Printer friendly files only) # "static_email" (For html email, this are different files due the MIME encoding) # "static_pdf" (For pdf_friendly html files) # # # Note, the output_format is not part of the report_element_id # so that we can refer to different formats by the same ID, respectively # generate the output format from the raw_report_element which has the same # ID as the dynamic, static, static_email and static_pdf report element. # KHP-RC, we need to add the column labels for the report fields # so that we get new report element ids upon column label change! # We should do that here where we loop through the report elements # anyway! We should also expand the report element labels, respectively # anything which has to be expanded. bool is_dynamic_report = (output_format eq "dynamic"); debug_message("\n\n#### create_report_job START \n"); debug_message("\n" . node_as_string("command_line") . "\n"); debug_message("\n" . node_as_string(db_state_node) . "\n"); debug_message("#### is_calendar: " . is_calendar . "\n"); string profile_path = "profiles." . profile_name; string statisctics_path = profile_path . ".statistics"; string session_profile_path = "sessions_cache." . session_id . ".profiles." . profile_name; node report_info; string report_name; node report_ori; node report_elements; bool sync_graph_axis_with_relative_date = false; string report_description; string report_header; string report_footer; if (!is_calendar) then ( report_info = session_profile_path . ".report_infos." . report_info_id; report_name = @report_info{"report_name"}; report_ori = statisctics_path . ".reports." . report_name; report_elements = report_info . ".report_elements"; if (report_ori?{"sync_graph_axis_with_relative_date"}) then ( sync_graph_axis_with_relative_date = @report_ori{"sync_graph_axis_with_relative_date"}; ); if (report_ori?{"description"}) then ( report_description = @report_ori{"description"}; ); if (report_ori?{"header"}) then ( report_header = @report_ori{"header"}; ); if (report_ori?{"footer"}) then ( report_footer = @report_ori{"footer"}; ); ) else ( # No report, its the calendar report_name = ""; ); node misc_options = statisctics_path . ".miscellaneous"; node output_options = profile_path . ".output"; string lai_directory = LOGANALYSISINFO_DIRECTORY; string earliest_date_time = if (db_state_node?{"earliest_date_time"}) then (@db_state_node{"earliest_date_time"}) else (""); string latest_date_time = if (db_state_node?{"latest_date_time"}) then (@db_state_node{"latest_date_time"}) else (""); bool is_date_time_support = if (earliest_date_time ne "" and latest_date_time ne "") then (true) else (false); bool no_date_range = if (db_state_node?{"no_date_range"}) then (@db_state_node{"no_date_range"}) else (false); debug_message("#### no_date_range: " . no_date_range . "\n"); debug_message("#### earliest_date_time: " . earliest_date_time . "\n"); debug_message("#### latest_date_time: " . latest_date_time . "\n"); debug_message("#### is_date_time_support: " . is_date_time_support . "\n"); string last_modification_time = if (db_state_node?{"last_modification_time"}) then (@db_state_node{"last_modification_time"}) else (""); string last_modification_time_localtime = if (db_state_node?{"last_modification_time_localtime"}) then (@db_state_node{"last_modification_time_localtime"}) else (""); # Create a calendar date entry to ensure that we get a day value without time, i.e. 01/Jan/2006, # This two values are used for the report tools file name to check wether the existing # report-tools file contains the right calendar days. string earliest_log_date = if (is_date_time_support) then (substr(earliest_date_time, 0, 11)) else (""); string latest_log_date = if (is_date_time_support) then (substr(latest_date_time, 0, 11)) else (""); debug_message("#### earliest_log_date: " . earliest_log_date . "\n"); debug_message("#### latest_log_date: " . latest_log_date . "\n"); delete_node("v.draft_report_job"); v.draft_report_job = ""; # # # Get any user, profile and report filter # # string user_report_filter_expression = ""; string profile_filter_expression = ""; string report_filter_expression = ""; node structured_report_filter_items; # Only used if structured filter items exist bool is_structured_report_filter_items = false; node combined_unique_filter_items; # Only used if structured filter items exist if (!is_calendar) then ( if (!is_root_admin) then ( string user_node_name = node_name(volatile.authenticated_user_node_path); if (?("users." . user_node_name . ".report_filters.all_profiles.filter_expression")) then ( user_report_filter_expression = get_expanded_filter_expression(@("users." . user_node_name . ".report_filters.all_profiles.filter_expression")); ); ); if (?(misc_options . ".filter.expression")) then ( profile_filter_expression = get_expanded_filter_expression(@(misc_options . ".filter.expression")); ); if (?(report_ori . ".filter.expression")) then ( report_filter_expression = get_expanded_filter_expression(@(report_ori . ".filter.expression")); ); if (?(report_ori . ".filter.filter_items")) then ( structured_report_filter_items = report_ori . ".filter.filter_items"; is_structured_report_filter_items = (num_subnodes(structured_report_filter_items) > 0); ); ); # # # Verify filter_id existence / get global & structured report filter items expression # # # Note, any structured_report_filter_items become a part of the global # filter expression by combining the global filter items with the report filter items (we overlay the filter items) # string filter_expression = ""; if (filter_id ne "" or is_structured_report_filter_items) then ( # KHP-RC, we may refine this part so that check_filter_expression is not executed when # we combine a global filter with structured_report_filter_items if (filter_id ne "") then ( filter_expression = check_filter_expression(session_id, is_root_admin, profile_name, filter_id); ); # # If filter expression is empty then reset filter_id to ""; # if (filter_expression eq "") then ( filter_id = ""; ); if (is_structured_report_filter_items) then ( # In case that a global filter exists we combine the global filter description and # the filter items and override the filter_expression so that it also contains # the structured report filter items. # If no global filter exists then we just create the expression for the structured report filter items. # However, we always get a new filters display node which we must use for the filters display. # So, if is_structured_report_filter_items is true we save a filters display node (unique_filter_items) # within the report job. # Get a modified filters description node which contains all report filter items and any filter item from global # filter if it exists. node combined_filters_description = get_combined_filters(profile_name, filter_id, structured_report_filter_items); node filters_result = create_filter_expression(session_id, is_root_admin, profile_name, combined_filters_description, true); filter_expression = @filters_result{"expression"}; combined_unique_filter_items = filters_result{"unique_filter_items"}; ); # KHP 14/June/2010 - expand expression in report job and not in get_main_filter_expression() filter_expression = get_expanded_filter_expression(filter_expression); ); # # # Save the basic IDs in report job for later use # # clone_node(basic_ids, "v.draft_report_job.basic_ids"); # # # Check if we have multiple report elements (required for date_filter display) # # bool is_multiple_report_elements = (!is_calendar and (num_subnodes(report_elements) > 1)); v.draft_report_job.is_multiple_report_elements = is_multiple_report_elements; # # *************************** # Handle the date filter info # *************************** # # The date filter does not become part of the report_state node because we don't know # yet which date filter we use, the global_date_filter, a report_date_filter or a # report_element_date_filter. Only one of the three date filters is applied, the one # at the lowest level (lowest level is the report_element_date_filter). # So date_filter becomes a separate node in the report_job. # Note, we always get the global_date_filter_info even if no date_filter has been applied, # get_date_filter_info() returns then the entire date range including the number of days, # both are required for date display. # debug_message("#### create_report_job() - date_filter: " . date_filter . "\n"); bool is_global_date_filter = (date_filter ne ""); bool is_report_date_filter = false; bool is_report_element_date_filter = false; # Required for date display bool is_date_filter_in_all_report_elements = false; # Required for date display bool is_fixed_date = false; # Is set to true if a global date filter has no effect on the report (report has report date filter or report element date filters) string report_date_filter; delete_node("v.global_date_filter_info"); v.global_date_filter_info = ""; get_date_filter_info(date_filter, "v.global_date_filter_info", is_date_time_support, earliest_log_date, latest_log_date); # debug_message("#### create_report_job() - global_date_filter_info:\n" . node_as_string("v.global_date_filter_info") . "\n"); if (!is_calendar) then ( report_date_filter = if (?(report_ori . ".date_filter.df")) then (@(report_ori . ".date_filter.df")) else (""); is_report_date_filter = (report_date_filter ne ""); int number_of_date_filters_in_report_elements = get_number_of_date_filters_in_report_elements(report_elements); is_report_element_date_filter = (number_of_date_filters_in_report_elements > 0); is_date_filter_in_all_report_elements = (number_of_date_filters_in_report_elements == num_subnodes(report_elements)); if (is_report_date_filter) then ( delete_node("v.report_date_filter_info"); v.report_date_filter_info = ""; get_date_filter_info(report_date_filter, "v.report_date_filter_info", is_date_time_support, earliest_log_date, latest_log_date); is_fixed_date = true; ) else if (is_report_element_date_filter and is_date_filter_in_all_report_elements) then ( is_fixed_date = true; ); ); string meta_date_filter_id = ""; if (is_global_date_filter or is_report_date_filter) then ( node meta_date_filter_info = if (is_report_date_filter) then ("v.report_date_filter_info") else ("v.global_date_filter_info"); # debug_message("#### create_report_job() - meta_date_filter_info:\n" . node_as_string(meta_date_filter_info) . "\n"); meta_date_filter_id = md5_digest(node_as_string(meta_date_filter_info)); ); v.draft_report_job.date_filter = ""; v.draft_report_job.date_filter.is_global_date_filter = is_global_date_filter; v.draft_report_job.date_filter.is_report_date_filter = is_report_date_filter; v.draft_report_job.date_filter.is_report_element_date_filter = is_report_element_date_filter; v.draft_report_job.date_filter.is_date_filter_in_all_report_elements = is_date_filter_in_all_report_elements; v.draft_report_job.date_filter.is_fixed_date = is_fixed_date; v.draft_report_job.date_filter.global_date_filter = date_filter; v.draft_report_job.date_filter.report_date_filter = report_date_filter; clone_node("v.global_date_filter_info", "v.draft_report_job.date_filter.global_date_filter_info"); if (is_report_date_filter) then ( clone_node("v.report_date_filter_info", "v.draft_report_job.date_filter.report_date_filter_info"); ); # show_date_in_report_element is required for html formatting only. It specifies if a date is displayed per report element. bool show_date_in_report_element = (is_multiple_report_elements and is_report_element_date_filter); string product_build_id = @basic_ids{"product_build_id"}; # # # ************************************************************************* # # Here comes data which are not relevant to the raw report element checksum # # ************************************************************************* # # # Important, include any html formatting options in the "html_formatting" node, # options which affect the html report element generation only, i.e. the # the thousand divider, text sizes or the active user agent. # html_formatting also includes RBAC permission (Pivot table, Export, Customize report element and hidden column values) # # We will use the checksum of the html_formatting # node to generate the final html report element id. It means when formatting options # changes we can still use the existing raw report element. This is particulary important # when reports are pre-cached by generating static reports via scheduler where i.e. # the active user agent is not known (the client user agent brand is required to set line breaking options). # If we would add the active user_agent to the report state section we couldn't reuse any pre-cached # raw report element generated via scheduler. # # # string user_agent = get_user_agent(profile_name, output_format); bool is_msie = if (user_agent eq "msie") then (true) else (false); bool is_msie_v6 = get_is_msie_v6(); # Add the user agent data to get quick access when generating the dynamic report v.draft_report_job.user_agent = user_agent; v.draft_report_job.is_msie = is_msie; v.draft_report_job.is_msie_v6 = is_msie_v6; v.draft_report_job.is_calendar = is_calendar; v.draft_report_job.page_header = @misc_options{"page_header"}; v.draft_report_job.page_footer = @misc_options{"page_footer"}; v.draft_report_job.page_header_file = @misc_options{"page_header_file"}; v.draft_report_job.page_footer_file = @misc_options{"page_footer_file"}; # Note, first_weekday must also become part of the report_state checksum # because first_weekday affects the weekday report element (at least when sorted by weekday) int first_weekday = get_calendar_first_weekday_or_marked_weekday(misc_options, "first_weekday"); int marked_weekday = get_calendar_first_weekday_or_marked_weekday(misc_options, "marked_weekday"); v.draft_report_job.enable_calendar_in_reports_menu = @misc_options{"enable_calendar_in_reports_menu"}; v.draft_report_job.first_weekday = first_weekday; v.draft_report_job.marked_weekday = marked_weekday; v.draft_report_job.report_info_id = report_info_id; v.draft_report_job.report_name = report_name; v.draft_report_job.report_label = if (!is_calendar) then (@report_ori{"label"}) else (lang_stats.btn.calendar); v.draft_report_job.description = report_description; v.draft_report_job.header = report_header; v.draft_report_job.footer = report_footer; v.draft_report_job.expanded_menu_groups = ""; if (num_subnodes(expanded_menu_groups) > 0) then ( clone_node(expanded_menu_groups, "v.draft_report_job.expanded_menu_groups"); ); v.draft_report_job.command_line_filter_comment = command_line_filter_comment; # HTML formatting - RBAC permissions bool is_csv_export_permission = true; bool is_customize_report_element_permission = true; if (!is_root_admin and is_dynamic_report) then ( # Verify if we have above permissions node user_grants = "sessions_cache." . session_id . ".session_info.user_grants"; string super_role_name; if (?(user_grants . ".profiles_grants." . profile_name)) then ( super_role_name = @(user_grants . ".profiles_grants." . profile_name . ".super_role"); ) else ( super_role_name = @(user_grants . ".all_profiles_grants.super_role"); ); node super_role_reports = user_grants . ".super_roles." . super_role_name . ".reports"; # is_pivot_table_permission = super_role_reports?{"pivot_table"}; is_csv_export_permission = super_role_reports?{"csv_export"}; is_customize_report_element_permission = super_role_reports?{"customize_report_element"}; ); # # # # # # Add the relevant html formatting options # Note, this part must not be included in the raw report element checksums! # # # # # v.draft_report_job.html_formatting = ""; node html_formatting = "v.draft_report_job.html_formatting"; set_subnode_value(html_formatting, "current_language", current_language); set_subnode_value(html_formatting, "lang_stats_checksum", @basic_ids{"lang_stats_checksum"}); set_subnode_value(html_formatting, "output_format", output_format); set_subnode_value(html_formatting, "show_date_in_report_element", show_date_in_report_element); string number_thousands_divider = @output_options{"number_thousands_divider"}; string number_decimal_divider = @output_options{"number_decimal_divider"}; if (number_thousands_divider eq "") then ( # No profile sepcific number_thousands_divider is defined, so we get the number_thousands_divider from lang_stats number_thousands_divider = @("lang_stats.numbers.thousands_divider"); ); if (number_decimal_divider eq "") then ( # No profile sepcific number_decimal_divider is defined, so we get the number_decimal_divider from lang_stats number_decimal_divider = @("lang_stats.numbers.decimal_divider"); ); set_subnode_value(html_formatting, "number_thousands_divider", number_thousands_divider); set_subnode_value(html_formatting, "number_decimal_divider", number_decimal_divider); set_subnode_value(html_formatting, "show_http_link", @misc_options{"show_http_link"}); set_subnode_value(html_formatting, "server_root", @misc_options{"server_root"}); set_subnode_value(html_formatting, "dash_breaks", get_dash_breaks(user_agent)); set_subnode_value(html_formatting, "break_entity", get_break_entity(user_agent)); # Clone the entire statistics.miscellaneous.sizes node clone_node(statisctics_path . ".sizes", html_formatting . ".sizes"); # clone the graph_color_scheme_types clone_node(statisctics_path . ".graphs.color_schemes", html_formatting . ".graph_color_scheme_types"); # Add the graph_colors checksum # KHP 05/Sep/2009 - don't get graph_colors_checksum at this place because it already exists in the basic_ids node # set_subnode_value(html_formatting, "graph_colors_checksum", md5_digest(node_as_string("graph_colors"))); # Add permissions set_subnode_value(html_formatting, "permissions", ""); node permissions = html_formatting{"permissions"}; # set_subnode_value(permissions, "pivot_table", is_pivot_table_permission); set_subnode_value(permissions, "csv_export", is_csv_export_permission); set_subnode_value(permissions, "customize_report_element", is_customize_report_element_permission); # Add unique prevent_caching_id for static files so that they don't get cached as HTML because in this case # we have problems with filerefs, respectively copying images to the output directory. # This ID is only used for the checksum! # if (output_format eq "static" or output_format eq "static_pdf") then ( if (!is_dynamic_report) then ( set_subnode_value(html_formatting, "prevent_caching_id", now_us()); ); # # # Create the html formatting checksum so that we can use it right away when checking or generating the html files # # string html_formatting_checksum = md5_digest(node_as_string(html_formatting)); # # # # ********************************************************************* # Here comes data which are relevant to the raw report element checksum # ********************************************************************* # # # # # # Get the database state (we require this data also to get the date filter info) # # # Note, we save some database info parameters so that data such as earliest date, etc. # are available for later use. This data also present the unique database state. # # # handle date_filter_expression # # Note, for the report element checksum we use the date_filter info data # and not the date_filter because different date_filters could result # in the same date_filter_info data. The date filter info is also set # if no df has been specified so that the start/end date and number of # days are always set! # # # delete_node("v.date_filter_info"); # v.date_filter_info = ""; # get_date_filter_info(date_filter, "v.date_filter_info", is_date_time_support, earliest_log_date, latest_log_date); # node date_filter_info = "v.date_filter_info"; # debug_message("\n\n#### date_filter_info result:\n" . node_as_string(date_filter_info) . "\n\n"); # # # We use a report_state node to get the checksum for all data # which are relevant per report_element # # # Add web server mode and CGI data because file references may be different when using CGI mode # with temporary_directory_pathname and temporary_directory_url. bool is_webserver_mode = !CGI_MODE; string server_preferences_temporary_directory_pathname; string server_preferences_temporary_directory_url; string server_preferences_cgi_directory; if (!is_webserver_mode) then ( node server_preferences = "preferences.server"; server_preferences_temporary_directory_pathname = @server_preferences{"temporary_directory_pathname"}; server_preferences_temporary_directory_url = @server_preferences{"temporary_directory_url"}; server_preferences_cgi_directory = @server_preferences{"cgi_directory"}; ); v.draft_report_job.report_state.is_webserver_mode = is_webserver_mode; v.draft_report_job.report_state.server_preferences_temporary_directory_pathname = server_preferences_temporary_directory_pathname; v.draft_report_job.report_state.server_preferences_temporary_directory_url = server_preferences_temporary_directory_url; v.draft_report_job.report_state.server_preferences_cgi_directory = server_preferences_cgi_directory; v.draft_report_job.report_state.product_build_id = product_build_id; v.draft_report_job.report_state.profile_name = profile_name; v.draft_report_job.report_state.first_weekday = first_weekday; # Required for weekday report element # clone_node(date_filter_info, "v.draft_report_job.report_state.date_filter_info"); v.draft_report_job.report_state.command_line_filter = get_expanded_filter_expression(command_line_filter); v.draft_report_job.report_state.filter_id = filter_id; # global filter v.draft_report_job.report_state.filter_expression = filter_expression; # global filter v.draft_report_job.report_state.user_report_filter_expression = user_report_filter_expression; v.draft_report_job.report_state.profile_filter_expression = profile_filter_expression; v.draft_report_job.report_state.report_filter_expression = report_filter_expression; v.draft_report_job.report_state.is_structured_report_filter_items = is_structured_report_filter_items; if (is_structured_report_filter_items) then ( # KHP-RC, this two items including is_structured_report_filter_items should not be in report state # because this items do not effect report element but only the report filters display # which isn't cached. So this should be moved -- REVISE -- once the items are global filter items # and once they are report filter items! # Further, when the user re-saves the reports in reports editor the structured_report_filter_items # node may be in different order than prior saving it because we currently don't restructure # the filter_items upon save! # Clone structured filter items to report job clone_node(structured_report_filter_items, "v.draft_report_job.report_state.structured_report_filter_items"); # Clone filters display items to report job clone_node(combined_unique_filter_items, "v.draft_report_job.report_state.unique_filter_items"); ); "v.draft_report_job.report_state.database" = ""; node new_db_node = "v.draft_report_job.report_state.database"; set_subnode_value(new_db_node, "is_date_time_support", is_date_time_support); set_subnode_value(new_db_node, "no_date_range", no_date_range); set_subnode_value(new_db_node, "earliest_log_date", earliest_log_date); set_subnode_value(new_db_node, "latest_log_date", latest_log_date); set_subnode_value(new_db_node, "earliest_date_time", earliest_date_time); set_subnode_value(new_db_node, "latest_date_time", latest_date_time); set_subnode_value(new_db_node, "last_modification_time", last_modification_time); set_subnode_value(new_db_node, "last_modification_time_localtime", last_modification_time_localtime); # # # # Add other statistics options which are relevant to the report_state, # though don't add any html formatting options! # # v.draft_report_job.report_state.sync_graph_axis_with_relative_date = sync_graph_axis_with_relative_date; # v.draft_report_job.report_state.options = ""; # node new_options = "v.draft_report_job.report_state.options"; # # KHP-RC, show_3d_pie_chart shouldn't really be part of the report_state, # in fact it should be only set for report elements where a pie-chart options exists. # The default_graphs node should probably be removed because each report element should # have its own default graph settings! # # clone_node("default_graphs", "v.draft_report_job.report_state.graphs"); # "v.draft_report_job.report_state.graphs.show_3d_pie_chart" = @(statisctics_path . ".graphs.show_3d_pie_chart"); # # # # Create the report_state checksum which will be used for each report element # # # string report_state_checksum = md5_digest(node_as_string("v.draft_report_job.report_state")); # # # # Create report element ids # # # # When we create the report_element_id we consider following parts for the resulting ID: # --> Command line filter (URL filter) # --> Profile filter # --> Date filter # --> Gloabl filter # --> Report filter # --> Checksum of the report element as in report elements v.draft_report_job.report_elements = ""; bool is_ready_report = true; if (!is_calendar) then ( node report_element; string report_element_name; string report_element_label; string report_element_id; string report_element_html_formatting_id; string report_element_date_filter; bool is_report_element_date_filter; string report_element_filter_expression; string html_report_element_id; bool html_report_element_exists; bool create_report_element; node column_item; node temp_columns; string report_field_name; string column_label; # Important # We make extended_profile_dat_id part of the report element checksum # so that any query_field or report_overview fields changes result in a new # raw report element! string extended_profile_dat_id = @basic_ids{"extended_profile_dat_id"}; node query_fields = get_query_fields(session_id, is_root_admin, profile_name); # node temp_report_element; int report_element_count = 0; bool show_graphs; bool graphs_are_active; string graphs_profile_directory_path = get_web_server_root_path() . "graphs/". profile_name . "/"; foreach report_element report_elements ( # debug_message("\n\n The report element to be cloned:\n" . node_as_string(report_element) . "\n\n"); # GET COLUMN LABELS, ETC before getting checksum! report_element_name = node_name(report_element); show_graphs = @report_element{"show_graphs"}; graphs_are_active = false; delete_node("v.temp_report_element"); v.temp_report_element = ""; # temp_report_element = "v.temp_report_element"; clone_node(report_element, "v.temp_report_element"); # debug_message("\n\n The report element right after cloning it to v.temp_report_element:\n" . node_as_string("v.temp_report_element") . "\n\n"); set_subnode_value("v.temp_report_element", "short_report_element_id", "re" . report_element_count); # Create a sid (short report element id, must be part of the checksum) which # can be used to create unique report element id's, # i.e. re1 (report_element_1) can be combined in ids like # col:re1:0, # col:re1:2, # etc. set_subnode_value("v.temp_report_element", "extended_profile_dat_id", extended_profile_dat_id); # # # # Handle report element date filter # # # report_element_date_filter = if (?("v.temp_report_element.date_filter.df")) then (@("v.temp_report_element.date_filter.df")) else (""); is_report_element_date_filter = (report_element_date_filter ne ""); set_subnode_value("v.temp_report_element", "is_date_filter", is_report_element_date_filter); if (is_report_element_date_filter) then ( # Add the date_filte_info to the report element delete_node("v.re_date_filter_info"); v.re_date_filter_info = ""; get_date_filter_info(report_element_date_filter, "v.re_date_filter_info", is_date_time_support, earliest_log_date, latest_log_date); clone_node("v.re_date_filter_info", "v.temp_report_element.date_filter_info"); # debug_message("#### report_element_date_filter: " . report_element_date_filter . "\n"); # debug_message("#### report_element_date_filter_info:\n" . node_as_string("v.re_date_filter_info") . "\n"); ) else ( # Include the checksum of the meta date filter info (which is a global or report date filter) # The value is only required for report element id! set_subnode_value("v.temp_report_element", "meta_date_filter_id", meta_date_filter_id); ); # # KHP 14/June/2010 - Handle report element filter, expand them in report job # if (?(report_element . ".filter.expression") and (@(report_element . ".filter.expression") ne "")) then ( report_element_filter_expression = @(report_element . ".filter.expression"); "v.temp_report_element.filter.expression" = get_expanded_filter_expression(report_element_filter_expression); ); # # Add labels, headers and footers. # if (?("v.temp_report_element.label")) then ( report_element_label = if (report_element?{"label"}) then (@report_element{"label"}) else (""); set_subnode_value("v.temp_report_element", "label", report_element_label); ); # KHP-RC, do the same for headers and footers, etc. or look for alternative solution! # New, 30/Oct/2007, we also need an HTML formatting checksum for the display_format_type # of the report element. The display_format_type per report_field can be different per # non-root-admin user due RBAC if certain report fields are hidden by category name. In such # a case the query field has a different display_format_type than defined in the default profile. # So we create a report_element_html_formatting_id to cover this_case! report_element_html_formatting_id = html_formatting_checksum; if (?("v.temp_report_element.columns")) then ( foreach column_item "v.temp_report_element.columns" ( report_field_name = @column_item{"report_field"}; # # Add display_format_type to report_element_html_formatting_id # report_element_html_formatting_id .= @(query_fields . "." . report_field_name . ".display_format_type"); # # Check if any graphs are active # if (!graphs_are_active and show_graphs) then ( if (column_item?{"show_graph"} and @column_item{"show_graph"}) then ( graphs_are_active = true; ); ); ); ); report_element_html_formatting_id = md5_digest(report_element_html_formatting_id); set_subnode_value("v.temp_report_element", "report_state_checksum", report_state_checksum); # debug_message("#### create_report_job() - v.temp_report_element:\n" . node_as_string("v.temp_report_element") . "\n"); report_element_id = md5_digest(node_as_string("v.temp_report_element")); # debug_message("#### create_report_job() - report_element_id: " . report_element_id . "\n"); set_subnode_value("v.temp_report_element", "report_element_id", report_element_id); set_subnode_value("v.temp_report_element", "report_element_html_formatting_id", report_element_html_formatting_id); # # Check if the html report element and graph images exist # # We check this by looking for the report element in html_report_elements. # The report element file name is the checksum of the report_element_id followed by the html_formatting_checksum. html_report_element_id = get_html_report_element_id(report_element_id, report_element_html_formatting_id); html_report_element_exists = get_html_rep_element_exists(profile_name, html_report_element_id); # If the html report element already exists then make sure the graph fake file (defined by html_report_element_id) # also exists (graph images could be missing due clean-up in WebServerRoot). # If the graph fake file doesn't exist then re-create the report element so that the # graph images are re-created. if (html_report_element_exists and graphs_are_active and !file_exists(graphs_profile_directory_path . html_report_element_id . ".txt")) then ( # Reset html_report_element_exists so that graph images become re-created html_report_element_exists = false; ); debug_message("#### create_report_job() - graphs_are_active: " . graphs_are_active . "\n"); debug_message("#### create_report_job() - html_report_element_exists: " . html_report_element_exists . "\n"); if (!html_report_element_exists) then ( is_ready_report = false; create_report_element = true; ) else ( create_report_element = false; ); # Set create_report_element which will be used in create_report_elements # to check whether the report element has to be created. set_subnode_value("v.temp_report_element", "create_report_element", create_report_element); # debug_message("\n\n" . node_as_string("v.temp_report_element") . "\n\n"); # # Clone report element over to report job # clone_node("v.temp_report_element", "v.draft_report_job.report_elements." . report_element_name); report_element_count++; ); ) # if !is_calendar else ( # No report, its the calendar. We don't care if the calendar is already generated or not. # It will be be checked and/or generated when assembling the report. is_ready_report = true; ); v.draft_report_job.is_ready_report = is_ready_report; # # Get the report job id # string report_job_id = md5_digest(report_name . now_us()); # # Save the report job # string report_job_path = session_profile_path . ".report_jobs." . report_job_id; clone_node("v.draft_report_job", report_job_path); save_node(report_job_path); debug_message("#### create_report_job() - report_job_id: " . report_job_id . "\n"); report_job_id; ));