HS: Basic: Add parameters table and fix save/load sql methods.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-12-12 14:23:36 +01:00
1 parent 6c9e90ceaf
commit 02bbdf9fda
7 files changed
+140 -16

No files matched your search

@@ -80,11 +80,15 @@ class BasicHS(SQLSubModel):
@classmethod
def _get_ctor_from_type(cls, t):
from Model.HydraulicStructure.Basic.Types import (
NotDefined,
from Model.HydraulicStructures.Basic.Types import (
NotDefined, Dummy,
)
res = NotDefined
if t == "DU":
res = Dummy
return res
@classmethod
@@ -93,7 +97,7 @@ class BasicHS(SQLSubModel):
table = execute(
"SELECT id, name, type, enabled, hs " +
"FROM hydraulic_structures "
"FROM hydraulic_structures_basic "
)
for row in table:
@@ -113,7 +117,7 @@ class BasicHS(SQLSubModel):
bhs.enabled = enabled
data['bhs_id'] = bhs_id
bhs._data = BasicHSValue._db_load(
bhs._data = BHSValue._db_load(
execute, data
)
@@ -144,7 +148,7 @@ class BasicHS(SQLSubModel):
data['bhs_id'] = self.id
execute(
"DELETE FROM hydraulic_structures_basic_value " +
f"WHERE bhs = {bhs_id}"
f"WHERE bhs = {self.id}"
)
for values in self._data:
@@ -183,8 +187,8 @@ class BasicHS(SQLSubModel):
self._status.modified()
@property
def lst(self):
return self._data.copy()
def parameters(self):
return self._data
def convert(self, new_type):
return new_type(id=self.id, name=self.name, status=self._status)