Report Manager
Registers custom report variables for layout design and handles report generation.
ReportManager
Bases: QObject
Registers custom report variables for layout design and handles report generation.
Source code in src/cplus_plugin/lib/reports/manager.py
variable_register
property
Get the instance of the variable register used for the management of variables.
Returns:
Type | Description |
---|---|
LayoutVariableRegister
|
The register for managing variables in report layout scope. |
create_comparison_report_context
classmethod
Create contextual information for generating the scenario comparison report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_results |
List[ScenarioResult]
|
Collection of scenario results to be compared. |
required |
feedback |
QgsFeedback
|
Feedback object for reporting back to the main application. |
required |
Source code in src/cplus_plugin/lib/reports/manager.py
create_report_context
classmethod
Creates the report context for use in the report generator task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_result |
ScenarioResult
|
Result of the scenario analysis. |
required |
feedback |
QgsFeedback
|
Feedback object for reporting back to the main application. |
required |
Returns:
Type | Description |
---|---|
ReportContext
|
A report context object containing the information for generating the report else None if it could not be created. |
Source code in src/cplus_plugin/lib/reports/manager.py
create_scenario_dir
Creates an output directory (within BASE_DIR) for saving the analysis outputs for the given scenario.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario |
Scenario
|
Reference scenario object. |
required |
Returns:
Type | Description |
---|---|
str
|
The absolute path to the output directory. If BASE_DIR does not exist, it will not create the directory and will return an empty string. If the current user does not have write permissions to the base directory, it will return an empty string. |
Source code in src/cplus_plugin/lib/reports/manager.py
generate
Initiates the report generation process using information resulting from the scenario analysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_result |
ScenarioResult
|
Contains details from the scenario analysis. |
required |
feedback |
QgsFeedback
|
Feedback for reporting back to the main application. If one is not specified then the manager will create one for the context. |
None
|
Returns:
Type | Description |
---|---|
ReportSubmitStatus
|
True if the report generation process was successfully submitted else False if a running process is re-submitted. Object also contains feedback object for report updating and cancellation. |
Source code in src/cplus_plugin/lib/reports/manager.py
generate_comparison_report
Generates a report comparing the two or more scenarios.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_results |
List[ScenarioResult]
|
Collection of scenario results to be compared. |
required |
feedback |
QgsFeedback
|
Feedback object for reporting back to the main application. Default is None. |
None
|
Returns:
Type | Description |
---|---|
ReportSubmitStatus
|
True if the report generation process was successfully submitted else False if a running process is re-submitted. Object also contains feedback object for report updating and cancellation. |
Source code in src/cplus_plugin/lib/reports/manager.py
on_comparison_task_status_changed
Slot raised when the comparison task status has changed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status |
int
|
Task status: |
required |
Source code in src/cplus_plugin/lib/reports/manager.py
on_layout_designer_opened
Sets a default zoom level for the report when opened for the first time.
Source code in src/cplus_plugin/lib/reports/manager.py
on_task_status_changed
Slot raised when the status of a task has changed.
This function will emit when the report generation task has started or when it has completed successfully or terminated due to an error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id |
int
|
ID of the task. |
required |
status |
TaskStatus
|
New task status. |
required |
Source code in src/cplus_plugin/lib/reports/manager.py
open_layout_designer
Opens the analysis report in the layout designer. The layout needs to exist in the currently loaded project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result |
ReportResult
|
Result object from the report generation process. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the layout was successfully loaded, else False if the result from the generation process was False or if the layout does not exist in the current project. |
Source code in src/cplus_plugin/lib/reports/manager.py
register_variables
Registers custom variables and their corresponding initial values in the layout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout |
QgsPrintLayout
|
Layout object where the custom variables will be registered. |
required |
Source code in src/cplus_plugin/lib/reports/manager.py
remove_report_task
Remove report task associated with the given scenario.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_id |
str
|
Identified of the scenario whose report generation process is to be removed. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the task has been successfully removed else False if there is no associated task for the given scenario. |
Source code in src/cplus_plugin/lib/reports/manager.py
remove_task_by_result
Remove a report task based on the submit result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
submit_result |
ReportSubmitStatus
|
Submit result information. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the task has been successfully removed else False if there is no associated task for the given submit result. |
Source code in src/cplus_plugin/lib/reports/manager.py
report_result
Gets the report result for the scenario with the given ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_id |
str
|
Identifier of the scenario whose report is to be retrieved. |
required |
Returns:
Type | Description |
---|---|
ReportResult
|
Result of the report generation process. Caller needs to check if the process was successful or there was an error by checking the status of the |
Source code in src/cplus_plugin/lib/reports/manager.py
scenario_by_task_id
Gets the scenario identifier for the report generation t ask with the given ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id |
int
|
ID of the task whose corresponding scenario is to be retrieved. |
required |
Returns:
Type | Description |
---|---|
str
|
Scenario identifier whose report is being generated by a process with the given task id or an empty string if there was no match. |
Source code in src/cplus_plugin/lib/reports/manager.py
task_by_id
Gets the task using its identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id |
int
|
Task identifier. |
required |
Returns:
Type | Description |
---|---|
QgsTask
|
The tas corresponding to the given ID or None if not found. |
Source code in src/cplus_plugin/lib/reports/manager.py
view_pdf
classmethod
Opens the analysis in the host's default PDF viewer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result |
ReportResult
|
Result object from the report generation process. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the PDF was successfully loaded, else False if the result from the generation process was False. |