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