Compare commits

..

10 Commits

Author SHA1 Message Date
Dylan Jeannin 2c0b155baf error in the name of a db table 2026-05-20 10:40:11 +02:00
Dylan Jeannin 4d20c2457a pep8 fix 2026-05-20 10:19:52 +02:00
Dylan Jeannin 2dd9003721 merge scenario (missing tables) 2026-05-20 10:18:56 +02:00
Dylan Jeannin 94ceb44fd4 debug load study after deleting a node in the child scenario network 2026-05-20 09:51:38 +02:00
Dylan Jeannin ab50d2adf4 little fixes with variable names 2026-05-19 18:00:39 +02:00
Dylan Jeannin 0eb979256f little fixes with variable names 2026-05-19 17:59:30 +02:00
Dylan Jeannin ccf3da114b fix duplication of same objects in db with when saving a child scenario 2026-05-19 16:13:21 +02:00
Dylan Jeannin 348417977d add missing tables in drop_all function, called on a scenario deletion 2026-05-19 15:58:37 +02:00
Dylan Jeannin cbbbeeac0b correct error that made InitialCondition addition bug 2026-05-19 11:40:03 +02:00
Dylan Jeannin c9ea726bfb correct error that made LateralContrib deletion bug 2026-05-19 11:30:38 +02:00
8 changed files with 29 additions and 13 deletions

View File

@ -274,6 +274,9 @@ class HydraulicStructure(SQLSubModel):
return hs
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
execute(
"DELETE FROM hydraulic_structures " +
f"WHERE pamhyr_id = {self.pamhyr_id} " +

View File

@ -225,6 +225,8 @@ class Data(SQLSubModel):
return new
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
ind = data["ind"]
execute(
@ -396,7 +398,7 @@ class InitialConditions(SQLSubModel):
@reach.setter
def reach(self, new):
self._reach = reach
self._reach = new
self.modified()
@property

View File

@ -147,9 +147,9 @@ class Data(SQLSubModel):
it = iter(v)
pid = next(it)
delete = next(it)
data0 = bc._types[0](next(it))
data1 = bc._types[1](next(it))
deleted = next(it)
data0 = lc._types[0](next(it))
data1 = lc._types[1](next(it))
owner_scenario = next(it)
nd = cls(

View File

@ -402,7 +402,7 @@ class Pollutants(SQLSubModel):
return new
table = execute(
"SELECT pamhyr_id, deleted, name FROM pollutants " +
"SELECT pamhyr_id, deleted, name, scenario FROM pollutants " +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
)
@ -414,10 +414,12 @@ class Pollutants(SQLSubModel):
pid = next(it)
deleted = (next(it) == 1)
name = next(it)
owner_scenario = next(it)
new_pollutant = cls(
id=pid, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
if deleted:
new_pollutant.set_as_deleted()

View File

@ -180,6 +180,9 @@ class RiverNode(Node):
return nodes
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
execute(
"INSERT OR REPLACE INTO river_node(" +
"pamhyr_id, deleted, name, x, y, scenario" +
@ -361,7 +364,7 @@ class RiverReach(Edge):
)
new.enable(enable=enabled)
if deleted:
nd.set_as_deleted()
new.set_as_deleted()
data["reach"] = new
new._reach = Reach._db_load(execute, data)
@ -377,6 +380,9 @@ class RiverReach(Edge):
return reachs
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
execute(
"INSERT OR REPLACE INTO " +
"river_reach(" +
@ -386,7 +392,7 @@ class RiverReach(Edge):
"VALUES (" +
f"{self.pamhyr_id}, {self._db_format(self.is_deleted())}, " +
f"'{self._db_format(self._name)}', " +
f"{self._db_format(self.is_enable())},"
f"{self._db_format(self.is_enable())}," +
f"{self.node1.pamhyr_id}, {self.node2.pamhyr_id}, " +
f"{self._status.scenario_id}" +
")"
@ -543,7 +549,7 @@ class River(Graph):
new._nodes = RiverNode._db_load(
execute, data
)
data["nodes"] = new.nodes()
data["nodes"] = new._nodes
data['loaded_pid'] = set()
new._edges = RiverReach._db_load(

View File

@ -35,8 +35,9 @@ class Scenario(SQLSubModel):
"output_rk_adists",
"boundary_condition_adists", "boundary_condition_data_adists",
"lateral_contribution_adists", "lateral_contribution_data_adists",
"initial_conditions_adists",
"d90_adists",
"initial_conditions_adists", "initial_conditions_adists_spec",
"d90_adists", "d90_adists_spec",
"dif_adists_spec",
"pollutants", "pollutants_characteristics",
# Hydraulic
"additional_files",
@ -51,12 +52,14 @@ class Scenario(SQLSubModel):
"rep_lines",
"geometry_pointXYZ", "geometry_profileXYZ",
"river_reach", "river_node",
"geotiff", "reservoir", "reservoir_data",
]
related_tables = tables_with_deleted_column + [
"dif_adists",
"solver_parameter",
"hydraulic_structures_basic_value",
"results", "results_data", "results_add_data",
]
def __init__(self,

View File

@ -173,7 +173,7 @@ class InitialConditionTableModel(PamhyrTableModel):
def add(self, row, parent=QModelIndex()):
self.beginInsertRows(parent, row, row - 1)
row = self.get_true_data_row(row)
# row = self.get_true_data_row(row)
self._undo.push(
AddCommand(

View File

@ -156,7 +156,7 @@ class DelCommand(QUndoCommand):
el.set_as_not_deleted()
def redo(self):
for el in self._bc:
for el in self._lc:
el.set_as_deleted()