move Parter+Debitor person+contact to related Relationsship #20

Merged
hsh-michaelhoennig merged 101 commits from remove-direct-partner-person-and-contact into master 2024-03-28 12:15:14 +01:00
10 changed files with 27 additions and 26 deletions
Showing only changes of commit c987cba53c - Show all commits

View File

@ -27,8 +27,8 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
public class HsOfficeBankAccountEntity implements HasUuid, Stringifyable {
private static Stringify<HsOfficeBankAccountEntity> toString = stringify(HsOfficeBankAccountEntity.class, "bankAccount")
.withIdProp(HsOfficeBankAccountEntity::getIban)
.withProp(Fields.holder, HsOfficeBankAccountEntity::getHolder)
.withProp(Fields.iban, HsOfficeBankAccountEntity::getIban)
.withProp(Fields.bic, HsOfficeBankAccountEntity::getBic);
@Id

View File

@ -30,13 +30,15 @@ public class HsOfficePartnerEntity implements Stringifyable, HasUuid {
public static final String PARTNER_NUMBER_TAG = "P-";
private static Stringify<HsOfficePartnerEntity> stringify = stringify(HsOfficePartnerEntity.class, "partner")
.withIdProp(HsOfficePartnerEntity::getPartnerNumber)
.withIdProp(HsOfficePartnerEntity::toShortString)
.withProp(p -> ofNullable(p.getPartnerRole())
.map(HsOfficeRelationshipEntity::getRelHolder)
.map(HsOfficePersonEntity::toShortString))
.map(HsOfficePersonEntity::toShortString)
.orElse(null))
.withProp(p -> ofNullable(p.getPartnerRole())
.map(HsOfficeRelationshipEntity::getContact)
.map(HsOfficeContactEntity::toShortString))
.map(HsOfficeContactEntity::toShortString)
.orElse(null))
.withSeparator(", ")
.quotedValues(false);

View File

@ -70,8 +70,8 @@ public final class Stringify<B> {
})
.map(propVal -> propName(propVal, "=") + optionallyQuoted(propVal))
.collect(Collectors.joining(separator));
return idProp == null
? name + "(" + idProp + ": " + propValues + ")"
return idProp != null
? name + "(" + idProp.apply(object) + ": " + propValues + ")"
: name + "(" + propValues + ")";
}

View File

@ -67,7 +67,7 @@ do language plpgsql $$
call createHsOfficePersonTestData('NP', null, 'Fouler', 'Ellie');
call createHsOfficePersonTestData('LP', 'Second e.K.', 'Smith', 'Peter');
call createHsOfficePersonTestData('IF', 'Third OHG');
call createHsOfficePersonTestData('IF', 'Fourth eG');
call createHsOfficePersonTestData('LP', 'Fourth eG');
call createHsOfficePersonTestData('UF', 'Erben Bessler', 'Mel', 'Bessler');
call createHsOfficePersonTestData('NP', null, 'Bessler', 'Anita');
call createHsOfficePersonTestData('NP', null, 'Winkler', 'Paul');

View File

@ -42,6 +42,8 @@ begin
if TG_OP = 'INSERT' then
perform createRoleWithGrants(
hsOfficeRelationshipOwner(NEW),
permissions => array['*'],

View File

@ -30,13 +30,7 @@ declare
oldPartnerRole hs_office_relationship;
newPartnerRole hs_office_relationship;
oldPersonX hs_office_person;
newPersonX hs_office_person;
oldContactX hs_office_contact;
newContactX hs_office_contact;
begin
select * from hs_office_relationship as r where r.uuid = NEW.partnerroleuuid into newPartnerRole;
if TG_OP = 'INSERT' then
@ -46,7 +40,9 @@ begin
perform createRoleWithGrants(
hsOfficePartnerOwner(NEW),
permissions => array['*'],
incomingSuperRoles => array[globalAdmin()]
incomingSuperRoles => array[globalAdmin()],
outgoingSubRoles => array[
hsOfficeRelationshipOwner(newPartnerRole)]
);
perform createRoleWithGrants(
@ -55,14 +51,14 @@ begin
incomingSuperRoles => array[
hsOfficePartnerOwner(NEW)],
outgoingSubRoles => array[
hsOfficeRelationshipTenant(newPartnerRole)]
hsOfficeRelationshipAdmin(newPartnerRole)]
);
perform createRoleWithGrants(
hsOfficePartnerAgent(NEW),
incomingSuperRoles => array[
hsOfficePartnerAdmin(NEW),
hsOfficeRelationshipAdmin(newPartnerRole)]
hsOfficeRelationshipAgent(newPartnerRole)]
);
perform createRoleWithGrants(

View File

@ -59,7 +59,7 @@ do language plpgsql $$
$$;
-- TODO.refa: the code below could be moved to a generator, maybe even the code above.
-- Additionally, the code below is not neccesary for all entities, specifiy when it is!
-- Additionally, the code below is not necessary for all entities, specify when it is!
/**
Used by the trigger to prevent the add-partner-details to current user respectively assumed roles.

View File

@ -19,7 +19,7 @@ class HsOfficeBankAccountEntityUnitTest {
.iban("DE02370502990000684712")
.bic("COKSDE33")
.build();
assertThat("" + givenBankAccount).isEqualTo("bankAccount(holder='given holder', iban='DE02370502990000684712', bic='COKSDE33')");
assertThat(givenBankAccount.toString()).isEqualTo("bankAccount(DE02370502990000684712: holder='given holder', bic='COKSDE33')");
}
@Test

View File

@ -519,7 +519,7 @@ public class ImportOfficeData extends ContextBasedTest {
jpaAttempt.transacted(() -> {
context(rbacSuperuser);
coopAssets.forEach(this::persist);
updateLegacyIds(coopShares, "hs_office_coopassetstransaction_legacy_id", "member_asset_id");
updateLegacyIds(coopAssets, "hs_office_coopassetstransaction_legacy_id", "member_asset_id");
}).assertSuccessful();
}

View File

@ -227,9 +227,11 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
// then
allThesePartnersAreReturned(
result,
"partner(IF Third OHG: third contact)",
"partner(LP Second e.K.: second contact)",
"partner(LP First GmbH: first contact)");
"partner(P-10001: LP First GmbH, first contact)",
"partner(P-10002: LP Second e.K., second contact)",
"partner(P-10003: IF Third OHG, third contact)",
"partner(P-10004: LP Fourth eG, fourth contact)",
"partner(P-10010: NP Smith, Peter, sixth contact)");
}
@Test
@ -241,7 +243,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
final var result = partnerRepo.findPartnerByOptionalNameLike(null);
// then:
exactlyThesePartnersAreReturned(result, "partner(LP First GmbH: first contact)");
exactlyThesePartnersAreReturned(result, "partner(P-10001: LP First GmbH: first contact)");
}
}
@ -257,7 +259,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
final var result = partnerRepo.findPartnerByOptionalNameLike("third contact");
// then
exactlyThesePartnersAreReturned(result, "partner(IF Third OHG: third contact)");
exactlyThesePartnersAreReturned(result, "partner(P-10003: IF Third OHG, third contact)");
}
}
@ -276,7 +278,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
assertThat(result)
.isNotNull()
.extracting(Object::toString)
.isEqualTo("partner(LP First GmbH: first contact)");
.isEqualTo("partner(P-10001: LP First GmbH, first contact)");
}
}
@ -317,7 +319,6 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
}
@Test
@Disabled // TODO: enable once partner.person and partner.contact are removed
public void partnerAgent_canNotUpdateRelatedPartner() {
// given
context("superuser-alex@hostsharing.net");