# # # # # request_report_util.cfv # # # # get_new_web_browser_session_id() # get_new_report_info_id() # # reset_row_numbers_in_request_report() # # handle_report_request_without_report_info_update() # handle_report_request_with_report_info_update() # # # # # # get_new_web_browser_session_id() # # # subroutine(get_new_web_browser_session_id, ( string s = now_us(); # s = md5_digest(s); # Shorten the ID to 26 characters by converting it to base 32 (this shortens the ID in the URL a bit) # s = hex_to_base_32(s); s; )); # # # # get_new_report_info_id() # # # subroutine(get_new_report_info_id, ( # Note, to make sure that there isn't any conflict with existing report info id's # in URL's (i.e. bookmarked URL's) we use the combination of now() and now_us() # (For command line reports the single now_us() is sufficient) now() . now_us(); )); # # # # reset_row_numbers_in_request_report() # # # subroutine(reset_row_numbers_in_request_report( node report), ( node report_elements = report{"report_elements"}; node report_element; string report_element_type; foreach report_element report_elements ( report_element_type = @report_element{"type"}; if ((report_element_type eq "table" or report_element_type eq "log_detail") and (@report_element{"starting_row"} != 1)) then ( report_element{"starting_row"} = 1; report_element{"ending_row"} = @report_element{"number_of_rows"}; ); ); )); # # # # handle_report_request_without_report_info_update() # # # subroutine(handle_report_request_without_report_info_update( string session_id, string user_node_name, bool is_root_admin, node web_browser_session_reports, string profile_name, string report_name, string report_info_id, bool skip_reset_row_numbers), ( # Use web browser session report or create new report info or use existing report info # Return new_report_info_id debug_message("\n#### handle_report_request_for_none_report_info_update START \n"); string session_profile_path = "sessions_cache." . session_id . ".profiles." . profile_name; string new_report_info_id; bool is_command_line = false; bool use_existing_web_browser_session_report = false; bool create_new_report_info = false; bool use_existing_report_info = false; if (report_info_id eq "") then ( if (web_browser_session_reports?{report_name}) then ( use_existing_web_browser_session_report = true; ) else ( create_new_report_info = true; ); new_report_info_id = get_new_report_info_id(); ) else ( # A report info id already exists, check if the report info exists. # Note, in this case we use the existing report_info and report_info_id! # If the report_info does not anymore exist we create a new one but # with the existing report_info_id. if (?(session_profile_path . ".report_infos." . report_info_id)) then ( use_existing_report_info = true; ) else ( create_new_report_info = true; ); new_report_info_id = report_info_id; ); debug_message("#### use_existing_web_browser_session_report: " . use_existing_web_browser_session_report . "\n"); debug_message("#### create_new_report_info: " . create_new_report_info . "\n"); debug_message("#### use_existing_report_info: " . use_existing_report_info . "\n"); if (use_existing_web_browser_session_report) then ( # # # # We use the existing web browser session report which we clone into a report_info # # # node web_browser_session_report = web_browser_session_reports{report_name}; # skip_reset_row_numbers is true after Customize Report Element # so that a row number setting like 50-150 is not reset to 1-150 if (!skip_reset_row_numbers) then ( # Reset the row numbers reset_row_numbers_in_request_report(web_browser_session_report); ); # Create a report_info from web_browser_session_report by simply cloning the node to report_infos clone_node(web_browser_session_report, session_profile_path . ".report_infos." . new_report_info_id); save_node(session_profile_path . ".report_infos." . new_report_info_id); ) else ( # # # # We create a new report info or use an existing one # # # # Delete any existing session report in web_browser_session_reports if (web_browser_session_reports?{report_name}) then ( delete_node(web_browser_session_reports{report_name}); ); if (create_new_report_info) then ( v.temp_command_line = ""; create_report_info(session_id, user_node_name, is_root_admin, new_report_info_id, profile_name, report_name, is_command_line, "v.temp_command_line"); ); # # # Clone the new or existing report_info to web_browser_session_reports # # node report_info = session_profile_path . ".report_infos." . new_report_info_id; clone_node(report_info, web_browser_session_reports . "." . report_name); ); new_report_info_id; )); # # # # handle_report_request_with_report_info_update() # # # subroutine(handle_report_request_with_report_info_update( string session_id, bool is_root_admin, node web_browser_session_reports, string profile_name, string report_name, node directives), ( # We clone the source report info, give it a new_report_info_id and update it. # Then we copy the new report info to the web browser session report. debug_message("\n#### handle_report_request_with_report_info_update START \n"); string session_profile_path = "sessions_cache." . session_id . ".profiles." . profile_name; string source_report_info_id = @directives{"source_report_info_id"}; node source_report_info = session_profile_path . ".report_infos." . source_report_info_id; string new_report_info_id = get_new_report_info_id(); clone_node(source_report_info, session_profile_path . ".report_infos." . new_report_info_id); node new_report_info = session_profile_path . ".report_infos." . new_report_info_id; update_report_info( session_id, is_root_admin, profile_name, new_report_info, directives ); # # Clean up web_browser_session_reports # if (web_browser_session_reports?{report_name}) then ( delete_node(web_browser_session_reports{report_name}); ); # # Clone new_report_info to web_browser_session_reports # clone_node(new_report_info, web_browser_session_reports{report_name}); save_node(new_report_info); new_report_info_id; ));