Skip to content

Commit 6f7e832

Browse files
authored
Merge pull request #116 from opengisch/modification_baskets_datasets_followup
Implement delete basket method in Ili2dbUtils
2 parents 1029271 + 2b96644 commit 6f7e832

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

modelbaker/iliwrapper/ili2dbconfig.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ class DeleteConfiguration(Ili2DbCommandConfiguration):
490490
def __init__(self, other: Ili2DbCommandConfiguration = None):
491491
super().__init__(other)
492492
self.dataset = ""
493+
self.baskets = ""
493494

494495
def to_ili2db_args(self, extra_args=[], with_action=True):
495496
args = list()
@@ -499,7 +500,11 @@ def to_ili2db_args(self, extra_args=[], with_action=True):
499500

500501
self.append_args(args, extra_args)
501502

502-
self.append_args(args, ["--dataset", self.dataset])
503+
if self.dataset:
504+
self.append_args(args, ["--dataset", self.dataset])
505+
506+
if self.baskets:
507+
self.append_args(args, ["--baskets", self.baskets])
503508

504509
self.append_args(args, Ili2DbCommandConfiguration.to_ili2db_args(self))
505510

modelbaker/utils/ili2db_utils.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,48 @@ def __init__(self):
4040

4141
self._log = ""
4242

43+
def delete_baskets(
44+
self, baskets: str, configuration: Ili2DbCommandConfiguration = None
45+
):
46+
"""
47+
:param baskets: Semicolon-separated list of baskets to be deleted
48+
:param configuration: Base Ili2DbCommandConfiguration object
49+
:return: Tuple with boolean result and optional message
50+
"""
51+
deleter = ilideleter.Deleter()
52+
deleter.tool = configuration.tool
53+
deleter.configuration = DeleteConfiguration(configuration)
54+
deleter.configuration.baskets = baskets
55+
56+
with OverrideCursor(Qt.WaitCursor):
57+
self._connect_ili_executable_signals(deleter)
58+
self._log = ""
59+
60+
res = True
61+
msg = self.tr("Basket(s) '{}' successfully deleted!").format(baskets)
62+
try:
63+
if deleter.run() != ilideleter.Deleter.SUCCESS:
64+
msg = self.tr(
65+
"An error occurred when deleting the basket(s) '{}' from the DB (check the QGIS log panel)."
66+
).format(baskets)
67+
res = False
68+
self.log_on_error.emit(self._log)
69+
except JavaNotFoundError as e:
70+
msg = e.error_string
71+
res = False
72+
73+
self._disconnect_ili_executable_signals(deleter)
74+
75+
return res, msg
76+
4377
def delete_dataset(
4478
self, dataset: str, configuration: Ili2DbCommandConfiguration = None
4579
):
80+
"""
81+
:param dataset: Dataset id to be deleted
82+
:param configuration: Base Ili2DbCommandConfiguration object
83+
:return: Tuple with boolean result and optional message
84+
"""
4685
deleter = ilideleter.Deleter()
4786
deleter.tool = configuration.tool
4887
deleter.configuration = DeleteConfiguration(configuration)

0 commit comments

Comments
 (0)