-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* BHBC-1173 - introduced survey_status view to encapsulate business rules for determining status of survey_status - incorporated survey status into occurrence submission, survey delete and project delete db api functions - chained occurrence submission, survey delete and project delete db api functions - introduced db api function api_user_is_administrator - introduced db api functions api_get_character_system_constant and api_get_numeric_system_constant - various data integrity checks * BHBC-1173 - introduced survey_status view to encapsulate business rules for determining status of survey_status - incorporated survey status into occurrence submission, survey delete and project delete db api functions - chained occurrence submission, survey delete and project delete db api functions - introduced db api function api_user_is_administrator - introduced db api functions api_get_character_system_constant and api_get_numeric_system_constant - various data integrity checks Co-authored-by: charlie garrett-jones <charlie.garrettjones@bayseumcom>
- Loading branch information
1 parent
0e483fb
commit faf2f2d
Showing
47 changed files
with
305 additions
and
382 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
database/src/migrations/20210625115350_project_add_publish_timestamp.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
database/src/migrations/release.0.19/api_delete_occurrence_submission.sql
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,45 @@ | ||
-- api_delete_occurrence_submission.sql | ||
drop procedure if exists api_delete_occurrence_submission; | ||
|
||
create or replace procedure api_delete_occurrence_submission(__occurrence_submission_id occurrence_submission.id%type) | ||
language plpgsql | ||
security definer | ||
as | ||
$$ | ||
-- ******************************************************************* | ||
-- Procedure: api_delete_occurrence_submission | ||
-- Purpose: deletes an occurrence submission | ||
-- | ||
-- MODIFICATION HISTORY | ||
-- Person Date Comments | ||
-- ---------------- ----------- -------------------------------------- | ||
-- [email protected] | ||
-- 2021-06-18 initial release | ||
-- ******************************************************************* | ||
declare | ||
__is_published boolean; | ||
__is_system_administrator boolean; | ||
begin | ||
select exists into __is_published (select 1 from survey_status ss, occurrence_submission os | ||
where os.id = __occurrence_submission_id | ||
and ss.survey_id = os.s_id | ||
and ss.survey_status = (select api_get_character_system_constant('SURVEY_STATE_PUBLISHED'))); | ||
|
||
if __is_published then | ||
select api_user_is_administrator() into __is_system_administrator; | ||
|
||
if not __is_system_administrator then | ||
raise exception 'Delete cannot proceed as published occurrence submissions exist and user is not a member of the system administrator role.'; | ||
end if; | ||
end if; | ||
|
||
delete from submission_message where subs_id in (select id from submission_status where os_id = __occurrence_submission_id); | ||
delete from submission_status where os_id = __occurrence_submission_id; | ||
delete from occurrence where os_id = __occurrence_submission_id; | ||
delete from occurrence_submission where id = __occurrence_submission_id; | ||
|
||
exception | ||
when others THEN | ||
raise; | ||
end; | ||
$$; |
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 |
---|---|---|
|
@@ -15,12 +15,18 @@ $$ | |
-- ---------------- ----------- -------------------------------------- | ||
-- [email protected] | ||
-- 2021-04-19 initial release | ||
-- 2021-06-21 added delete survey | ||
-- ******************************************************************* | ||
declare | ||
v_id survey.id%type; | ||
begin | ||
for v_id in (select id from survey where p_id = __project_id) loop | ||
call api_delete_survey(v_id); | ||
end loop; | ||
|
||
delete from survey_proprietor where s_id in (select id from survey where p_id = __project_id); | ||
delete from survey_attachment where s_id in (select id from survey where p_id = __project_id); | ||
delete from study_species where s_id in (select id from survey where p_id = __project_id); | ||
delete from block_observation where s_id in (select id from survey where p_id = __project_id); | ||
delete from permit where p_id = __project_id; | ||
delete from survey where p_id = __project_id; | ||
delete from stakeholder_partnership where p_id = __project_id; | ||
|
@@ -34,6 +40,7 @@ begin | |
delete from project_first_nation where p_id = __project_id; | ||
delete from project_participation where p_id = __project_id; | ||
delete from project where id = __project_id; | ||
|
||
exception | ||
when others THEN | ||
raise; | ||
|
Oops, something went wrong.