2022-09-07 20:24:35 +02:00
|
|
|
|
--liquibase formatted sql
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ============================================================================
|
2022-09-13 13:27:52 +02:00
|
|
|
|
--changeset hs-office-person-TEST-DATA-GENERATOR:1 endDelimiter:--//
|
2022-09-07 20:24:35 +02:00
|
|
|
|
-- ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Creates a single person test record.
|
|
|
|
|
*/
|
2022-09-13 13:27:52 +02:00
|
|
|
|
create or replace procedure createHsOfficePersonTestData(
|
|
|
|
|
newPersonType HsOfficePersonType,
|
2022-09-09 17:43:43 +02:00
|
|
|
|
newTradeName varchar,
|
|
|
|
|
newFamilyName varchar = null,
|
|
|
|
|
newGivenName varchar = null
|
2022-09-07 20:24:35 +02:00
|
|
|
|
)
|
|
|
|
|
language plpgsql as $$
|
|
|
|
|
declare
|
|
|
|
|
fullName varchar;
|
|
|
|
|
currentTask varchar;
|
|
|
|
|
emailAddr varchar;
|
|
|
|
|
begin
|
2022-09-09 17:43:43 +02:00
|
|
|
|
fullName := concat_ws(', ', newTradeName, newFamilyName, newGivenName);
|
2022-09-07 20:24:35 +02:00
|
|
|
|
currentTask = 'creating RBAC test person ' || fullName;
|
|
|
|
|
emailAddr = 'person-' || left(cleanIdentifier(fullName), 32) || '@example.com';
|
|
|
|
|
call defineContext(currentTask);
|
|
|
|
|
perform createRbacUser(emailAddr);
|
|
|
|
|
call defineContext(currentTask, null, emailAddr);
|
|
|
|
|
execute format('set local hsadminng.currentTask to %L', currentTask);
|
|
|
|
|
|
|
|
|
|
raise notice 'creating test person: %', fullName;
|
|
|
|
|
insert
|
2022-09-13 13:27:52 +02:00
|
|
|
|
into hs_office_person (persontype, tradename, givenname, familyname)
|
2022-09-09 17:43:43 +02:00
|
|
|
|
values (newPersonType, newTradeName, newGivenName, newFamilyName);
|
2022-09-07 20:24:35 +02:00
|
|
|
|
end; $$;
|
|
|
|
|
--//
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Creates a range of test persons for mass data generation.
|
|
|
|
|
*/
|
|
|
|
|
create or replace procedure createTestPersonTestData(
|
|
|
|
|
startCount integer, -- count of auto generated rows before the run
|
|
|
|
|
endCount integer -- count of auto generated rows after the run
|
|
|
|
|
)
|
|
|
|
|
language plpgsql as $$
|
|
|
|
|
begin
|
|
|
|
|
for t in startCount..endCount
|
|
|
|
|
loop
|
2022-09-13 13:27:52 +02:00
|
|
|
|
call createHsOfficePersonTestData('LEGAL', intToVarChar(t, 4));
|
2022-09-07 20:24:35 +02:00
|
|
|
|
commit;
|
|
|
|
|
end loop;
|
|
|
|
|
end; $$;
|
|
|
|
|
--//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ============================================================================
|
2022-09-13 13:27:52 +02:00
|
|
|
|
--changeset hs-office-person-TEST-DATA-GENERATION:1 –context=dev,tc endDelimiter:--//
|
2022-09-07 20:24:35 +02:00
|
|
|
|
-- ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
do language plpgsql $$
|
|
|
|
|
begin
|
2022-09-30 13:11:34 +02:00
|
|
|
|
call createHsOfficePersonTestData('LEGAL', 'First GmbH');
|
2022-09-26 10:57:22 +02:00
|
|
|
|
call createHsOfficePersonTestData('NATURAL', null, 'Smith', 'Peter');
|
2022-09-30 13:11:34 +02:00
|
|
|
|
call createHsOfficePersonTestData('LEGAL', 'Second e.K.', 'Sandra', 'Miller');
|
|
|
|
|
call createHsOfficePersonTestData('SOLE_REPRESENTATION', 'Third OHG');
|
2022-10-03 11:09:36 +02:00
|
|
|
|
call createHsOfficePersonTestData('SOLE_REPRESENTATION', 'Fourth e.G.');
|
2022-09-13 13:27:52 +02:00
|
|
|
|
call createHsOfficePersonTestData('JOINT_REPRESENTATION', 'Erben Bessler', 'Mel', 'Bessler');
|
2022-09-26 10:57:22 +02:00
|
|
|
|
call createHsOfficePersonTestData('NATURAL', null, 'Bessler', 'Anita');
|
|
|
|
|
call createHsOfficePersonTestData('NATURAL', null, 'Winkler', 'Paul');
|
2022-09-07 20:24:35 +02:00
|
|
|
|
end;
|
|
|
|
|
$$;
|
|
|
|
|
--//
|