{= # # # run_schedule_start.cfv (is called from client upon running a single schedule action) # # include "templates.util.base_util"; include "templates.util.encoding"; include "templates.util.rbac.rbac_util"; include "templates.admin_pages.scheduler.schedule_report_filters"; debug_message("\n\n#### run_schedule_start.cfv \n"); # # Note, schedules which are send to run_schedule_now are limited to a single action. # This allows us a more flexible state indication in the client GUI, i.e. which action # is currently processed and it is easier to cancel Run Now as only one action is # processed. # # The schedule node is saved in sessions_cache and run_task() is executed via exec() by using # the saved schedule node. We do this so that this template returns immediately and the # client can check the saved node if run_task() completed. # If we wouldn't do that we could get time out problems, depending when run_task() returns. # # # # Save v.fp processing node with the given run_id in sessions_cache # # string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); string page_token = v.fp.page_token; # # Check RBAC permissions # if ((is_root_admin or get_admin_feature_permission(session_id, "scheduler", "view")) and get_is_valid_page_token(session_id, "scheduler", page_token)) then ( debug_message("\n" . node_as_string("v.fp") . "\n"); string run_id = v.fp.run_id; string basket_id = v.fp.basket_id; # # Handle report filters in actions. # Create and set a filter_id for every action # with active report filters. # node actions = "v.fp.schedule.actions"; node action_item; foreach action_item actions ( # Make sure that the filter_id is empty. # Only an empty filter_id will force the # creation of a new filter and will set the # filter_id in options.fi. if (?(action_item . ".report_filters.filter_id")) then ( (action_item . ".report_filters.filter_id") = ""; ); set_report_filter_id_in_action_item(action_item); ); # # Save the schedule in sessions_cache # string session_schedule_run_path = "sessions_cache." . session_id . ".scheduler_run_now." . run_id; clone_node("v.fp", session_schedule_run_path); save_node(session_schedule_run_path); # # # Start the schedule via exec # # string cmd = ""; v.options.1 = "background"; v.options.2 = "-dp"; v.options.3 = "templates.admin_pages.scheduler.run_schedule_exec"; v.options.4 = "volatile.session_id"; v.options.5 = session_id; v.options.6 = "volatile.run_id"; v.options.7 = run_id; v.options.8 = "volatile.page_token"; v.options.9 = page_token; string pid = exec(cmd, "v.options", false); # # # Send response # # string dat = "{"; dat .= add_json("runId", run_id, "string"); dat .= add_json("basketId", basket_id, "string"); dat = close_json(dat); 'schedulerRun.runScheduleActionResponse(' . dat . ')\n'; ) else ( # No permission to access this resource (URL) display_no_permission_html(); ); debug_message("\n\n#### run_schedule_start.cfv EDN\n\n"); =}