mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "f13ab03192f741e4fc89a0cc0e8e6f5570f51847" and "23a0bc33fa4c087e06e8b4196636292b31b90b1e" have entirely different histories.
f13ab03192
...
23a0bc33fa
|
|
@ -126,29 +126,6 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
|||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_node_pid(execute, table, nodes)
|
||||
cls._db_update_to_0_2_0_set_pollutants_pid(execute, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_set_pollutants_pid(cls, execute, data):
|
||||
pid_pol = data["id2pid"]["Pollutants"]
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, pollutant " +
|
||||
"FROM boundary_condition_adists"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
pol_id = next(it)
|
||||
|
||||
if pol_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE boundary_condition_adists " +
|
||||
f"SET pollutant = {pid_pol[pol_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_data(cls, execute, data):
|
||||
|
|
@ -169,30 +146,6 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
|||
execute(f"DROP TABLE {table}")
|
||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_bca_pid(execute, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_set_bca_pid(cls, execute, data):
|
||||
pid_bca = data["id2pid"]["boundary_condition_adists"]
|
||||
els = execute(
|
||||
"SELECT pamhyr_id, bca " +
|
||||
"FROM boundary_condition_data_adists"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
bca_id = next(it)
|
||||
|
||||
if bca_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE boundary_condition_data_adists " +
|
||||
f"SET bca = {pid_bca[bca_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
new = []
|
||||
|
|
|
|||
|
|
@ -103,29 +103,6 @@ class D90AdisTSSpec(SQLSubModel):
|
|||
execute(f"DROP TABLE {table}")
|
||||
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_d90_pid(execute, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_set_d90_pid(cls, execute, data):
|
||||
pid_d90 = data["id2pid"]["d90_adists"]
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, d90 FROM d90_adists_spec"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
d90_id = next(it)
|
||||
|
||||
if d90_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE d90_adists_spec" +
|
||||
f"SET d90 = {pid_d90[d90_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
new = []
|
||||
|
|
|
|||
|
|
@ -115,28 +115,6 @@ class DIFAdisTSSpec(SQLSubModel):
|
|||
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
|
||||
cls._db_update_to_0_2_0_set_dif_pid(execute, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_set_dif_pid(cls, execute, data):
|
||||
pid_dif = data["id2pid"]["dif_adists"]
|
||||
els = execute(
|
||||
"SELECT pamhyr_id, dif FROM dif_adists_spec"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
dif_id = next(it)
|
||||
|
||||
if dif_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE dif_adists_spec" +
|
||||
f"SET dif = {pid_dif[dif_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
|
|
|
|||
|
|
@ -167,26 +167,25 @@ class Friction(SQLSubModel):
|
|||
deleted = (next(it) == 1)
|
||||
begin_rk = next(it)
|
||||
end_rk = next(it)
|
||||
begin_strickler_pid = int(next(it))
|
||||
end_strickler_pid = int(next(it))
|
||||
begin_strickler_pid = next(it)
|
||||
end_strickler_pid = next(it)
|
||||
owner_scenario = next(it)
|
||||
|
||||
# Get stricklers
|
||||
begin_strickler = None
|
||||
if begin_strickler_pid != -1:
|
||||
if int(begin_strickler_pid) != -1:
|
||||
begin_strickler = next(
|
||||
filter(
|
||||
lambda s: s.id == begin_strickler_pid,
|
||||
lambda s: s.pamhyr_id == begin_strickler_pid,
|
||||
stricklers
|
||||
)
|
||||
)
|
||||
|
||||
end_strickler = None
|
||||
if end_strickler_pid != -1:
|
||||
end_strickler = next(
|
||||
begin_strickler = None
|
||||
if int(end_strickler_pid) != -1:
|
||||
begin_strickler = next(
|
||||
filter(
|
||||
lambda s: s.id == begin_strickler_pid,
|
||||
stricklers
|
||||
lambda s: s.id == begin_strickler_pid, stricklers
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
|||
@classmethod
|
||||
def _db_update_to_0_2_0(cls, execute, data):
|
||||
table = "initial_conditions_adists"
|
||||
reachs = data['id2pid']['river_reach']
|
||||
|
||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||
Scenario.update_db_add_scenario(execute, table)
|
||||
|
|
@ -112,30 +113,6 @@ class InitialConditionsAdisTS(SQLSubModel):
|
|||
execute(f"DROP TABLE {table}")
|
||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_pollutants_pid(execute, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_set_pollutants_pid(cls, execute, data):
|
||||
pid_pol = data["id2pid"]["Pollutants"]
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, pollutant " +
|
||||
"FROM initial_conditions_adists"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
pol_id = next(it)
|
||||
|
||||
if pol_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE initial_conditions_adists " +
|
||||
f"SET pollutant = {pid_pol[pol_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
new = []
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class ICAdisTSSpec(SQLSubModel):
|
|||
if major == 0 and minor < 1:
|
||||
if int(release) < 6:
|
||||
cls._db_create(execute)
|
||||
created = True
|
||||
created =True
|
||||
|
||||
if major == "0" and int(minor) < 2:
|
||||
if not created:
|
||||
|
|
@ -113,29 +113,6 @@ class ICAdisTSSpec(SQLSubModel):
|
|||
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_reach_pid(execute, table_new, reachs)
|
||||
cls._db_update_to_0_2_0_set_ica_pid(execute, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_set_ica_pid(cls, execute, data):
|
||||
pid_ica = data["id2pid"]["initial_conditions_adist"]
|
||||
els = execute(
|
||||
"SELECT pamhyr_id, ic_default " +
|
||||
"FROM initial_conditions_adists_spec"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
ica_id = next(it)
|
||||
|
||||
if ica_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE initial_conditions_adists_spec " +
|
||||
f"SET ic_default = {pid_ica[ica_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
|
|
|
|||
|
|
@ -127,29 +127,6 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
|
||||
cls._db_update_to_0_2_0_set_pollutants_pid(execute, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_set_pollutants_pid(cls, execute, data):
|
||||
pid_pol = data["id2pid"]["Pollutants"]
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, pollutant " +
|
||||
"FROM lateral_contribution_adists"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
pol_id = next(it)
|
||||
|
||||
if pol_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE lateral_contribution_adists " +
|
||||
f"SET pollutant = {pid_pol[pol_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_data(cls, execute, data):
|
||||
|
|
@ -169,29 +146,6 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||
|
||||
execute(f"DROP TABLE {table}")
|
||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||
cls._db_update_to_0_2_0_set_ica_pid(execute, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_set_lca_pid(cls, execute, data):
|
||||
pid_lca = data["id2pid"]["lateral_contribution_adists"]
|
||||
els = execute(
|
||||
"SELECT pamhyr_id, lca " +
|
||||
"FROM lateral_contribution_data_adists"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
lca_id = next(it)
|
||||
|
||||
if lca_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE lateral_contribution_data_adists " +
|
||||
f"SET lca = {pid_lca[lca_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
|
|
|
|||
|
|
@ -163,30 +163,6 @@ class Pollutants(SQLSubModel):
|
|||
execute(f"DROP TABLE {table}")
|
||||
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
|
||||
|
||||
cls._db_update_to_0_2_0_set_pollutants_pid(execute, data)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_2_0_set_pollutants_pid(cls, execute, data):
|
||||
pid_pol = data["id2pid"]["Pollutants"]
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, pollutant " +
|
||||
"FROM pollutants_characteristics"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
pol_id = next(it)
|
||||
|
||||
if pol_id == -1:
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE pollutants_characteristics " +
|
||||
f"SET pollutant = {pid_pol[pol_id]} " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
new = []
|
||||
|
|
@ -226,7 +202,7 @@ class Pollutants(SQLSubModel):
|
|||
|
||||
if table is not None:
|
||||
for t in table:
|
||||
new_data = t[1:-2]
|
||||
new_data = t[1:-1]
|
||||
|
||||
new_pollutant._data.append(new_data)
|
||||
|
||||
|
|
|
|||
|
|
@ -353,6 +353,10 @@ class SQLSubModel(PamhyrID):
|
|||
if len(section) != 0:
|
||||
section_id = section[0][0]
|
||||
|
||||
logger.info(
|
||||
f"Update reach rk {rk}({reach_id}) to pid {section_id}"
|
||||
)
|
||||
|
||||
execute(
|
||||
f"UPDATE {table} " +
|
||||
f"SET {section_column} = {section_id} " +
|
||||
|
|
|
|||
|
|
@ -55,9 +55,6 @@ class TableModel(PamhyrTableModel):
|
|||
row = index.row()
|
||||
column = index.column()
|
||||
|
||||
if len(self._data.data) == 0 or len(self._data.data[row]) == 0:
|
||||
return QVariant()
|
||||
|
||||
return self._data.data[row][column]
|
||||
|
||||
def setData(self, index, value, role=Qt.EditRole):
|
||||
|
|
|
|||
Loading…
Reference in New Issue