rename partnerRole -> partnerRel, relationship -> relation and remove rel-Prefix (relAnchor etc.) #23

Merged
hsh-michaelhoennig merged 5 commits from rename-partnerRole-to-partnerRel into master 2024-03-13 15:01:25 +01:00
15 changed files with 113 additions and 112 deletions
Showing only changes of commit 0ecf2a1e2e - Show all commits

View File

@ -10,7 +10,7 @@ classDiagram
namespace Partner { namespace Partner {
class partner-MeierGmbH class partner-MeierGmbH
class role-MeierGmbH class rel-MeierGmbH
class personDetails-MeierGmbH class personDetails-MeierGmbH
class contactData-MeierGmbH class contactData-MeierGmbH
class person-MeierGmbH class person-MeierGmbH
@ -19,28 +19,29 @@ classDiagram
namespace Representatives { namespace Representatives {
class person-FrankMeier class person-FrankMeier
class contactData-FrankMeier class contactData-FrankMeier
class role-MeierGmbH-FrankMeier class rel-MeierGmbH-FrankMeier
} }
namespace Debitors { namespace Debitors {
class debitor-MeierGmbH class debitor-MeierGmbH
class contactData-MeierGmbH-Buha class contactData-MeierGmbH-Buha
class role-MeierGmbH-Buha class rel-MeierGmbH-Buha
} }
namespace Operations { namespace Operations {
class person-SabineMeier class person-SabineMeier
class contactData-SabineMeier class contactData-SabineMeier
class role-MeierGmbH-SabineMeier class rel-MeierGmbH-SabineMeier
} }
namespace Enums { namespace Enums {
class RoleType { class RelationType {
<<enumeration>> <<enumeration>>
UNKNOWN UNKNOWN
PARTNER
DEBITOR
REPRESENTATIVE REPRESENTATIVE
ACCOUNTING
OPERATIONS OPERATIONS
} }
@ -64,9 +65,9 @@ classDiagram
class partner-MeierGmbH { class partner-MeierGmbH {
+Numeric partnerNumber: 12345 +Numeric partnerNumber: 12345
+Role partnerRole +Relation partnerRel
} }
partner-MeierGmbH *-- role-MeierGmbH partner-MeierGmbH *-- rel-MeierGmbH
class person-MeierGmbH { class person-MeierGmbH {
+personType: LEGAL +personType: LEGAL
@ -90,22 +91,22 @@ classDiagram
+emailAddresses: office@meier-gmbh.de +emailAddresses: office@meier-gmbh.de
} }
class role-MeierGmbH { class rel-MeierGmbH {
+RoleType RoleType PARTNER +RelationType type PARTNER
+Person anchor +Person anchor
+Person holder +Person holder
+Contact roleContact +Contact contact
} }
role-MeierGmbH o-- person-HostsharingEG : anchor rel-MeierGmbH o-- person-HostsharingEG : anchor
role-MeierGmbH o-- person-MeierGmbH : holder rel-MeierGmbH o-- person-MeierGmbH : holder
role-MeierGmbH o-- contactData-MeierGmbH rel-MeierGmbH o-- contactData-MeierGmbH
%% --- Debitors --- %% --- Debitors ---
class debitor-MeierGmbH { class debitor-MeierGmbH {
+Partner partner +Partner partner
+Numeric[2] debitorNumberSuffix: 00 +Numeric[2] debitorNumberSuffix: 00
+Role billingRole +Relation debitorRel
+boolean billable: true +boolean billable: true
+String vatId: ID123456789 +String vatId: ID123456789
+String vatCountryCode: DE +String vatCountryCode: DE
@ -115,7 +116,7 @@ classDiagram
+String defaultPrefix: mei +String defaultPrefix: mei
} }
debitor-MeierGmbH o-- partner-MeierGmbH debitor-MeierGmbH o-- partner-MeierGmbH
debitor-MeierGmbH *-- role-MeierGmbH-Buha debitor-MeierGmbH *-- rel-MeierGmbH-Buha
class contactData-MeierGmbH-Buha { class contactData-MeierGmbH-Buha {
+postalAddress: Hauptstraße 5, 22345 Hamburg +postalAddress: Hauptstraße 5, 22345 Hamburg
@ -123,15 +124,15 @@ classDiagram
+emailAddresses: buha@meier-gmbh.de +emailAddresses: buha@meier-gmbh.de
} }
class role-MeierGmbH-Buha { class rel-MeierGmbH-Buha {
+RoleType RoleType ACCOUNTING +RelationType type ACCOUNTING

soll das jetzt DEBITOR sein?

soll das jetzt DEBITOR sein?
+Person anchor +Person anchor
+Person holder +Person holder
+Contact roleContact +Contact contact
} }
role-MeierGmbH-Buha o-- person-MeierGmbH : anchor rel-MeierGmbH-Buha o-- person-MeierGmbH : anchor
role-MeierGmbH-Buha o-- person-MeierGmbH : holder rel-MeierGmbH-Buha o-- person-MeierGmbH : holder
role-MeierGmbH-Buha o-- contactData-MeierGmbH-Buha rel-MeierGmbH-Buha o-- contactData-MeierGmbH-Buha
%% --- Representatives --- %% --- Representatives ---
@ -148,15 +149,15 @@ classDiagram
+emailAddresses: frank.meier@meier-gmbh.de +emailAddresses: frank.meier@meier-gmbh.de
} }
class role-MeierGmbH-FrankMeier { class rel-MeierGmbH-FrankMeier {
+RoleType RoleType REPRESENTATIVE +RelationType type REPRESENTATIVE
+Person anchor +Person anchor
+Person holder +Person holder
+Contact roleContact +Contact contact
} }
role-MeierGmbH-FrankMeier o-- person-MeierGmbH : anchor rel-MeierGmbH-FrankMeier o-- person-MeierGmbH : anchor
role-MeierGmbH-FrankMeier o-- person-FrankMeier : holder rel-MeierGmbH-FrankMeier o-- person-FrankMeier : holder
role-MeierGmbH-FrankMeier o-- contactData-FrankMeier rel-MeierGmbH-FrankMeier o-- contactData-FrankMeier
%% --- Operations --- %% --- Operations ---
@ -173,14 +174,14 @@ classDiagram
+emailAddresses: sabine.meier@meier-gmbh.de +emailAddresses: sabine.meier@meier-gmbh.de
} }
class role-MeierGmbH-SabineMeier { class rel-MeierGmbH-SabineMeier {
+RoleType RoleType OPERATIONAL +RelationType type OPERATIONAL
+Person anchor +Person anchor
+Person holder +Person holder
+Contact roleContact +Contact contact
} }
role-MeierGmbH-SabineMeier o-- person-MeierGmbH : anchor rel-MeierGmbH-SabineMeier o-- person-MeierGmbH : anchor
role-MeierGmbH-SabineMeier o-- person-SabineMeier : holder rel-MeierGmbH-SabineMeier o-- person-SabineMeier : holder
role-MeierGmbH-SabineMeier o-- contactData-SabineMeier rel-MeierGmbH-SabineMeier o-- contactData-SabineMeier
``` ```

