From 4a23f48c24a76739e42e153ad5058f42fe332018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Tue, 26 Nov 2024 00:14:15 -0500 Subject: [PATCH 1/6] [pre-commit] Upgrade autoflake so that we get rid of its distutils dependency (package removed in Python 3.12, and deprecated in Python 3.10) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 429f5404b..12461ea94 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: # Remove unused imports/variables - repo: https://github.com/myint/autoflake - rev: v1.4 + rev: v2.3.1 hooks: - id: autoflake args: From 1ccab153aece402dacb7e8dc42dd79a2ba539102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Tue, 26 Nov 2024 00:15:22 -0500 Subject: [PATCH 2/6] [toppingexporter] Use ili2db's --exportMetaConfig to get schema import parameters from a DB --- .../gui/topping_wizard/ili2dbsettings_page.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py b/QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py index c0a6eba93..f5ffe5e8a 100644 --- a/QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py +++ b/QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py @@ -16,9 +16,10 @@ * * ***************************************************************************/ """ +import tempfile from enum import IntEnum -from qgis.core import QgsMapLayer, QgsProject +from qgis.core import Qgis, QgsMapLayer, QgsMessageLog, QgsProject from qgis.PyQt.QtCore import QAbstractItemModel, QModelIndex, Qt from qgis.PyQt.QtWidgets import QHeaderView, QTableView, QWizardPage @@ -26,6 +27,7 @@ Ili2DbCommandConfiguration, ) from QgisModelBaker.libs.modelbaker.utils import db_utils +from QgisModelBaker.libs.modelbaker.utils.ili2db_utils import Ili2DbUtils from QgisModelBaker.libs.modelbaker.utils.qt_utils import make_file_selector from QgisModelBaker.utils import gui_utils @@ -288,14 +290,22 @@ def _refresh_combobox(self): def _schema_changed(self): configuration = self.schema_combobox.currentData() + parsed_from_file = False if configuration: - db_connector = db_utils.get_db_connector(configuration) - if db_connector: - self.topping_wizard.topping.metaconfig.ili2db_settings.parse_parameters_from_db( - db_connector + _, tmp_ini_file = tempfile.mkstemp(".ini") + + ili2db_utils = Ili2DbUtils() + ili2db_utils.log_on_error.connect(self._log_on_export_metagonfig_error) + res, msg = ili2db_utils.export_metaconfig(tmp_ini_file, configuration) + if res: + parsed_from_file = self.topping_wizard.topping.metaconfig.ili2db_settings.parse_parameters_from_ini_file( + tmp_ini_file ) - else: + if not parsed_from_file: self.topping_wizard.topping.metaconfig.ili2db_settings.parameters = {} self.parameters_model.refresh_model( self.topping_wizard.topping.metaconfig.ili2db_settings.parameters ) + + def _log_on_export_metagonfig_error(self, log): + QgsMessageLog.logMessage(log, self.tr("Export metaConfig"), Qgis.Critical) From e26e87f26d8abbdd9e30b5192322550033c9a2fa Mon Sep 17 00:00:00 2001 From: signedav Date: Wed, 27 Nov 2024 10:34:21 +0100 Subject: [PATCH 3/6] improve usability of basket page with desciptive text next to the buttons --- .../ui/workflow_wizard/default_baskets.ui | 101 +++++++++++++----- 1 file changed, 73 insertions(+), 28 deletions(-) diff --git a/QgisModelBaker/ui/workflow_wizard/default_baskets.ui b/QgisModelBaker/ui/workflow_wizard/default_baskets.ui index 4354b6fc4..1db037ff0 100644 --- a/QgisModelBaker/ui/workflow_wizard/default_baskets.ui +++ b/QgisModelBaker/ui/workflow_wizard/default_baskets.ui @@ -14,14 +14,27 @@ Create default Baskets - - - - QLayout::SetMaximumSize + + + + 0 - + + + + + + + 0 + 0 + + + + Create baskets + + - + @@ -36,7 +49,7 @@ - <html><head/><body><p>You need baskets of the default dataset (<code>Baseset</code>) to collect new data in the created schema. </p><p>If you plan to start with the import of existing data, you can skip this step. To create baskets later on, find the <b><i>Dataset Manager</i></b> in the Model Baker Menu.</p></body></html> + <html><head/><body><p>You need baskets of the default dataset (<span style=" font-family:'monospace';">Baseset</span>) to collect new data in the created schema, otherwise you can skip this step. To create baskets later on, find the <span style=" font-style:italic;">Dataset Manager</span> in the Model Baker Menu.</p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -46,37 +59,69 @@ - - + + + + + 0 + 0 + + - Create baskets + Skip this step - - - - Qt::Horizontal - - - - 40 - 20 - + + + + QLayout::SetMaximumSize - + - - - - 0 + + + + + 0 + 0 + + + + + 50 + false + false + + + + <html><head/><body><p>If you are planning to start with <span style=" font-weight:600;">importing existing</span> data...</p></body></html> + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + + + 0 + 0 + + + + + 50 + false + false + + - Skip this step + <html><head/><body><p>If you are planning to start with<span style=" font-weight:600;"> collecting new </span>data...</p></body></html> + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter From 4c14740303d8d9820e56e004c35a5c49110e1488 Mon Sep 17 00:00:00 2001 From: signedav Date: Wed, 27 Nov 2024 11:46:26 +0100 Subject: [PATCH 4/6] make difference between action type SCHEMA_IMPORT and GENERATE what fixes #987 --- QgisModelBaker/gui/panel/gpkg_config_panel.py | 7 +++++-- QgisModelBaker/gui/panel/mssql_config_panel.py | 7 +++++-- QgisModelBaker/gui/panel/pg_config_panel.py | 7 +++++-- QgisModelBaker/gui/panel/session_panel.py | 12 ++++++------ .../gui/workflow_wizard/database_selection_page.py | 1 - QgisModelBaker/gui/workflow_wizard/execution_page.py | 5 ++--- .../gui/workflow_wizard/workflow_wizard.py | 2 +- QgisModelBaker/utils/globals.py | 2 +- 8 files changed, 25 insertions(+), 18 deletions(-) diff --git a/QgisModelBaker/gui/panel/gpkg_config_panel.py b/QgisModelBaker/gui/panel/gpkg_config_panel.py index d6d70c6be..c61d47a8b 100644 --- a/QgisModelBaker/gui/panel/gpkg_config_panel.py +++ b/QgisModelBaker/gui/panel/gpkg_config_panel.py @@ -62,7 +62,7 @@ def __init__(self, parent, db_action_type): def _show_panel(self): if ( - self._db_action_type == DbActionType.GENERATE + self._db_action_type == DbActionType.SCHEMA_IMPORT or self._db_action_type == DbActionType.IMPORT_DATA ): validator = self.gpkgSaveFileValidator @@ -73,7 +73,10 @@ def _show_panel(self): extensions=["." + ext for ext in self.ValidExtensions], dont_confirm_overwrite=True, ) - elif self._db_action_type == DbActionType.EXPORT: + elif ( + self._db_action_type == DbActionType.EXPORT + or self._db_action_type == DbActionType.GENERATE + ): validator = self.gpkgOpenFileValidator file_selector = make_file_selector( self.gpkg_file_line_edit, diff --git a/QgisModelBaker/gui/panel/mssql_config_panel.py b/QgisModelBaker/gui/panel/mssql_config_panel.py index 7898da550..7ef3475be 100644 --- a/QgisModelBaker/gui/panel/mssql_config_panel.py +++ b/QgisModelBaker/gui/panel/mssql_config_panel.py @@ -66,7 +66,7 @@ def __init__(self, parent, db_action_type): self.mssql_password_line_edit.textChanged.connect(self.notify_fields_modified) def _show_panel(self): - if self._db_action_type == DbActionType.GENERATE: + if self._db_action_type == DbActionType.SCHEMA_IMPORT: self.mssql_schema_line_edit.setPlaceholderText( self.tr("[Leave empty to create a default schema]") ) @@ -74,7 +74,10 @@ def _show_panel(self): self.mssql_schema_line_edit.setPlaceholderText( self.tr("[Leave empty to import data into a default schema]") ) - elif self._db_action_type == DbActionType.EXPORT: + elif ( + self._db_action_type == DbActionType.EXPORT + or self._db_action_type == DbActionType.GENERATE + ): self.mssql_schema_line_edit.setPlaceholderText( self.tr("[Enter a valid schema]") ) diff --git a/QgisModelBaker/gui/panel/pg_config_panel.py b/QgisModelBaker/gui/panel/pg_config_panel.py index 909bc4ff5..bde65be26 100644 --- a/QgisModelBaker/gui/panel/pg_config_panel.py +++ b/QgisModelBaker/gui/panel/pg_config_panel.py @@ -193,13 +193,16 @@ def _show_panel(self): self._fill_schema_combo_box() if ( - self._db_action_type == DbActionType.GENERATE + self._db_action_type == DbActionType.SCHEMA_IMPORT or self._db_action_type == DbActionType.IMPORT_DATA ): self.pg_schema_combo_box.lineEdit().setPlaceholderText( self.tr("Schema Name") ) - elif self._db_action_type == DbActionType.EXPORT: + elif ( + self._db_action_type == DbActionType.EXPORT + or self._db_action_type == DbActionType.GENERATE + ): self.pg_schema_combo_box.lineEdit().setPlaceholderText( self.tr("[Enter a valid schema]") ) diff --git a/QgisModelBaker/gui/panel/session_panel.py b/QgisModelBaker/gui/panel/session_panel.py index eb4642f1a..6f76fd86a 100644 --- a/QgisModelBaker/gui/panel/session_panel.py +++ b/QgisModelBaker/gui/panel/session_panel.py @@ -80,7 +80,7 @@ def __init__( self.set_button_to_create_action.triggered.connect(self.set_button_to_create) self.db_action_type = db_action_type - if self.db_action_type == DbActionType.GENERATE: + if self.db_action_type == DbActionType.SCHEMA_IMPORT: self.create_without_constraints_text = self.tr("Run without constraints") else: self.create_without_constraints_text = self.tr("Run without validation") @@ -116,7 +116,7 @@ def __init__( and not self.configuration.dbusr ): self.configuration.dbusr = QgsApplication.userLoginName() - if self.db_action_type == DbActionType.GENERATE: + if self.db_action_type == DbActionType.SCHEMA_IMPORT: self.configuration.ilifile = "" if os.path.isfile(self.file): self.configuration.ilifile = self.file @@ -331,7 +331,7 @@ def run(self, edited_command=None): self.set_button_to_cancel() self.is_running = True - if self.db_action_type == DbActionType.GENERATE: + if self.db_action_type == DbActionType.SCHEMA_IMPORT: self._pre_generate_project() porter = self._get_porter() @@ -350,7 +350,7 @@ def run(self, edited_command=None): try: if porter.run(edited_command) != iliexecutable.IliExecutable.SUCCESS: self.progress_bar.setValue(0) - if not self.db_action_type == DbActionType.GENERATE: + if not self.db_action_type == DbActionType.SCHEMA_IMPORT: self.set_button_to_create_without_constraints() else: self.set_button_to_create() @@ -359,7 +359,7 @@ def run(self, edited_command=None): except JavaNotFoundError as e: self.print_info.emit(e.error_string, LogLevel.FAIL) self.progress_bar.setValue(0) - if not self.db_action_type == DbActionType.GENERATE: + if not self.db_action_type == DbActionType.SCHEMA_IMPORT: self.set_button_to_create_without_constraints() else: self.set_button_to_create() @@ -377,7 +377,7 @@ def run(self, edited_command=None): # an user interaction (cancel) here cannot interupt the process, why it's disabled (and enabled again below). self.setDisabled(True) if ( - self.db_action_type == DbActionType.GENERATE + self.db_action_type == DbActionType.SCHEMA_IMPORT and self.configuration.create_basket_col ): self._create_default_dataset() diff --git a/QgisModelBaker/gui/workflow_wizard/database_selection_page.py b/QgisModelBaker/gui/workflow_wizard/database_selection_page.py index 61cf14ce6..bfd2ca77a 100644 --- a/QgisModelBaker/gui/workflow_wizard/database_selection_page.py +++ b/QgisModelBaker/gui/workflow_wizard/database_selection_page.py @@ -45,7 +45,6 @@ def __init__(self, parent, title, db_action_type): self.setupUi(self) self.setTitle(title) - # in this context we use GENERATE for the project generation and the IMPORT_DATA for the schema import (and the data import) if db_action_type == DbActionType.GENERATE: self.description.setText( self.tr( diff --git a/QgisModelBaker/gui/workflow_wizard/execution_page.py b/QgisModelBaker/gui/workflow_wizard/execution_page.py index 9c8131306..38a5dcf5e 100644 --- a/QgisModelBaker/gui/workflow_wizard/execution_page.py +++ b/QgisModelBaker/gui/workflow_wizard/execution_page.py @@ -47,8 +47,7 @@ def __init__(self, parent, title, db_action_type): self.setupUi(self) self.setTitle(title) - # in this context we use GENERATE for the schema import and IMPORT_DATA for the data import - if self.db_action_type == DbActionType.GENERATE: + if self.db_action_type == DbActionType.SCHEMA_IMPORT: self.description.setText( self.tr( "Run the ili2db sessions to make the model imports (or skip to continue)." @@ -186,7 +185,7 @@ def _on_process_finished(self, exit_code, result): if exit_code == 0: message = "Finished with success." level = LogLevel.SUCCESS - if self.db_action_type == DbActionType.GENERATE: + if self.db_action_type == DbActionType.SCHEMA_IMPORT: message = self.tr( "INTERLIS model(s) successfully imported into the database!" ) diff --git a/QgisModelBaker/gui/workflow_wizard/workflow_wizard.py b/QgisModelBaker/gui/workflow_wizard/workflow_wizard.py index 936f03f4a..d7089aea2 100644 --- a/QgisModelBaker/gui/workflow_wizard/workflow_wizard.py +++ b/QgisModelBaker/gui/workflow_wizard/workflow_wizard.py @@ -154,7 +154,7 @@ def __init__(self, iface, base_config, parent): self.import_schema_execution_page = ExecutionPage( self, self._current_page_title(PageIds.ImportSchemaExecution), - DbActionType.GENERATE, + DbActionType.SCHEMA_IMPORT, ) self.default_baskets_page = DefaultBasketsPage( self, self._current_page_title(PageIds.DefaultBaskets) diff --git a/QgisModelBaker/utils/globals.py b/QgisModelBaker/utils/globals.py index 30a50a13b..b421f363c 100644 --- a/QgisModelBaker/utils/globals.py +++ b/QgisModelBaker/utils/globals.py @@ -56,5 +56,5 @@ class AdministrativeDBActionTypes(Enum): """Defines constants for modelbaker actions that require superuser login""" - GENERATE = DbActionType.GENERATE + SCHEMA_IMPORT = DbActionType.SCHEMA_IMPORT IMPORT_DATA = DbActionType.IMPORT_DATA From e588c6b884c789075f5795f6ca84f1ee617391eb Mon Sep 17 00:00:00 2001 From: signedav Date: Wed, 27 Nov 2024 12:27:37 +0100 Subject: [PATCH 5/6] hide system layers in legend. resolves #587 --- QgisModelBaker/gui/workflow_wizard/project_creation_page.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QgisModelBaker/gui/workflow_wizard/project_creation_page.py b/QgisModelBaker/gui/workflow_wizard/project_creation_page.py index 2b077e027..0400eacae 100644 --- a/QgisModelBaker/gui/workflow_wizard/project_creation_page.py +++ b/QgisModelBaker/gui/workflow_wizard/project_creation_page.py @@ -443,7 +443,7 @@ def _create_project(self): self.workflow_wizard.log_panel.print_info( self.tr("Arranging layers into groups…") ) - legend = generator.legend(available_layers) + legend = generator.legend(available_layers, hide_systemlayers=True) self.progress_bar.setValue(50) From cf1b547fd27761d0e153621554b429418871d248 Mon Sep 17 00:00:00 2001 From: signedav Date: Wed, 27 Nov 2024 16:17:07 +0100 Subject: [PATCH 6/6] bump modelbaker to 1.9.4 --- scripts/package_pip_packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/package_pip_packages.sh b/scripts/package_pip_packages.sh index d62562cd0..69eccaf7d 100755 --- a/scripts/package_pip_packages.sh +++ b/scripts/package_pip_packages.sh @@ -1,7 +1,7 @@ #!/bin/bash LIBS_DIR="QgisModelBaker/libs" -MODELBAKER_LIBRARY=("modelbaker" "1.9.3") +MODELBAKER_LIBRARY=("modelbaker" "1.9.4") PACKAGING=("packaging" "21.3") PACKAGES=(