Compare commits

..

No commits in common. "f13ab03192f741e4fc89a0cc0e8e6f5570f51847" and "23a0bc33fa4c087e06e8b4196636292b31b90b1e" have entirely different histories.

10 changed files with 15 additions and 223 deletions

View File

@ -126,29 +126,6 @@ class BoundaryConditionAdisTS(SQLSubModel):
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}") 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_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 @classmethod
def _db_update_to_0_2_0_data(cls, execute, data): 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"DROP TABLE {table}")
execute(f"ALTER TABLE {table}_tmp RENAME TO {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 @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []

View File

@ -103,29 +103,6 @@ class D90AdisTSSpec(SQLSubModel):
execute(f"DROP TABLE {table}") execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}") 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 @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []

View File

@ -115,28 +115,6 @@ class DIFAdisTSSpec(SQLSubModel):
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}") 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_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 @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):

View File

@ -167,26 +167,25 @@ class Friction(SQLSubModel):
deleted = (next(it) == 1) deleted = (next(it) == 1)
begin_rk = next(it) begin_rk = next(it)
end_rk = next(it) end_rk = next(it)
begin_strickler_pid = int(next(it)) begin_strickler_pid = next(it)
end_strickler_pid = int(next(it)) end_strickler_pid = next(it)
owner_scenario = next(it) owner_scenario = next(it)
# Get stricklers # Get stricklers
begin_strickler = None begin_strickler = None
if begin_strickler_pid != -1: if int(begin_strickler_pid) != -1:
begin_strickler = next( begin_strickler = next(
filter( filter(
lambda s: s.id == begin_strickler_pid, lambda s: s.pamhyr_id == begin_strickler_pid,
stricklers stricklers
) )
) )
end_strickler = None begin_strickler = None
if end_strickler_pid != -1: if int(end_strickler_pid) != -1:
end_strickler = next( begin_strickler = next(
filter( filter(
lambda s: s.id == begin_strickler_pid, lambda s: s.id == begin_strickler_pid, stricklers
stricklers
) )
) )

View File

@ -94,6 +94,7 @@ class InitialConditionsAdisTS(SQLSubModel):
@classmethod @classmethod
def _db_update_to_0_2_0(cls, execute, data): def _db_update_to_0_2_0(cls, execute, data):
table = "initial_conditions_adists" table = "initial_conditions_adists"
reachs = data['id2pid']['river_reach']
cls.update_db_add_pamhyr_id(execute, table, data) cls.update_db_add_pamhyr_id(execute, table, data)
Scenario.update_db_add_scenario(execute, table) Scenario.update_db_add_scenario(execute, table)
@ -112,30 +113,6 @@ class InitialConditionsAdisTS(SQLSubModel):
execute(f"DROP TABLE {table}") execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table}_tmp RENAME TO {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 @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []

View File

@ -81,7 +81,7 @@ class ICAdisTSSpec(SQLSubModel):
if major == 0 and minor < 1: if major == 0 and minor < 1:
if int(release) < 6: if int(release) < 6:
cls._db_create(execute) cls._db_create(execute)
created = True created =True
if major == "0" and int(minor) < 2: if major == "0" and int(minor) < 2:
if not created: if not created:
@ -113,29 +113,6 @@ class ICAdisTSSpec(SQLSubModel):
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}") 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_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 @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):

View File

@ -127,29 +127,6 @@ class LateralContributionAdisTS(SQLSubModel):
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}") 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_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 @classmethod
def _db_update_to_0_2_0_data(cls, execute, data): 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"DROP TABLE {table}")
execute(f"ALTER TABLE {table}_tmp RENAME TO {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 @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):

View File

@ -163,30 +163,6 @@ class Pollutants(SQLSubModel):
execute(f"DROP TABLE {table}") execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}") 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 @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []
@ -226,7 +202,7 @@ class Pollutants(SQLSubModel):
if table is not None: if table is not None:
for t in table: for t in table:
new_data = t[1:-2] new_data = t[1:-1]
new_pollutant._data.append(new_data) new_pollutant._data.append(new_data)

View File

@ -353,6 +353,10 @@ class SQLSubModel(PamhyrID):
if len(section) != 0: if len(section) != 0:
section_id = section[0][0] section_id = section[0][0]
logger.info(
f"Update reach rk {rk}({reach_id}) to pid {section_id}"
)
execute( execute(
f"UPDATE {table} " + f"UPDATE {table} " +
f"SET {section_column} = {section_id} " + f"SET {section_column} = {section_id} " +

View File

@ -55,9 +55,6 @@ class TableModel(PamhyrTableModel):
row = index.row() row = index.row()
column = index.column() column = index.column()
if len(self._data.data) == 0 or len(self._data.data[row]) == 0:
return QVariant()
return self._data.data[row][column] return self._data.data[row][column]
def setData(self, index, value, role=Qt.EditRole): def setData(self, index, value, role=Qt.EditRole):