View File

@ -114,7 +114,7 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable {
'D-' || (SELECT partner.partnerNumber 'D-' || (SELECT partner.partnerNumber
FROM hs_office_partner partner FROM hs_office_partner partner
JOIN hs_office_relationship partnerRel JOIN hs_office_relationship partnerRel
ON partnerRel.uuid = partner.partnerRoleUUid AND partnerRel.relType = 'PARTNER' ON partnerRel.uuid = partner.partnerRelUUid AND partnerRel.relType = 'PARTNER'
JOIN hs_office_relationship debitorRel JOIN hs_office_relationship debitorRel
ON debitorRel.relAnchorUuid = partnerRel.relHolderUuid AND partnerRel.relType = 'DEBITOR' ON debitorRel.relAnchorUuid = partnerRel.relHolderUuid AND partnerRel.relType = 'DEBITOR'
WHERE debitorRel.uuid = debitor.debitorRelUuid) WHERE debitorRel.uuid = debitor.debitorRelUuid)

View File

@ -7,7 +7,7 @@ import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficePartners
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerInsertResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerInsertResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerRoleInsertResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerRelInsertResource;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity; import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipRepository; import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipRepository;
@ -112,7 +112,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
if (partnerRepo.deleteByUuid(partnerUuid) != 1 || if (partnerRepo.deleteByUuid(partnerUuid) != 1 ||
// TODO: move to after delete trigger in partner // TODO: move to after delete trigger in partner
relationshipRepo.deleteByUuid(partnerToDelete.get().getPartnerRole().getUuid()) != 1 ) { relationshipRepo.deleteByUuid(partnerToDelete.get().getPartnerRel().getUuid()) != 1 ) {
return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
} }
@ -141,14 +141,14 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
private HsOfficePartnerEntity createPartnerEntity(final HsOfficePartnerInsertResource body) { private HsOfficePartnerEntity createPartnerEntity(final HsOfficePartnerInsertResource body) {
final var entityToSave = new HsOfficePartnerEntity(); final var entityToSave = new HsOfficePartnerEntity();
entityToSave.setPartnerNumber(body.getPartnerNumber()); entityToSave.setPartnerNumber(body.getPartnerNumber());
entityToSave.setPartnerRole(persistPartnerRole(body.getPartnerRole())); entityToSave.setPartnerRel(persistPartnerRel(body.getPartnerRel()));
entityToSave.setContact(ref(HsOfficeContactEntity.class, body.getContactUuid())); entityToSave.setContact(ref(HsOfficeContactEntity.class, body.getContactUuid()));
entityToSave.setPerson(ref(HsOfficePersonEntity.class, body.getPersonUuid())); entityToSave.setPerson(ref(HsOfficePersonEntity.class, body.getPersonUuid()));
entityToSave.setDetails(mapper.map(body.getDetails(), HsOfficePartnerDetailsEntity.class)); entityToSave.setDetails(mapper.map(body.getDetails(), HsOfficePartnerDetailsEntity.class));
return entityToSave; return entityToSave;
} }
private HsOfficeRelationshipEntity persistPartnerRole(final HsOfficePartnerRoleInsertResource resource) { private HsOfficeRelationshipEntity persistPartnerRel(final HsOfficePartnerRelInsertResource resource) {
final var entity = new HsOfficeRelationshipEntity(); final var entity = new HsOfficeRelationshipEntity();
entity.setRelType(HsOfficeRelationshipType.PARTNER); entity.setRelType(HsOfficeRelationshipType.PARTNER);
entity.setRelAnchor(ref(HsOfficePersonEntity.class, resource.getRelAnchorUuid())); entity.setRelAnchor(ref(HsOfficePersonEntity.class, resource.getRelAnchorUuid()));

View File

@ -92,9 +92,9 @@ public class HsOfficePartnerDetailsEntity implements HasUuid, Stringifyable {
FROM hs_office_relationship AS partnerRel FROM hs_office_relationship AS partnerRel
JOIN hs_office_partner AS partner JOIN hs_office_partner AS partner
ON partner.detailsUuid = ${ref}.uuid ON partner.detailsUuid = ${ref}.uuid
WHERE partnerRel.uuid = partner.partnerRoleUuid WHERE partnerRel.uuid = partner.partnerRelUuid
"""), """),
dependsOnColumn("partnerRoleUuid")) dependsOnColumn("partnerRelUuid"))
// The grants are defined in HsOfficePartnerEntity.rbac() // The grants are defined in HsOfficePartnerEntity.rbac()
// because they have to be changed when its partnerRel changes, // because they have to be changed when its partnerRel changes,

View File

@ -50,15 +50,15 @@ public class HsOfficePartnerEntity implements Stringifyable, HasUuid {
private Integer partnerNumber; private Integer partnerNumber;
@ManyToOne @ManyToOne
@JoinColumn(name = "partnerroleuuid", nullable = false) @JoinColumn(name = "partnerreluuid", nullable = false)
private HsOfficeRelationshipEntity partnerRole; private HsOfficeRelationshipEntity partnerRel;
// TODO: remove, is replaced by partnerRole // TODO: remove, is replaced by partnerRel
@ManyToOne @ManyToOne
@JoinColumn(name = "personuuid", nullable = false) @JoinColumn(name = "personuuid", nullable = false)
private HsOfficePersonEntity person; private HsOfficePersonEntity person;
// TODO: remove, is replaced by partnerRole // TODO: remove, is replaced by partnerRel
@ManyToOne @ManyToOne
@JoinColumn(name = "contactuuid", nullable = false) @JoinColumn(name = "contactuuid", nullable = false)
private HsOfficeContactEntity contact; private HsOfficeContactEntity contact;
@ -87,13 +87,13 @@ public class HsOfficePartnerEntity implements Stringifyable, HasUuid {
FROM hs_office_partner AS partner FROM hs_office_partner AS partner
""")) """))
.withUpdatableColumns( .withUpdatableColumns(
"partnerRoleUuid", "partnerRelUuid",
"personUuid", "personUuid",
"contactUuid") "contactUuid")
.createPermission(custom("new-partner")).grantedTo("global", ADMIN) .createPermission(custom("new-partner")).grantedTo("global", ADMIN)
.importRootEntityAliasProxy("partnerRel", HsOfficeRelationshipEntity.class, .importRootEntityAliasProxy("partnerRel", HsOfficeRelationshipEntity.class,
fetchedBySql("SELECT * FROM hs_office_relationship AS r WHERE r.uuid = ${ref}.partnerRoleUuid"), fetchedBySql("SELECT * FROM hs_office_relationship AS r WHERE r.uuid = ${ref}.partnerRelUuid"),
dependsOnColumn("partnerRelUuid")) dependsOnColumn("partnerRelUuid"))
.createPermission(DELETE).grantedTo("partnerRel", ADMIN) .createPermission(DELETE).grantedTo("partnerRel", ADMIN)
.createPermission(UPDATE).grantedTo("partnerRel", AGENT) .createPermission(UPDATE).grantedTo("partnerRel", AGENT)

View File

@ -96,8 +96,8 @@ components:
format: int8 format: int8
minimum: 10000 minimum: 10000
maximum: 99999 maximum: 99999
partnerRole: partnerRel:
$ref: '#/components/schemas/HsOfficePartnerRoleInsert' $ref: '#/components/schemas/HsOfficePartnerRelInsert'
personUuid: personUuid:
type: string type: string
format: uuid format: uuid
@ -112,7 +112,7 @@ components:
- contactUuid - contactUuid
- details - details
HsOfficePartnerRoleInsert: HsOfficePartnerRelInsert:
type: object type: object
nullable: false nullable: false
properties: properties:

View File

@ -9,9 +9,9 @@ components:
- UNKNOWN - UNKNOWN
- PARTNER - PARTNER
- EX_PARTNER - EX_PARTNER
- REPRESENTATIVE, - DEBITOR
- REPRESENTATIVE
- VIP_CONTACT - VIP_CONTACT
- ACCOUNTING,
- OPERATIONS - OPERATIONS
- SUBSCRIBER - SUBSCRIBER

View File

@ -33,9 +33,9 @@ create table hs_office_partner
( (
uuid uuid unique references RbacObject (uuid) initially deferred, uuid uuid unique references RbacObject (uuid) initially deferred,
partnerNumber numeric(5) unique not null, partnerNumber numeric(5) unique not null,
partnerRoleUuid uuid not null references hs_office_relationship(uuid), -- TODO: delete in after delete trigger partnerRelUuid uuid not null references hs_office_relationship(uuid), -- TODO: delete in after delete trigger
personUuid uuid not null references hs_office_person(uuid), -- TODO: remove, replaced by partnerRoleUuid personUuid uuid not null references hs_office_person(uuid), -- TODO: remove, replaced by partnerRelUuid
contactUuid uuid not null references hs_office_contact(uuid), -- TODO: remove, replaced by partnerRoleUuid contactUuid uuid not null references hs_office_contact(uuid), -- TODO: remove, replaced by partnerRelUuid
detailsUuid uuid not null references hs_office_partner_details(uuid) -- deleted in after delete trigger detailsUuid uuid not null references hs_office_partner_details(uuid) -- deleted in after delete trigger
); );
--// --//

View File

@ -27,8 +27,8 @@ create or replace function hsOfficePartnerRbacRolesTrigger()
language plpgsql language plpgsql
strict as $$ strict as $$
declare declare
oldPartnerRole hs_office_relationship; oldPartnerRel hs_office_relationship;
newPartnerRole hs_office_relationship; newPartnerRel hs_office_relationship;
oldPerson hs_office_person; oldPerson hs_office_person;
newPerson hs_office_person; newPerson hs_office_person;
@ -38,7 +38,7 @@ declare
begin begin
call enterTriggerForObjectUuid(NEW.uuid); call enterTriggerForObjectUuid(NEW.uuid);
select * from hs_office_relationship as r where r.uuid = NEW.partnerroleuuid into newPartnerRole; select * from hs_office_relationship as r where r.uuid = NEW.partnerReluuid into newPartnerRel;
select * from hs_office_person as p where p.uuid = NEW.personUuid into newPerson; select * from hs_office_person as p where p.uuid = NEW.personUuid into newPerson;
select * from hs_office_contact as c where c.uuid = NEW.contactUuid into newContact; select * from hs_office_contact as c where c.uuid = NEW.contactUuid into newContact;
@ -58,7 +58,7 @@ begin
incomingSuperRoles => array[ incomingSuperRoles => array[
hsOfficePartnerOwner(NEW)], hsOfficePartnerOwner(NEW)],
outgoingSubRoles => array[ outgoingSubRoles => array[
hsOfficeRelationshipTenant(newPartnerRole), hsOfficeRelationshipTenant(newPartnerRel),
hsOfficePersonTenant(newPerson), hsOfficePersonTenant(newPerson),
hsOfficeContactTenant(newContact)] hsOfficeContactTenant(newContact)]
); );
@ -67,7 +67,7 @@ begin
hsOfficePartnerAgent(NEW), hsOfficePartnerAgent(NEW),
incomingSuperRoles => array[ incomingSuperRoles => array[
hsOfficePartnerAdmin(NEW), hsOfficePartnerAdmin(NEW),
hsOfficeRelationshipAdmin(newPartnerRole), hsOfficeRelationshipAdmin(newPartnerRel),
hsOfficePersonAdmin(newPerson), hsOfficePersonAdmin(newPerson),
hsOfficeContactAdmin(newContact)] hsOfficeContactAdmin(newContact)]
); );
@ -77,7 +77,7 @@ begin
incomingSuperRoles => array[ incomingSuperRoles => array[
hsOfficePartnerAgent(NEW)], hsOfficePartnerAgent(NEW)],
outgoingSubRoles => array[ outgoingSubRoles => array[
hsOfficeRelationshipTenant(newPartnerRole), hsOfficeRelationshipTenant(newPartnerRel),
hsOfficePersonGuest(newPerson), hsOfficePersonGuest(newPerson),
hsOfficeContactGuest(newContact)] hsOfficeContactGuest(newContact)]
); );
@ -118,17 +118,17 @@ begin
elsif TG_OP = 'UPDATE' then elsif TG_OP = 'UPDATE' then
if OLD.partnerRoleUuid <> NEW.partnerRoleUuid then if OLD.partnerRelUuid <> NEW.partnerRelUuid then
select * from hs_office_relationship as r where r.uuid = OLD.partnerRoleUuid into oldPartnerRole; select * from hs_office_relationship as r where r.uuid = OLD.partnerRelUuid into oldPartnerRel;
call revokeRoleFromRole(hsOfficeRelationshipTenant(oldPartnerRole), hsOfficePartnerAdmin(OLD)); call revokeRoleFromRole(hsOfficeRelationshipTenant(oldPartnerRel), hsOfficePartnerAdmin(OLD));
call grantRoleToRole(hsOfficeRelationshipTenant(newPartnerRole), hsOfficePartnerAdmin(NEW)); call grantRoleToRole(hsOfficeRelationshipTenant(newPartnerRel), hsOfficePartnerAdmin(NEW));
call revokeRoleFromRole(hsOfficePartnerAgent(OLD), hsOfficeRelationshipAdmin(oldPartnerRole)); call revokeRoleFromRole(hsOfficePartnerAgent(OLD), hsOfficeRelationshipAdmin(oldPartnerRel));
call grantRoleToRole(hsOfficePartnerAgent(NEW), hsOfficeRelationshipAdmin(newPartnerRole)); call grantRoleToRole(hsOfficePartnerAgent(NEW), hsOfficeRelationshipAdmin(newPartnerRel));
call revokeRoleFromRole(hsOfficeRelationshipGuest(oldPartnerRole), hsOfficePartnerTenant(OLD)); call revokeRoleFromRole(hsOfficeRelationshipGuest(oldPartnerRel), hsOfficePartnerTenant(OLD));
call grantRoleToRole(hsOfficeRelationshipGuest(newPartnerRole), hsOfficePartnerTenant(NEW)); call grantRoleToRole(hsOfficeRelationshipGuest(newPartnerRel), hsOfficePartnerTenant(NEW));
end if; end if;
if OLD.personUuid <> NEW.personUuid then if OLD.personUuid <> NEW.personUuid then
@ -202,7 +202,7 @@ call generateRbacIdentityViewFromProjection('hs_office_partner', $idName$
call generateRbacRestrictedView('hs_office_partner', call generateRbacRestrictedView('hs_office_partner',
'(select idName from hs_office_person_iv p where p.uuid = target.personUuid)', '(select idName from hs_office_person_iv p where p.uuid = target.personUuid)',
$updates$ $updates$
partnerRoleUuid = new.partnerRoleUuid, partnerRelUuid = new.partnerRelUuid,
personUuid = new.personUuid, personUuid = new.personUuid,
contactUuid = new.contactUuid contactUuid = new.contactUuid
$updates$); $updates$);

View File

@ -18,7 +18,7 @@ declare
currentTask varchar; currentTask varchar;
idName varchar; idName varchar;
mandantPerson hs_office_person; mandantPerson hs_office_person;
partnerRole hs_office_relationship; partnerRel hs_office_relationship;

Einrückung

Einrückung
relatedPerson hs_office_person; relatedPerson hs_office_person;
relatedContact hs_office_contact; relatedContact hs_office_contact;
relatedDetailsUuid uuid; relatedDetailsUuid uuid;
@ -45,13 +45,13 @@ begin
select r.* from hs_office_relationship r select r.* from hs_office_relationship r
where r.reltype = 'PARTNER' where r.reltype = 'PARTNER'
and r.relanchoruuid = mandantPerson.uuid and r.relholderuuid = relatedPerson.uuid and r.relanchoruuid = mandantPerson.uuid and r.relholderuuid = relatedPerson.uuid
into partnerRole; into partnerRel;
if partnerRole is null then if partnerRel is null then
raise exception 'partnerRole "%"-"%" not found', mandantPerson.tradename, partnerPersonName; raise exception 'partnerRel "%"-"%" not found', mandantPerson.tradename, partnerPersonName;
end if; end if;
raise notice 'creating test partner: %', idName; raise notice 'creating test partner: %', idName;
raise notice '- using partnerRole (%): %', partnerRole.uuid, partnerRole; raise notice '- using partnerRel (%): %', partnerRel.uuid, partnerRel;
raise notice '- using person (%): %', relatedPerson.uuid, relatedPerson; raise notice '- using person (%): %', relatedPerson.uuid, relatedPerson;
raise notice '- using contact (%): %', relatedContact.uuid, relatedContact; raise notice '- using contact (%): %', relatedContact.uuid, relatedContact;
@ -68,8 +68,8 @@ begin
end if; end if;
insert insert
into hs_office_partner (uuid, partnerNumber, partnerRoleUuid, personuuid, contactuuid, detailsUuid) into hs_office_partner (uuid, partnerNumber, partnerRelUuid, personuuid, contactuuid, detailsUuid)
values (uuid_generate_v4(), partnerNumber, partnerRole.uuid, relatedPerson.uuid, relatedContact.uuid, relatedDetailsUuid); values (uuid_generate_v4(), partnerNumber, partnerRel.uuid, relatedPerson.uuid, relatedContact.uuid, relatedDetailsUuid);
end; $$; end; $$;
--// --//

View File

@ -224,8 +224,8 @@ public class ImportOfficeData extends ContextBasedTest {
debitors.forEach( (id, debitor) -> { debitors.forEach( (id, debitor) -> {
final var debitorRel = HsOfficeRelationshipEntity.builder() final var debitorRel = HsOfficeRelationshipEntity.builder()
.relType(HsOfficeRelationshipType.DEBITOR) .relType(HsOfficeRelationshipType.DEBITOR)
.relAnchor(debitor.getPartner().getPartnerRole().getRelHolder()) .relAnchor(debitor.getPartner().getPartnerRel().getRelHolder())
.relHolder(debitor.getPartner().getPartnerRole().getRelHolder()) // just 1 debitor/partner in legacy hsadmin .relHolder(debitor.getPartner().getPartnerRel().getRelHolder()) // just 1 debitor/partner in legacy hsadmin
.contact(debitor.getBillingContact()) .contact(debitor.getBillingContact())
.build(); .build();
if (debitorRel.getRelAnchor() != null && debitorRel.getRelHolder() != null && if (debitorRel.getRelAnchor() != null && debitorRel.getRelHolder() != null &&
@ -687,7 +687,7 @@ public class ImportOfficeData extends ContextBasedTest {
final var partner = HsOfficePartnerEntity.builder() final var partner = HsOfficePartnerEntity.builder()
.partnerNumber(rec.getInteger("member_id")) .partnerNumber(rec.getInteger("member_id"))
.details(HsOfficePartnerDetailsEntity.builder().build()) .details(HsOfficePartnerDetailsEntity.builder().build())
.partnerRole(partnerRelationship) .partnerRel(partnerRelationship)
.contact(null) // is set during contacts import depending on assigned roles .contact(null) // is set during contacts import depending on assigned roles
.person(person) .person(person)
.build(); .build();
@ -845,7 +845,7 @@ public class ImportOfficeData extends ContextBasedTest {
final var debitor = debitors.get(bpId); final var debitor = debitors.get(bpId);
final var partnerPerson = partner.getPerson(); final var partnerPerson = partner.getPerson();
if (containsPartnerRole(rec)) { if (containsPartnerRel(rec)) {
initPerson(partner.getPerson(), rec); initPerson(partner.getPerson(), rec);
} }
@ -859,10 +859,10 @@ public class ImportOfficeData extends ContextBasedTest {
final var contact = HsOfficeContactEntity.builder().build(); final var contact = HsOfficeContactEntity.builder().build();
initContact(contact, rec); initContact(contact, rec);
if (containsPartnerRole(rec)) { if (containsPartnerRel(rec)) {
assertThat(partner.getContact()).isNull(); assertThat(partner.getContact()).isNull();
partner.setContact(contact); partner.setContact(contact);
partner.getPartnerRole().setContact(contact); partner.getPartnerRel().setContact(contact);
} }
if (containsRole(rec, "billing")) { if (containsRole(rec, "billing")) {
assertThat(debitor.getBillingContact()).isNull(); assertThat(debitor.getBillingContact()).isNull();
@ -909,7 +909,7 @@ public class ImportOfficeData extends ContextBasedTest {
return ("," + roles + ",").contains("," + role + ","); return ("," + roles + ",").contains("," + role + ",");
} }
private static boolean containsPartnerRole(final Record rec) { private static boolean containsPartnerRel(final Record rec) {
return containsRole(rec, "partner"); return containsRole(rec, "partner");
} }

View File

@ -102,7 +102,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
.body(""" .body("""
{ {
"partnerNumber": "20002", "partnerNumber": "20002",
"partnerRole": { "partnerRel": {
"relAnchorUuid": "%s", "relAnchorUuid": "%s",
"relHolderUuid": "%s", "relHolderUuid": "%s",
"contactUuid": "%s" "contactUuid": "%s"
@ -155,7 +155,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
.body(""" .body("""
{ {
"partnerNumber": "20003", "partnerNumber": "20003",
"partnerRole": { "partnerRel": {
"relAnchorUuid": "%s", "relAnchorUuid": "%s",
"relHolderUuid": "%s", "relHolderUuid": "%s",
"contactUuid": "%s" "contactUuid": "%s"
@ -193,7 +193,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
.body(""" .body("""
{ {
"partnerNumber": "20004", "partnerNumber": "20004",
"partnerRole": { "partnerRel": {
"relAnchorUuid": "%s", "relAnchorUuid": "%s",
"relHolderUuid": "%s", "relHolderUuid": "%s",
"contactUuid": "%s" "contactUuid": "%s"
@ -413,7 +413,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
// then the given partner is gone // then the given partner is gone
assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isEmpty(); assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isEmpty();
assertThat(relationshipRepository.findByUuid(givenPartner.getPartnerRole().getUuid())).isEmpty(); assertThat(relationshipRepository.findByUuid(givenPartner.getPartnerRel().getUuid())).isEmpty();
} }
@Test @Test
@ -465,15 +465,15 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
final var givenPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0); final var givenPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0); final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0);
final var partnerRole = new HsOfficeRelationshipEntity(); final var partnerRel = new HsOfficeRelationshipEntity();
partnerRole.setRelType(HsOfficeRelationshipType.PARTNER); partnerRel.setRelType(HsOfficeRelationshipType.PARTNER);
partnerRole.setRelAnchor(givenMandantPerson); partnerRel.setRelAnchor(givenMandantPerson);
partnerRole.setRelHolder(givenPerson); partnerRel.setRelHolder(givenPerson);
partnerRole.setContact(givenContact); partnerRel.setContact(givenContact);
em.persist(partnerRole); em.persist(partnerRel);
final var newPartner = HsOfficePartnerEntity.builder() final var newPartner = HsOfficePartnerEntity.builder()
.partnerRole(partnerRole) .partnerRel(partnerRel)
.partnerNumber(partnerNumber) .partnerNumber(partnerNumber)
.person(givenPerson) .person(givenPerson)
.contact(givenContact) .contact(givenContact)

View File

@ -100,7 +100,7 @@ class HsOfficePartnerControllerRestTest {
.content(""" .content("""
{ {
"partnerNumber": "20002", "partnerNumber": "20002",
"partnerRole": { "partnerRel": {
"relAnchorUuid": "%s", "relAnchorUuid": "%s",
"relHolderUuid": "%s", "relHolderUuid": "%s",
"contactUuid": "%s" "contactUuid": "%s"
@ -137,7 +137,7 @@ class HsOfficePartnerControllerRestTest {
.content(""" .content("""
{ {
"partnerNumber": "20002", "partnerNumber": "20002",
"partnerRole": { "partnerRel": {
"relAnchorUuid": "%s", "relAnchorUuid": "%s",
"relHolderUuid": "%s", "relHolderUuid": "%s",
"contactUuid": "%s" "contactUuid": "%s"
@ -176,7 +176,7 @@ class HsOfficePartnerControllerRestTest {
when(partnerRepo.deleteByUuid(givenPartnerUuid)).thenReturn(0); when(partnerRepo.deleteByUuid(givenPartnerUuid)).thenReturn(0);
final UUID givenRelationshipUuid = UUID.randomUUID(); final UUID givenRelationshipUuid = UUID.randomUUID();
when(partnerMock.getPartnerRole()).thenReturn(HsOfficeRelationshipEntity.builder() when(partnerMock.getPartnerRel()).thenReturn(HsOfficeRelationshipEntity.builder()
.uuid(givenRelationshipUuid) .uuid(givenRelationshipUuid)
.build()); .build());
when(relationshipRepo.deleteByUuid(givenRelationshipUuid)).thenReturn(0); when(relationshipRepo.deleteByUuid(givenRelationshipUuid)).thenReturn(0);
@ -201,7 +201,7 @@ class HsOfficePartnerControllerRestTest {
when(relationshipRepo.deleteByUuid(any())).thenReturn(0); when(relationshipRepo.deleteByUuid(any())).thenReturn(0);
final UUID givenRelationshipUuid = UUID.randomUUID(); final UUID givenRelationshipUuid = UUID.randomUUID();
when(partnerMock.getPartnerRole()).thenReturn(HsOfficeRelationshipEntity.builder() when(partnerMock.getPartnerRel()).thenReturn(HsOfficeRelationshipEntity.builder()
.uuid(givenRelationshipUuid) .uuid(givenRelationshipUuid)
.build()); .build());
when(relationshipRepo.deleteByUuid(givenRelationshipUuid)).thenReturn(0); when(relationshipRepo.deleteByUuid(givenRelationshipUuid)).thenReturn(0);

View File

@ -80,19 +80,19 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike("First GmbH").get(0); final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike("First GmbH").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("first contact").get(0); final var givenContact = contactRepo.findContactByOptionalLabelLike("first contact").get(0);
final var partnerRole = HsOfficeRelationshipEntity.builder() final var partnerRel = HsOfficeRelationshipEntity.builder()
.relHolder(givenPartnerPerson) .relHolder(givenPartnerPerson)
.relType(HsOfficeRelationshipType.PARTNER) .relType(HsOfficeRelationshipType.PARTNER)
.relAnchor(givenMandantorPerson) .relAnchor(givenMandantorPerson)
.contact(givenContact) .contact(givenContact)
.build(); .build();
relationshipRepo.save(partnerRole); relationshipRepo.save(partnerRel);
// when // when
final var result = attempt(em, () -> { final var result = attempt(em, () -> {
final var newPartner = HsOfficePartnerEntity.builder() final var newPartner = HsOfficePartnerEntity.builder()
.partnerNumber(20031) .partnerNumber(20031)
.partnerRole(partnerRole) .partnerRel(partnerRel)
.person(givenPartnerPerson) .person(givenPartnerPerson)
.contact(givenContact) .contact(givenContact)
.details(HsOfficePartnerDetailsEntity.builder() .details(HsOfficePartnerDetailsEntity.builder()
@ -135,7 +135,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
final var newPartner = HsOfficePartnerEntity.builder() final var newPartner = HsOfficePartnerEntity.builder()
.partnerNumber(20032) .partnerNumber(20032)
.partnerRole(newRelationship) .partnerRel(newRelationship)
.person(givenPartnerPerson) .person(givenPartnerPerson)
.contact(givenContact) .contact(givenContact)
.details(HsOfficePartnerDetailsEntity.builder().build()) .details(HsOfficePartnerDetailsEntity.builder().build())
@ -429,7 +429,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
// TODO: should deleting a partner automatically delete the PARTNER relationship? (same for debitor) // TODO: should deleting a partner automatically delete the PARTNER relationship? (same for debitor)
// TODO: why did the test cleanup check does not notice this, if missing? // TODO: why did the test cleanup check does not notice this, if missing?
return partnerRepo.deleteByUuid(givenPartner.getUuid()) + return partnerRepo.deleteByUuid(givenPartner.getUuid()) +
relationshipRepo.deleteByUuid(givenPartner.getPartnerRole().getUuid()); relationshipRepo.deleteByUuid(givenPartner.getPartnerRel().getUuid());
}); });
// then // then
@ -466,17 +466,17 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike(person).get(0); final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike(person).get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike(contact).get(0); final var givenContact = contactRepo.findContactByOptionalLabelLike(contact).get(0);
final var partnerRole = HsOfficeRelationshipEntity.builder() final var partnerRel = HsOfficeRelationshipEntity.builder()
.relHolder(givenPartnerPerson) .relHolder(givenPartnerPerson)
.relType(HsOfficeRelationshipType.PARTNER) .relType(HsOfficeRelationshipType.PARTNER)
.relAnchor(givenMandantorPerson) .relAnchor(givenMandantorPerson)
.contact(givenContact) .contact(givenContact)
.build(); .build();
relationshipRepo.save(partnerRole); relationshipRepo.save(partnerRel);
final var newPartner = HsOfficePartnerEntity.builder() final var newPartner = HsOfficePartnerEntity.builder()
.partnerNumber(partnerNumber) .partnerNumber(partnerNumber)
.partnerRole(partnerRole) .partnerRel(partnerRel)
.person(givenPartnerPerson) .person(givenPartnerPerson)
.contact(givenContact) .contact(givenContact)
.details(HsOfficePartnerDetailsEntity.builder().build()) .details(HsOfficePartnerDetailsEntity.builder().build())

View File

@ -142,7 +142,7 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
"contactUuid": "%s" "contactUuid": "%s"
} }
""".formatted( """.formatted(
HsOfficeRelationshipTypeResource.ACCOUNTING, HsOfficeRelationshipTypeResource.DEBITOR,
givenAnchorPerson.getUuid(), givenAnchorPerson.getUuid(),
givenHolderPerson.getUuid(), givenHolderPerson.getUuid(),
givenContact.getUuid())) givenContact.getUuid()))
@ -153,7 +153,7 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
.statusCode(201) .statusCode(201)
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("relType", is("ACCOUNTING")) .body("relType", is("DEBITOR"))
.body("relAnchor.tradeName", is("Third OHG")) .body("relAnchor.tradeName", is("Third OHG"))
.body("relHolder.givenName", is("Paul")) .body("relHolder.givenName", is("Paul"))
.body("contact.label", is("second contact")) .body("contact.label", is("second contact"))
@ -186,7 +186,7 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
"contactUuid": "%s" "contactUuid": "%s"
} }
""".formatted( """.formatted(
HsOfficeRelationshipTypeResource.ACCOUNTING, HsOfficeRelationshipTypeResource.DEBITOR,
givenAnchorPersonUuid, givenAnchorPersonUuid,
givenHolderPerson.getUuid(), givenHolderPerson.getUuid(),
givenContact.getUuid())) givenContact.getUuid()))
@ -218,7 +218,7 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
"contactUuid": "%s" "contactUuid": "%s"
} }
""".formatted( """.formatted(
HsOfficeRelationshipTypeResource.ACCOUNTING, HsOfficeRelationshipTypeResource.DEBITOR,
givenAnchorPerson.getUuid(), givenAnchorPerson.getUuid(),
GIVEN_NON_EXISTING_HOLDER_PERSON_UUID, GIVEN_NON_EXISTING_HOLDER_PERSON_UUID,
givenContact.getUuid())) givenContact.getUuid()))
@ -251,7 +251,7 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
"contactUuid": "%s" "contactUuid": "%s"
} }
""".formatted( """.formatted(
HsOfficeRelationshipTypeResource.ACCOUNTING, HsOfficeRelationshipTypeResource.DEBITOR,
givenAnchorPerson.getUuid(), givenAnchorPerson.getUuid(),
givenHolderPerson.getUuid(), givenHolderPerson.getUuid(),
givenContactUuid)) givenContactUuid))