Skip to content

Commit

Permalink
Merge branch 'master' into busy2
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav authored Nov 27, 2024
2 parents c462134 + fae8bcc commit 84cb302
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions QgisModelBaker/gui/panel/gpkg_config_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions QgisModelBaker/gui/panel/mssql_config_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,18 @@ 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]")
)
elif self._db_action_type == DbActionType.IMPORT_DATA:
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]")
)
Expand Down
7 changes: 5 additions & 2 deletions QgisModelBaker/gui/panel/pg_config_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
)
Expand Down
12 changes: 6 additions & 6 deletions QgisModelBaker/gui/panel/session_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down
23 changes: 17 additions & 6 deletions QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
* *
***************************************************************************/
"""
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

from QgisModelBaker.libs.modelbaker.iliwrapper.ili2dbconfig import (
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

Expand Down Expand Up @@ -291,15 +293,24 @@ def _schema_changed(self):
self, True, self.tr("Get ili2db settings of the current schema...")
)
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
)
self.topping_wizard.busy(self, False)

def _log_on_export_metagonfig_error(self, log):
QgsMessageLog.logMessage(log, self.tr("Export metaConfig"), Qgis.Critical)

Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 2 additions & 3 deletions QgisModelBaker/gui/workflow_wizard/execution_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)."
Expand Down Expand Up @@ -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!"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion QgisModelBaker/gui/workflow_wizard/workflow_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
101 changes: 73 additions & 28 deletions QgisModelBaker/ui/workflow_wizard/default_baskets.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,27 @@
<string>Create default Baskets</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<layout class="QVBoxLayout" name="baskets_layout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
<item row="2" column="0" colspan="3">
<widget class="QProgressBar" name="progress_bar">
<property name="value">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item row="3" column="2">
<widget class="QCommandLinkButton" name="create_default_baskets_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Create baskets</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="description">
<property name="minimumSize">
<size>
Expand All @@ -36,7 +49,7 @@
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;You need baskets of the default dataset (&lt;code&gt;Baseset&lt;/code&gt;) to collect new data in the created schema. &lt;/p&gt;&lt;p&gt;If you plan to start with the import of existing data, you can skip this step. To create baskets later on, find the &lt;b&gt;&lt;i&gt;Dataset Manager&lt;/i&gt;&lt;/b&gt; in the Model Baker Menu.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;You need baskets of the default dataset (&lt;span style=&quot; font-family:'monospace';&quot;&gt;Baseset&lt;/span&gt;) to collect new data in the created schema, otherwise you can skip this step. To create baskets later on, find the &lt;span style=&quot; font-style:italic;&quot;&gt;Dataset Manager&lt;/span&gt; in the Model Baker Menu.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
Expand All @@ -46,37 +59,69 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCommandLinkButton" name="create_default_baskets_button">
<item row="4" column="2">
<widget class="QCommandLinkButton" name="skip_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Create baskets</string>
<string>Skip this step</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<item row="1" column="0" colspan="3">
<layout class="QVBoxLayout" name="baskets_layout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
</spacer>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QProgressBar" name="progress_bar">
<property name="value">
<number>0</number>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="skip_desc">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If you are planning to start with &lt;span style=&quot; font-weight:600;&quot;&gt;importing existing&lt;/span&gt; data...&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCommandLinkButton" name="skip_button">
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="create_default_basket_desc">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Skip this step</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If you are planning to start with&lt;span style=&quot; font-weight:600;&quot;&gt; collecting new &lt;/span&gt;data...&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion QgisModelBaker/utils/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion scripts/package_pip_packages.sh
Original file line number Diff line number Diff line change
@@ -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=(
Expand Down

0 comments on commit 84cb302

Please sign in to comment.