2022-09-26 10:57:22 +02:00
|
|
|
|
--liquibase formatted sql
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ============================================================================
|
|
|
|
|
--changeset hs-office-relationship-TEST-DATA-GENERATOR:1 endDelimiter:--//
|
|
|
|
|
-- ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Creates a single relationship test record.
|
|
|
|
|
*/
|
|
|
|
|
create or replace procedure createHsOfficeRelationshipTestData(
|
|
|
|
|
anchorPersonTradeName varchar,
|
|
|
|
|
holderPersonFamilyName varchar,
|
|
|
|
|
relationshipType HsOfficeRelationshipType,
|
|
|
|
|
contactLabel varchar)
|
|
|
|
|
language plpgsql as $$
|
|
|
|
|
declare
|
|
|
|
|
currentTask varchar;
|
|
|
|
|
idName varchar;
|
|
|
|
|
anchorPerson hs_office_person;
|
|
|
|
|
holderPerson hs_office_person;
|
|
|
|
|
contact hs_office_contact;
|
|
|
|
|
|
|
|
|
|
begin
|
2022-10-05 17:22:33 +02:00
|
|
|
|
idName := cleanIdentifier( anchorPersonTradeName || '-' || holderPersonFamilyName);
|
2022-10-13 10:36:20 +02:00
|
|
|
|
currentTask := 'creating relationship test-data ' || idName;
|
2022-09-26 10:57:22 +02:00
|
|
|
|
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global.admin');
|
|
|
|
|
execute format('set local hsadminng.currentTask to %L', currentTask);
|
|
|
|
|
|
|
|
|
|
select p.* from hs_office_person p where p.tradeName = anchorPersonTradeName into anchorPerson;
|
|
|
|
|
select p.* from hs_office_person p where p.familyName = holderPersonFamilyName into holderPerson;
|
|
|
|
|
select c.* from hs_office_contact c where c.label = contactLabel into contact;
|
|
|
|
|
|
|
|
|
|
raise notice 'creating test relationship: %', idName;
|
|
|
|
|
raise notice '- using anchor person (%): %', anchorPerson.uuid, anchorPerson;
|
|
|
|
|
raise notice '- using holder person (%): %', holderPerson.uuid, holderPerson;
|
|
|
|
|
raise notice '- using contact (%): %', contact.uuid, contact;
|
|
|
|
|
insert
|
|
|
|
|
into hs_office_relationship (uuid, relanchoruuid, relholderuuid, reltype, contactUuid)
|
|
|
|
|
values (uuid_generate_v4(), anchorPerson.uuid, holderPerson.uuid, relationshipType, contact.uuid);
|
|
|
|
|
end; $$;
|
|
|
|
|
--//
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Creates a range of test relationship for mass data generation.
|
|
|
|
|
*/
|
|
|
|
|
create or replace procedure createHsOfficeRelationshipTestData(
|
|
|
|
|
startCount integer, -- count of auto generated rows before the run
|
|
|
|
|
endCount integer -- count of auto generated rows after the run
|
|
|
|
|
)
|
|
|
|
|
language plpgsql as $$
|
|
|
|
|
declare
|
|
|
|
|
person hs_office_person;
|
|
|
|
|
contact hs_office_contact;
|
|
|
|
|
begin
|
|
|
|
|
for t in startCount..endCount
|
|
|
|
|
loop
|
|
|
|
|
select p.* from hs_office_person p where tradeName = intToVarChar(t, 4) into person;
|
|
|
|
|
select c.* from hs_office_contact c where c.label = intToVarChar(t, 4) || '#' || t into contact;
|
|
|
|
|
|
2024-01-23 15:11:23 +01:00
|
|
|
|
call createHsOfficeRelationshipTestData(person.uuid, contact.uuid, 'REPRESENTATIVE');
|
2022-09-26 10:57:22 +02:00
|
|
|
|
commit;
|
|
|
|
|
end loop;
|
|
|
|
|
end; $$;
|
|
|
|
|
--//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- ============================================================================
|
|
|
|
|
--changeset hs-office-relationship-TEST-DATA-GENERATION:1 –context=dev,tc endDelimiter:--//
|
|
|
|
|
-- ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
do language plpgsql $$
|
|
|
|
|
begin
|
2024-01-23 15:11:23 +01:00
|
|
|
|
call createHsOfficeRelationshipTestData('First GmbH', 'Smith', 'REPRESENTATIVE', 'first contact');
|
2022-09-26 10:57:22 +02:00
|
|
|
|
|
2024-01-23 15:11:23 +01:00
|
|
|
|
call createHsOfficeRelationshipTestData('Second e.K.', 'Smith', 'REPRESENTATIVE', 'second contact');
|
2022-09-26 10:57:22 +02:00
|
|
|
|
|
2024-01-23 15:11:23 +01:00
|
|
|
|
call createHsOfficeRelationshipTestData('Third OHG', 'Smith', 'REPRESENTATIVE', 'third contact');
|
2022-09-26 10:57:22 +02:00
|
|
|
|
end;
|
|
|
|
|
$$;
|
|
|
|
|
--//
|