-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- addition of models fro Idera ER/Studio
- Loading branch information
1 parent
8b1bcc8
commit fd51f91
Showing
312 changed files
with
2,279,221 additions
and
0 deletions.
There are no files selected for viewing
6,374 changes: 6,374 additions & 0 deletions
6,374
database/models/custom_mappings/DatatypeMappings_SystemDefault.xml
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,66 @@ | ||
'#Language "WWB-COM" | ||
|
||
Sub Main | ||
|
||
Dim MyDiagram As Diagram | ||
Dim MyModel As Model | ||
Dim MyEntity As Entity | ||
Dim MyAttribute As AttributeObj | ||
Dim MyDefaults As Default | ||
Dim MyTimestampNowDefaultId As Variant | ||
Dim MyUserDefaultId As Variant | ||
Dim MyRevisionCountDefaultId As Variant | ||
|
||
Set MyDiagram = DiagramManager.ActiveDiagram | ||
Set MyModel = MyDiagram.ActiveModel | ||
|
||
If Not MyModel.Logical Then | ||
If MsgBox("This macro will add audit columns to all objects in the currently selected Physical model.", vbOkCancel) = vbOK Then | ||
For Each MyDefaults In MyDiagram.Dictionary.Defaults | ||
If MyDefaults.Name = "timestamp now" Then | ||
Set MyTimestampNowDefaultId = MyDefaults.ID | ||
ElseIf MyDefaults.Name = "user" Then | ||
Set MyUserDefaultId = MyDefaults.ID | ||
ElseIf MyDefaults.Name = "revision count" Then | ||
Set MyRevisionCountDefaultId = MyDefaults.ID | ||
End If | ||
Next | ||
For Each MyEntity In MyModel.Entities | ||
Set MyAttribute = MyEntity.Attributes.Add("create_date", False) | ||
MyAttribute.Datatype = "TIMESTAMP" | ||
MyAttribute.Definition = "The datetime the record was created." | ||
MyAttribute.NullOption = "NOT NULL" | ||
MyAttribute.DefaultId = MyTimestampNowDefaultId | ||
|
||
Set MyAttribute = MyEntity.Attributes.Add("create_user", False) | ||
MyAttribute.Datatype = "VARCHAR" | ||
MyAttribute.DataLength = 63 | ||
MyAttribute.Definition = "The user who created the record." | ||
MyAttribute.NullOption = "NOT NULL" | ||
MyAttribute.DefaultId = MyUserDefaultId | ||
|
||
Set MyAttribute = MyEntity.Attributes.Add("update_date", False) | ||
MyAttribute.Datatype = "TIMESTAMP" | ||
MyAttribute.Definition = "The datetime the record was updated." | ||
MyAttribute.NullOption = "NULL" | ||
|
||
Set MyAttribute = MyEntity.Attributes.Add("update_user", False) | ||
MyAttribute.Datatype = "VARCHAR" | ||
MyAttribute.DataLength = 63 | ||
MyAttribute.Definition = "The user who updated the record." | ||
MyAttribute.NullOption = "NULL" | ||
|
||
Set MyAttribute = MyEntity.Attributes.Add("revision_count", False) | ||
MyAttribute.Datatype = "INTEGER" | ||
MyAttribute.Definition = "Revision count used for concurrency control." | ||
MyAttribute.NullOption = "NOT NULL" | ||
MyAttribute.DefaultId = MyRevisionCountDefaultId | ||
Next | ||
|
||
MsgBox "Work complete." | ||
End If | ||
Else | ||
MsgBox "This macro is designed to run in the Physical model. Please switch to Physical model first." | ||
End If | ||
|
||
End Sub |
205,476 changes: 205,476 additions & 0 deletions
205,476
database/models/releases/release.0.1.0/BioHub.DM1
Large diffs are not rendered by default.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
database/models/releases/release.0.1.0/api_get_context_system_user_role_id.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,27 @@ | ||
-- api_get_context_system_user_role_id.sql | ||
|
||
CREATE OR REPLACE FUNCTION api_get_context_system_user_role_id() | ||
RETURNS integer | ||
LANGUAGE 'plpgsql' | ||
COST 100 | ||
stable | ||
AS $$ | ||
-- ******************************************************************* | ||
-- Procedure: api_get_context_system_user_role_id | ||
-- Purpose: returns the context system user role id from the invokers | ||
-- temp table | ||
-- | ||
-- MODIFICATION HISTORY | ||
-- Person Date Comments | ||
-- ---------------- ----------- -------------------------------------- | ||
-- [email protected] | ||
-- 2021-06-03 initial release | ||
-- ******************************************************************* | ||
declare | ||
_system_role_id system_user_role.system_role_id%type; | ||
begin | ||
select value::integer into _system_role_id from biohub_context_temp where tag = 'system_user_role_id'; | ||
|
||
return _system_role_id; | ||
end; | ||
$$; |
25 changes: 25 additions & 0 deletions
25
database/models/releases/release.0.1.0/api_get_context_user_id.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,25 @@ | ||
-- api_get_context_user_id.sql | ||
create or replace function api_get_context_user_id() returns system_user.system_user_id%type | ||
language plpgsql | ||
security invoker | ||
stable | ||
as | ||
$$ | ||
-- ******************************************************************* | ||
-- Procedure: api_get_context_user_id | ||
-- Purpose: returns the context user id from the invokers temp table | ||
-- | ||
-- MODIFICATION HISTORY | ||
-- Person Date Comments | ||
-- ---------------- ----------- -------------------------------------- | ||
-- [email protected] | ||
-- 2021-01-03 initial release | ||
-- ******************************************************************* | ||
declare | ||
_system_user_id system_user.system_user_id%type; | ||
begin | ||
select value::integer into _system_user_id from biohub_context_temp where tag = 'user_id'; | ||
|
||
return _system_user_id; | ||
end; | ||
$$; |
58 changes: 58 additions & 0 deletions
58
database/models/releases/release.0.1.0/api_get_system_constant.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,58 @@ | ||
-- api_get_system_constant.sql | ||
drop function if exists api_get_character_system_constant; | ||
|
||
create or replace function api_get_character_system_constant(_constant_name system_constant.constant_name%type) returns system_constant.character_value%type | ||
language plpgsql | ||
security definer | ||
stable | ||
as | ||
$$ | ||
-- ******************************************************************* | ||
-- Procedure: api_get_character_system_constant | ||
-- Purpose: returns a text value from the system constants table | ||
-- | ||
-- MODIFICATION HISTORY | ||
-- Person Date Comments | ||
-- ---------------- ----------- -------------------------------------- | ||
-- [email protected] | ||
-- 2021-06-29 initial release | ||
-- ******************************************************************* | ||
begin | ||
return (select character_value from system_constant where constant_name = _constant_name); | ||
|
||
exception | ||
when others then | ||
raise; | ||
end; | ||
$$; | ||
|
||
grant execute on function api_get_character_system_constant to biohub_api; | ||
|
||
drop function if exists api_get_numeric_system_constant; | ||
|
||
create or replace function api_get_numeric_system_constant(_constant_name system_constant.constant_name%type) returns system_constant.numeric_value%type | ||
language plpgsql | ||
security definer | ||
stable | ||
as | ||
$$ | ||
-- ******************************************************************* | ||
-- Procedure: api_get_numeric_system_constant | ||
-- Purpose: returns a numeric value from the system constants table | ||
-- | ||
-- MODIFICATION HISTORY | ||
-- Person Date Comments | ||
-- ---------------- ----------- -------------------------------------- | ||
-- [email protected] | ||
-- 2021-06-29 initial release | ||
-- ******************************************************************* | ||
begin | ||
return (select numeric_value from system_constant where constant_name = _constant_name); | ||
|
||
exception | ||
when others then | ||
raise; | ||
end; | ||
$$; | ||
|
||
grant execute on function api_get_numeric_system_constant to biohub_api; |
58 changes: 58 additions & 0 deletions
58
database/models/releases/release.0.1.0/api_get_system_metadata_constant.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,58 @@ | ||
-- api_get_system_metadata_constant.sql | ||
drop function if exists api_get_character_system_metadata_constant; | ||
|
||
create or replace function api_get_character_system_metadata_constant(_constant_name system_metadata_constant.constant_name%type) returns system_metadata_constant.character_value%type | ||
language plpgsql | ||
security definer | ||
stable | ||
as | ||
$$ | ||
-- ******************************************************************* | ||
-- Procedure: api_get_character_system_metadata_constant | ||
-- Purpose: returns a text value from the system constants table | ||
-- | ||
-- MODIFICATION HISTORY | ||
-- Person Date Comments | ||
-- ---------------- ----------- -------------------------------------- | ||
-- [email protected] | ||
-- 2021-06-29 initial release | ||
-- ******************************************************************* | ||
begin | ||
return (select character_value from system_metadata_constant where constant_name = _constant_name); | ||
|
||
exception | ||
when others then | ||
raise; | ||
end; | ||
$$; | ||
|
||
grant execute on function api_get_character_system_metadata_constant to biohub_api; | ||
|
||
drop function if exists api_get_numeric_system_metadata_constant; | ||
|
||
create or replace function api_get_numeric_system_metadata_constant(_constant_name system_metadata_constant.constant_name%type) returns system_metadata_constant.numeric_value%type | ||
language plpgsql | ||
security definer | ||
stable | ||
as | ||
$$ | ||
-- ******************************************************************* | ||
-- Procedure: api_get_numeric_system_metadata_constant | ||
-- Purpose: returns a numeric value from the system constants table | ||
-- | ||
-- MODIFICATION HISTORY | ||
-- Person Date Comments | ||
-- ---------------- ----------- -------------------------------------- | ||
-- [email protected] | ||
-- 2021-06-29 initial release | ||
-- ******************************************************************* | ||
begin | ||
return (select numeric_value from system_metadata_constant where constant_name = _constant_name); | ||
|
||
exception | ||
when others then | ||
raise; | ||
end; | ||
$$; | ||
|
||
grant execute on function api_get_numeric_system_metadata_constant to biohub_api; |
43 changes: 43 additions & 0 deletions
43
database/models/releases/release.0.1.0/api_set_context.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,43 @@ | ||
-- api_set_context.sql | ||
drop function if exists api_set_context; | ||
|
||
create or replace function api_set_context(p_system_user_identifier system_user.user_identifier%type, p_user_identity_source_name user_identity_source.name%type) returns system_user.system_user_id%type | ||
language plpgsql | ||
security invoker | ||
set client_min_messages = warning | ||
as | ||
$$ | ||
-- ******************************************************************* | ||
-- Procedure: api_set_context | ||
-- Purpose: sets the initial context for api users | ||
-- | ||
-- MODIFICATION HISTORY | ||
-- Person Date Comments | ||
-- ---------------- ----------- -------------------------------------- | ||
-- [email protected] | ||
-- 2021-01-03 initial release | ||
-- 2021-04-16 adjusted to accepted defined user identity source | ||
-- ******************************************************************* | ||
declare | ||
_system_user_id system_user.system_user_id%type; | ||
_user_identity_source_id user_identity_source.user_identity_source_id%type; | ||
begin | ||
|
||
select user_identity_source_id into strict _user_identity_source_id from user_identity_source | ||
where name = p_user_identity_source_name | ||
and record_end_date is null; | ||
|
||
select system_user_id into strict _system_user_id from system_user | ||
where user_identity_source_id = _user_identity_source_id | ||
and user_identifier = p_system_user_identifier; | ||
|
||
create temp table if not exists biohub_context_temp (tag varchar(200), value varchar(200)); | ||
delete from biohub_context_temp where tag = 'user_id'; | ||
insert into biohub_context_temp (tag, value) values ('user_id', _system_user_id::varchar(200)); | ||
|
||
return _system_user_id; | ||
exception | ||
when others THEN | ||
raise; | ||
end; | ||
$$; |
39 changes: 39 additions & 0 deletions
39
database/models/releases/release.0.1.0/api_user_is_administrator.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,39 @@ | ||
-- api_user_is_administrator.sql | ||
drop function if exists api_user_is_administrator; | ||
|
||
create or replace function api_user_is_administrator(p_system_user_id system_user.system_user_id%type default null) returns boolean | ||
language plpgsql | ||
security definer | ||
stable | ||
as | ||
$$ | ||
-- ******************************************************************* | ||
-- Procedure: api_user_is_administrator | ||
-- Purpose: returns true if user is a system administrator and false otherwise | ||
-- | ||
-- MODIFICATION HISTORY | ||
-- Person Date Comments | ||
-- ---------------- ----------- -------------------------------------- | ||
-- [email protected] | ||
-- 2021-06-21 initial release | ||
-- ******************************************************************* | ||
declare | ||
_system_user_id system_user.system_user_id%type; | ||
begin | ||
if (p_system_user_id is null) then | ||
select api_get_context_user_id() into _system_user_id; | ||
else | ||
_system_user_id = p_system_user_id; | ||
end if; | ||
|
||
return (select exists (select 1 from system_user_role sur, system_role sr | ||
where sur.system_user_id = _system_user_id | ||
and sur.system_role_id = sr.system_role_id | ||
and sr.name = (select api_get_character_system_constant('SYSTEM_ROLES_SYSTEM_ADMINISTRATOR')) | ||
and sr.record_end_date is null)); | ||
|
||
exception | ||
when others THEN | ||
raise; | ||
end; | ||
$$; |
Oops, something went wrong.