Skip to content

Commit

Permalink
pass delete_data to import config (to control deleteData parameter or…
Browse files Browse the repository at this point in the history
… to update config to control if it's an --update or a --replace. This resolves #718
  • Loading branch information
signedav committed Dec 7, 2023
1 parent db04966 commit 8d5b24c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
22 changes: 18 additions & 4 deletions QgisModelBaker/gui/panel/session_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(
baskets,
export_models,
db_action_type,
delete_data,
parent=None,
):
super().__init__(parent)
Expand All @@ -70,6 +71,7 @@ def __init__(
self.datasets = datasets
self.baskets = baskets
self.export_models = export_models
self.delete_data = delete_data

# set up the gui
self.create_text = self.tr("Run")
Expand Down Expand Up @@ -130,24 +132,36 @@ def __init__(
self.tr(
"""
<html><head/><body>
<p>Update the data in dataset <b>{dataset}</b></p>
<p>{update_word} the data in dataset <b>{dataset}</b></p>
<p>with the data from <i>{file}</i></p>
</body></html>
"""
).format(dataset=self.datasets[0], file=self.file)
).format(
update_word=self.tr("Update")
if not self.delete_data
else self.tr("Replace"),
dataset=self.datasets[0],
file=self.file,
)
)
else:
self.info_label.setText(
self.tr(
"""
<html><head/><body>
<p>Import the data from <i>{file}</i></p>
<p>{import_word} the data from <i>{file}</i></p>
</body></html>
"""
).format(file=self.file)
).format(
import_word=self.tr("Import")
if not self.delete_data
else self.tr("Delete existing data and import"),
file=self.file,
)
)

self.configuration.dataset = self.datasets[0] if self.datasets else None
self.configuration.delete_data = self.delete_data
elif self.db_action_type == DbActionType.EXPORT:
self.configuration.xtffile = self.file
self.configuration.with_exporttid = self._get_tid_handling()
Expand Down
6 changes: 5 additions & 1 deletion QgisModelBaker/gui/workflow_wizard/execution_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,14 @@ def setup_sessions(self, configuration, sessions):
sessions[key]["datasets"] if "datasets" in sessions[key] else None
)
baskets = sessions[key]["baskets"] if "baskets" in sessions[key] else None

export_models = (
sessions[key]["export_models"]
if "export_models" in sessions[key]
else None
)
delete_data = (
sessions[key]["delete_data"] if "delete_data" in sessions[key] else None
)

skipped_session_widget = self._find_skipped_session_widget(
(
Expand All @@ -111,6 +113,7 @@ def setup_sessions(self, configuration, sessions):
baskets,
export_models,
db_utils.get_schema_identificator_from_configuration(configuration),
delete_data,
)
)
if skipped_session_widget:
Expand All @@ -124,6 +127,7 @@ def setup_sessions(self, configuration, sessions):
baskets,
export_models,
self.db_action_type,
delete_data,
)
session.on_done_or_skipped.connect(self._on_done_or_skipped_received)
session.print_info.connect(self.workflow_wizard.log_panel.print_info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ def setup_dialog(self, basket_handling):
gui_utils.SourceModel.Columns.DATASET, True
)
self.datasetmanager_button.setHidden(True)

self.file_table_view.setItemDelegateForColumn(
gui_utils.SourceModel.Columns.DELETE_DATA,
CheckDelegate(self, role=gui_utils.SourceModel.Roles.DELETE_DATA),
)
self._update_referencedata_completer()

def _set_basket_defaults(self):
Expand Down Expand Up @@ -272,11 +277,6 @@ def _set_basket_defaults(self):
int(gui_utils.SourceModel.Roles.DELETE_DATA),
)

# needs to be fixed
self.file_table_view.setItemDelegateForColumn(
gui_utils.SourceModel.Columns.DELETE_DATA,
CheckDelegate(self, role=gui_utils.SourceModel.Roles.DELETE_DATA),
)
self.file_table_view.setItemDelegateForColumn(
gui_utils.SourceModel.Columns.IS_CATALOGUE,
CheckDelegate(self, role=gui_utils.SourceModel.Roles.IS_CATALOGUE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import os

import yaml
from qgis.core import QgsProject
from qgis.core import Qgis, QgsProject
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtWidgets import QWizardPage

Expand Down
4 changes: 2 additions & 2 deletions QgisModelBaker/utils/gui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,8 @@ def import_sessions(self, order_list) -> dict():
else CATALOGUE_DATASETNAME
)
sessions[source] = {}
sessions[source]["datasets"] = [dataset]
sessions[source]["delete_data"] = [delete_data]
sessions[source]["datasets"] = [dataset] if dataset else []
sessions[source]["delete_data"] = delete_data
i += 1
return sessions

Expand Down

0 comments on commit 8d5b24c

Please sign in to comment.