From 1e2a123693fe4ae10f306165164a3ddb87b7c808 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Tue, 2 Sep 2025 17:20:09 +0200 Subject: [PATCH] Model: Tools: Prepare scenario duplication. --- src/Model/Tools/PamhyrDB.py | 1 - src/Model/Tools/PamhyrDict.py | 15 +++++++++++++++ src/Model/Tools/PamhyrList.py | 15 +++++++++++++++ src/Model/Tools/PamhyrListExt.py | 15 +++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/Model/Tools/PamhyrDB.py b/src/Model/Tools/PamhyrDB.py index 24c521b9..3314960f 100644 --- a/src/Model/Tools/PamhyrDB.py +++ b/src/Model/Tools/PamhyrDB.py @@ -202,7 +202,6 @@ class SQLSubModel(PamhyrID): self._owner_scenario = self._status.scenario_id self._status.modified() - def set_owner_scenario_if(self, predicate): """Set study status the object owner_scenario to current scenario if predicate(scenario_id) is true diff --git a/src/Model/Tools/PamhyrDict.py b/src/Model/Tools/PamhyrDict.py index ffb14e65..9a890d55 100644 --- a/src/Model/Tools/PamhyrDict.py +++ b/src/Model/Tools/PamhyrDict.py @@ -82,5 +82,20 @@ class PamhyrModelDict(SQLSubModel): self.set(key, new) return new + def rec_set_owner_scenario_if(self, predicate): + """Set study status the object owner_scenario to current + scenario if predicate(scenario_id) is true + + Args: + predicate: Function predicate on owner_scenario id + + Returns: + Nothing + """ + self.set_owner_scenario_if(predicate) + + for k in self._lst: + self._dict[key].set_owner_scenario_if(predicate) + def new(self, key): raise NotImplementedMethodeError(self, self.new) diff --git a/src/Model/Tools/PamhyrList.py b/src/Model/Tools/PamhyrList.py index 91b7a201..d757a2d4 100644 --- a/src/Model/Tools/PamhyrList.py +++ b/src/Model/Tools/PamhyrList.py @@ -85,6 +85,21 @@ class PamhyrModelList(SQLSubModel): if self._status is not None: self._status.modified() + def rec_set_owner_scenario_if(self, predicate): + """Set study status the object owner_scenario to current + scenario if predicate(scenario_id) is true + + Args: + predicate: Function predicate on owner_scenario id + + Returns: + Nothing + """ + self.set_owner_scenario_if(predicate) + + for el in self._lst: + el.set_owner_scenario_if(predicate) + def new(self, index): """Create new elements and add it to list diff --git a/src/Model/Tools/PamhyrListExt.py b/src/Model/Tools/PamhyrListExt.py index dd9ac1e3..870d4b7a 100644 --- a/src/Model/Tools/PamhyrListExt.py +++ b/src/Model/Tools/PamhyrListExt.py @@ -90,6 +90,21 @@ class PamhyrModelList(SQLSubModel): if self._status is not None: self._status.modified() + def rec_set_owner_scenario_if(self, predicate): + """Set study status the object owner_scenario to current + scenario if predicate(scenario_id) is true + + Args: + predicate: Function predicate on owner_scenario id + + Returns: + Nothing + """ + self.set_owner_scenario_if(predicate) + + for el in self._lst: + el.set_owner_scenario_if(predicate) + def new(self, index): """Create new elements and add it to list