move Parter+Debitor person+contact to related Relationsship #20
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 + ")";
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
|
@ -42,6 +42,8 @@ begin
|
||||
|
||||
if TG_OP = 'INSERT' then
|
||||
|
||||
|
||||
|
||||
perform createRoleWithGrants(
|
||||
hsOfficeRelationshipOwner(NEW),
|
||||
permissions => array['*'],
|
||||
|
@ -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(
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user