mirror of https://gitlab.com/pamhyr/pamhyr2
add d50/sigma in database + load/save data in UI
parent
4f6e8249e0
commit
63836527c7
|
|
@ -232,6 +232,8 @@ class BoundaryCondition(SQLSubModel):
|
|||
type TEXT NOT NULL,
|
||||
tab TEXT NOT NULL,
|
||||
node INTEGER,
|
||||
d50 REAL DEFAULT 0.002,
|
||||
sigma REAL DEFAULT 1,
|
||||
{Scenario.create_db_add_scenario()},
|
||||
{Scenario.create_db_add_scenario_fk()},
|
||||
FOREIGN KEY(node) REFERENCES river_node(pamhyr_id),
|
||||
|
|
@ -258,6 +260,17 @@ class BoundaryCondition(SQLSubModel):
|
|||
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
|
||||
)
|
||||
|
||||
if major == "0" and int(minor) <= 2:
|
||||
if int(release) < 4:
|
||||
execute(
|
||||
"ALTER TABLE boundary_condition " +
|
||||
"ADD COLUMN d50 REAL DEFAULT 0.002"
|
||||
)
|
||||
execute(
|
||||
"ALTER TABLE boundary_condition " +
|
||||
"ADD COLUMN sigma REAL DEFAULT 1"
|
||||
)
|
||||
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
||||
@classmethod
|
||||
|
|
@ -316,7 +329,7 @@ class BoundaryCondition(SQLSubModel):
|
|||
return new
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, deleted, name, type, node, scenario " +
|
||||
"SELECT pamhyr_id, deleted, name, type, node, d50, sigma, scenario " +
|
||||
"FROM boundary_condition " +
|
||||
f"WHERE tab = '{tab}' " +
|
||||
f"AND scenario = {scenario.id} " +
|
||||
|
|
@ -331,6 +344,8 @@ class BoundaryCondition(SQLSubModel):
|
|||
name = next(it)
|
||||
t = next(it)
|
||||
node = next(it)
|
||||
d50 = next(it)
|
||||
sigma = next(it)
|
||||
owner_scenario = next(it)
|
||||
|
||||
ctor = cls._get_ctor_from_type(t)
|
||||
|
|
@ -342,7 +357,9 @@ class BoundaryCondition(SQLSubModel):
|
|||
)
|
||||
if deleted:
|
||||
bc.set_as_deleted()
|
||||
|
||||
if t=="SL":
|
||||
bc.d50 = d50
|
||||
bc.sigma = sigma
|
||||
bc.node = None
|
||||
if node != -1:
|
||||
bc.node = next(filter(lambda n: n.id == node, nodes), None)
|
||||
|
|
@ -374,16 +391,23 @@ class BoundaryCondition(SQLSubModel):
|
|||
node = -1
|
||||
if self._node is not None:
|
||||
node = self._node.id
|
||||
|
||||
|
||||
d50 = 0.002
|
||||
sigma = 1
|
||||
if self._type == "SL":
|
||||
d50 = self._d50
|
||||
sigma = self._sigma
|
||||
|
||||
execute(
|
||||
"INSERT INTO " +
|
||||
"boundary_condition(" +
|
||||
"pamhyr_id, deleted, name, type, tab, node, scenario" +
|
||||
"pamhyr_id, deleted, name, type, tab, node, d50, sigma, scenario" +
|
||||
") " +
|
||||
"VALUES (" +
|
||||
f"{self._pamhyr_id}, {self._db_format(self.is_deleted())}, " +
|
||||
f"'{self._db_format(self._name)}', " +
|
||||
f"'{self._db_format(self._type)}', '{tab}', {node}, " +
|
||||
f"{d50}, {sigma}, " +
|
||||
f"{self._status.scenario_id}" +
|
||||
")"
|
||||
)
|
||||
|
|
@ -467,6 +491,24 @@ class BoundaryCondition(SQLSubModel):
|
|||
|
||||
def has_node(self):
|
||||
return self._node is not None
|
||||
|
||||
@property
|
||||
def d50(self):
|
||||
return self._d50
|
||||
|
||||
@d50.setter
|
||||
def d50(self, value):
|
||||
self._d50 = float(value)
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def sigma(self):
|
||||
return self._sigma
|
||||
|
||||
@sigma.setter
|
||||
def sigma(self, value):
|
||||
self._sigma = float(value)
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def header(self):
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ logger = logging.getLogger()
|
|||
|
||||
|
||||
class Study(SQLModel):
|
||||
_version = "0.2.3"
|
||||
_version = "0.2.4"
|
||||
|
||||
_sub_classes = [
|
||||
Scenario,
|
||||
|
|
|
|||
Loading…
Reference in New Issue