-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#499 | Add privileges for metadata and associate it with group, data…
… entry operator
- Loading branch information
1 parent
b7ca018
commit 3f69be6
Showing
1 changed file
with
141 additions
and
0 deletions.
There are no files selected for viewing
141 changes: 141 additions & 0 deletions
141
avni-server-api/src/main/resources/db/migration/V1_272__AddNewRolesAndPrivileges.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,141 @@ | ||
insert into privilege(uuid, name, description, entity_type, created_date_time, last_modified_date_time) | ||
values (uuid_generate_v4(), 'View subject type', 'View subject type', 'SubjectType', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit subject type', 'Edit subject type', 'Subject', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View program', 'View program', 'Program', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit program', 'Edit program', 'Program', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View encounter type', 'View encounter type', 'EncounterType', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit encounter type', 'Edit encounter type', 'EncounterType', | ||
current_timestamp, current_timestamp), | ||
(uuid_generate_v4(), 'View form', 'View form', 'Form', | ||
current_timestamp, current_timestamp), | ||
(uuid_generate_v4(), 'Edit form', 'Edit form', 'Form', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View concept', 'View concept', 'Concept', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit concept', 'Edit concept', 'Concept', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View organisation config', 'View organisation configuration like filters, languages, etc.,', 'OrganisationConfig', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit organisation config', 'Edit organisation configuration like like filters, languages, etc.,', 'OrganisationConfig', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Delete organisation config', 'Delete organisation configuration like filters, languages, etc.,', 'OrganisationConfig', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Upload bundle', 'Upload bundle', 'Bundle', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Download bundle', 'Download bundle', 'Bundle', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View checklist config', 'View checklist configuration', 'ChecklistConfig', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit checklist config', 'Edit checklist configuration', 'ChecklistConfig', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View relationship', 'View relationship and its types', 'Relationship', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit relationship', 'Edit relationship and its types', 'Relationship', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View documentation', 'View documentation and video playlist', 'Documentation', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit documentation', 'Edit documentation and video playlist', 'Documentation', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View offline dashboard and report card', 'View offline dashboard and report card', 'OfflineView', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit offline dashboard and report card', 'Edit offline dashboard and report card', 'OfflineView', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View application menu', 'View application menu', 'ApplicationMenu', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit application menu', 'Edit application menu', 'ApplicationMenu', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View extension', 'View extension', 'Extension', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit extension', 'Edit extension', 'Extension', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View rule failure', 'View rule failure', 'RuleFailure', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit rule failure', 'Edit rule failure', 'RuleFailure', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View location type', 'View location type', 'LocationType', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit location type', 'Edit location type', 'LocationType', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View location', 'View location', 'Location', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit location', 'Edit location', 'Location', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View catchment', 'View catchment', 'Catchment', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit catchment', 'Edit catchment', 'Catchment', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View user information', 'View identifier assignment, user subject assignment, user task assignment and user group assignment', 'User', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit user information', 'Edit identifier assignment, user subject assignment, user task assignment and user group assignment', 'User', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View user group', 'View user group details', 'UserGroup', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit user group', 'Edit user group details', 'UserGroup', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View identifier source', 'View identifier source', 'IdentifierSource', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit identifier source', 'Edit identifier source', 'IdentifierSource', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View identifier user assignment', 'View identifier user assignment', 'IdentifierUserAssignment', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit identifier user assignment', 'Edit identifier user assignment', 'IdentifierUserAssignment', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Upload metadata and data', 'Upload metadata and data', 'Upload', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'View task', 'View task', 'Task', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Edit task', 'Edit task', 'Task', current_timestamp, | ||
current_timestamp), | ||
(uuid_generate_v4(), 'Delete task', 'Delete task', 'Task', current_timestamp, | ||
current_timestamp); | ||
|
||
insert into groups(uuid, name, version, organisation_id, audit_id, | ||
created_by_id, last_modified_by_id, created_date_time, last_modified_date_time) | ||
select uuid_generate_v4(), | ||
'Data entry operator', | ||
0, | ||
id, | ||
create_audit(), | ||
1, 1, current_timestamp, current_timestamp | ||
from organisation; | ||
|
||
insert into user_group(uuid, user_id, group_id, version, organisation_id, audit_id, | ||
created_by_id, last_modified_by_id, created_date_time, last_modified_date_time) | ||
select uuid_generate_v4(), | ||
u.id, | ||
(select g.id from groups g where u.organisation_id = g.organisation_id and g.name = 'Data entry operator'), | ||
0, | ||
u.organisation_id, | ||
create_audit(), | ||
1, 1, current_timestamp, current_timestamp | ||
from users u where is_org_admin = false; | ||
|
||
insert into group_privilege | ||
(uuid, group_id, privilege_id, subject_type_id, program_id, program_encounter_type_id, encounter_type_id, | ||
checklist_detail_id, version, organisation_id, audit_id, allow, | ||
created_by_id, last_modified_by_id, created_date_time, last_modified_date_time) | ||
select uuid_generate_v4(), | ||
g.id, | ||
p.id, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
0, | ||
g.organisation_id, | ||
create_audit(), | ||
true, | ||
1, 1, current_timestamp, current_timestamp | ||
from groups g join privilege p on true | ||
where g.name = 'Data entry operator' and p.name in ('View subject type', 'View program', 'View encounter type', | ||
'View form', 'View concept', 'View organisation config', 'View checklist config', 'View relationship', 'View documentation', | ||
'View offline dashboard and report card', 'View application menu', 'View extension', 'View rule failure', 'View location type' | ||
'View location', 'View catchment', 'View user information', 'View user group', 'View identifier source' | ||
'View identifier user assignment', 'Upload metadata and data', 'View task'); | ||
|