Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
BMG PUBLIC RESOURCES
SIG-TOPO-BMG
Commits
4a7758d7
Commit
4a7758d7
authored
Jan 31, 2021
by
Alice Salsé
Browse files
👌
related tables VM
parent
eef01f59
Changes
4
Hide whitespace changes
Inline
Side-by-side
python/qgs_plugins/NetworkPlugin/mainPlugin.py
View file @
4a7758d7
...
...
@@ -7,8 +7,9 @@ from qgis.core import QgsDataSourceUri, QgsWkbTypes, QgsMapLayerType,QgsFeature
# initialize Qt resources from file resources.py
# execute : pyrcc5 -o resources.py resources.qrc
from
.
import
resources
import
csv
qconst
=
"""select * from utils.related_table
qconst
=
"""select * from utils.
vm_
related_table
where pt_schema='{0}'
and pt_name='{1}';"""
...
...
@@ -126,7 +127,7 @@ class NetworkTools:
def
activeLayerSelection
(
self
)
:
layer
=
self
.
iface
.
activeLayer
()
if
not
layer
:
if
not
layer
:
self
.
iface
.
messageBar
().
pushMessage
(
"Veuillez sélectionner une couche d'abord"
,
Qgis
.
Warning
)
return
else
:
...
...
@@ -278,7 +279,7 @@ class NetworkTools:
column_names
,
records
=
executeQuery
(
layer
.
dataProvider
(),
qconst
.
format
(
_schema
,
typ
))
for
rec
in
records
:
self
.
selectLayerFromTable
(
rec
[
0
],
rec
[
1
],
'id in ({0})'
.
format
(
','
.
join
([
str
(
i
)
for
i
in
ids
]
or
'0'
)))
self
.
selectLayerFromTable
(
rec
[
0
]
,
typ
,
'id in ({0})'
.
format
(
','
.
join
([
str
(
i
)
for
i
in
ids
]
or
'0'
)))
self
.
selectLayerFromTable
(
_schema
,
typ
,
'id in ({0})'
.
format
(
','
.
join
([
str
(
i
)
for
i
in
ids
]
or
'0'
)))
else
:
self
.
iface
.
messageBar
().
pushMessage
(
"La couche sélectionnée n'est pas de type ligne"
,
Qgis
.
Warning
)
...
...
sql/all/view_related_table.sql
View file @
4a7758d7
...
...
@@ -3,7 +3,8 @@
set
search_path
to
utils
,
public
;
-- VUE recensant les tables reliées
CREATE
OR
REPLACE
VIEW
utils
.
related_table
AS
DROP
MATERIALIZED
VIEW
IF
EXISTS
utils
.
vm_related_table
;
CREATE
MATERIALIZED
VIEW
utils
.
vm_related_table
AS
select
kcu
.
table_schema
as
ft_schema
,
kcu
.
table_name
as
ft_name
,
kcu
.
table_schema
||
'.'
||
kcu
.
table_name
as
foreign_table
,
...
...
sql/network/create_view.sql
View file @
4a7758d7
...
...
@@ -6,7 +6,7 @@ SET tmpvar.schemaname TO :'schemaname';
DO
$$
DECLARE
_relations
CURSOR
FOR
select
*
from
utils
.
related_table
select
*
from
utils
.
vm_
related_table
where
ft_schema
=
current_setting
(
'tmpvar.schemaname'
,
true
)
and
no
=
1
;
l
record
;
...
...
sql/network/function_duplicate_attributes.sql
View file @
4a7758d7
...
...
@@ -8,7 +8,7 @@ CREATE OR REPLACE FUNCTION fnc_duplicate_attributes(
RETURNS
void
AS
$
BODY
$
DECLARE
_relations
CURSOR
FOR
select
*
from
utils
.
related_table
select
*
from
utils
.
vm_
related_table
where
foreign_table
=
i_nw_regclass
::
text
;
_new_obj
jsonb
;
BEGIN
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment