mirror of https://gitlab.com/pamhyr/pamhyr2
AdisTS: OutputRK, IC, LC: Add deleted tag in DB.
parent
0ed7660e72
commit
ba60585550
|
|
@ -60,6 +60,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
|||
execute(f"""
|
||||
CREATE TABLE initial_conditions_adists{ext}(
|
||||
{cls.create_db_add_pamhyr_id()},
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
pollutant INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
concentration REAL NOT NULL,
|
||||
|
|
@ -147,7 +148,8 @@ class InitialConditionsAdisTS(SQLSubModel):
|
|||
return new
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, pollutant, name, concentration, eg, em, ed, " +
|
||||
"SELECT pamhyr_id, deleted, " +
|
||||
"pollutant, name, concentration, eg, em, ed, " +
|
||||
"enabled, scenario " +
|
||||
"FROM initial_conditions_adists " +
|
||||
f"WHERE scenario = {scenario.id} " +
|
||||
|
|
@ -159,6 +161,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
|||
it = iter(row)
|
||||
|
||||
pid = next(it)
|
||||
deleted = (next(it) == 1)
|
||||
pollutant = next(it)
|
||||
name = next(it)
|
||||
concentration = next(it)
|
||||
|
|
@ -174,6 +177,8 @@ class InitialConditionsAdisTS(SQLSubModel):
|
|||
status=status,
|
||||
owner_scenario=owner_scenario
|
||||
)
|
||||
if deleted:
|
||||
ic.set_as_deleted()
|
||||
|
||||
ic.pollutant = pollutant
|
||||
ic.concentration = concentration
|
||||
|
|
@ -227,11 +232,12 @@ class InitialConditionsAdisTS(SQLSubModel):
|
|||
sql = (
|
||||
"INSERT INTO " +
|
||||
"initial_conditions_adists(" +
|
||||
"pamhyr_id, pollutant, name, concentration, " +
|
||||
"pamhyr_id, deletec, pollutant, name, concentration, " +
|
||||
"eg, em, ed, enabled, scenario" +
|
||||
") " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {pollutant}, '{self._db_format(self._name)}', " +
|
||||
f"{self.id}, {self.is_deleted()}, " +
|
||||
f"{pollutant}, '{self._db_format(self._name)}', " +
|
||||
f"{concentration}, {eg}, {em}, {ed}, {self._enabled}, " +
|
||||
f"{self._status.scenario_id}" +
|
||||
")"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
from copy import copy
|
||||
from tools import trace, timer
|
||||
|
||||
from Model.Tools.PamhyrList import PamhyrModelList
|
||||
from Model.Tools.PamhyrListExt import PamhyrModelList
|
||||
from Model.InitialConditionsAdisTS.InitialConditionsAdisTS \
|
||||
import InitialConditionsAdisTS
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class ICAdisTSSpec(SQLSubModel):
|
|||
execute(f"""
|
||||
CREATE TABLE initial_conditions_adists_spec{ext}(
|
||||
{cls.create_db_add_pamhyr_id()},
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
ic_default INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
reach INTEGER NOT NULL,
|
||||
|
|
@ -149,7 +150,7 @@ class ICAdisTSSpec(SQLSubModel):
|
|||
return new
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, name, reach, start_rk, end_rk, " +
|
||||
"SELECT pamhyr_id, deleted, name, reach, start_rk, end_rk, " +
|
||||
"concentration, eg, em, ed, rate, enabled, scenario " +
|
||||
"FROM initial_conditions_adists_spec " +
|
||||
f"WHERE ic_default = {data['ic_default_id']} " +
|
||||
|
|
@ -162,6 +163,7 @@ class ICAdisTSSpec(SQLSubModel):
|
|||
it = iter(row)
|
||||
|
||||
id = next(it)
|
||||
deleted = (next(it) == 1)
|
||||
name = next(it)
|
||||
reach = next(it)
|
||||
start_rk = next(it)
|
||||
|
|
@ -179,6 +181,8 @@ class ICAdisTSSpec(SQLSubModel):
|
|||
status=status,
|
||||
owner_scenario=owner_scenario
|
||||
)
|
||||
if deleted:
|
||||
new_spec.set_as_deleted()
|
||||
|
||||
new_spec.reach = reach
|
||||
new_spec.start_rk = start_rk
|
||||
|
|
@ -207,11 +211,13 @@ class ICAdisTSSpec(SQLSubModel):
|
|||
|
||||
sql = (
|
||||
"INSERT INTO " +
|
||||
"initial_conditions_adists_spec(id, ic_default, name, reach, " +
|
||||
"initial_conditions_adists_spec(id, deleted, " +
|
||||
"ic_default, name, reach, " +
|
||||
"start_rk, end_rk, concentration, eg, em, ed, rate, " +
|
||||
"enabled, scenario) " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {ic_default}, " +
|
||||
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
||||
f"{ic_default}, " +
|
||||
f"'{self._db_format(self._name_section)}', " +
|
||||
f"{self._reach}, " +
|
||||
f"{self._start_rk}, {self._end_rk}, " +
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
execute(f"""
|
||||
CREATE TABLE lateral_contribution_adists{ext}(
|
||||
{cls.create_db_add_pamhyr_id()},
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
pollutant INTEGER NOT NULL,
|
||||
reach INTEGER NOT NULL,
|
||||
begin_rk REAL NOT NULL,
|
||||
|
|
@ -81,6 +82,7 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
execute(f"""
|
||||
CREATE TABLE lateral_contribution_data_adists{ext}(
|
||||
{cls.create_db_add_pamhyr_id()},
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
data0 TEXT NOT NULL,
|
||||
data1 TEXT NOT NULL,
|
||||
lca INTEGER,
|
||||
|
|
@ -204,7 +206,7 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
return new
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, pollutant, reach, " +
|
||||
"SELECT pamhyr_id, deleted, pollutant, reach, " +
|
||||
"begin_rk, end_rk, scenario " +
|
||||
"FROM lateral_contribution_adists " +
|
||||
f"WHERE scenario = {scenario.id} " +
|
||||
|
|
@ -216,6 +218,7 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
it = iter(row)
|
||||
|
||||
pid = next(it)
|
||||
deleted = (next(it) == 1)
|
||||
pollutant = next(it)
|
||||
reach = next(it)
|
||||
brk = next(it)
|
||||
|
|
@ -228,6 +231,8 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
status=status,
|
||||
owner_scenario=owner_scenario
|
||||
)
|
||||
if deleted:
|
||||
lca.set_as_deleted()
|
||||
|
||||
lca.reach = reach
|
||||
lca.begin_rk = brk
|
||||
|
|
@ -274,10 +279,11 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
|
||||
execute(
|
||||
"INSERT INTO " +
|
||||
"lateral_contribution_adists(id, " +
|
||||
"lateral_contribution_adists(id, deleted," +
|
||||
"pollutant, reach, begin_rk, end_rk, scenario) " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {self._pollutant}, {self.reach}, " +
|
||||
f"{self.id}, {self._db_format(self.is_deleted())}, " +
|
||||
f"{self._pollutant}, {self.reach}, " +
|
||||
f"{self._begin_rk}, {self._end_rk}" +
|
||||
f"{self._status.scenario_id}" +
|
||||
")"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
from copy import copy
|
||||
from tools import trace, timer
|
||||
|
||||
from Model.Tools.PamhyrList import PamhyrModelList
|
||||
from Model.Tools.PamhyrListExt import PamhyrModelList
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
from Model.LateralContributionsAdisTS.LateralContributionAdisTS \
|
||||
|
|
|
|||
|
|
@ -77,17 +77,18 @@ class OutputRKAdists(SQLSubModel):
|
|||
|
||||
@classmethod
|
||||
def _db_create(cls, execute, ext=""):
|
||||
execute(
|
||||
f"CREATE TABLE output_rk_adists{ext}(" +
|
||||
f"{cls.create_db_add_pamhyr_id()},"
|
||||
"reach INTEGER NOT NULL, " +
|
||||
"rk REAL NOT NULL, " +
|
||||
"title TEXT NOT NULL, " +
|
||||
f"{Scenario.create_db_add_scenario()},"
|
||||
f"{Scenario.create_db_add_scenario_fk()},"
|
||||
"FOREIGN KEY(reach) REFERENCES river_reach(id)" +
|
||||
")"
|
||||
)
|
||||
execute(f"""
|
||||
CREATE TABLE output_rk_adists{ext}(
|
||||
{cls.create_db_add_pamhyr_id()},
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
reach INTEGER NOT NULL,
|
||||
rk REAL NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
{Scenario.create_db_add_scenario()},
|
||||
{Scenario.create_db_add_scenario_fk()},
|
||||
FOREIGN KEY(reach) REFERENCES river_reach(id)
|
||||
)
|
||||
""")
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
|
|
@ -144,7 +145,7 @@ class OutputRKAdists(SQLSubModel):
|
|||
return new
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, reach, rk, title, scenario " +
|
||||
"SELECT pamhyr_id, deleted, reach, rk, title, scenario " +
|
||||
f"FROM output_rk_adists"
|
||||
)
|
||||
|
||||
|
|
@ -153,6 +154,7 @@ class OutputRKAdists(SQLSubModel):
|
|||
it = iter(row)
|
||||
|
||||
pid = next(it)
|
||||
deleted = (next(it) == 1)
|
||||
id_reach = next(it)
|
||||
id_rk = next(it)
|
||||
title = next(it)
|
||||
|
|
@ -164,6 +166,8 @@ class OutputRKAdists(SQLSubModel):
|
|||
status=status,
|
||||
owner_scenario=owner_scenario,
|
||||
)
|
||||
if deleted:
|
||||
new_output.set_as_deleted()
|
||||
|
||||
loaded.add(pid)
|
||||
new.append(new_output)
|
||||
|
|
@ -186,9 +190,11 @@ class OutputRKAdists(SQLSubModel):
|
|||
|
||||
execute(
|
||||
"INSERT INTO " +
|
||||
"output_rk_adists(pamhyr_id, reach, rk, title, scenario) " +
|
||||
"output_rk_adists(pamhyr_id, deleted, " +
|
||||
"reach, rk, title, scenario) " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, {self._reach}, {self._rk}, " +
|
||||
f"{self.id}, {self._db_format({self.is_deleted()})}" +
|
||||
f"{self._reach}, {self._rk}, " +
|
||||
f"'{self._db_format(self._title)}'" +
|
||||
f"{self._status.scenario_id}" +
|
||||
")"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
from tools import trace, timer
|
||||
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
from Model.Tools.PamhyrList import PamhyrModelList
|
||||
from Model.Tools.PamhyrListExt import PamhyrModelList
|
||||
from Model.OutputRKAdists.OutputRKAdists import OutputRKAdists
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue