Commit ba66a9d6 authored by Alice Salsé's avatar Alice Salsé
Browse files

🐛 resolve archivage problems

parent 58c3103b
......@@ -226,30 +226,24 @@ class NetworkTools:
level, ctrl = QInputDialog.getItem(QInputDialog(), "Level", "Choisir le niveau", levels, 0)
if ctrl :
lvl=lvls[levels.index(level)]
col_names, rcrds = executeQuery(first_lyr.dataProvider(), qconst2.format(_schema))
before_q = []
for r in rcrds :
before_q.append("SET CONSTRAINTS {0}.{1} DEFERRED;".format(*r))
before_q=' '.join(before_q)
result=first_lyr.dataProvider().transaction().executeSql(before_q,False)
result=first_lyr.dataProvider().transaction().executeSql("SET CONSTRAINTS ALL DEFERRED;",False)
if result[0] == False :
self.iface.messageBar().pushMessage("Echec : " + result[1].split('\n')[0], Qgis.Warning)
return
query="UPDATE {0}.{1} SET level = {2} WHERE id in ({3});"
for typ in ['node', 'pipe', 'part', 'lnode', 'lpipe', 'lpart'] :
ids=[]
column_names, records = executeQuery(first_lyr.dataProvider(), qconst.format(_schema, typ))
for rec in records :
for lyr_id in lyrs :
lyr=self.root.findLayer(lyr_id).layer()
l_sch, l_tab = lyr.dataProvider().uri().schema(), lyr.dataProvider().uri().table()
if l_sch == rec[0] and (l_tab[-len(rec[1]):]== rec[1] or l_tab==typ) :
ids=list(set(ids+lyrs[lyr_id]))
result=first_lyr.dataProvider().transaction().executeSql(query.format(l_sch, typ, lvl, ','.join([str(i) for i in ids]) or '0'))
result=first_lyr.dataProvider().transaction().executeSql(query.format(l_sch, l_tab, lvl, ','.join([str(i) for i in lyrs[lyr_id]]) or '0'))
if result[0] == False :
self.iface.messageBar().pushMessage("Echec : " + result[1].split('\n')[0], Qgis.Warning)
return
result=first_lyr.dataProvider().transaction().executeSql(before_q.replace('DEFERRED','IMMEDIATE'),True)
print('debuggg')
result=first_lyr.dataProvider().transaction().executeSql("SET CONSTRAINTS ALL IMMEDIATE;",True)
if result[0] == True :
self.iface.messageBar().pushMessage("Déplacement vers le niveau {0} réussie".format(level), Qgis.Info)
else:
......@@ -325,18 +319,12 @@ class NetworkTools:
self.iface.messageBar().pushMessage("Les couches doivent être en édition", Qgis.Warning)
return
_schema=first_lyr.dataProvider().uri().schema()
col_names, rcrds = executeQuery(first_lyr.dataProvider(), qconst2.format(_schema))
before_q = []
for r in rcrds :
before_q.append("SET CONSTRAINTS {0}.{1} DEFERRED;".format(*r))
before_q=' '.join(before_q)
result=first_lyr.dataProvider().transaction().executeSql(before_q,False)
result=first_lyr.dataProvider().transaction().executeSql("SET CONSTRAINTS ALL DEFERRED;",False)
if result[0] == False :
self.iface.messageBar().pushMessage("Echec : " + result[1].split('\n')[0], Qgis.Warning)
return
query="DELETE FROM {0} WHERE id in ({1});"
for typ in ['lpart', 'lnode', 'lpipe', 'part', 'node', 'pipe'] :
ids=[]
column_names, records = executeQuery(first_lyr.dataProvider(), qconst.format(_schema, typ))
for rec in records :
for lyr_id in lyrs :
......@@ -348,7 +336,7 @@ class NetworkTools:
if result[0] == False :
self.iface.messageBar().pushMessage("Echec : " + result[1].split('\n')[0], Qgis.Warning)
return
result=first_lyr.dataProvider().transaction().executeSql(before_q.replace('DEFERRED','IMMEDIATE'),True)
result=first_lyr.dataProvider().transaction().executeSql("SET CONSTRAINTS ALL IMMEDIATE;",True)
if result[0] == True :
self.iface.messageBar().pushMessage("Suppression réussie", Qgis.Info)
else:
......
......@@ -12,13 +12,13 @@ EXECUTE PROCEDURE utils.fnc_tgg_pipe_before('{"node"}');
DROP TRIGGER IF EXISTS tgg_pipe_after ON pipe ;
CREATE TRIGGER tgg_pipe_after
AFTER INSERT OR UPDATE of geom, level OR DELETE
AFTER INSERT OR UPDATE of geom OR DELETE
ON pipe FOR EACH ROW
EXECUTE PROCEDURE utils.fnc_tgg_pipe_after('node', '{"lnode","part"}');
DROP TRIGGER IF EXISTS tgg_pipe_check_geom ON pipe ;
CREATE CONSTRAINT TRIGGER tgg_pipe_check_geom
AFTER INSERT OR UPDATE of geom, level
AFTER INSERT OR UPDATE of geom
ON pipe FOR EACH ROW
EXECUTE PROCEDURE utils.fnc_tgg_pipe_check_geom('lpipe');
......@@ -31,12 +31,12 @@ EXECUTE PROCEDURE utils.fnc_tgg_pipe_before('{"lnode","node"}');
DROP TRIGGER IF EXISTS tgg_lpipe_after ON lpipe ;
CREATE TRIGGER tgg_lpipe_after
AFTER INSERT OR UPDATE of geom, level OR DELETE
AFTER INSERT OR UPDATE of geom OR DELETE
ON lpipe FOR EACH ROW
EXECUTE PROCEDURE utils.fnc_tgg_pipe_after('lnode', '{"lpart"}');
DROP TRIGGER IF EXISTS tgg_lpipe_check_geom ON lpipe ;
CREATE CONSTRAINT TRIGGER tgg_lpipe_check_geom
AFTER INSERT OR UPDATE of geom, level
AFTER INSERT OR UPDATE of geom
ON lpipe FOR EACH ROW
EXECUTE PROCEDURE utils.fnc_tgg_pipe_check_geom('pipe');
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment