-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lpoaura/develop
First release
- Loading branch information
Showing
13 changed files
with
21,125 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
TRIGGERS | ||
----- | ||
??? | ||
*/ | ||
DO | ||
$$ | ||
BEGIN | ||
|
||
DROP TRIGGER IF EXISTS tri_vigienature_delete_releve ON src_vn_json.forms_json; | ||
|
||
CREATE TRIGGER tri_vigienature_delete_releve | ||
AFTER DELETE | ||
ON src_vn_json.forms_json | ||
FOR EACH ROW | ||
WHEN (old.item #>> '{protocol, protocol_name}' LIKE 'S_OC%') | ||
EXECUTE PROCEDURE pr_vigienature.fct_tri_delete_releve(); | ||
|
||
|
||
DROP TRIGGER IF EXISTS tri_vigienature_upsert_releve | ||
ON src_vn_json.forms_json; | ||
|
||
CREATE TRIGGER tri_vigienature_upsert_releve | ||
AFTER UPDATE OR INSERT | ||
ON src_vn_json.forms_json | ||
FOR EACH ROW | ||
-- WHEN pr_vigienature.is_stoc_eps_form(new.item, 'STOC_EPS') | ||
WHEN (new.item #>> '{protocol,protocol_name}' LIKE 'S_OC%') | ||
EXECUTE PROCEDURE pr_vigienature.fct_tri_upsert_releve(); | ||
|
||
DROP TRIGGER IF EXISTS tri_vigienature_insert_alti | ||
ON pr_vigienature.t_releve; | ||
CREATE TRIGGER tri_vigienature_insert_alti | ||
AFTER INSERT | ||
ON pr_vigienature.t_releve | ||
FOR EACH ROW | ||
-- WHEN (new.geom_point IS NOT NULL) | ||
EXECUTE PROCEDURE pr_vigienature.fct_tri_update_releve_altitude(); | ||
|
||
DROP TRIGGER IF EXISTS tri_vigienature_update_alti | ||
ON pr_vigienature.t_releve; | ||
CREATE TRIGGER tri_vigienature_update_alti | ||
AFTER UPDATE OF geom_point | ||
ON pr_vigienature.t_releve | ||
FOR EACH ROW | ||
-- WHEN (NOT old.geom_point ~= new.geom_point AND new.geom_point IS NOT NULL) | ||
EXECUTE PROCEDURE pr_vigienature.fct_tri_update_releve_altitude(); | ||
|
||
DROP TRIGGER IF EXISTS tri_vigienature_upsert_obs | ||
ON src_vn_json.observations_json; | ||
|
||
CREATE TRIGGER tri_vigienature_upsert_obs | ||
AFTER UPDATE OR INSERT | ||
ON src_vn_json.observations_json | ||
FOR EACH ROW | ||
WHEN (new.id_form_universal IS NOT NULL) | ||
EXECUTE PROCEDURE pr_vigienature.fct_tri_update_obs(); | ||
COMMIT; | ||
END | ||
$$ | ||
; | ||
|
||
BEGIN | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
PEUPLEMENT DES TABLES PAR TRIGGERS | ||
----- | ||
Simulation d'un update pour déclencher le trigger | ||
*/ | ||
|
||
BEGIN TRANSACTION | ||
; | ||
|
||
TRUNCATE pr_vigienature.t_releve RESTART IDENTITY CASCADE | ||
; | ||
|
||
|
||
|
||
UPDATE src_vn_json.forms_json | ||
SET | ||
item = item | ||
WHERE | ||
(site, id) IN (SELECT | ||
site | ||
, id | ||
FROM | ||
src_vn_json.forms_json f | ||
WHERE | ||
f.item #>> '{protocol,protocol_name}' LIKE 'S_OC%' | ||
AND item ->> 'id_form_universal' NOT LIKE '0') | ||
|
||
; | ||
|
||
END TRANSACTION; | ||
|
||
BEGIN TRANSACTION; | ||
|
||
ALTER TABLE src_vn_json.observations_json DISABLE TRIGGER fct_tri_c_upsert_vn_observation_to_geonature; | ||
|
||
UPDATE src_vn_json.observations_json | ||
SET | ||
item = item | ||
WHERE | ||
observations_json.id_form_universal IN | ||
(SELECT | ||
bdd_source_id_universal | ||
FROM | ||
pr_vigienature.t_releve | ||
) | ||
; | ||
|
||
|
||
ALTER TABLE src_vn_json.observations_json DISABLE TRIGGER fct_tri_c_upsert_vn_observation_to_geonature; | ||
|
||
END TRANSACTION; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
# visionature-data-for-vigie-nature | ||
|
||
Transformation process of VisioNature data for the French national program Vigie-Nature | ||
|
||
|
||
## Database model | ||
|
||
![modelisation_bdd.png](modelisation_bdd.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.