mirror of https://gitlab.com/pamhyr/pamhyr2
Pamhyr2: Some fixes.
parent
19d9a29459
commit
0d33072a7e
|
|
@ -101,7 +101,8 @@ class Friction(SQLSubModel):
|
||||||
cls._db_update_to_0_1_0_set_stricklers_pid(execute, table, stricklers)
|
cls._db_update_to_0_1_0_set_stricklers_pid(execute, table, stricklers)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0_set_stricklers_pid(cls, execute, table, stricklers):
|
def _db_update_to_0_1_0_set_stricklers_pid(cls, execute, table,
|
||||||
|
stricklers):
|
||||||
els = execute(
|
els = execute(
|
||||||
f"SELECT pamhyr_id, begin_strickler, end_strickler FROM {table}"
|
f"SELECT pamhyr_id, begin_strickler, end_strickler FROM {table}"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,8 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0(cls, execute, data):
|
def _db_update_to_0_1_0(cls, execute, data):
|
||||||
table = "geometry_pointXYZ"
|
table = "geometry_pointXYZ"
|
||||||
reachs = data['id2pid']['sedimentary_layer']
|
id2pid = data['id2pid']
|
||||||
profiles = data['id2pid']['geometry_profileXYZ']
|
profiles = id2pid['geometry_profileXYZ']
|
||||||
|
|
||||||
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)
|
||||||
|
|
@ -100,7 +100,10 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
|
||||||
cls._db_update_to_0_1_0_set_profile_pid(execute, table, profiles)
|
cls._db_update_to_0_1_0_set_profile_pid(execute, table, profiles)
|
||||||
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
|
||||||
|
if 'sedimentary_layer' in id2pid:
|
||||||
|
sl = id2pid['sedimentary_layer']
|
||||||
|
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0_set_profile_pid(cls, execute, table, profiles):
|
def _db_update_to_0_1_0_set_profile_pid(cls, execute, table, profiles):
|
||||||
|
|
|
||||||
|
|
@ -123,8 +123,8 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0(cls, execute, data):
|
def _db_update_to_0_1_0(cls, execute, data):
|
||||||
table = "geometry_profileXYZ"
|
table = "geometry_profileXYZ"
|
||||||
reachs = data['id2pid']['river_reach']
|
id2pid = data['id2pid']
|
||||||
sl = data['id2pid']['sedimentary_layer']
|
reachs = 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)
|
||||||
|
|
@ -144,7 +144,10 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
|
||||||
cls._db_update_to_0_1_0_set_reach_pid(execute, table, reachs)
|
cls._db_update_to_0_1_0_set_reach_pid(execute, table, reachs)
|
||||||
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
|
||||||
|
if 'sedimentary_layer' in id2pid:
|
||||||
|
sl = id2pid['sedimentary_layer']
|
||||||
|
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0_set_sl_pid(cls, execute, table, sl):
|
def _db_update_to_0_1_0_set_sl_pid(cls, execute, table, sl):
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ class BasicHS(SQLSubModel):
|
||||||
if major == minor == "0":
|
if major == minor == "0":
|
||||||
if int(release) < 6:
|
if int(release) < 6:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
else:
|
||||||
cls._db_update_to_0_1_0(execute, data)
|
cls._db_update_to_0_1_0(execute, data)
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@ class BHSValue(SQLSubModel):
|
||||||
if major == minor == "0":
|
if major == minor == "0":
|
||||||
if int(release) < 6:
|
if int(release) < 6:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
else:
|
||||||
cls._db_update_to_0_1_0(execute, data)
|
cls._db_update_to_0_1_0(execute, data)
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,20 +84,16 @@ class HydraulicStructure(SQLSubModel):
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
|
||||||
if rl < 11:
|
if rl < 11:
|
||||||
execute(
|
for v in ["input", "output"]:
|
||||||
"""
|
execute(
|
||||||
ALTER TABLE hydraulic_structures
|
f"""
|
||||||
RENAME COLUMN input_kp TO input_rk
|
ALTER TABLE hydraulic_structures
|
||||||
"""
|
RENAME COLUMN {v}_kp TO {v}_rk
|
||||||
)
|
"""
|
||||||
execute(
|
)
|
||||||
"""
|
|
||||||
ALTER TABLE hydraulic_structures
|
|
||||||
RENAME COLUMN output_kp TO output_rk
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
cls._db_update_to_0_1_0(execute, data)
|
if 6 < rl:
|
||||||
|
cls._db_update_to_0_1_0(execute, data)
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,11 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from Model.Tools.PamhyrDB import PamhyrID
|
||||||
from Model.Network.Node import Node
|
from Model.Network.Node import Node
|
||||||
|
|
||||||
|
|
||||||
class Edge(object):
|
class Edge(PamhyrID):
|
||||||
def __init__(self, id: int, name: str,
|
def __init__(self, id: int, name: str,
|
||||||
node1: Node = None,
|
node1: Node = None,
|
||||||
node2: Node = None,
|
node2: Node = None,
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,11 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from Model.Tools.PamhyrDB import PamhyrID
|
||||||
from Model.Network.Point import Point
|
from Model.Network.Point import Point
|
||||||
|
|
||||||
|
|
||||||
class Node(object):
|
class Node(PamhyrID):
|
||||||
def __init__(self, id: int, name: str,
|
def __init__(self, id: int, name: str,
|
||||||
x: float = 0.0, y: float = 0.0,
|
x: float = 0.0, y: float = 0.0,
|
||||||
status=None):
|
status=None):
|
||||||
|
|
|
||||||
|
|
@ -56,14 +56,15 @@ class Data(SQLSubModel):
|
||||||
major, minor, release = version.strip().split(".")
|
major, minor, release = version.strip().split(".")
|
||||||
|
|
||||||
if major == minor == "0":
|
if major == minor == "0":
|
||||||
cls._db_update_to_0_1_0(execute, data)
|
if 5 < int(release):
|
||||||
|
cls._db_update_to_0_1_0(execute, data)
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0(cls, execute, data):
|
def _db_update_to_0_1_0(cls, execute, data):
|
||||||
table = "reservoir_data"
|
table = "reservoir_data"
|
||||||
reservoirs = data['id2pid']['reservoir']
|
id2pid = data['id2pid']
|
||||||
|
|
||||||
cls.update_db_add_pamhyr_id(
|
cls.update_db_add_pamhyr_id(
|
||||||
execute, table,
|
execute, table,
|
||||||
|
|
@ -82,7 +83,9 @@ class Data(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_1_0_set_reservoir_pid(execute, table, reservoirs)
|
if 'reservoir' in id2pid:
|
||||||
|
reservoirs = id2pid['reservoir']
|
||||||
|
cls._db_update_to_0_1_0_set_reservoir_pid(execute, table, reservoirs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0_set_reservoir_pid(cls, execute, table, reservoirs):
|
def _db_update_to_0_1_0_set_reservoir_pid(cls, execute, table, reservoirs):
|
||||||
|
|
@ -190,8 +193,8 @@ class Reservoir(SQLSubModel):
|
||||||
if major == minor == "0":
|
if major == minor == "0":
|
||||||
if int(release) < 5:
|
if int(release) < 5:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
else:
|
||||||
cls._db_update_to_0_1_0(execute, data)
|
cls._db_update_to_0_1_0(execute, data)
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -308,12 +308,12 @@ class RiverReach(Edge, SQLSubModel):
|
||||||
|
|
||||||
class River(Graph, SQLSubModel):
|
class River(Graph, SQLSubModel):
|
||||||
_sub_classes = [
|
_sub_classes = [
|
||||||
|
StricklersList,
|
||||||
RiverNode,
|
RiverNode,
|
||||||
RiverReach,
|
RiverReach,
|
||||||
BoundaryConditionList,
|
BoundaryConditionList,
|
||||||
LateralContributionList,
|
LateralContributionList,
|
||||||
InitialConditionsDict,
|
InitialConditionsDict,
|
||||||
StricklersList,
|
|
||||||
SolverParametersList,
|
SolverParametersList,
|
||||||
SedimentLayerList,
|
SedimentLayerList,
|
||||||
ReservoirList,
|
ReservoirList,
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,6 @@ class SQLSubModel(PamhyrID):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedMethodeError(cls, cls._db_update)
|
raise NotImplementedMethodeError(cls, cls._db_update)
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0_set_node_pid(cls, execute, table, nodes):
|
def _db_update_to_0_1_0_set_node_pid(cls, execute, table, nodes):
|
||||||
els = execute(
|
els = execute(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue