merging master aftermath, ImportOfficeData not fully working yet
This commit is contained in:
parent
6e663cf525
commit
37f00a19f0
@ -8,7 +8,7 @@ Vor einigen Wochen hatten wir schon einmal darüber geredet, ob wir dieses Gefle
|
|||||||
|
|
||||||
Und nun gehe ich noch einen Schritt weiter: Könnte es nicht auch andersherum sein? Also wenn jemand z.B. SELECT-Recht am Partner hat, dass wir davon ausgehen können, dass derjenige auch die Partner-Personen- und Kontaktdaten sehen darf, und zwar implizit durch seine Partner-SELECT-Permission und ohne dass er explizit Rollen für diese Partner-Personen oder Kontaktdaten inne hat?
|
Und nun gehe ich noch einen Schritt weiter: Könnte es nicht auch andersherum sein? Also wenn jemand z.B. SELECT-Recht am Partner hat, dass wir davon ausgehen können, dass derjenige auch die Partner-Personen- und Kontaktdaten sehen darf, und zwar implizit durch seine Partner-SELECT-Permission und ohne dass er explizit Rollen für diese Partner-Personen oder Kontaktdaten inne hat?
|
||||||
|
|
||||||
Im Halbschlaf kam mir nur die Idee, warum wir nicht einfach die komplexen JPA-Entitäten zwar auf die restricted View setzen, wie bisher, aber für die verknüpften Entitäten auf die direkten (bisher "Raw..." genannt) Entitäten gehen. Dann könnte jemand mit einer Rolle, welche die SELECT-Permission auf die komplexe JPA-Entität (z.B.) Partner inne hat, auch die dazugehörige Relation(ship) ["Relationship" wurde vor kurzem auf kurz "Relation" umbenannt] und die wiederum dazu gehörigen Personen- und Kontaktdaten lesen, ohne dass in einem INSERT- und UPDATE-Trigger der Partner-Entität die ganzen Grants mit den verknüpften Entäten aufgebaut und aktualisiert werden müssen.
|
Im Halbschlaf kam mir nur die Idee, warum wir nicht einfach die komplexen JPA-Entitäten zwar auf die restricted View setzen, wie bisher, aber für die verknüpften Entitäten auf die direkten (bisher "Raw..." genannt) Entitäten gehen. Dann könnte jemand mit einer Rolle, welche die SELECT-Permission auf die komplexe JPA-Entität (z.B.) Partner inne hat, auch die dazugehörige Relation(ship) ["Relation" wurde vor kurzem auf kurz "Relation" umbenannt] und die wiederum dazu gehörigen Personen- und Kontaktdaten lesen, ohne dass in einem INSERT- und UPDATE-Trigger der Partner-Entität die ganzen Grants mit den verknüpften Entäten aufgebaut und aktualisiert werden müssen.
|
||||||
|
|
||||||
Beim Debitor ist das nämlich selbst mit Generator die Hölle, zumal eben auch Querverbindungen gegranted werden müssen, z.B. von der Debitor-Person zum Sema-Mandat - jedenfalls wenn man nicht Gefahr laufen wollte, dass jemand mit Admin-Rechten an der Partner-Person (also z.B. ein Repräsentant des Partners) die Sepa-Mandate der Debitoren gar nicht mehr sehen kann. Natürlich bräuchte man immer noch die Agent-Rolle am Partner und Debitor (evtl. repräsentiert durch die jeweils zugehörigen Relation - falls dieser Trick überhaupt noch nötig wäre), sowie ein Grant vom Partner-Agent auf den Debitor-Agent und vom Debitor-Agent auf die Sepa-Mandate-Admins, aber eben ohne filigran die ganzen Neben-Entäten (Personen- und Kontaktdaten von Partner und Debitor sowie Bank-Account) in jedem Trigger berücksichtigen zu müssen. Beim Refund-Bank-Account sogar besonders ätzend, weil der optional ist und dadurch zig "if ...refundBankAccountUuid is not null then ..." im Code enstehen (wenn der auch generiert ist).
|
Beim Debitor ist das nämlich selbst mit Generator die Hölle, zumal eben auch Querverbindungen gegranted werden müssen, z.B. von der Debitor-Person zum Sema-Mandat - jedenfalls wenn man nicht Gefahr laufen wollte, dass jemand mit Admin-Rechten an der Partner-Person (also z.B. ein Repräsentant des Partners) die Sepa-Mandate der Debitoren gar nicht mehr sehen kann. Natürlich bräuchte man immer noch die Agent-Rolle am Partner und Debitor (evtl. repräsentiert durch die jeweils zugehörigen Relation - falls dieser Trick überhaupt noch nötig wäre), sowie ein Grant vom Partner-Agent auf den Debitor-Agent und vom Debitor-Agent auf die Sepa-Mandate-Admins, aber eben ohne filigran die ganzen Neben-Entäten (Personen- und Kontaktdaten von Partner und Debitor sowie Bank-Account) in jedem Trigger berücksichtigen zu müssen. Beim Refund-Bank-Account sogar besonders ätzend, weil der optional ist und dadurch zig "if ...refundBankAccountUuid is not null then ..." im Code enstehen (wenn der auch generiert ist).
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@ Das folgende Schema soll dabei unterstützen, die richtigen Permissions, Rollen
|
|||||||
|
|
||||||
An einigen Stellen ist vom *Initiator* die Rede. Als *Initiator* gilt derjenige User, der die Operation (INSERT oder UPDATE) durchführt bzw. dessen primary assumed Rol. (TODO: bisher gibt es nur assumed roles, das Konzept einer primary assumed Role müsste noch eingeführt werden, derzeit nehmen wir dafür immer den `globalAdmin()`. Bevor Kunden aber selbst Objekte anlegen können, muss das geklärt sein.)
|
An einigen Stellen ist vom *Initiator* die Rede. Als *Initiator* gilt derjenige User, der die Operation (INSERT oder UPDATE) durchführt bzw. dessen primary assumed Rol. (TODO: bisher gibt es nur assumed roles, das Konzept einer primary assumed Role müsste noch eingeführt werden, derzeit nehmen wir dafür immer den `globalAdmin()`. Bevor Kunden aber selbst Objekte anlegen können, muss das geklärt sein.)
|
||||||
|
|
||||||
#### Typ Root: Objekte, welche nur eine Spezialisierung bzw. Zusatzdaten für andere Objekte bereitstellen (z.B. Partner für Relationships vom Typ Partner oder Partner Details für Partner)
|
#### Typ Root: Objekte, welche nur eine Spezialisierung bzw. Zusatzdaten für andere Objekte bereitstellen (z.B. Partner für Relations vom Typ Partner oder Partner Details für Partner)
|
||||||
|
|
||||||
Objektorientiert gedacht, enthalten solche Objekte die Zusatzdaten einer Subklasse; die Daten im Partner erweitern also eine Relationship vom Typ `partner`.
|
Objektorientiert gedacht, enthalten solche Objekte die Zusatzdaten einer Subklasse; die Daten im Partner erweitern also eine Relation vom Typ `partner`.
|
||||||
|
|
||||||
- Dann muss dieses Objekt zeitlich nach dem Objekt erzeugt werden, auf dass es sich bezieht, also z.B. zeitlich nach der Relationship.
|
- Dann muss dieses Objekt zeitlich nach dem Objekt erzeugt werden, auf dass es sich bezieht, also z.B. zeitlich nach der Relation.
|
||||||
- Es werden Delete (\*), Edit und View Permissions für dieses Objekt erzeugt.
|
- Es werden Delete (\*), Edit und View Permissions für dieses Objekt erzeugt.
|
||||||
- Es werden **keine** Rollen für dieses Objekt erzeugt.
|
- Es werden **keine** Rollen für dieses Objekt erzeugt.
|
||||||
- Statt eigener Rollen werden die o.g. Permissions passenden Rollen des Hauptobjekts zugewiesen (granted) bzw. aus denen entfernt (revoked).
|
- Statt eigener Rollen werden die o.g. Permissions passenden Rollen des Hauptobjekts zugewiesen (granted) bzw. aus denen entfernt (revoked).
|
||||||
@ -33,7 +33,7 @@ Objektorientiert gedacht, enthalten solche Objekte die Zusatzdaten einer Subklas
|
|||||||
Anmerkung: Der Typ-Begriff *Root* bezieht sich auf die Rolle im fachlichen Datenmodell. Im Bezug auf den Teilgraphen eines fachlichen Kontexts ist dies auch eine Wurzel im Sinne der Graphentheorie. Aber in anderen fachlichen Kontexten können auch diese Objekte von anderen Teilgraphen referenziert werden und werden dann zum inneren Knoten.
|
Anmerkung: Der Typ-Begriff *Root* bezieht sich auf die Rolle im fachlichen Datenmodell. Im Bezug auf den Teilgraphen eines fachlichen Kontexts ist dies auch eine Wurzel im Sinne der Graphentheorie. Aber in anderen fachlichen Kontexten können auch diese Objekte von anderen Teilgraphen referenziert werden und werden dann zum inneren Knoten.
|
||||||
|
|
||||||
|
|
||||||
#### Typ Aggregator: Objekte, welche weitere Objekte zusammenfassen (z.B. Relationship fasst zwei Persons und einen Contact zusammen)
|
#### Typ Aggregator: Objekte, welche weitere Objekte zusammenfassen (z.B. Relation fasst zwei Persons und einen Contact zusammen)
|
||||||
|
|
||||||
Solche Objekte verweisen üblicherweise auf Objekte vom Typ Leaf und werden oft von Objekten des Typs Root referenziert.
|
Solche Objekte verweisen üblicherweise auf Objekte vom Typ Leaf und werden oft von Objekten des Typs Root referenziert.
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeDebitors
|
|||||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorInsertResource;
|
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorInsertResource;
|
||||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
||||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorResource;
|
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorResource;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipRepository;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||||
import net.hostsharing.hsadminng.mapper.Mapper;
|
import net.hostsharing.hsadminng.mapper.Mapper;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -21,7 +21,7 @@ import jakarta.persistence.PersistenceContext;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipType.ACCOUNTING;
|
import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.DEBITOR;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
|
|||||||
private HsOfficeDebitorRepository debitorRepo;
|
private HsOfficeDebitorRepository debitorRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HsOfficeRelationshipRepository relRepo;
|
private HsOfficeRelationRepository relRepo;
|
||||||
|
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
@ -73,15 +73,15 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
|
|||||||
Validate.isTrue(body.getDebitorRel() != null || body.getDebitorRelUuid() != null,
|
Validate.isTrue(body.getDebitorRel() != null || body.getDebitorRelUuid() != null,
|
||||||
"ERROR: [400] exactly one of debitorRel and debitorRelUuid must be supplied, but found none");
|
"ERROR: [400] exactly one of debitorRel and debitorRelUuid must be supplied, but found none");
|
||||||
Validate.isTrue(body.getDebitorRel() == null ||
|
Validate.isTrue(body.getDebitorRel() == null ||
|
||||||
body.getDebitorRel().getRelType() == null || ACCOUNTING.name().equals(body.getDebitorRel().getRelType()),
|
body.getDebitorRel().getType() == null || DEBITOR.name().equals(body.getDebitorRel().getType()),
|
||||||
"ERROR: [400] debitorRel.relType must be '"+ACCOUNTING.name()+"' or null for default");
|
"ERROR: [400] debitorRel.type must be '"+DEBITOR.name()+"' or null for default");
|
||||||
Validate.isTrue(body.getDebitorRel() == null || body.getDebitorRel().getRelMark() == null,
|
Validate.isTrue(body.getDebitorRel() == null || body.getDebitorRel().getMark() == null,
|
||||||
"ERROR: [400] debitorRel.relMark must be null");
|
"ERROR: [400] debitorRel.mark must be null");
|
||||||
|
|
||||||
final var entityToSave = mapper.map(body, HsOfficeDebitorEntity.class);
|
final var entityToSave = mapper.map(body, HsOfficeDebitorEntity.class);
|
||||||
if ( body.getDebitorRel() != null ) {
|
if ( body.getDebitorRel() != null ) {
|
||||||
body.getDebitorRel().setRelType(ACCOUNTING.name());
|
body.getDebitorRel().setType(DEBITOR.name());
|
||||||
final var debitorRel = mapper.map(body.getDebitorRel(), HsOfficeRelationshipEntity.class);
|
final var debitorRel = mapper.map(body.getDebitorRel(), HsOfficeRelationEntity.class);
|
||||||
entityToSave.setDebitorRel(relRepo.save(debitorRel));
|
entityToSave.setDebitorRel(relRepo.save(debitorRel));
|
||||||
// FIXME em.flush();
|
// FIXME em.flush();
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,8 +3,8 @@ package net.hostsharing.hsadminng.hs.office.debitor;
|
|||||||
import lombok.*;
|
import lombok.*;
|
||||||
import net.hostsharing.hsadminng.errors.DisplayName;
|
import net.hostsharing.hsadminng.errors.DisplayName;
|
||||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
|
||||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||||
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.persistence.HasUuid;
|
import net.hostsharing.hsadminng.persistence.HasUuid;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
|
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
|
||||||
@ -43,7 +43,7 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable {
|
|||||||
private static Stringify<HsOfficeDebitorEntity> stringify =
|
private static Stringify<HsOfficeDebitorEntity> stringify =
|
||||||
stringify(HsOfficeDebitorEntity.class, "debitor")
|
stringify(HsOfficeDebitorEntity.class, "debitor")
|
||||||
.withIdProp(HsOfficeDebitorEntity::toShortString)
|
.withIdProp(HsOfficeDebitorEntity::toShortString)
|
||||||
.withProp(e -> ofNullable(e.getDebitorRel()).map(HsOfficeRelationshipEntity::toShortString).orElse(null))
|
.withProp(e -> ofNullable(e.getDebitorRel()).map(HsOfficeRelationEntity::toShortString).orElse(null))
|
||||||
.withProp(HsOfficeDebitorEntity::getDefaultPrefix)
|
.withProp(HsOfficeDebitorEntity::getDefaultPrefix)
|
||||||
.quotedValues(false);
|
.quotedValues(false);
|
||||||
|
|
||||||
@ -60,11 +60,11 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable {
|
|||||||
(
|
(
|
||||||
SELECT DISTINCT partner.uuid
|
SELECT DISTINCT partner.uuid
|
||||||
FROM hs_office_partner partner
|
FROM hs_office_partner partner
|
||||||
JOIN hs_office_relationship dRel
|
JOIN hs_office_relation dRel
|
||||||
ON dRel.uuid = debitorreluuid AND dRel.relType = 'ACCOUNTING'
|
ON dRel.uuid = debitorreluuid AND dRel.type = 'DEBITOR'
|
||||||
JOIN hs_office_relationship pRel
|
JOIN hs_office_relation pRel
|
||||||
ON pRel.uuid = partner.partnerRoleUuid AND pRel.relType = 'PARTNER'
|
ON pRel.uuid = partner.partnerRelUuid AND pRel.type = 'PARTNER'
|
||||||
WHERE pRel.relHolderUuid = dRel.relAnchorUuid
|
WHERE pRel.holderUuid = dRel.anchorUuid
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
@NotFound(action = NotFoundAction.IGNORE)
|
@NotFound(action = NotFoundAction.IGNORE)
|
||||||
@ -75,7 +75,7 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable {
|
|||||||
|
|
||||||
@ManyToOne(cascade = CascadeType.ALL)
|
@ManyToOne(cascade = CascadeType.ALL)
|
||||||
@JoinColumn(name = "debitorreluuid", nullable = false)
|
@JoinColumn(name = "debitorreluuid", nullable = false)
|
||||||
private HsOfficeRelationshipEntity debitorRel;
|
private HsOfficeRelationEntity debitorRel;
|
||||||
|
|
||||||
@Column(name = "billable", nullable = false)
|
@Column(name = "billable", nullable = false)
|
||||||
private Boolean billable; // not a primitive because otherwise the default would be false
|
private Boolean billable; // not a primitive because otherwise the default would be false
|
||||||
@ -128,10 +128,10 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable {
|
|||||||
SELECT debitor.uuid AS uuid,
|
SELECT debitor.uuid AS uuid,
|
||||||
'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_relation partnerRel
|
||||||
ON partnerRel.uuid = partner.partnerRoleUUid AND partnerRel.relType = 'PARTNER'
|
ON partnerRel.uuid = partner.partnerRelUUid AND partnerRel.type = 'PARTNER'
|
||||||
JOIN hs_office_relationship debitorRel
|
JOIN hs_office_relation debitorRel
|
||||||
ON debitorRel.relAnchorUuid = partnerRel.relHolderUuid AND debitorRel.relType = 'ACCOUNTING'
|
ON debitorRel.anchorUuid = partnerRel.holderUuid AND debitorRel.type = 'DEBITOR'
|
||||||
WHERE debitorRel.uuid = debitor.debitorRelUuid)
|
WHERE debitorRel.uuid = debitor.debitorRelUuid)
|
||||||
|| to_char(debitorNumberSuffix, 'fm00') as idName
|
|| to_char(debitorNumberSuffix, 'fm00') as idName
|
||||||
FROM hs_office_debitor AS debitor
|
FROM hs_office_debitor AS debitor
|
||||||
@ -148,11 +148,11 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable {
|
|||||||
"defaultPrefix" /* TODO: do we want that updatable? */)
|
"defaultPrefix" /* TODO: do we want that updatable? */)
|
||||||
.toRole("global", ADMIN).grantPermission(INSERT)
|
.toRole("global", ADMIN).grantPermission(INSERT)
|
||||||
|
|
||||||
.importRootEntityAliasProxy("debitorRel", HsOfficeRelationshipEntity.class,
|
.importRootEntityAliasProxy("debitorRel", HsOfficeRelationEntity.class,
|
||||||
fetchedBySql("""
|
fetchedBySql("""
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM hs_office_relationship AS r
|
FROM hs_office_relation AS r
|
||||||
WHERE r.relType = 'ACCOUNTING' AND r.uuid = ${REF}.debitorRelUuid
|
WHERE r.type = 'DEBITOR' AND r.uuid = ${REF}.debitorRelUuid
|
||||||
"""),
|
"""),
|
||||||
dependsOnColumn("debitorRelUuid"))
|
dependsOnColumn("debitorRelUuid"))
|
||||||
.createPermission(DELETE).grantedTo("debitorRel", OWNER)
|
.createPermission(DELETE).grantedTo("debitorRel", OWNER)
|
||||||
@ -171,14 +171,14 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable {
|
|||||||
.toRole("refundBankAccount", ADMIN).grantRole("debitorRel", AGENT)
|
.toRole("refundBankAccount", ADMIN).grantRole("debitorRel", AGENT)
|
||||||
.toRole("debitorRel", AGENT).grantRole("refundBankAccount", REFERRER)
|
.toRole("debitorRel", AGENT).grantRole("refundBankAccount", REFERRER)
|
||||||
|
|
||||||
.importEntityAlias("partnerRel", HsOfficeRelationshipEntity.class,
|
.importEntityAlias("partnerRel", HsOfficeRelationEntity.class,
|
||||||
dependsOnColumn("debitorRelUuid"),
|
dependsOnColumn("debitorRelUuid"),
|
||||||
fetchedBySql("""
|
fetchedBySql("""
|
||||||
SELECT partnerRel.*
|
SELECT partnerRel.*
|
||||||
FROM hs_office_relationship AS partnerRel
|
FROM hs_office_relation AS partnerRel
|
||||||
JOIN hs_office_relationship AS debitorRel
|
JOIN hs_office_relation AS debitorRel
|
||||||
ON debitorRel.relType = 'ACCOUNTING' AND debitorRel.relAnchorUuid = partnerRel.relHolderUuid
|
ON debitorRel.type = 'DEBITOR' AND debitorRel.anchorUuid = partnerRel.holderUuid
|
||||||
WHERE partnerRel.relType = 'PARTNER'
|
WHERE partnerRel.type = 'PARTNER'
|
||||||
AND ${REF}.debitorRelUuid = debitorRel.uuid
|
AND ${REF}.debitorRelUuid = debitorRel.uuid
|
||||||
""")
|
""")
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.debitor;
|
|||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.mapper.EntityPatcher;
|
import net.hostsharing.hsadminng.mapper.EntityPatcher;
|
||||||
import net.hostsharing.hsadminng.mapper.OptionalFromJson;
|
import net.hostsharing.hsadminng.mapper.OptionalFromJson;
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ class HsOfficeDebitorEntityPatcher implements EntityPatcher<HsOfficeDebitorPatch
|
|||||||
public void apply(final HsOfficeDebitorPatchResource resource) {
|
public void apply(final HsOfficeDebitorPatchResource resource) {
|
||||||
OptionalFromJson.of(resource.getDebitorRelUuid()).ifPresent(newValue -> {
|
OptionalFromJson.of(resource.getDebitorRelUuid()).ifPresent(newValue -> {
|
||||||
verifyNotNull(newValue, "debitorRel");
|
verifyNotNull(newValue, "debitorRel");
|
||||||
entity.setDebitorRel(em.getReference(HsOfficeRelationshipEntity.class, newValue));
|
entity.setDebitorRel(em.getReference(HsOfficeRelationEntity.class, newValue));
|
||||||
});
|
});
|
||||||
Optional.ofNullable(resource.getBillable()).ifPresent(entity::setBillable);
|
Optional.ofNullable(resource.getBillable()).ifPresent(entity::setBillable);
|
||||||
OptionalFromJson.of(resource.getVatId()).ifPresent(entity::setVatId);
|
OptionalFromJson.of(resource.getVatId()).ifPresent(entity::setVatId);
|
||||||
|
@ -14,8 +14,8 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
|
|||||||
@Query("""
|
@Query("""
|
||||||
SELECT debitor FROM HsOfficeDebitorEntity debitor
|
SELECT debitor FROM HsOfficeDebitorEntity debitor
|
||||||
JOIN HsOfficePartnerEntity partner
|
JOIN HsOfficePartnerEntity partner
|
||||||
ON partner.partnerRole.relHolder = debitor.debitorRel.relAnchor
|
ON partner.partnerRel.holder = debitor.debitorRel.anchor
|
||||||
AND partner.partnerRole.relType = 'PARTNER' AND debitor.debitorRel.relType = 'ACCOUNTING'
|
AND partner.partnerRel.type = 'PARTNER' AND debitor.debitorRel.type = 'DEBITOR'
|
||||||
WHERE cast(partner.partnerNumber as integer) = :partnerNumber
|
WHERE cast(partner.partnerNumber as integer) = :partnerNumber
|
||||||
AND cast(debitor.debitorNumberSuffix as integer) = :debitorNumberSuffix
|
AND cast(debitor.debitorNumberSuffix as integer) = :debitorNumberSuffix
|
||||||
""")
|
""")
|
||||||
@ -28,14 +28,14 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
|
|||||||
@Query("""
|
@Query("""
|
||||||
SELECT debitor FROM HsOfficeDebitorEntity debitor
|
SELECT debitor FROM HsOfficeDebitorEntity debitor
|
||||||
JOIN HsOfficePartnerEntity partner
|
JOIN HsOfficePartnerEntity partner
|
||||||
ON partner.partnerRole.relHolder = debitor.debitorRel.relAnchor
|
ON partner.partnerRel.holder = debitor.debitorRel.anchor
|
||||||
AND partner.partnerRole.relType = 'PARTNER' AND debitor.debitorRel.relType = 'ACCOUNTING'
|
AND partner.partnerRel.type = 'PARTNER' AND debitor.debitorRel.type = 'DEBITOR'
|
||||||
JOIN HsOfficePersonEntity person
|
JOIN HsOfficePersonEntity person
|
||||||
ON person.uuid = partner.partnerRole.relHolder.uuid
|
ON person.uuid = partner.partnerRel.holder.uuid
|
||||||
OR person.uuid = debitor.debitorRel.relHolder.uuid
|
OR person.uuid = debitor.debitorRel.holder.uuid
|
||||||
JOIN HsOfficeContactEntity contact
|
JOIN HsOfficeContactEntity contact
|
||||||
ON contact.uuid = debitor.debitorRel.contact.uuid
|
ON contact.uuid = debitor.debitorRel.contact.uuid
|
||||||
OR contact.uuid = partner.partnerRole.contact.uuid
|
OR contact.uuid = partner.partnerRel.contact.uuid
|
||||||
WHERE :name is null
|
WHERE :name is null
|
||||||
OR partner.details.birthName like concat(cast(:name as text), '%')
|
OR partner.details.birthName like concat(cast(:name as text), '%')
|
||||||
OR person.tradeName like concat(cast(:name as text), '%')
|
OR person.tradeName like concat(cast(:name as text), '%')
|
||||||
|
@ -4,7 +4,7 @@ import com.vladmihalcea.hibernate.type.range.PostgreSQLRangeType;
|
|||||||
import com.vladmihalcea.hibernate.type.range.Range;
|
import com.vladmihalcea.hibernate.type.range.Range;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import net.hostsharing.hsadminng.errors.DisplayName;
|
import net.hostsharing.hsadminng.errors.DisplayName;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.persistence.HasUuid;
|
import net.hostsharing.hsadminng.persistence.HasUuid;
|
||||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||||
@ -128,12 +128,12 @@ public class HsOfficeMembershipEntity implements HasUuid, Stringifyable {
|
|||||||
.withRestrictedViewOrderBy(SQL.projection("validity"))
|
.withRestrictedViewOrderBy(SQL.projection("validity"))
|
||||||
.withUpdatableColumns("validity", "membershipFeeBillable", "reasonForTermination")
|
.withUpdatableColumns("validity", "membershipFeeBillable", "reasonForTermination")
|
||||||
|
|
||||||
.importEntityAlias("partnerRel", HsOfficeRelationshipEntity.class,
|
.importEntityAlias("partnerRel", HsOfficeRelationEntity.class,
|
||||||
dependsOnColumn("partnerUuid"),
|
dependsOnColumn("partnerUuid"),
|
||||||
fetchedBySql("""
|
fetchedBySql("""
|
||||||
SELECT r.*
|
SELECT r.*
|
||||||
FROM hs_office_partner AS p
|
FROM hs_office_partner AS p
|
||||||
JOIN hs_office_relationship AS r ON r.uuid = p.partnerRoleUuid
|
JOIN hs_office_relation AS r ON r.uuid = p.partnerRelUuid
|
||||||
WHERE p.uuid = ${REF}.partnerUuid
|
WHERE p.uuid = ${REF}.partnerUuid
|
||||||
"""))
|
"""))
|
||||||
.toRole("partnerRel", ADMIN).grantPermission(INSERT)
|
.toRole("partnerRel", ADMIN).grantPermission(INSERT)
|
||||||
|
@ -7,11 +7,11 @@ 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.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipRepository;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipType;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||||
import net.hostsharing.hsadminng.mapper.Mapper;
|
import net.hostsharing.hsadminng.mapper.Mapper;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -40,7 +40,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
|
|||||||
private HsOfficePartnerRepository partnerRepo;
|
private HsOfficePartnerRepository partnerRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HsOfficeRelationshipRepository relationshipRepo;
|
private HsOfficeRelationRepository relationRepo;
|
||||||
|
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
@ -139,16 +139,16 @@ 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.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 HsOfficeRelationEntity persistPartnerRel(final HsOfficePartnerRelInsertResource resource) {
|
||||||
final var entity = new HsOfficeRelationshipEntity();
|
final var entity = new HsOfficeRelationEntity();
|
||||||
entity.setRelType(HsOfficeRelationshipType.PARTNER);
|
entity.setType(HsOfficeRelationType.PARTNER);
|
||||||
entity.setRelAnchor(ref(HsOfficePersonEntity.class, resource.getRelAnchorUuid()));
|
entity.setAnchor(ref(HsOfficePersonEntity.class, resource.getAnchorUuid()));
|
||||||
entity.setRelHolder(ref(HsOfficePersonEntity.class, resource.getRelHolderUuid()));
|
entity.setHolder(ref(HsOfficePersonEntity.class, resource.getHolderUuid()));
|
||||||
entity.setContact(ref(HsOfficeContactEntity.class, resource.getContactUuid()));
|
entity.setContact(ref(HsOfficeContactEntity.class, resource.getContactUuid()));
|
||||||
em.persist(entity);
|
em.persist(entity);
|
||||||
return entity;
|
return entity;
|
||||||
|
@ -9,7 +9,7 @@ import net.hostsharing.hsadminng.errors.DisplayName;
|
|||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||||
import net.hostsharing.hsadminng.persistence.HasUuid;
|
import net.hostsharing.hsadminng.persistence.HasUuid;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
|
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
|
||||||
import net.hostsharing.hsadminng.stringify.Stringify;
|
import net.hostsharing.hsadminng.stringify.Stringify;
|
||||||
@ -51,12 +51,12 @@ public class HsOfficePartnerEntity implements Stringifyable, HasUuid {
|
|||||||
|
|
||||||
private static Stringify<HsOfficePartnerEntity> stringify = stringify(HsOfficePartnerEntity.class, "partner")
|
private static Stringify<HsOfficePartnerEntity> stringify = stringify(HsOfficePartnerEntity.class, "partner")
|
||||||
.withIdProp(HsOfficePartnerEntity::toShortString)
|
.withIdProp(HsOfficePartnerEntity::toShortString)
|
||||||
.withProp(p -> ofNullable(p.getPartnerRole())
|
.withProp(p -> ofNullable(p.getPartnerRel())
|
||||||
.map(HsOfficeRelationshipEntity::getRelHolder)
|
.map(HsOfficeRelationEntity::getHolder)
|
||||||
.map(HsOfficePersonEntity::toShortString)
|
.map(HsOfficePersonEntity::toShortString)
|
||||||
.orElse(null))
|
.orElse(null))
|
||||||
.withProp(p -> ofNullable(p.getPartnerRole())
|
.withProp(p -> ofNullable(p.getPartnerRel())
|
||||||
.map(HsOfficeRelationshipEntity::getContact)
|
.map(HsOfficeRelationEntity::getContact)
|
||||||
.map(HsOfficeContactEntity::toShortString)
|
.map(HsOfficeContactEntity::toShortString)
|
||||||
.orElse(null))
|
.orElse(null))
|
||||||
.quotedValues(false);
|
.quotedValues(false);
|
||||||
@ -69,8 +69,8 @@ public class HsOfficePartnerEntity implements Stringifyable, HasUuid {
|
|||||||
private Integer partnerNumber;
|
private Integer partnerNumber;
|
||||||
|
|
||||||
@ManyToOne(cascade = CascadeType.ALL)
|
@ManyToOne(cascade = CascadeType.ALL)
|
||||||
@JoinColumn(name = "partnerroleuuid", nullable = false)
|
@JoinColumn(name = "partnerReluuid", nullable = false)
|
||||||
private HsOfficeRelationshipEntity partnerRole;
|
private HsOfficeRelationEntity partnerRel;
|
||||||
|
|
||||||
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.DETACH }, optional = true)
|
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.DETACH }, optional = true)
|
||||||
@JoinColumn(name = "detailsuuid")
|
@JoinColumn(name = "detailsuuid")
|
||||||
@ -94,12 +94,12 @@ public class HsOfficePartnerEntity implements Stringifyable, HasUuid {
|
|||||||
public static RbacView rbac() {
|
public static RbacView rbac() {
|
||||||
return rbacViewFor("partner", HsOfficePartnerEntity.class)
|
return rbacViewFor("partner", HsOfficePartnerEntity.class)
|
||||||
.withIdentityView(SQL.projection("'P-' || partnerNumber"))
|
.withIdentityView(SQL.projection("'P-' || partnerNumber"))
|
||||||
.withUpdatableColumns("partnerRoleUuid")
|
.withUpdatableColumns("partnerRelUuid")
|
||||||
.toRole("global", ADMIN).grantPermission(INSERT) // FIXME: global -> partnerRel.relAnchor?
|
.toRole("global", ADMIN).grantPermission(INSERT) // FIXME: global -> partnerRel.anchor?
|
||||||
|
|
||||||
.importRootEntityAliasProxy("partnerRel", HsOfficeRelationshipEntity.class,
|
.importRootEntityAliasProxy("partnerRel", HsOfficeRelationEntity.class,
|
||||||
fetchedBySql("SELECT * FROM hs_office_relationship AS r WHERE r.uuid = ${ref}.partnerRoleUuid"),
|
fetchedBySql("SELECT * FROM hs_office_relation AS r WHERE r.uuid = ${ref}.partnerRelUuid"),
|
||||||
dependsOnColumn("partnerRoleUuid"))
|
dependsOnColumn("partnerRelUuid"))
|
||||||
.createPermission(DELETE).grantedTo("partnerRel", ADMIN)
|
.createPermission(DELETE).grantedTo("partnerRel", ADMIN)
|
||||||
.createPermission(UPDATE).grantedTo("partnerRel", AGENT)
|
.createPermission(UPDATE).grantedTo("partnerRel", AGENT)
|
||||||
.createPermission(SELECT).grantedTo("partnerRel", TENANT)
|
.createPermission(SELECT).grantedTo("partnerRel", TENANT)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.partner;
|
package net.hostsharing.hsadminng.hs.office.partner;
|
||||||
|
|
||||||
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.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.mapper.EntityPatcher;
|
import net.hostsharing.hsadminng.mapper.EntityPatcher;
|
||||||
import net.hostsharing.hsadminng.mapper.OptionalFromJson;
|
import net.hostsharing.hsadminng.mapper.OptionalFromJson;
|
||||||
|
|
||||||
@ -19,9 +19,9 @@ class HsOfficePartnerEntityPatcher implements EntityPatcher<HsOfficePartnerPatch
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(final HsOfficePartnerPatchResource resource) {
|
public void apply(final HsOfficePartnerPatchResource resource) {
|
||||||
OptionalFromJson.of(resource.getPartnerRoleUuid()).ifPresent(newValue -> {
|
OptionalFromJson.of(resource.getPartnerRelUuid()).ifPresent(newValue -> {
|
||||||
verifyNotNull(newValue, "partnerRole");
|
verifyNotNull(newValue, "partnerRel");
|
||||||
entity.setPartnerRole(em.getReference(HsOfficeRelationshipEntity.class, newValue));
|
entity.setPartnerRel(em.getReference(HsOfficeRelationEntity.class, newValue));
|
||||||
});
|
});
|
||||||
|
|
||||||
new HsOfficePartnerDetailsEntityPatcher(em, entity.getDetails()).apply(resource.getDetails());
|
new HsOfficePartnerDetailsEntityPatcher(em, entity.getDetails()).apply(resource.getDetails());
|
||||||
|
@ -15,9 +15,9 @@ public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEnt
|
|||||||
|
|
||||||
@Query("""
|
@Query("""
|
||||||
SELECT partner FROM HsOfficePartnerEntity partner
|
SELECT partner FROM HsOfficePartnerEntity partner
|
||||||
JOIN HsOfficeRelationshipEntity rel ON rel.uuid = partner.partnerRole.uuid
|
JOIN HsOfficeRelationEntity rel ON rel.uuid = partner.partnerRel.uuid
|
||||||
JOIN HsOfficeContactEntity contact ON contact.uuid = rel.contact.uuid
|
JOIN HsOfficeContactEntity contact ON contact.uuid = rel.contact.uuid
|
||||||
JOIN HsOfficePersonEntity person ON person.uuid = rel.relHolder.uuid
|
JOIN HsOfficePersonEntity person ON person.uuid = rel.holder.uuid
|
||||||
WHERE :name is null
|
WHERE :name is null
|
||||||
OR partner.details.birthName like concat(cast(:name as text), '%')
|
OR partner.details.birthName like concat(cast(:name as text), '%')
|
||||||
OR contact.label like concat(cast(:name as text), '%')
|
OR contact.label like concat(cast(:name as text), '%')
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.relationship;
|
package net.hostsharing.hsadminng.hs.office.relation;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.FieldNameConstants;
|
import lombok.experimental.FieldNameConstants;
|
||||||
@ -24,49 +24,49 @@ import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.rbacViewFor;
|
|||||||
import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
|
import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "hs_office_relationship_rv")
|
@Table(name = "hs_office_relation_rv")
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@FieldNameConstants
|
@FieldNameConstants
|
||||||
public class HsOfficeRelationshipEntity implements HasUuid, Stringifyable {
|
public class HsOfficeRelationEntity implements HasUuid, Stringifyable {
|
||||||
|
|
||||||
private static Stringify<HsOfficeRelationshipEntity> toString = stringify(HsOfficeRelationshipEntity.class, "rel")
|
private static Stringify<HsOfficeRelationEntity> toString = stringify(HsOfficeRelationEntity.class, "rel")
|
||||||
.withProp(Fields.relAnchor, HsOfficeRelationshipEntity::getRelAnchor)
|
.withProp(Fields.anchor, HsOfficeRelationEntity::getAnchor)
|
||||||
.withProp(Fields.relType, HsOfficeRelationshipEntity::getRelType)
|
.withProp(Fields.type, HsOfficeRelationEntity::getType)
|
||||||
.withProp(Fields.relMark, HsOfficeRelationshipEntity::getRelMark)
|
.withProp(Fields.mark, HsOfficeRelationEntity::getMark)
|
||||||
.withProp(Fields.relHolder, HsOfficeRelationshipEntity::getRelHolder)
|
.withProp(Fields.holder, HsOfficeRelationEntity::getHolder)
|
||||||
.withProp(Fields.contact, HsOfficeRelationshipEntity::getContact);
|
.withProp(Fields.contact, HsOfficeRelationEntity::getContact);
|
||||||
|
|
||||||
private static Stringify<HsOfficeRelationshipEntity> toShortString = stringify(HsOfficeRelationshipEntity.class, "rel")
|
private static Stringify<HsOfficeRelationEntity> toShortString = stringify(HsOfficeRelationEntity.class, "rel")
|
||||||
.withProp(Fields.relAnchor, HsOfficeRelationshipEntity::getRelAnchor)
|
.withProp(Fields.anchor, HsOfficeRelationEntity::getAnchor)
|
||||||
.withProp(Fields.relType, HsOfficeRelationshipEntity::getRelType)
|
.withProp(Fields.type, HsOfficeRelationEntity::getType)
|
||||||
.withProp(Fields.relHolder, HsOfficeRelationshipEntity::getRelHolder);
|
.withProp(Fields.holder, HsOfficeRelationEntity::getHolder);
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "relanchoruuid")
|
@JoinColumn(name = "anchoruuid")
|
||||||
private HsOfficePersonEntity relAnchor;
|
private HsOfficePersonEntity anchor;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "relholderuuid")
|
@JoinColumn(name = "holderuuid")
|
||||||
private HsOfficePersonEntity relHolder;
|
private HsOfficePersonEntity holder;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "contactuuid")
|
@JoinColumn(name = "contactuuid")
|
||||||
private HsOfficeContactEntity contact;
|
private HsOfficeContactEntity contact;
|
||||||
|
|
||||||
@Column(name = "reltype")
|
@Column(name = "type")
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private HsOfficeRelationshipType relType;
|
private HsOfficeRelationType type;
|
||||||
|
|
||||||
@Column(name = "relmark")
|
@Column(name = "mark")
|
||||||
private String relMark;
|
private String mark;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@ -79,22 +79,22 @@ public class HsOfficeRelationshipEntity implements HasUuid, Stringifyable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static RbacView rbac() {
|
public static RbacView rbac() {
|
||||||
return rbacViewFor("relationship", HsOfficeRelationshipEntity.class)
|
return rbacViewFor("relation", HsOfficeRelationEntity.class)
|
||||||
.withIdentityView(SQL.projection("""
|
.withIdentityView(SQL.projection("""
|
||||||
(select idName from hs_office_person_iv p where p.uuid = relAnchorUuid)
|
(select idName from hs_office_person_iv p where p.uuid = anchorUuid)
|
||||||
|| '-with-' || target.relType || '-'
|
|| '-with-' || target.type || '-'
|
||||||
|| (select idName from hs_office_person_iv p where p.uuid = relHolderUuid)
|
|| (select idName from hs_office_person_iv p where p.uuid = holderUuid)
|
||||||
"""))
|
"""))
|
||||||
.withRestrictedViewOrderBy(SQL.expression(
|
.withRestrictedViewOrderBy(SQL.expression(
|
||||||
"(select idName from hs_office_person_iv p where p.uuid = target.relHolderUuid)"))
|
"(select idName from hs_office_person_iv p where p.uuid = target.holderUuid)"))
|
||||||
.withUpdatableColumns("contactUuid")
|
.withUpdatableColumns("contactUuid")
|
||||||
.importEntityAlias("anchorPerson", HsOfficePersonEntity.class,
|
.importEntityAlias("anchorPerson", HsOfficePersonEntity.class,
|
||||||
dependsOnColumn("relAnchorUuid"),
|
dependsOnColumn("anchorUuid"),
|
||||||
fetchedBySql("select * from hs_office_person as p where p.uuid = ${REF}.relAnchorUuid")
|
fetchedBySql("select * from hs_office_person as p where p.uuid = ${REF}.anchorUuid")
|
||||||
)
|
)
|
||||||
.importEntityAlias("holderPerson", HsOfficePersonEntity.class,
|
.importEntityAlias("holderPerson", HsOfficePersonEntity.class,
|
||||||
dependsOnColumn("relHolderUuid"),
|
dependsOnColumn("holderUuid"),
|
||||||
fetchedBySql("select * from hs_office_person as p where p.uuid = ${REF}.relHolderUuid")
|
fetchedBySql("select * from hs_office_person as p where p.uuid = ${REF}.holderUuid")
|
||||||
)
|
)
|
||||||
.importEntityAlias("contact", HsOfficeContactEntity.class,
|
.importEntityAlias("contact", HsOfficeContactEntity.class,
|
||||||
dependsOnColumn("contactUuid"),
|
dependsOnColumn("contactUuid"),
|
||||||
@ -129,6 +129,6 @@ public class HsOfficeRelationshipEntity implements HasUuid, Stringifyable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
rbac().generateWithBaseFileName("223-hs-office-relationship-rbac");
|
rbac().generateWithBaseFileName("223-hs-office-relation-rbac");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import lombok.*;
|
|||||||
import net.hostsharing.hsadminng.errors.DisplayName;
|
import net.hostsharing.hsadminng.errors.DisplayName;
|
||||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
|
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.persistence.HasUuid;
|
import net.hostsharing.hsadminng.persistence.HasUuid;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||||
import net.hostsharing.hsadminng.stringify.Stringify;
|
import net.hostsharing.hsadminng.stringify.Stringify;
|
||||||
@ -103,11 +103,11 @@ public class HsOfficeSepaMandateEntity implements Stringifyable, HasUuid {
|
|||||||
.withRestrictedViewOrderBy(expression("validity"))
|
.withRestrictedViewOrderBy(expression("validity"))
|
||||||
.withUpdatableColumns("reference", "agreement", "validity")
|
.withUpdatableColumns("reference", "agreement", "validity")
|
||||||
|
|
||||||
.importEntityAlias("debitorRel", HsOfficeRelationshipEntity.class,
|
.importEntityAlias("debitorRel", HsOfficeRelationEntity.class,
|
||||||
dependsOnColumn("debitorUuid"),
|
dependsOnColumn("debitorUuid"),
|
||||||
fetchedBySql("""
|
fetchedBySql("""
|
||||||
SELECT debitorRel.*
|
SELECT debitorRel.*
|
||||||
FROM hs_office_relationship debitorRel
|
FROM hs_office_relation debitorRel
|
||||||
JOIN hs_office_debitor debitor ON debitor.debitorRelUuid = debitorRel.uuid
|
JOIN hs_office_debitor debitor ON debitor.debitorRelUuid = debitorRel.uuid
|
||||||
WHERE debitor.uuid = ${REF}.debitorUuid
|
WHERE debitor.uuid = ${REF}.debitorUuid
|
||||||
""")
|
""")
|
||||||
|
@ -10,7 +10,7 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
debitorRel:
|
debitorRel:
|
||||||
$ref: './hs-office-relationship-schemas.yaml#/components/schemas/HsOfficeRelationship'
|
$ref: './hs-office-relation-schemas.yaml#/components/schemas/HsOfficeRelation'
|
||||||
debitorNumber:
|
debitorNumber:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
@ -76,7 +76,7 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
debitorRel:
|
debitorRel:
|
||||||
$ref: './hs-office-relationship-schemas.yaml#/components/schemas/HsOfficeRelationshipInsert'
|
$ref: './hs-office-relation-schemas.yaml#/components/schemas/HsOfficeRelationInsert'
|
||||||
debitorRelUuid:
|
debitorRelUuid:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
|
@ -14,8 +14,8 @@ components:
|
|||||||
format: int8
|
format: int8
|
||||||
minimum: 10000
|
minimum: 10000
|
||||||
maximum: 99999
|
maximum: 99999
|
||||||
partnerRole:
|
partnerRel:
|
||||||
$ref: './hs-office-relationship-schemas.yaml#/components/schemas/HsOfficeRelationship'
|
$ref: './hs-office-relation-schemas.yaml#/components/schemas/HsOfficeRelation'
|
||||||
details:
|
details:
|
||||||
$ref: '#/components/schemas/HsOfficePartnerDetails'
|
$ref: '#/components/schemas/HsOfficePartnerDetails'
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ components:
|
|||||||
HsOfficePartnerPatch:
|
HsOfficePartnerPatch:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
partnerRoleUuid:
|
partnerRelUuid:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
nullable: true
|
nullable: true
|
||||||
@ -90,31 +90,31 @@ components:
|
|||||||
format: int8
|
format: int8
|
||||||
minimum: 10000
|
minimum: 10000
|
||||||
maximum: 99999
|
maximum: 99999
|
||||||
partnerRole:
|
partnerRel:
|
||||||
$ref: '#/components/schemas/HsOfficePartnerRoleInsert'
|
$ref: '#/components/schemas/HsOfficePartnerRelInsert'
|
||||||
details:
|
details:
|
||||||
$ref: '#/components/schemas/HsOfficePartnerDetailsInsert'
|
$ref: '#/components/schemas/HsOfficePartnerDetailsInsert'
|
||||||
required:
|
required:
|
||||||
- partnerNumber
|
- partnerNumber
|
||||||
- partnerRole
|
- partnerRel
|
||||||
- details
|
- details
|
||||||
|
|
||||||
HsOfficePartnerRoleInsert:
|
HsOfficePartnerRelInsert:
|
||||||
type: object
|
type: object
|
||||||
nullable: false
|
nullable: false
|
||||||
properties:
|
properties:
|
||||||
relAnchorUuid:
|
anchorUuid:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
relHolderUuid:
|
holderUuid:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
contactUuid:
|
contactUuid:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
required:
|
required:
|
||||||
- relAnchorUuid
|
- anchorUuid
|
||||||
- relHolderUuid
|
- holderUuid
|
||||||
- relContactUuid
|
- relContactUuid
|
||||||
|
|
||||||
HsOfficePartnerDetailsInsert:
|
HsOfficePartnerDetailsInsert:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
--liquibase formatted sql
|
--liquibase formatted sql
|
||||||
-- This code generated was by RbacViewPostgresGenerator at 2024-03-11T11:29:11.625353859.
|
-- This code generated was by RbacViewPostgresGenerator at 2024-03-22T12:01:44.554331877.
|
||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset test-package-rbac-OBJECT:1 endDelimiter:--//
|
--changeset test-package-rbac-OBJECT:1 endDelimiter:--//
|
||||||
@ -33,9 +34,12 @@ declare
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
call enterTriggerForObjectUuid(NEW.uuid);
|
call enterTriggerForObjectUuid(NEW.uuid);
|
||||||
|
|
||||||
SELECT * FROM test_customer c
|
SELECT * FROM test_customer c
|
||||||
WHERE c.uuid= NEW.customerUuid
|
WHERE c.uuid= NEW.customerUuid
|
||||||
into newCustomer;
|
INTO newCustomer;
|
||||||
|
assert newCustomer.uuid is not null, format('newCustomer must not be null for NEW.customerUuid = %s', NEW.customerUuid);
|
||||||
|
|
||||||
|
|
||||||
perform createRoleWithGrants(
|
perform createRoleWithGrants(
|
||||||
testPackageOwner(NEW),
|
testPackageOwner(NEW),
|
||||||
@ -75,9 +79,9 @@ create trigger insertTriggerForTestPackage_tg
|
|||||||
after insert on test_package
|
after insert on test_package
|
||||||
for each row
|
for each row
|
||||||
execute procedure insertTriggerForTestPackage_tf();
|
execute procedure insertTriggerForTestPackage_tf();
|
||||||
|
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset test-package-rbac-update-trigger:1 endDelimiter:--//
|
--changeset test-package-rbac-update-trigger:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
@ -101,14 +105,18 @@ begin
|
|||||||
|
|
||||||
SELECT * FROM test_customer c
|
SELECT * FROM test_customer c
|
||||||
WHERE c.uuid= OLD.customerUuid
|
WHERE c.uuid= OLD.customerUuid
|
||||||
into oldCustomer;
|
INTO oldCustomer;
|
||||||
|
assert oldCustomer.uuid is not null, format('oldCustomer must not be null for OLD.customerUuid = %s', OLD.customerUuid);
|
||||||
|
|
||||||
SELECT * FROM test_customer c
|
SELECT * FROM test_customer c
|
||||||
WHERE c.uuid= NEW.customerUuid
|
WHERE c.uuid= NEW.customerUuid
|
||||||
into newCustomer;
|
INTO newCustomer;
|
||||||
|
assert newCustomer.uuid is not null, format('newCustomer must not be null for NEW.customerUuid = %s', NEW.customerUuid);
|
||||||
|
|
||||||
|
|
||||||
if NEW.customerUuid <> OLD.customerUuid then
|
if NEW.customerUuid <> OLD.customerUuid then
|
||||||
|
|
||||||
call revokePermissionFromRole(findPermissionId(OLD.uuid, 'INSERT'), testCustomerAdmin(oldCustomer));
|
call revokePermissionFromRole(getPermissionId(OLD.uuid, 'INSERT'), testCustomerAdmin(oldCustomer));
|
||||||
|
|
||||||
call revokeRoleFromRole(testPackageOwner(OLD), testCustomerAdmin(oldCustomer));
|
call revokeRoleFromRole(testPackageOwner(OLD), testCustomerAdmin(oldCustomer));
|
||||||
call grantRoleToRole(testPackageOwner(NEW), testCustomerAdmin(newCustomer));
|
call grantRoleToRole(testPackageOwner(NEW), testCustomerAdmin(newCustomer));
|
||||||
@ -138,9 +146,9 @@ create trigger updateTriggerForTestPackage_tg
|
|||||||
after update on test_package
|
after update on test_package
|
||||||
for each row
|
for each row
|
||||||
execute procedure updateTriggerForTestPackage_tf();
|
execute procedure updateTriggerForTestPackage_tf();
|
||||||
|
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset test-package-rbac-INSERT:1 endDelimiter:--//
|
--changeset test-package-rbac-INSERT:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
@ -179,29 +187,43 @@ begin
|
|||||||
return NEW;
|
return NEW;
|
||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
|
-- z_... is to put it at the end of after insert triggers, to make sure the roles exist
|
||||||
create trigger z_test_package_test_customer_insert_tg
|
create trigger z_test_package_test_customer_insert_tg
|
||||||
after insert on test_customer
|
after insert on test_customer
|
||||||
for each row
|
for each row
|
||||||
execute procedure test_package_test_customer_insert_tf();
|
execute procedure test_package_test_customer_insert_tf();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Checks if the user or assumed roles are allowed to insert a row to test_package.
|
Checks if the user or assumed roles are allowed to insert a row to test_package,
|
||||||
|
where the check is performed by an indirect role.
|
||||||
|
|
||||||
|
An indirect role is a role FIXME.
|
||||||
*/
|
*/
|
||||||
create or replace function test_package_insert_permission_missing_tf()
|
create or replace function test_package_insert_permission_missing_tf()
|
||||||
returns trigger
|
returns trigger
|
||||||
language plpgsql as $$
|
language plpgsql as $$
|
||||||
begin
|
begin
|
||||||
raise exception '[403] insert into test_package not allowed for current subjects % (%)',
|
if ( not hasInsertPermission(
|
||||||
currentSubjects(), currentSubjectsUuids();
|
( SELECT customer.uuid FROM
|
||||||
|
|
||||||
|
(SELECT * FROM test_customer c
|
||||||
|
WHERE c.uuid= NEW.customerUuid
|
||||||
|
) AS customer
|
||||||
|
|
||||||
|
), 'INSERT', 'test_package') ) then
|
||||||
|
raise exception
|
||||||
|
'[403] insert into test_package not allowed for current subjects % (%)',
|
||||||
|
currentSubjects(), currentSubjectsUuids();
|
||||||
|
end if;
|
||||||
|
return NEW;
|
||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
create trigger test_package_insert_permission_check_tg
|
create trigger test_package_insert_permission_check_tg
|
||||||
before insert on test_package
|
before insert on test_package
|
||||||
for each row
|
for each row
|
||||||
when ( not hasInsertPermission(NEW.customerUuid, 'INSERT', 'test_package') )
|
|
||||||
execute procedure test_package_insert_permission_missing_tf();
|
execute procedure test_package_insert_permission_missing_tf();
|
||||||
|
|
||||||
--//
|
--//
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset test-package-rbac-IDENTITY-VIEW:1 endDelimiter:--//
|
--changeset test-package-rbac-IDENTITY-VIEW:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
@ -209,13 +231,15 @@ create trigger test_package_insert_permission_check_tg
|
|||||||
call generateRbacIdentityViewFromProjection('test_package', $idName$
|
call generateRbacIdentityViewFromProjection('test_package', $idName$
|
||||||
name
|
name
|
||||||
$idName$);
|
$idName$);
|
||||||
|
|
||||||
--//
|
--//
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset test-package-rbac-RESTRICTED-VIEW:1 endDelimiter:--//
|
--changeset test-package-rbac-RESTRICTED-VIEW:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
call generateRbacRestrictedView('test_package',
|
call generateRbacRestrictedView('test_package',
|
||||||
'name',
|
$orderBy$
|
||||||
|
name
|
||||||
|
$orderBy$,
|
||||||
$updates$
|
$updates$
|
||||||
version = new.version,
|
version = new.version,
|
||||||
customerUuid = new.customerUuid,
|
customerUuid = new.customerUuid,
|
||||||
@ -223,4 +247,3 @@ call generateRbacRestrictedView('test_package',
|
|||||||
$updates$);
|
$updates$);
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
### rbac relationship
|
### rbac relation
|
||||||
|
|
||||||
This code generated was by RbacViewMermaidFlowchartGenerator at 2024-03-15T17:17:00.854621634.
|
This code generated was by RbacViewMermaidFlowchartGenerator at 2024-03-15T17:17:00.854621634.
|
||||||
|
|
||||||
@ -45,31 +45,31 @@ subgraph contact["`**contact**`"]
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
subgraph relationship["`**relationship**`"]
|
subgraph relation["`**relation**`"]
|
||||||
direction TB
|
direction TB
|
||||||
style relationship fill:#dd4901,stroke:#274d6e,stroke-width:8px
|
style relation fill:#dd4901,stroke:#274d6e,stroke-width:8px
|
||||||
|
|
||||||
subgraph relationship:roles[ ]
|
subgraph relation:roles[ ]
|
||||||
style relationship:roles fill:#dd4901,stroke:white
|
style relation:roles fill:#dd4901,stroke:white
|
||||||
|
|
||||||
role:relationship:owner[[relationship:owner]]
|
role:relation:owner[[relation:owner]]
|
||||||
role:relationship:admin[[relationship:admin]]
|
role:relation:admin[[relation:admin]]
|
||||||
role:relationship:agent[[relationship:agent]]
|
role:relation:agent[[relation:agent]]
|
||||||
role:relationship:tenant[[relationship:tenant]]
|
role:relation:tenant[[relation:tenant]]
|
||||||
end
|
end
|
||||||
|
|
||||||
subgraph relationship:permissions[ ]
|
subgraph relation:permissions[ ]
|
||||||
style relationship:permissions fill:#dd4901,stroke:white
|
style relation:permissions fill:#dd4901,stroke:white
|
||||||
|
|
||||||
perm:relationship:DELETE{{relationship:DELETE}}
|
perm:relation:DELETE{{relation:DELETE}}
|
||||||
perm:relationship:UPDATE{{relationship:UPDATE}}
|
perm:relation:UPDATE{{relation:UPDATE}}
|
||||||
perm:relationship:SELECT{{relationship:SELECT}}
|
perm:relation:SELECT{{relation:SELECT}}
|
||||||
perm:relationship:INSERT{{relationship:INSERT}}
|
perm:relation:INSERT{{relation:INSERT}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%% granting roles to users
|
%% granting roles to users
|
||||||
user:creator ==> role:relationship:owner
|
user:creator ==> role:relation:owner
|
||||||
|
|
||||||
%% granting roles to roles
|
%% granting roles to roles
|
||||||
role:global:admin -.-> role:anchorPerson:owner
|
role:global:admin -.-> role:anchorPerson:owner
|
||||||
@ -81,22 +81,22 @@ role:holderPerson:admin -.-> role:holderPerson:referrer
|
|||||||
role:global:admin -.-> role:contact:owner
|
role:global:admin -.-> role:contact:owner
|
||||||
role:contact:owner -.-> role:contact:admin
|
role:contact:owner -.-> role:contact:admin
|
||||||
role:contact:admin -.-> role:contact:referrer
|
role:contact:admin -.-> role:contact:referrer
|
||||||
role:global:admin ==> role:relationship:owner
|
role:global:admin ==> role:relation:owner
|
||||||
role:relationship:owner ==> role:relationship:admin
|
role:relation:owner ==> role:relation:admin
|
||||||
role:anchorPerson:admin ==> role:relationship:admin
|
role:anchorPerson:admin ==> role:relation:admin
|
||||||
role:relationship:admin ==> role:relationship:agent
|
role:relation:admin ==> role:relation:agent
|
||||||
role:holderPerson:admin ==> role:relationship:agent
|
role:holderPerson:admin ==> role:relation:agent
|
||||||
role:relationship:agent ==> role:relationship:tenant
|
role:relation:agent ==> role:relation:tenant
|
||||||
role:holderPerson:admin ==> role:relationship:tenant
|
role:holderPerson:admin ==> role:relation:tenant
|
||||||
role:contact:admin ==> role:relationship:tenant
|
role:contact:admin ==> role:relation:tenant
|
||||||
role:relationship:tenant ==> role:anchorPerson:referrer
|
role:relation:tenant ==> role:anchorPerson:referrer
|
||||||
role:relationship:tenant ==> role:holderPerson:referrer
|
role:relation:tenant ==> role:holderPerson:referrer
|
||||||
role:relationship:tenant ==> role:contact:referrer
|
role:relation:tenant ==> role:contact:referrer
|
||||||
|
|
||||||
%% granting permissions to roles
|
%% granting permissions to roles
|
||||||
role:relationship:owner ==> perm:relationship:DELETE
|
role:relation:owner ==> perm:relation:DELETE
|
||||||
role:relationship:admin ==> perm:relationship:UPDATE
|
role:relation:admin ==> perm:relation:UPDATE
|
||||||
role:relationship:tenant ==> perm:relationship:SELECT
|
role:relation:tenant ==> perm:relation:SELECT
|
||||||
role:anchorPerson:admin ==> perm:relationship:INSERT
|
role:anchorPerson:admin ==> perm:relation:INSERT
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -3,29 +3,29 @@
|
|||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-office-relationship-rbac-OBJECT:1 endDelimiter:--//
|
--changeset hs-office-relation-rbac-OBJECT:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
call generateRelatedRbacObject('hs_office_relationship');
|
call generateRelatedRbacObject('hs_office_relation');
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-office-relationship-rbac-ROLE-DESCRIPTORS:1 endDelimiter:--//
|
--changeset hs-office-relation-rbac-ROLE-DESCRIPTORS:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
call generateRbacRoleDescriptors('hsOfficeRelationship', 'hs_office_relationship');
|
call generateRbacRoleDescriptors('hsOfficeRelation', 'hs_office_relation');
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-office-relationship-rbac-insert-trigger:1 endDelimiter:--//
|
--changeset hs-office-relation-rbac-insert-trigger:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Creates the roles, grants and permission for the AFTER INSERT TRIGGER.
|
Creates the roles, grants and permission for the AFTER INSERT TRIGGER.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
create or replace procedure buildRbacSystemForHsOfficeRelationship(
|
create or replace procedure buildRbacSystemForHsOfficeRelation(
|
||||||
NEW hs_office_relationship
|
NEW hs_office_relation
|
||||||
)
|
)
|
||||||
language plpgsql as $$
|
language plpgsql as $$
|
||||||
|
|
||||||
@ -37,43 +37,43 @@ declare
|
|||||||
begin
|
begin
|
||||||
call enterTriggerForObjectUuid(NEW.uuid);
|
call enterTriggerForObjectUuid(NEW.uuid);
|
||||||
|
|
||||||
select * from hs_office_person as p where p.uuid = NEW.relHolderUuid INTO newHolderPerson;
|
select * from hs_office_person as p where p.uuid = NEW.holderUuid INTO newHolderPerson;
|
||||||
assert newHolderPerson.uuid is not null, format('newHolderPerson must not be null for NEW.relHolderUuid = %s', NEW.relHolderUuid);
|
assert newHolderPerson.uuid is not null, format('newHolderPerson must not be null for NEW.holderUuid = %s', NEW.holderUuid);
|
||||||
|
|
||||||
select * from hs_office_person as p where p.uuid = NEW.relAnchorUuid INTO newAnchorPerson;
|
select * from hs_office_person as p where p.uuid = NEW.anchorUuid INTO newAnchorPerson;
|
||||||
assert newAnchorPerson.uuid is not null, format('newAnchorPerson must not be null for NEW.relAnchorUuid = %s', NEW.relAnchorUuid);
|
assert newAnchorPerson.uuid is not null, format('newAnchorPerson must not be null for NEW.anchorUuid = %s', NEW.anchorUuid);
|
||||||
|
|
||||||
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;
|
||||||
assert newContact.uuid is not null, format('newContact must not be null for NEW.contactUuid = %s', NEW.contactUuid);
|
assert newContact.uuid is not null, format('newContact must not be null for NEW.contactUuid = %s', NEW.contactUuid);
|
||||||
|
|
||||||
|
|
||||||
perform createRoleWithGrants(
|
perform createRoleWithGrants(
|
||||||
hsOfficeRelationshipOwner(NEW),
|
hsOfficeRelationOwner(NEW),
|
||||||
permissions => array['DELETE'],
|
permissions => array['DELETE'],
|
||||||
incomingSuperRoles => array[globalAdmin()],
|
incomingSuperRoles => array[globalAdmin()],
|
||||||
userUuids => array[currentUserUuid()]
|
userUuids => array[currentUserUuid()]
|
||||||
);
|
);
|
||||||
|
|
||||||
perform createRoleWithGrants(
|
perform createRoleWithGrants(
|
||||||
hsOfficeRelationshipAdmin(NEW),
|
hsOfficeRelationAdmin(NEW),
|
||||||
permissions => array['UPDATE'],
|
permissions => array['UPDATE'],
|
||||||
incomingSuperRoles => array[
|
incomingSuperRoles => array[
|
||||||
hsOfficeRelationshipOwner(NEW),
|
hsOfficeRelationOwner(NEW),
|
||||||
hsOfficePersonAdmin(newAnchorPerson)]
|
hsOfficePersonAdmin(newAnchorPerson)]
|
||||||
);
|
);
|
||||||
|
|
||||||
perform createRoleWithGrants(
|
perform createRoleWithGrants(
|
||||||
hsOfficeRelationshipAgent(NEW),
|
hsOfficeRelationAgent(NEW),
|
||||||
incomingSuperRoles => array[
|
incomingSuperRoles => array[
|
||||||
hsOfficePersonAdmin(newHolderPerson),
|
hsOfficePersonAdmin(newHolderPerson),
|
||||||
hsOfficeRelationshipAdmin(NEW)]
|
hsOfficeRelationAdmin(NEW)]
|
||||||
);
|
);
|
||||||
|
|
||||||
perform createRoleWithGrants(
|
perform createRoleWithGrants(
|
||||||
hsOfficeRelationshipTenant(NEW),
|
hsOfficeRelationTenant(NEW),
|
||||||
permissions => array['SELECT'],
|
permissions => array['SELECT'],
|
||||||
incomingSuperRoles => array[
|
incomingSuperRoles => array[
|
||||||
hsOfficeRelationshipAgent(NEW),
|
hsOfficeRelationAgent(NEW),
|
||||||
hsOfficeContactAdmin(newContact),
|
hsOfficeContactAdmin(newContact),
|
||||||
hsOfficePersonAdmin(newHolderPerson)],
|
hsOfficePersonAdmin(newHolderPerson)],
|
||||||
outgoingSubRoles => array[
|
outgoingSubRoles => array[
|
||||||
@ -86,36 +86,36 @@ begin
|
|||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
AFTER INSERT TRIGGER to create the role+grant structure for a new hs_office_relationship row.
|
AFTER INSERT TRIGGER to create the role+grant structure for a new hs_office_relation row.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
create or replace function insertTriggerForHsOfficeRelationship_tf()
|
create or replace function insertTriggerForHsOfficeRelation_tf()
|
||||||
returns trigger
|
returns trigger
|
||||||
language plpgsql
|
language plpgsql
|
||||||
strict as $$
|
strict as $$
|
||||||
begin
|
begin
|
||||||
call buildRbacSystemForHsOfficeRelationship(NEW);
|
call buildRbacSystemForHsOfficeRelation(NEW);
|
||||||
return NEW;
|
return NEW;
|
||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
create trigger insertTriggerForHsOfficeRelationship_tg
|
create trigger insertTriggerForHsOfficeRelation_tg
|
||||||
after insert on hs_office_relationship
|
after insert on hs_office_relation
|
||||||
for each row
|
for each row
|
||||||
execute procedure insertTriggerForHsOfficeRelationship_tf();
|
execute procedure insertTriggerForHsOfficeRelation_tf();
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-office-relationship-rbac-update-trigger:1 endDelimiter:--//
|
--changeset hs-office-relation-rbac-update-trigger:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called from the AFTER UPDATE TRIGGER to re-wire the grants.
|
Called from the AFTER UPDATE TRIGGER to re-wire the grants.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
create or replace procedure updateRbacRulesForHsOfficeRelationship(
|
create or replace procedure updateRbacRulesForHsOfficeRelation(
|
||||||
OLD hs_office_relationship,
|
OLD hs_office_relation,
|
||||||
NEW hs_office_relationship
|
NEW hs_office_relation
|
||||||
)
|
)
|
||||||
language plpgsql as $$
|
language plpgsql as $$
|
||||||
|
|
||||||
@ -130,17 +130,17 @@ declare
|
|||||||
begin
|
begin
|
||||||
call enterTriggerForObjectUuid(NEW.uuid);
|
call enterTriggerForObjectUuid(NEW.uuid);
|
||||||
|
|
||||||
select * from hs_office_person as p where p.uuid = OLD.relHolderUuid INTO oldHolderPerson;
|
select * from hs_office_person as p where p.uuid = OLD.holderUuid INTO oldHolderPerson;
|
||||||
assert oldHolderPerson.uuid is not null, format('oldHolderPerson must not be null for OLD.relHolderUuid = %s', OLD.relHolderUuid);
|
assert oldHolderPerson.uuid is not null, format('oldHolderPerson must not be null for OLD.holderUuid = %s', OLD.holderUuid);
|
||||||
|
|
||||||
select * from hs_office_person as p where p.uuid = NEW.relHolderUuid INTO newHolderPerson;
|
select * from hs_office_person as p where p.uuid = NEW.holderUuid INTO newHolderPerson;
|
||||||
assert newHolderPerson.uuid is not null, format('newHolderPerson must not be null for NEW.relHolderUuid = %s', NEW.relHolderUuid);
|
assert newHolderPerson.uuid is not null, format('newHolderPerson must not be null for NEW.holderUuid = %s', NEW.holderUuid);
|
||||||
|
|
||||||
select * from hs_office_person as p where p.uuid = OLD.relAnchorUuid INTO oldAnchorPerson;
|
select * from hs_office_person as p where p.uuid = OLD.anchorUuid INTO oldAnchorPerson;
|
||||||
assert oldAnchorPerson.uuid is not null, format('oldAnchorPerson must not be null for OLD.relAnchorUuid = %s', OLD.relAnchorUuid);
|
assert oldAnchorPerson.uuid is not null, format('oldAnchorPerson must not be null for OLD.anchorUuid = %s', OLD.anchorUuid);
|
||||||
|
|
||||||
select * from hs_office_person as p where p.uuid = NEW.relAnchorUuid INTO newAnchorPerson;
|
select * from hs_office_person as p where p.uuid = NEW.anchorUuid INTO newAnchorPerson;
|
||||||
assert newAnchorPerson.uuid is not null, format('newAnchorPerson must not be null for NEW.relAnchorUuid = %s', NEW.relAnchorUuid);
|
assert newAnchorPerson.uuid is not null, format('newAnchorPerson must not be null for NEW.anchorUuid = %s', NEW.anchorUuid);
|
||||||
|
|
||||||
select * from hs_office_contact as c where c.uuid = OLD.contactUuid INTO oldContact;
|
select * from hs_office_contact as c where c.uuid = OLD.contactUuid INTO oldContact;
|
||||||
assert oldContact.uuid is not null, format('oldContact must not be null for OLD.contactUuid = %s', OLD.contactUuid);
|
assert oldContact.uuid is not null, format('oldContact must not be null for OLD.contactUuid = %s', OLD.contactUuid);
|
||||||
@ -151,11 +151,11 @@ begin
|
|||||||
|
|
||||||
if NEW.contactUuid <> OLD.contactUuid then
|
if NEW.contactUuid <> OLD.contactUuid then
|
||||||
|
|
||||||
call revokeRoleFromRole(hsOfficeRelationshipTenant(OLD), hsOfficeContactAdmin(oldContact));
|
call revokeRoleFromRole(hsOfficeRelationTenant(OLD), hsOfficeContactAdmin(oldContact));
|
||||||
call grantRoleToRole(hsOfficeRelationshipTenant(NEW), hsOfficeContactAdmin(newContact));
|
call grantRoleToRole(hsOfficeRelationTenant(NEW), hsOfficeContactAdmin(newContact));
|
||||||
|
|
||||||
call revokeRoleFromRole(hsOfficeContactReferrer(oldContact), hsOfficeRelationshipTenant(OLD));
|
call revokeRoleFromRole(hsOfficeContactReferrer(oldContact), hsOfficeRelationTenant(OLD));
|
||||||
call grantRoleToRole(hsOfficeContactReferrer(newContact), hsOfficeRelationshipTenant(NEW));
|
call grantRoleToRole(hsOfficeContactReferrer(newContact), hsOfficeRelationTenant(NEW));
|
||||||
|
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
@ -163,31 +163,31 @@ begin
|
|||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
AFTER INSERT TRIGGER to re-wire the grant structure for a new hs_office_relationship row.
|
AFTER INSERT TRIGGER to re-wire the grant structure for a new hs_office_relation row.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
create or replace function updateTriggerForHsOfficeRelationship_tf()
|
create or replace function updateTriggerForHsOfficeRelation_tf()
|
||||||
returns trigger
|
returns trigger
|
||||||
language plpgsql
|
language plpgsql
|
||||||
strict as $$
|
strict as $$
|
||||||
begin
|
begin
|
||||||
call updateRbacRulesForHsOfficeRelationship(OLD, NEW);
|
call updateRbacRulesForHsOfficeRelation(OLD, NEW);
|
||||||
return NEW;
|
return NEW;
|
||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
create trigger updateTriggerForHsOfficeRelationship_tg
|
create trigger updateTriggerForHsOfficeRelation_tg
|
||||||
after update on hs_office_relationship
|
after update on hs_office_relation
|
||||||
for each row
|
for each row
|
||||||
execute procedure updateTriggerForHsOfficeRelationship_tf();
|
execute procedure updateTriggerForHsOfficeRelation_tf();
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-office-relationship-rbac-INSERT:1 endDelimiter:--//
|
--changeset hs-office-relation-rbac-INSERT:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Creates INSERT INTO hs_office_relationship permissions for the related hs_office_person rows.
|
Creates INSERT INTO hs_office_relation permissions for the related hs_office_person rows.
|
||||||
*/
|
*/
|
||||||
do language plpgsql $$
|
do language plpgsql $$
|
||||||
declare
|
declare
|
||||||
@ -195,80 +195,80 @@ do language plpgsql $$
|
|||||||
permissionUuid uuid;
|
permissionUuid uuid;
|
||||||
roleUuid uuid;
|
roleUuid uuid;
|
||||||
begin
|
begin
|
||||||
call defineContext('create INSERT INTO hs_office_relationship permissions for the related hs_office_person rows');
|
call defineContext('create INSERT INTO hs_office_relation permissions for the related hs_office_person rows');
|
||||||
|
|
||||||
FOR row IN SELECT * FROM hs_office_person
|
FOR row IN SELECT * FROM hs_office_person
|
||||||
LOOP
|
LOOP
|
||||||
roleUuid := findRoleId(hsOfficePersonAdmin(row));
|
roleUuid := findRoleId(hsOfficePersonAdmin(row));
|
||||||
permissionUuid := createPermission(row.uuid, 'INSERT', 'hs_office_relationship');
|
permissionUuid := createPermission(row.uuid, 'INSERT', 'hs_office_relation');
|
||||||
call grantPermissionToRole(permissionUuid, roleUuid);
|
call grantPermissionToRole(permissionUuid, roleUuid);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds hs_office_relationship INSERT permission to specified role of new hs_office_person rows.
|
Adds hs_office_relation INSERT permission to specified role of new hs_office_person rows.
|
||||||
*/
|
*/
|
||||||
create or replace function hs_office_relationship_hs_office_person_insert_tf()
|
create or replace function hs_office_relation_hs_office_person_insert_tf()
|
||||||
returns trigger
|
returns trigger
|
||||||
language plpgsql
|
language plpgsql
|
||||||
strict as $$
|
strict as $$
|
||||||
begin
|
begin
|
||||||
call grantPermissionToRole(
|
call grantPermissionToRole(
|
||||||
createPermission(NEW.uuid, 'INSERT', 'hs_office_relationship'),
|
createPermission(NEW.uuid, 'INSERT', 'hs_office_relation'),
|
||||||
hsOfficePersonAdmin(NEW));
|
hsOfficePersonAdmin(NEW));
|
||||||
return NEW;
|
return NEW;
|
||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
create trigger z_hs_office_relationship_hs_office_person_insert_tg
|
create trigger z_hs_office_relation_hs_office_person_insert_tg
|
||||||
after insert on hs_office_person
|
after insert on hs_office_person
|
||||||
for each row
|
for each row
|
||||||
execute procedure hs_office_relationship_hs_office_person_insert_tf();
|
execute procedure hs_office_relation_hs_office_person_insert_tf();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Checks if the user or assumed roles are allowed to insert a row to hs_office_relationship.
|
Checks if the user or assumed roles are allowed to insert a row to hs_office_relation.
|
||||||
*/
|
*/
|
||||||
create or replace function hs_office_relationship_insert_permission_missing_tf()
|
create or replace function hs_office_relation_insert_permission_missing_tf()
|
||||||
returns trigger
|
returns trigger
|
||||||
language plpgsql as $$
|
language plpgsql as $$
|
||||||
begin
|
begin
|
||||||
if ( not hasInsertPermission(
|
if ( not hasInsertPermission(
|
||||||
( SELECT anchorPerson.uuid FROM
|
( SELECT anchorPerson.uuid FROM
|
||||||
|
|
||||||
(select * from hs_office_person as p where p.uuid = NEW.relAnchorUuid) AS anchorPerson
|
(select * from hs_office_person as p where p.uuid = NEW.anchorUuid) AS anchorPerson
|
||||||
|
|
||||||
), 'INSERT', 'hs_office_relationship') ) then
|
), 'INSERT', 'hs_office_relation') ) then
|
||||||
raise exception
|
raise exception
|
||||||
'[403] insert into hs_office_relationship not allowed for current subjects % (%)',
|
'[403] insert into hs_office_relation not allowed for current subjects % (%)',
|
||||||
currentSubjects(), currentSubjectsUuids();
|
currentSubjects(), currentSubjectsUuids();
|
||||||
end if;
|
end if;
|
||||||
return NEW;
|
return NEW;
|
||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
create trigger hs_office_relationship_insert_permission_check_tg
|
create trigger hs_office_relation_insert_permission_check_tg
|
||||||
before insert on hs_office_relationship
|
before insert on hs_office_relation
|
||||||
for each row
|
for each row
|
||||||
execute procedure hs_office_relationship_insert_permission_missing_tf();
|
execute procedure hs_office_relation_insert_permission_missing_tf();
|
||||||
--//
|
--//
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-office-relationship-rbac-IDENTITY-VIEW:1 endDelimiter:--//
|
--changeset hs-office-relation-rbac-IDENTITY-VIEW:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
call generateRbacIdentityViewFromProjection('hs_office_relationship', $idName$
|
call generateRbacIdentityViewFromProjection('hs_office_relation', $idName$
|
||||||
(select idName from hs_office_person_iv p where p.uuid = relAnchorUuid)
|
(select idName from hs_office_person_iv p where p.uuid = anchorUuid)
|
||||||
|| '-with-' || target.relType || '-'
|
|| '-with-' || target.type || '-'
|
||||||
|| (select idName from hs_office_person_iv p where p.uuid = relHolderUuid)
|
|| (select idName from hs_office_person_iv p where p.uuid = holderUuid)
|
||||||
|
|
||||||
$idName$);
|
$idName$);
|
||||||
--//
|
--//
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-office-relationship-rbac-RESTRICTED-VIEW:1 endDelimiter:--//
|
--changeset hs-office-relation-rbac-RESTRICTED-VIEW:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
call generateRbacRestrictedView('hs_office_relationship',
|
call generateRbacRestrictedView('hs_office_relation',
|
||||||
$orderBy$
|
$orderBy$
|
||||||
(select idName from hs_office_person_iv p where p.uuid = target.relHolderUuid)
|
(select idName from hs_office_person_iv p where p.uuid = target.holderUuid)
|
||||||
$orderBy$,
|
$orderBy$,
|
||||||
$updates$
|
$updates$
|
||||||
contactUuid = new.contactUuid
|
contactUuid = new.contactUuid
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-office-relationship-TEST-DATA-GENERATOR:1 endDelimiter:--//
|
--changeset hs-office-relation-TEST-DATA-GENERATOR:1 endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Creates a single relationship test record.
|
Creates a single relation test record.
|
||||||
*/
|
*/
|
||||||
create or replace procedure createHsOfficeRelationshipTestData(
|
create or replace procedure createHsOfficeRelationTestData(
|
||||||
holderPersonName varchar,
|
holderPersonName varchar,
|
||||||
relationshipType HsOfficeRelationshipType,
|
relationType HsOfficeRelationType,
|
||||||
anchorPersonName varchar,
|
anchorPersonName varchar,
|
||||||
contactLabel varchar,
|
contactLabel varchar,
|
||||||
mark varchar default null)
|
mark varchar default null)
|
||||||
@ -24,7 +24,7 @@ declare
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
idName := cleanIdentifier( anchorPersonName || '-' || holderPersonName);
|
idName := cleanIdentifier( anchorPersonName || '-' || holderPersonName);
|
||||||
currentTask := 'creating relationship test-data ' || idName;
|
currentTask := 'creating relation test-data ' || idName;
|
||||||
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global.admin');
|
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global.admin');
|
||||||
execute format('set local hsadminng.currentTask to %L', currentTask);
|
execute format('set local hsadminng.currentTask to %L', currentTask);
|
||||||
|
|
||||||
@ -49,20 +49,20 @@ begin
|
|||||||
raise exception 'contact "%" not found', contactLabel;
|
raise exception 'contact "%" not found', contactLabel;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
raise notice 'creating test relationship: %', idName;
|
raise notice 'creating test relation: %', idName;
|
||||||
raise notice '- using anchor person (%): %', anchorPerson.uuid, anchorPerson;
|
raise notice '- using anchor person (%): %', anchorPerson.uuid, anchorPerson;
|
||||||
raise notice '- using holder person (%): %', holderPerson.uuid, holderPerson;
|
raise notice '- using holder person (%): %', holderPerson.uuid, holderPerson;
|
||||||
raise notice '- using contact (%): %', contact.uuid, contact;
|
raise notice '- using contact (%): %', contact.uuid, contact;
|
||||||
insert
|
insert
|
||||||
into hs_office_relationship (uuid, relanchoruuid, relholderuuid, reltype, relmark, contactUuid)
|
into hs_office_relation (uuid, anchoruuid, holderuuid, type, mark, contactUuid)
|
||||||
values (uuid_generate_v4(), anchorPerson.uuid, holderPerson.uuid, relationshipType, mark, contact.uuid);
|
values (uuid_generate_v4(), anchorPerson.uuid, holderPerson.uuid, relationType, mark, contact.uuid);
|
||||||
end; $$;
|
end; $$;
|
||||||
--//
|
--//
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Creates a range of test relationship for mass data generation.
|
Creates a range of test relation for mass data generation.
|
||||||
*/
|
*/
|
||||||
create or replace procedure createHsOfficeRelationshipTestData(
|
create or replace procedure createHsOfficeRelationTestData(
|
||||||
startCount integer, -- count of auto generated rows before the run
|
startCount integer, -- count of auto generated rows before the run
|
||||||
endCount integer -- count of auto generated rows after the run
|
endCount integer -- count of auto generated rows after the run
|
||||||
)
|
)
|
||||||
@ -76,7 +76,7 @@ begin
|
|||||||
select p.* from hs_office_person p where tradeName = intToVarChar(t, 4) into person;
|
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;
|
select c.* from hs_office_contact c where c.label = intToVarChar(t, 4) || '#' || t into contact;
|
||||||
|
|
||||||
call createHsOfficeRelationshipTestData(person.uuid, contact.uuid, 'REPRESENTATIVE');
|
call createHsOfficeRelationTestData(person.uuid, contact.uuid, 'REPRESENTATIVE');
|
||||||
commit;
|
commit;
|
||||||
end loop;
|
end loop;
|
||||||
end; $$;
|
end; $$;
|
||||||
@ -84,30 +84,30 @@ end; $$;
|
|||||||
|
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
--changeset hs-office-relationship-TEST-DATA-GENERATION:1 –context=dev,tc endDelimiter:--//
|
--changeset hs-office-relation-TEST-DATA-GENERATION:1 –context=dev,tc endDelimiter:--//
|
||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
do language plpgsql $$
|
do language plpgsql $$
|
||||||
begin
|
begin
|
||||||
call createHsOfficeRelationshipTestData('First GmbH', 'PARTNER', 'Hostsharing eG', 'first contact');
|
call createHsOfficeRelationTestData('First GmbH', 'PARTNER', 'Hostsharing eG', 'first contact');
|
||||||
call createHsOfficeRelationshipTestData('Firby', 'REPRESENTATIVE', 'First GmbH', 'first contact');
|
call createHsOfficeRelationTestData('Firby', 'REPRESENTATIVE', 'First GmbH', 'first contact');
|
||||||
call createHsOfficeRelationshipTestData('First GmbH', 'ACCOUNTING', 'First GmbH', 'first contact');
|
call createHsOfficeRelationTestData('First GmbH', 'DEBITOR', 'First GmbH', 'first contact');
|
||||||
|
|
||||||
call createHsOfficeRelationshipTestData('Second e.K.', 'PARTNER', 'Hostsharing eG', 'second contact');
|
call createHsOfficeRelationTestData('Second e.K.', 'PARTNER', 'Hostsharing eG', 'second contact');
|
||||||
call createHsOfficeRelationshipTestData('Smith', 'REPRESENTATIVE', 'Second e.K.', 'second contact');
|
call createHsOfficeRelationTestData('Smith', 'REPRESENTATIVE', 'Second e.K.', 'second contact');
|
||||||
call createHsOfficeRelationshipTestData('Second e.K.', 'ACCOUNTING', 'Second e.K.', 'second contact');
|
call createHsOfficeRelationTestData('Second e.K.', 'DEBITOR', 'Second e.K.', 'second contact');
|
||||||
|
|
||||||
call createHsOfficeRelationshipTestData('Third OHG', 'PARTNER', 'Hostsharing eG', 'third contact');
|
call createHsOfficeRelationTestData('Third OHG', 'PARTNER', 'Hostsharing eG', 'third contact');
|
||||||
call createHsOfficeRelationshipTestData('Tucker', 'REPRESENTATIVE', 'Third OHG', 'third contact');
|
call createHsOfficeRelationTestData('Tucker', 'REPRESENTATIVE', 'Third OHG', 'third contact');
|
||||||
call createHsOfficeRelationshipTestData('Third OHG', 'ACCOUNTING', 'Third OHG', 'third contact');
|
call createHsOfficeRelationTestData('Third OHG', 'DEBITOR', 'Third OHG', 'third contact');
|
||||||
|
|
||||||
call createHsOfficeRelationshipTestData('Fourth eG', 'PARTNER', 'Hostsharing eG', 'fourth contact');
|
call createHsOfficeRelationTestData('Fourth eG', 'PARTNER', 'Hostsharing eG', 'fourth contact');
|
||||||
call createHsOfficeRelationshipTestData('Fouler', 'REPRESENTATIVE', 'Third OHG', 'third contact');
|
call createHsOfficeRelationTestData('Fouler', 'REPRESENTATIVE', 'Third OHG', 'third contact');
|
||||||
call createHsOfficeRelationshipTestData('Third OHG', 'ACCOUNTING', 'Third OHG', 'third contact');
|
call createHsOfficeRelationTestData('Third OHG', 'DEBITOR', 'Third OHG', 'third contact');
|
||||||
|
|
||||||
call createHsOfficeRelationshipTestData('Smith', 'PARTNER', 'Hostsharing eG', 'sixth contact');
|
call createHsOfficeRelationTestData('Smith', 'PARTNER', 'Hostsharing eG', 'sixth contact');
|
||||||
call createHsOfficeRelationshipTestData('Smith', 'ACCOUNTING', 'Smith', 'third contact');
|
call createHsOfficeRelationTestData('Smith', 'DEBITOR', 'Smith', 'third contact');
|
||||||
call createHsOfficeRelationshipTestData('Smith', 'SUBSCRIBER', 'Third OHG', 'third contact', 'members-announce');
|
call createHsOfficeRelationTestData('Smith', 'SUBSCRIBER', 'Third OHG', 'third contact', 'members-announce');
|
||||||
end;
|
end;
|
||||||
$$;
|
$$;
|
||||||
--//
|
--//
|
||||||
|
@ -33,7 +33,7 @@ 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_relation(uuid), -- TODO: delete in after delete trigger
|
||||||
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
|
||||||
);
|
);
|
||||||
--//
|
--//
|
||||||
|
@ -30,24 +30,24 @@ create or replace procedure buildRbacSystemForHsOfficePartner(
|
|||||||
language plpgsql as $$
|
language plpgsql as $$
|
||||||
|
|
||||||
declare
|
declare
|
||||||
newPartnerRel hs_office_relationship;
|
newPartnerRel hs_office_relation;
|
||||||
newPartnerDetails hs_office_partner_details;
|
newPartnerDetails hs_office_partner_details;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
call enterTriggerForObjectUuid(NEW.uuid);
|
call enterTriggerForObjectUuid(NEW.uuid);
|
||||||
|
|
||||||
SELECT * FROM hs_office_relationship AS r WHERE r.uuid = NEW.partnerRoleUuid INTO newPartnerRel;
|
SELECT * FROM hs_office_relation AS r WHERE r.uuid = NEW.partnerRelUuid INTO newPartnerRel;
|
||||||
assert newPartnerRel.uuid is not null, format('newPartnerRel must not be null for NEW.partnerRoleUuid = %s', NEW.partnerRoleUuid);
|
assert newPartnerRel.uuid is not null, format('newPartnerRel must not be null for NEW.partnerRelUuid = %s', NEW.partnerRelUuid);
|
||||||
|
|
||||||
SELECT * FROM hs_office_partner_details AS d WHERE d.uuid = NEW.detailsUuid INTO newPartnerDetails;
|
SELECT * FROM hs_office_partner_details AS d WHERE d.uuid = NEW.detailsUuid INTO newPartnerDetails;
|
||||||
assert newPartnerDetails.uuid is not null, format('newPartnerDetails must not be null for NEW.detailsUuid = %s', NEW.detailsUuid);
|
assert newPartnerDetails.uuid is not null, format('newPartnerDetails must not be null for NEW.detailsUuid = %s', NEW.detailsUuid);
|
||||||
|
|
||||||
call grantPermissionToRole(createPermission(NEW.uuid, 'DELETE'), hsOfficeRelationshipAdmin(newPartnerRel));
|
call grantPermissionToRole(createPermission(NEW.uuid, 'DELETE'), hsOfficeRelationAdmin(newPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(NEW.uuid, 'SELECT'), hsOfficeRelationshipTenant(newPartnerRel));
|
call grantPermissionToRole(createPermission(NEW.uuid, 'SELECT'), hsOfficeRelationTenant(newPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(NEW.uuid, 'UPDATE'), hsOfficeRelationshipAgent(newPartnerRel));
|
call grantPermissionToRole(createPermission(NEW.uuid, 'UPDATE'), hsOfficeRelationAgent(newPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'DELETE'), hsOfficeRelationshipAdmin(newPartnerRel));
|
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'DELETE'), hsOfficeRelationAdmin(newPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'SELECT'), hsOfficeRelationshipAgent(newPartnerRel));
|
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'SELECT'), hsOfficeRelationAgent(newPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'UPDATE'), hsOfficeRelationshipAgent(newPartnerRel));
|
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'UPDATE'), hsOfficeRelationAgent(newPartnerRel));
|
||||||
|
|
||||||
call leaveTriggerForObjectUuid(NEW.uuid);
|
call leaveTriggerForObjectUuid(NEW.uuid);
|
||||||
end; $$;
|
end; $$;
|
||||||
@ -87,19 +87,19 @@ create or replace procedure updateRbacRulesForHsOfficePartner(
|
|||||||
language plpgsql as $$
|
language plpgsql as $$
|
||||||
|
|
||||||
declare
|
declare
|
||||||
oldPartnerRel hs_office_relationship;
|
oldPartnerRel hs_office_relation;
|
||||||
newPartnerRel hs_office_relationship;
|
newPartnerRel hs_office_relation;
|
||||||
oldPartnerDetails hs_office_partner_details;
|
oldPartnerDetails hs_office_partner_details;
|
||||||
newPartnerDetails hs_office_partner_details;
|
newPartnerDetails hs_office_partner_details;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
call enterTriggerForObjectUuid(NEW.uuid);
|
call enterTriggerForObjectUuid(NEW.uuid);
|
||||||
|
|
||||||
SELECT * FROM hs_office_relationship AS r WHERE r.uuid = OLD.partnerRoleUuid INTO oldPartnerRel;
|
SELECT * FROM hs_office_relation AS r WHERE r.uuid = OLD.partnerRelUuid INTO oldPartnerRel;
|
||||||
assert oldPartnerRel.uuid is not null, format('oldPartnerRel must not be null for OLD.partnerRoleUuid = %s', OLD.partnerRoleUuid);
|
assert oldPartnerRel.uuid is not null, format('oldPartnerRel must not be null for OLD.partnerRelUuid = %s', OLD.partnerRelUuid);
|
||||||
|
|
||||||
SELECT * FROM hs_office_relationship AS r WHERE r.uuid = NEW.partnerRoleUuid INTO newPartnerRel;
|
SELECT * FROM hs_office_relation AS r WHERE r.uuid = NEW.partnerRelUuid INTO newPartnerRel;
|
||||||
assert newPartnerRel.uuid is not null, format('newPartnerRel must not be null for NEW.partnerRoleUuid = %s', NEW.partnerRoleUuid);
|
assert newPartnerRel.uuid is not null, format('newPartnerRel must not be null for NEW.partnerRelUuid = %s', NEW.partnerRelUuid);
|
||||||
|
|
||||||
SELECT * FROM hs_office_partner_details AS d WHERE d.uuid = OLD.detailsUuid INTO oldPartnerDetails;
|
SELECT * FROM hs_office_partner_details AS d WHERE d.uuid = OLD.detailsUuid INTO oldPartnerDetails;
|
||||||
assert oldPartnerDetails.uuid is not null, format('oldPartnerDetails must not be null for OLD.detailsUuid = %s', OLD.detailsUuid);
|
assert oldPartnerDetails.uuid is not null, format('oldPartnerDetails must not be null for OLD.detailsUuid = %s', OLD.detailsUuid);
|
||||||
@ -108,31 +108,31 @@ begin
|
|||||||
assert newPartnerDetails.uuid is not null, format('newPartnerDetails must not be null for NEW.detailsUuid = %s', NEW.detailsUuid);
|
assert newPartnerDetails.uuid is not null, format('newPartnerDetails must not be null for NEW.detailsUuid = %s', NEW.detailsUuid);
|
||||||
|
|
||||||
|
|
||||||
if NEW.partnerRoleUuid <> OLD.partnerRoleUuid then
|
if NEW.partnerRelUuid <> OLD.partnerRelUuid then
|
||||||
|
|
||||||
call revokePermissionFromRole(getPermissionId(OLD.uuid, 'DELETE'), hsOfficeRelationshipAdmin(oldPartnerRel));
|
call revokePermissionFromRole(getPermissionId(OLD.uuid, 'DELETE'), hsOfficeRelationAdmin(oldPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(NEW.uuid, 'DELETE'), hsOfficeRelationshipAdmin(newPartnerRel));
|
call grantPermissionToRole(createPermission(NEW.uuid, 'DELETE'), hsOfficeRelationAdmin(newPartnerRel));
|
||||||
|
|
||||||
call revokePermissionFromRole(getPermissionId(OLD.uuid, 'UPDATE'), hsOfficeRelationshipAgent(oldPartnerRel));
|
call revokePermissionFromRole(getPermissionId(OLD.uuid, 'UPDATE'), hsOfficeRelationAgent(oldPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(NEW.uuid, 'UPDATE'), hsOfficeRelationshipAgent(newPartnerRel));
|
call grantPermissionToRole(createPermission(NEW.uuid, 'UPDATE'), hsOfficeRelationAgent(newPartnerRel));
|
||||||
|
|
||||||
call revokePermissionFromRole(getPermissionId(OLD.uuid, 'SELECT'), hsOfficeRelationshipTenant(oldPartnerRel));
|
call revokePermissionFromRole(getPermissionId(OLD.uuid, 'SELECT'), hsOfficeRelationTenant(oldPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(NEW.uuid, 'SELECT'), hsOfficeRelationshipTenant(newPartnerRel));
|
call grantPermissionToRole(createPermission(NEW.uuid, 'SELECT'), hsOfficeRelationTenant(newPartnerRel));
|
||||||
|
|
||||||
call revokePermissionFromRole(getPermissionId(oldPartnerDetails.uuid, 'DELETE'), hsOfficeRelationshipAdmin(oldPartnerRel));
|
call revokePermissionFromRole(getPermissionId(oldPartnerDetails.uuid, 'DELETE'), hsOfficeRelationAdmin(oldPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'DELETE'), hsOfficeRelationshipAdmin(newPartnerRel));
|
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'DELETE'), hsOfficeRelationAdmin(newPartnerRel));
|
||||||
|
|
||||||
call revokePermissionFromRole(getPermissionId(oldPartnerDetails.uuid, 'UPDATE'), hsOfficeRelationshipAgent(oldPartnerRel));
|
call revokePermissionFromRole(getPermissionId(oldPartnerDetails.uuid, 'UPDATE'), hsOfficeRelationAgent(oldPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'UPDATE'), hsOfficeRelationshipAgent(newPartnerRel));
|
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'UPDATE'), hsOfficeRelationAgent(newPartnerRel));
|
||||||
|
|
||||||
call revokePermissionFromRole(getPermissionId(oldPartnerDetails.uuid, 'SELECT'), hsOfficeRelationshipAgent(oldPartnerRel));
|
call revokePermissionFromRole(getPermissionId(oldPartnerDetails.uuid, 'SELECT'), hsOfficeRelationAgent(oldPartnerRel));
|
||||||
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'SELECT'), hsOfficeRelationshipAgent(newPartnerRel));
|
call grantPermissionToRole(createPermission(newPartnerDetails.uuid, 'SELECT'), hsOfficeRelationAgent(newPartnerRel));
|
||||||
|
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
call leaveTriggerForObjectUuid(NEW.uuid);
|
call leaveTriggerForObjectUuid(NEW.uuid);
|
||||||
|
|
||||||
-- raise exception 'RBAC updated from rel % to %', OLD.partnerroleuuid, NEW.partnerroleuuid;
|
-- raise exception 'RBAC updated from rel % to %', OLD.partnerReluuid, NEW.partnerReluuid;
|
||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
|
|
||||||
@ -143,20 +143,20 @@ create or replace procedure updateRbacRulesForHsOfficePartnerX(
|
|||||||
)
|
)
|
||||||
language plpgsql as $$
|
language plpgsql as $$
|
||||||
declare
|
declare
|
||||||
partnerRel hs_office_relationship;
|
partnerRel hs_office_relation;
|
||||||
grantCount int;
|
grantCount int;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
assert OLD.uuid = NEW.uuid, 'uuid did change, but should not';
|
assert OLD.uuid = NEW.uuid, 'uuid did change, but should not';
|
||||||
assert OLD.partnerroleuuid <> NEW.partnerroleuuid, 'partnerroleuuid did not change, but should have';
|
assert OLD.partnerReluuid <> NEW.partnerReluuid, 'partnerReluuid did not change, but should have';
|
||||||
|
|
||||||
delete from rbacgrants where grantedbytriggerof = OLD.uuid;
|
delete from rbacgrants where grantedbytriggerof = OLD.uuid;
|
||||||
select count(*) from rbacgrants where grantedbytriggerof=NEW.uuid into grantCount;
|
select count(*) from rbacgrants where grantedbytriggerof=NEW.uuid into grantCount;
|
||||||
assert grantCount=0, format('unexpected grantCount>0: %d', grantCount);
|
assert grantCount=0, format('unexpected grantCount>0: %d', grantCount);
|
||||||
|
|
||||||
call buildRbacSystemForHsOfficePartner(NEW);
|
call buildRbacSystemForHsOfficePartner(NEW);
|
||||||
select * from hs_office_relationship where uuid=NEW.partnerroleuuid into partnerRel;
|
select * from hs_office_relation where uuid=NEW.partnerReluuid into partnerRel;
|
||||||
call grantPermissionToRole(createPermission(NEW.uuid, 'SELECT'), hsOfficeRelationshipTenant(partnerRel));
|
call grantPermissionToRole(createPermission(NEW.uuid, 'SELECT'), hsOfficeRelationTenant(partnerRel));
|
||||||
select count(*) from rbacgrants where grantedbytriggerof=NEW.uuid into grantCount;
|
select count(*) from rbacgrants where grantedbytriggerof=NEW.uuid into grantCount;
|
||||||
assert grantCount>0, format('unexpected grantCount=0: %d', grantCount);
|
assert grantCount>0, format('unexpected grantCount=0: %d', grantCount);
|
||||||
raise warning 'WARNING grantCount=%', grantCount;
|
raise warning 'WARNING grantCount=%', grantCount;
|
||||||
@ -262,7 +262,7 @@ call generateRbacRestrictedView('hs_office_partner',
|
|||||||
'P-' || partnerNumber
|
'P-' || partnerNumber
|
||||||
$orderBy$,
|
$orderBy$,
|
||||||
$updates$
|
$updates$
|
||||||
partnerRoleUuid = new.partnerRoleUuid
|
partnerRelUuid = new.partnerRelUuid
|
||||||
$updates$);
|
$updates$);
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
@ -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_relation;
|
||||||
relatedPerson hs_office_person;
|
relatedPerson hs_office_person;
|
||||||
relatedDetailsUuid uuid;
|
relatedDetailsUuid uuid;
|
||||||
begin
|
begin
|
||||||
@ -38,16 +38,16 @@ begin
|
|||||||
where p.tradeName = partnerPersonName or p.familyName = partnerPersonName
|
where p.tradeName = partnerPersonName or p.familyName = partnerPersonName
|
||||||
into relatedPerson;
|
into relatedPerson;
|
||||||
|
|
||||||
select r.* from hs_office_relationship r
|
select r.* from hs_office_relation r
|
||||||
where r.reltype = 'PARTNER'
|
where r.type = 'PARTNER'
|
||||||
and r.relanchoruuid = mandantPerson.uuid and r.relholderuuid = relatedPerson.uuid
|
and r.anchoruuid = mandantPerson.uuid and r.holderuuid = 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;
|
||||||
|
|
||||||
if relatedPerson.persontype = 'NP' then
|
if relatedPerson.persontype = 'NP' then
|
||||||
@ -63,8 +63,8 @@ begin
|
|||||||
end if;
|
end if;
|
||||||
|
|
||||||
insert
|
insert
|
||||||
into hs_office_partner (uuid, partnerNumber, partnerRoleUuid, detailsUuid)
|
into hs_office_partner (uuid, partnerNumber, partnerRelUuid, detailsUuid)
|
||||||
values (uuid_generate_v4(), newPartnerNumber, partnerRole.uuid, relatedDetailsUuid);
|
values (uuid_generate_v4(), newPartnerNumber, partnerRel.uuid, relatedDetailsUuid);
|
||||||
end; $$;
|
end; $$;
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ create or replace procedure buildRbacSystemForHsOfficeSepaMandate(
|
|||||||
|
|
||||||
declare
|
declare
|
||||||
newBankAccount hs_office_bankaccount;
|
newBankAccount hs_office_bankaccount;
|
||||||
newDebitorRel hs_office_relationship;
|
newDebitorRel hs_office_relation;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
call enterTriggerForObjectUuid(NEW.uuid);
|
call enterTriggerForObjectUuid(NEW.uuid);
|
||||||
@ -40,7 +40,7 @@ begin
|
|||||||
assert newBankAccount.uuid is not null, format('newBankAccount must not be null for NEW.bankAccountUuid = %s', NEW.bankAccountUuid);
|
assert newBankAccount.uuid is not null, format('newBankAccount must not be null for NEW.bankAccountUuid = %s', NEW.bankAccountUuid);
|
||||||
|
|
||||||
SELECT debitorRel.*
|
SELECT debitorRel.*
|
||||||
FROM hs_office_relationship debitorRel
|
FROM hs_office_relation debitorRel
|
||||||
JOIN hs_office_debitor debitor ON debitor.debitorRelUuid = debitorRel.uuid
|
JOIN hs_office_debitor debitor ON debitor.debitorRelUuid = debitorRel.uuid
|
||||||
WHERE debitor.uuid = NEW.debitorUuid
|
WHERE debitor.uuid = NEW.debitorUuid
|
||||||
INTO newDebitorRel;
|
INTO newDebitorRel;
|
||||||
@ -64,7 +64,7 @@ begin
|
|||||||
hsOfficeSepaMandateAgent(NEW),
|
hsOfficeSepaMandateAgent(NEW),
|
||||||
incomingSuperRoles => array[hsOfficeSepaMandateAdmin(NEW)],
|
incomingSuperRoles => array[hsOfficeSepaMandateAdmin(NEW)],
|
||||||
outgoingSubRoles => array[
|
outgoingSubRoles => array[
|
||||||
hsOfficeRelationshipAgent(newDebitorRel),
|
hsOfficeRelationAgent(newDebitorRel),
|
||||||
hsOfficeBankAccountReferrer(newBankAccount)]
|
hsOfficeBankAccountReferrer(newBankAccount)]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -74,8 +74,8 @@ begin
|
|||||||
incomingSuperRoles => array[
|
incomingSuperRoles => array[
|
||||||
hsOfficeSepaMandateAgent(NEW),
|
hsOfficeSepaMandateAgent(NEW),
|
||||||
hsOfficeBankAccountAdmin(newBankAccount),
|
hsOfficeBankAccountAdmin(newBankAccount),
|
||||||
hsOfficeRelationshipAgent(newDebitorRel)],
|
hsOfficeRelationAgent(newDebitorRel)],
|
||||||
outgoingSubRoles => array[hsOfficeRelationshipTenant(newDebitorRel)]
|
outgoingSubRoles => array[hsOfficeRelationTenant(newDebitorRel)]
|
||||||
);
|
);
|
||||||
|
|
||||||
call leaveTriggerForObjectUuid(NEW.uuid);
|
call leaveTriggerForObjectUuid(NEW.uuid);
|
||||||
@ -106,19 +106,19 @@ execute procedure insertTriggerForHsOfficeSepaMandate_tf();
|
|||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Creates INSERT INTO hs_office_sepamandate permissions for the related hs_office_relationship rows.
|
Creates INSERT INTO hs_office_sepamandate permissions for the related hs_office_relation rows.
|
||||||
*/
|
*/
|
||||||
do language plpgsql $$
|
do language plpgsql $$
|
||||||
declare
|
declare
|
||||||
row hs_office_relationship;
|
row hs_office_relation;
|
||||||
permissionUuid uuid;
|
permissionUuid uuid;
|
||||||
roleUuid uuid;
|
roleUuid uuid;
|
||||||
begin
|
begin
|
||||||
call defineContext('create INSERT INTO hs_office_sepamandate permissions for the related hs_office_relationship rows');
|
call defineContext('create INSERT INTO hs_office_sepamandate permissions for the related hs_office_relation rows');
|
||||||
|
|
||||||
FOR row IN SELECT * FROM hs_office_relationship
|
FOR row IN SELECT * FROM hs_office_relation
|
||||||
LOOP
|
LOOP
|
||||||
roleUuid := findRoleId(hsOfficeRelationshipAdmin(row));
|
roleUuid := findRoleId(hsOfficeRelationAdmin(row));
|
||||||
permissionUuid := createPermission(row.uuid, 'INSERT', 'hs_office_sepamandate');
|
permissionUuid := createPermission(row.uuid, 'INSERT', 'hs_office_sepamandate');
|
||||||
call grantPermissionToRole(permissionUuid, roleUuid);
|
call grantPermissionToRole(permissionUuid, roleUuid);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
@ -126,24 +126,24 @@ do language plpgsql $$
|
|||||||
$$;
|
$$;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds hs_office_sepamandate INSERT permission to specified role of new hs_office_relationship rows.
|
Adds hs_office_sepamandate INSERT permission to specified role of new hs_office_relation rows.
|
||||||
*/
|
*/
|
||||||
create or replace function hs_office_sepamandate_hs_office_relationship_insert_tf()
|
create or replace function hs_office_sepamandate_hs_office_relation_insert_tf()
|
||||||
returns trigger
|
returns trigger
|
||||||
language plpgsql
|
language plpgsql
|
||||||
strict as $$
|
strict as $$
|
||||||
begin
|
begin
|
||||||
call grantPermissionToRole(
|
call grantPermissionToRole(
|
||||||
createPermission(NEW.uuid, 'INSERT', 'hs_office_sepamandate'),
|
createPermission(NEW.uuid, 'INSERT', 'hs_office_sepamandate'),
|
||||||
hsOfficeRelationshipAdmin(NEW));
|
hsOfficeRelationAdmin(NEW));
|
||||||
return NEW;
|
return NEW;
|
||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
-- z_... is to put it at the end of after insert triggers, to make sure the roles exist
|
-- z_... is to put it at the end of after insert triggers, to make sure the roles exist
|
||||||
create trigger z_hs_office_sepamandate_hs_office_relationship_insert_tg
|
create trigger z_hs_office_sepamandate_hs_office_relation_insert_tg
|
||||||
after insert on hs_office_relationship
|
after insert on hs_office_relation
|
||||||
for each row
|
for each row
|
||||||
execute procedure hs_office_sepamandate_hs_office_relationship_insert_tf();
|
execute procedure hs_office_sepamandate_hs_office_relation_insert_tf();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Checks if the user or assumed roles are allowed to insert a row to hs_office_sepamandate.
|
Checks if the user or assumed roles are allowed to insert a row to hs_office_sepamandate.
|
||||||
@ -156,7 +156,7 @@ begin
|
|||||||
( SELECT debitorRel.uuid FROM
|
( SELECT debitorRel.uuid FROM
|
||||||
|
|
||||||
(SELECT debitorRel.*
|
(SELECT debitorRel.*
|
||||||
FROM hs_office_relationship debitorRel
|
FROM hs_office_relation debitorRel
|
||||||
JOIN hs_office_debitor debitor ON debitor.debitorRelUuid = debitorRel.uuid
|
JOIN hs_office_debitor debitor ON debitor.debitorRelUuid = debitorRel.uuid
|
||||||
WHERE debitor.uuid = NEW.debitorUuid
|
WHERE debitor.uuid = NEW.debitorUuid
|
||||||
) AS debitorRel
|
) AS debitorRel
|
||||||
|
@ -25,9 +25,9 @@ begin
|
|||||||
|
|
||||||
select debitor.* into relatedDebitor
|
select debitor.* into relatedDebitor
|
||||||
from hs_office_debitor debitor
|
from hs_office_debitor debitor
|
||||||
join hs_office_relationship debitorRel on debitorRel.uuid = debitor.debitorRelUuid
|
join hs_office_relation debitorRel on debitorRel.uuid = debitor.debitorRelUuid
|
||||||
join hs_office_relationship partnerRel on partnerRel.relHolderUuid = debitorRel.relAnchorUuid
|
join hs_office_relation partnerRel on partnerRel.holderUuid = debitorRel.anchorUuid
|
||||||
join hs_office_partner partner on partner.partnerRoleUuid = partnerRel.uuid
|
join hs_office_partner partner on partner.partnerRelUuid = partnerRel.uuid
|
||||||
where partner.partnerNumber = forPartnerNumber and debitor.debitorNumberSuffix = forDebitorSuffix;
|
where partner.partnerNumber = forPartnerNumber and debitor.debitorNumberSuffix = forDebitorSuffix;
|
||||||
select b.* into relatedBankAccount
|
select b.* into relatedBankAccount
|
||||||
from hs_office_bankAccount b where b.iban = forIban;
|
from hs_office_bankAccount b where b.iban = forIban;
|
||||||
|
@ -8,7 +8,7 @@ create table hs_office_debitor
|
|||||||
(
|
(
|
||||||
uuid uuid unique references RbacObject (uuid) initially deferred,
|
uuid uuid unique references RbacObject (uuid) initially deferred,
|
||||||
debitorNumberSuffix numeric(2) not null,
|
debitorNumberSuffix numeric(2) not null,
|
||||||
debitorRelUuid uuid not null references hs_office_relationship(uuid),
|
debitorRelUuid uuid not null references hs_office_relation(uuid),
|
||||||
billable boolean not null default true,
|
billable boolean not null default true,
|
||||||
vatId varchar(24), -- TODO.spec: here or in person?
|
vatId varchar(24), -- TODO.spec: here or in person?
|
||||||
vatCountryCode varchar(2),
|
vatCountryCode varchar(2),
|
||||||
|
@ -30,25 +30,25 @@ create or replace procedure buildRbacSystemForHsOfficeDebitor(
|
|||||||
language plpgsql as $$
|
language plpgsql as $$
|
||||||
|
|
||||||
declare
|
declare
|
||||||
newPartnerRel hs_office_relationship;
|
newPartnerRel hs_office_relation;
|
||||||
newDebitorRel hs_office_relationship;
|
newDebitorRel hs_office_relation;
|
||||||
newRefundBankAccount hs_office_bankaccount;
|
newRefundBankAccount hs_office_bankaccount;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
call enterTriggerForObjectUuid(NEW.uuid);
|
call enterTriggerForObjectUuid(NEW.uuid);
|
||||||
|
|
||||||
SELECT partnerRel.*
|
SELECT partnerRel.*
|
||||||
FROM hs_office_relationship AS partnerRel
|
FROM hs_office_relation AS partnerRel
|
||||||
JOIN hs_office_relationship AS debitorRel
|
JOIN hs_office_relation AS debitorRel
|
||||||
ON debitorRel.relType = 'ACCOUNTING' AND debitorRel.relAnchorUuid = partnerRel.relHolderUuid
|
ON debitorRel.type = 'DEBITOR' AND debitorRel.anchorUuid = partnerRel.holderUuid
|
||||||
WHERE partnerRel.relType = 'PARTNER'
|
WHERE partnerRel.type = 'PARTNER'
|
||||||
AND NEW.debitorRelUuid = debitorRel.uuid
|
AND NEW.debitorRelUuid = debitorRel.uuid
|
||||||
INTO newPartnerRel;
|
INTO newPartnerRel;
|
||||||
assert newPartnerRel.uuid is not null, format('newPartnerRel must not be null for NEW.debitorRelUuid = %s', NEW.debitorRelUuid);
|
assert newPartnerRel.uuid is not null, format('newPartnerRel must not be null for NEW.debitorRelUuid = %s', NEW.debitorRelUuid);
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM hs_office_relationship AS r
|
FROM hs_office_relation AS r
|
||||||
WHERE r.relType = 'ACCOUNTING' AND r.uuid = NEW.debitorRelUuid
|
WHERE r.type = 'DEBITOR' AND r.uuid = NEW.debitorRelUuid
|
||||||
INTO newDebitorRel;
|
INTO newDebitorRel;
|
||||||
assert newDebitorRel.uuid is not null, format('newDebitorRel must not be null for NEW.debitorRelUuid = %s', NEW.debitorRelUuid);
|
assert newDebitorRel.uuid is not null, format('newDebitorRel must not be null for NEW.debitorRelUuid = %s', NEW.debitorRelUuid);
|
||||||
|
|
||||||
@ -57,15 +57,15 @@ begin
|
|||||||
WHERE b.uuid = NEW.refundBankAccountUuid
|
WHERE b.uuid = NEW.refundBankAccountUuid
|
||||||
INTO newRefundBankAccount;
|
INTO newRefundBankAccount;
|
||||||
|
|
||||||
call grantRoleToRole(hsOfficeBankAccountReferrer(newRefundBankAccount), hsOfficeRelationshipAgent(newDebitorRel));
|
call grantRoleToRole(hsOfficeBankAccountReferrer(newRefundBankAccount), hsOfficeRelationAgent(newDebitorRel));
|
||||||
call grantRoleToRole(hsOfficeRelationshipAdmin(newDebitorRel), hsOfficeRelationshipAdmin(newPartnerRel));
|
call grantRoleToRole(hsOfficeRelationAdmin(newDebitorRel), hsOfficeRelationAdmin(newPartnerRel));
|
||||||
call grantRoleToRole(hsOfficeRelationshipAgent(newDebitorRel), hsOfficeBankAccountAdmin(newRefundBankAccount));
|
call grantRoleToRole(hsOfficeRelationAgent(newDebitorRel), hsOfficeBankAccountAdmin(newRefundBankAccount));
|
||||||
call grantRoleToRole(hsOfficeRelationshipAgent(newDebitorRel), hsOfficeRelationshipAgent(newPartnerRel));
|
call grantRoleToRole(hsOfficeRelationAgent(newDebitorRel), hsOfficeRelationAgent(newPartnerRel));
|
||||||
call grantRoleToRole(hsOfficeRelationshipTenant(newPartnerRel), hsOfficeRelationshipAgent(newDebitorRel));
|
call grantRoleToRole(hsOfficeRelationTenant(newPartnerRel), hsOfficeRelationAgent(newDebitorRel));
|
||||||
|
|
||||||
call grantPermissionToRole(createPermission(NEW.uuid, 'DELETE'), hsOfficeRelationshipOwner(newDebitorRel));
|
call grantPermissionToRole(createPermission(NEW.uuid, 'DELETE'), hsOfficeRelationOwner(newDebitorRel));
|
||||||
call grantPermissionToRole(createPermission(NEW.uuid, 'SELECT'), hsOfficeRelationshipTenant(newDebitorRel));
|
call grantPermissionToRole(createPermission(NEW.uuid, 'SELECT'), hsOfficeRelationTenant(newDebitorRel));
|
||||||
call grantPermissionToRole(createPermission(NEW.uuid, 'UPDATE'), hsOfficeRelationshipAdmin(newDebitorRel));
|
call grantPermissionToRole(createPermission(NEW.uuid, 'UPDATE'), hsOfficeRelationAdmin(newDebitorRel));
|
||||||
|
|
||||||
call leaveTriggerForObjectUuid(NEW.uuid);
|
call leaveTriggerForObjectUuid(NEW.uuid);
|
||||||
end; $$;
|
end; $$;
|
||||||
@ -202,10 +202,10 @@ create trigger hs_office_debitor_insert_permission_check_tg
|
|||||||
SELECT debitor.uuid AS uuid,
|
SELECT debitor.uuid AS uuid,
|
||||||
'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_relation partnerRel
|
||||||
ON partnerRel.uuid = partner.partnerRoleUUid AND partnerRel.relType = 'PARTNER'
|
ON partnerRel.uuid = partner.partnerRelUUid AND partnerRel.type = 'PARTNER'
|
||||||
JOIN hs_office_relationship debitorRel
|
JOIN hs_office_relation debitorRel
|
||||||
ON debitorRel.relAnchorUuid = partnerRel.relHolderUuid AND debitorRel.relType = 'ACCOUNTING'
|
ON debitorRel.anchorUuid = partnerRel.holderUuid AND debitorRel.type = 'DEBITOR'
|
||||||
WHERE debitorRel.uuid = debitor.debitorRelUuid)
|
WHERE debitorRel.uuid = debitor.debitorRelUuid)
|
||||||
|| to_char(debitorNumberSuffix, 'fm00') as idName
|
|| to_char(debitorNumberSuffix, 'fm00') as idName
|
||||||
FROM hs_office_debitor AS debitor
|
FROM hs_office_debitor AS debitor
|
||||||
|
@ -28,10 +28,10 @@ begin
|
|||||||
|
|
||||||
select debitorRel.uuid
|
select debitorRel.uuid
|
||||||
into relatedDebitorRelUuid
|
into relatedDebitorRelUuid
|
||||||
from hs_office_relationship debitorRel
|
from hs_office_relation debitorRel
|
||||||
join hs_office_person person on person.uuid = debitorRel.relHolderUuid
|
join hs_office_person person on person.uuid = debitorRel.holderUuid
|
||||||
and (person.tradeName = forPartnerPersonName or person.familyName = forPartnerPersonName)
|
and (person.tradeName = forPartnerPersonName or person.familyName = forPartnerPersonName)
|
||||||
where debitorRel.relType = 'ACCOUNTING';
|
where debitorRel.type = 'DEBITOR';
|
||||||
|
|
||||||
select b.uuid
|
select b.uuid
|
||||||
into relatedBankAccountUuid
|
into relatedBankAccountUuid
|
||||||
|
@ -30,14 +30,14 @@ create or replace procedure buildRbacSystemForHsOfficeMembership(
|
|||||||
language plpgsql as $$
|
language plpgsql as $$
|
||||||
|
|
||||||
declare
|
declare
|
||||||
newPartnerRel hs_office_relationship;
|
newPartnerRel hs_office_relation;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
call enterTriggerForObjectUuid(NEW.uuid);
|
call enterTriggerForObjectUuid(NEW.uuid);
|
||||||
|
|
||||||
SELECT r.*
|
SELECT r.*
|
||||||
FROM hs_office_partner AS p
|
FROM hs_office_partner AS p
|
||||||
JOIN hs_office_relationship AS r ON r.uuid = p.partnerRoleUuid
|
JOIN hs_office_relation AS r ON r.uuid = p.partnerRelUuid
|
||||||
WHERE p.uuid = NEW.partnerUuid
|
WHERE p.uuid = NEW.partnerUuid
|
||||||
INTO newPartnerRel;
|
INTO newPartnerRel;
|
||||||
assert newPartnerRel.uuid is not null, format('newPartnerRel must not be null for NEW.partnerUuid = %s', NEW.partnerUuid);
|
assert newPartnerRel.uuid is not null, format('newPartnerRel must not be null for NEW.partnerUuid = %s', NEW.partnerUuid);
|
||||||
@ -46,7 +46,7 @@ begin
|
|||||||
perform createRoleWithGrants(
|
perform createRoleWithGrants(
|
||||||
hsOfficeMembershipOwner(NEW),
|
hsOfficeMembershipOwner(NEW),
|
||||||
permissions => array['DELETE'],
|
permissions => array['DELETE'],
|
||||||
incomingSuperRoles => array[hsOfficeRelationshipAdmin(newPartnerRel)],
|
incomingSuperRoles => array[hsOfficeRelationAdmin(newPartnerRel)],
|
||||||
userUuids => array[currentUserUuid()]
|
userUuids => array[currentUserUuid()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -55,14 +55,14 @@ begin
|
|||||||
permissions => array['UPDATE'],
|
permissions => array['UPDATE'],
|
||||||
incomingSuperRoles => array[
|
incomingSuperRoles => array[
|
||||||
hsOfficeMembershipOwner(NEW),
|
hsOfficeMembershipOwner(NEW),
|
||||||
hsOfficeRelationshipAgent(newPartnerRel)]
|
hsOfficeRelationAgent(newPartnerRel)]
|
||||||
);
|
);
|
||||||
|
|
||||||
perform createRoleWithGrants(
|
perform createRoleWithGrants(
|
||||||
hsOfficeMembershipReferrer(NEW),
|
hsOfficeMembershipReferrer(NEW),
|
||||||
permissions => array['SELECT'],
|
permissions => array['SELECT'],
|
||||||
incomingSuperRoles => array[hsOfficeMembershipAdmin(NEW)],
|
incomingSuperRoles => array[hsOfficeMembershipAdmin(NEW)],
|
||||||
outgoingSubRoles => array[hsOfficeRelationshipTenant(newPartnerRel)]
|
outgoingSubRoles => array[hsOfficeRelationTenant(newPartnerRel)]
|
||||||
);
|
);
|
||||||
|
|
||||||
call leaveTriggerForObjectUuid(NEW.uuid);
|
call leaveTriggerForObjectUuid(NEW.uuid);
|
||||||
@ -93,19 +93,19 @@ execute procedure insertTriggerForHsOfficeMembership_tf();
|
|||||||
-- ----------------------------------------------------------------------------
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Creates INSERT INTO hs_office_membership permissions for the related hs_office_relationship rows.
|
Creates INSERT INTO hs_office_membership permissions for the related hs_office_relation rows.
|
||||||
*/
|
*/
|
||||||
do language plpgsql $$
|
do language plpgsql $$
|
||||||
declare
|
declare
|
||||||
row hs_office_relationship;
|
row hs_office_relation;
|
||||||
permissionUuid uuid;
|
permissionUuid uuid;
|
||||||
roleUuid uuid;
|
roleUuid uuid;
|
||||||
begin
|
begin
|
||||||
call defineContext('create INSERT INTO hs_office_membership permissions for the related hs_office_relationship rows');
|
call defineContext('create INSERT INTO hs_office_membership permissions for the related hs_office_relation rows');
|
||||||
|
|
||||||
FOR row IN SELECT * FROM hs_office_relationship
|
FOR row IN SELECT * FROM hs_office_relation
|
||||||
LOOP
|
LOOP
|
||||||
roleUuid := findRoleId(hsOfficeRelationshipAdmin(row));
|
roleUuid := findRoleId(hsOfficeRelationAdmin(row));
|
||||||
permissionUuid := createPermission(row.uuid, 'INSERT', 'hs_office_membership');
|
permissionUuid := createPermission(row.uuid, 'INSERT', 'hs_office_membership');
|
||||||
call grantPermissionToRole(permissionUuid, roleUuid);
|
call grantPermissionToRole(permissionUuid, roleUuid);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
@ -113,24 +113,24 @@ do language plpgsql $$
|
|||||||
$$;
|
$$;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds hs_office_membership INSERT permission to specified role of new hs_office_relationship rows.
|
Adds hs_office_membership INSERT permission to specified role of new hs_office_relation rows.
|
||||||
*/
|
*/
|
||||||
create or replace function hs_office_membership_hs_office_relationship_insert_tf()
|
create or replace function hs_office_membership_hs_office_relation_insert_tf()
|
||||||
returns trigger
|
returns trigger
|
||||||
language plpgsql
|
language plpgsql
|
||||||
strict as $$
|
strict as $$
|
||||||
begin
|
begin
|
||||||
call grantPermissionToRole(
|
call grantPermissionToRole(
|
||||||
createPermission(NEW.uuid, 'INSERT', 'hs_office_membership'),
|
createPermission(NEW.uuid, 'INSERT', 'hs_office_membership'),
|
||||||
hsOfficeRelationshipAdmin(NEW));
|
hsOfficeRelationAdmin(NEW));
|
||||||
return NEW;
|
return NEW;
|
||||||
end; $$;
|
end; $$;
|
||||||
|
|
||||||
-- z_... is to put it at the end of after insert triggers, to make sure the roles exist
|
-- z_... is to put it at the end of after insert triggers, to make sure the roles exist
|
||||||
create trigger z_hs_office_membership_hs_office_relationship_insert_tg
|
create trigger z_hs_office_membership_hs_office_relation_insert_tg
|
||||||
after insert on hs_office_relationship
|
after insert on hs_office_relation
|
||||||
for each row
|
for each row
|
||||||
execute procedure hs_office_membership_hs_office_relationship_insert_tf();
|
execute procedure hs_office_membership_hs_office_relation_insert_tf();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Checks if the user or assumed roles are allowed to insert a row to hs_office_membership.
|
Checks if the user or assumed roles are allowed to insert a row to hs_office_membership.
|
||||||
@ -144,7 +144,7 @@ begin
|
|||||||
|
|
||||||
(SELECT r.*
|
(SELECT r.*
|
||||||
FROM hs_office_partner AS p
|
FROM hs_office_partner AS p
|
||||||
JOIN hs_office_relationship AS r ON r.uuid = p.partnerRoleUuid
|
JOIN hs_office_relation AS r ON r.uuid = p.partnerRelUuid
|
||||||
WHERE p.uuid = NEW.partnerUuid
|
WHERE p.uuid = NEW.partnerUuid
|
||||||
) AS partnerRel
|
) AS partnerRel
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountReposi
|
|||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipRepository;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
|
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
|
||||||
import net.hostsharing.test.Accepts;
|
import net.hostsharing.test.Accepts;
|
||||||
import net.hostsharing.test.JpaAttempt;
|
import net.hostsharing.test.JpaAttempt;
|
||||||
@ -27,7 +27,7 @@ import jakarta.persistence.EntityManager;
|
|||||||
import jakarta.persistence.PersistenceContext;
|
import jakarta.persistence.PersistenceContext;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipType.ACCOUNTING;
|
import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.DEBITOR;
|
||||||
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
|
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
|
||||||
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
|
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -65,7 +65,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
HsOfficePersonRepository personRepo;
|
HsOfficePersonRepository personRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsOfficeRelationshipRepository relRepo;
|
HsOfficeRelationRepository relRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
JpaAttempt jpaAttempt;
|
JpaAttempt jpaAttempt;
|
||||||
@ -93,20 +93,20 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"debitorRel": {
|
"debitorRel": {
|
||||||
"relAnchor": {
|
"anchor": {
|
||||||
"personType": "LEGAL_PERSON",
|
"personType": "LEGAL_PERSON",
|
||||||
"tradeName": "First GmbH",
|
"tradeName": "First GmbH",
|
||||||
"givenName": null,
|
"givenName": null,
|
||||||
"familyName": null
|
"familyName": null
|
||||||
},
|
},
|
||||||
"relHolder": {
|
"holder": {
|
||||||
"personType": "LEGAL_PERSON",
|
"personType": "LEGAL_PERSON",
|
||||||
"tradeName": "First GmbH",
|
"tradeName": "First GmbH",
|
||||||
"givenName": null,
|
"givenName": null,
|
||||||
"familyName": null
|
"familyName": null
|
||||||
},
|
},
|
||||||
"relType": "ACCOUNTING",
|
"type": "DEBITOR",
|
||||||
"relMark": null,
|
"mark": null,
|
||||||
"contact": {
|
"contact": {
|
||||||
"label": "first contact",
|
"label": "first contact",
|
||||||
"emailAddresses": "contact-admin@firstcontact.example.com",
|
"emailAddresses": "contact-admin@firstcontact.example.com",
|
||||||
@ -117,21 +117,21 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
"debitorNumberSuffix": 11,
|
"debitorNumberSuffix": 11,
|
||||||
"partner": {
|
"partner": {
|
||||||
"partnerNumber": 10001,
|
"partnerNumber": 10001,
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchor": {
|
"anchor": {
|
||||||
"personType": "LEGAL_PERSON",
|
"personType": "LEGAL_PERSON",
|
||||||
"tradeName": "Hostsharing eG",
|
"tradeName": "Hostsharing eG",
|
||||||
"givenName": null,
|
"givenName": null,
|
||||||
"familyName": null
|
"familyName": null
|
||||||
},
|
},
|
||||||
"relHolder": {
|
"holder": {
|
||||||
"personType": "LEGAL_PERSON",
|
"personType": "LEGAL_PERSON",
|
||||||
"tradeName": "First GmbH",
|
"tradeName": "First GmbH",
|
||||||
"givenName": null,
|
"givenName": null,
|
||||||
"familyName": null
|
"familyName": null
|
||||||
},
|
},
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"relMark": null,
|
"mark": null,
|
||||||
"contact": {
|
"contact": {
|
||||||
"label": "first contact",
|
"label": "first contact",
|
||||||
"emailAddresses": "contact-admin@firstcontact.example.com",
|
"emailAddresses": "contact-admin@firstcontact.example.com",
|
||||||
@ -161,19 +161,19 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"debitorRel": {
|
"debitorRel": {
|
||||||
"relAnchor": {"tradeName": "Second e.K."},
|
"anchor": {"tradeName": "Second e.K."},
|
||||||
"relHolder": {"tradeName": "Second e.K."},
|
"holder": {"tradeName": "Second e.K."},
|
||||||
"relType": "ACCOUNTING",
|
"type": "DEBITOR",
|
||||||
"contact": {"emailAddresses": "contact-admin@secondcontact.example.com"}
|
"contact": {"emailAddresses": "contact-admin@secondcontact.example.com"}
|
||||||
},
|
},
|
||||||
"debitorNumber": 1000212,
|
"debitorNumber": 1000212,
|
||||||
"debitorNumberSuffix": 12,
|
"debitorNumberSuffix": 12,
|
||||||
"partner": {
|
"partner": {
|
||||||
"partnerNumber": 10002,
|
"partnerNumber": 10002,
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchor": {"tradeName": "Hostsharing eG"},
|
"anchor": {"tradeName": "Hostsharing eG"},
|
||||||
"relHolder": {"tradeName": "Second e.K."},
|
"holder": {"tradeName": "Second e.K."},
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"contact": {"emailAddresses": "contact-admin@secondcontact.example.com"}
|
"contact": {"emailAddresses": "contact-admin@secondcontact.example.com"}
|
||||||
},
|
},
|
||||||
"details": {
|
"details": {
|
||||||
@ -191,19 +191,19 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"debitorRel": {
|
"debitorRel": {
|
||||||
"relAnchor": {"tradeName": "Third OHG"},
|
"anchor": {"tradeName": "Third OHG"},
|
||||||
"relHolder": {"tradeName": "Third OHG"},
|
"holder": {"tradeName": "Third OHG"},
|
||||||
"relType": "ACCOUNTING",
|
"type": "DEBITOR",
|
||||||
"contact": {"emailAddresses": "contact-admin@thirdcontact.example.com"}
|
"contact": {"emailAddresses": "contact-admin@thirdcontact.example.com"}
|
||||||
},
|
},
|
||||||
"debitorNumber": 1000313,
|
"debitorNumber": 1000313,
|
||||||
"debitorNumberSuffix": 13,
|
"debitorNumberSuffix": 13,
|
||||||
"partner": {
|
"partner": {
|
||||||
"partnerNumber": 10003,
|
"partnerNumber": 10003,
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchor": {"tradeName": "Hostsharing eG"},
|
"anchor": {"tradeName": "Hostsharing eG"},
|
||||||
"relHolder": {"tradeName": "Third OHG"},
|
"holder": {"tradeName": "Third OHG"},
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"contact": {"emailAddresses": "contact-admin@thirdcontact.example.com"}
|
"contact": {"emailAddresses": "contact-admin@thirdcontact.example.com"}
|
||||||
},
|
},
|
||||||
"details": {
|
"details": {
|
||||||
@ -268,10 +268,10 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
|
|
||||||
final var givenDebitorRelUUid = jpaAttempt.transacted(() -> {
|
final var givenDebitorRelUUid = jpaAttempt.transacted(() -> {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
return relRepo.save(HsOfficeRelationshipEntity.builder()
|
return relRepo.save(HsOfficeRelationEntity.builder()
|
||||||
.relType(ACCOUNTING)
|
.type(DEBITOR)
|
||||||
.relAnchor(givenPartner.getPartnerRole().getRelHolder())
|
.anchor(givenPartner.getPartnerRel().getHolder())
|
||||||
.relHolder(givenBillingPerson)
|
.holder(givenBillingPerson)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build()).getUuid();
|
.build()).getUuid();
|
||||||
}).assertSuccessful().returnedValue();
|
}).assertSuccessful().returnedValue();
|
||||||
@ -303,7 +303,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("vatId", is("VAT123456"))
|
.body("vatId", is("VAT123456"))
|
||||||
.body("defaultPrefix", is("for"))
|
.body("defaultPrefix", is("for"))
|
||||||
.body("debitorRel.contact.label", is(givenContact.getLabel()))
|
.body("debitorRel.contact.label", is(givenContact.getLabel()))
|
||||||
.body("debitorRel.relHolder.tradeName", is(givenBillingPerson.getTradeName()))
|
.body("debitorRel.holder.tradeName", is(givenBillingPerson.getTradeName()))
|
||||||
.body("refundBankAccount.holder", is(givenBankAccount.getHolder()))
|
.body("refundBankAccount.holder", is(givenBankAccount.getHolder()))
|
||||||
.header("Location", startsWith("http://localhost"))
|
.header("Location", startsWith("http://localhost"))
|
||||||
.extract().header("Location"); // @formatter:on
|
.extract().header("Location"); // @formatter:on
|
||||||
@ -328,9 +328,9 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"debitorRel": {
|
"debitorRel": {
|
||||||
"relType": "ACCOUNTING",
|
"type": "DEBITOR",
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
},
|
},
|
||||||
"debitorNumberSuffix": "%s",
|
"debitorNumberSuffix": "%s",
|
||||||
@ -339,8 +339,8 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
"vatReverseCharge": "false"
|
"vatReverseCharge": "false"
|
||||||
}
|
}
|
||||||
""".formatted(
|
""".formatted(
|
||||||
givenPartner.getPartnerRole().getRelHolder().getUuid(),
|
givenPartner.getPartnerRel().getHolder().getUuid(),
|
||||||
givenPartner.getPartnerRole().getRelHolder().getUuid(),
|
givenPartner.getPartnerRel().getHolder().getUuid(),
|
||||||
givenContact.getUuid(),
|
givenContact.getUuid(),
|
||||||
++nextDebitorSuffix))
|
++nextDebitorSuffix))
|
||||||
.port(port)
|
.port(port)
|
||||||
@ -351,7 +351,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("uuid", isUuidValid())
|
.body("uuid", isUuidValid())
|
||||||
.body("debitorRel.contact.label", is(givenContact.getLabel()))
|
.body("debitorRel.contact.label", is(givenContact.getLabel()))
|
||||||
.body("partner.partnerRole.relHolder.tradeName", is(givenPartner.getPartnerRole().getRelHolder().getTradeName()))
|
.body("partner.partnerRel.holder.tradeName", is(givenPartner.getPartnerRel().getHolder().getTradeName()))
|
||||||
.body("vatId", equalTo(null))
|
.body("vatId", equalTo(null))
|
||||||
.body("vatCountryCode", equalTo(null))
|
.body("vatCountryCode", equalTo(null))
|
||||||
.body("vatBusiness", equalTo(false))
|
.body("vatBusiness", equalTo(false))
|
||||||
@ -380,9 +380,9 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"debitorRel": {
|
"debitorRel": {
|
||||||
"relType": "ACCOUNTING",
|
"type": "DEBITOR",
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
},
|
},
|
||||||
"debitorNumberSuffix": "%s",
|
"debitorNumberSuffix": "%s",
|
||||||
@ -391,8 +391,8 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
"vatReverseCharge": "false"
|
"vatReverseCharge": "false"
|
||||||
}
|
}
|
||||||
""".formatted(
|
""".formatted(
|
||||||
givenPartner.getPartnerRole().getRelAnchor().getUuid(),
|
givenPartner.getPartnerRel().getAnchor().getUuid(),
|
||||||
givenPartner.getPartnerRole().getRelAnchor().getUuid(),
|
givenPartner.getPartnerRel().getAnchor().getUuid(),
|
||||||
givenContactUuid, ++nextDebitorSuffix))
|
givenContactUuid, ++nextDebitorSuffix))
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
@ -428,7 +428,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.post("http://localhost/api/hs/office/debitors")
|
.post("http://localhost/api/hs/office/debitors")
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(400)
|
.statusCode(400)
|
||||||
.body("message", is("Unable to find HsOfficeRelationshipEntity with uuid 00000000-0000-0000-0000-000000000000"));
|
.body("message", is("Unable to find HsOfficeRelationEntity with uuid 00000000-0000-0000-0000-000000000000"));
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -454,9 +454,9 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("", lenientlyEquals("""
|
.body("", lenientlyEquals("""
|
||||||
{
|
{
|
||||||
"debitorRel": {
|
"debitorRel": {
|
||||||
"relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH"},
|
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH"},
|
||||||
"relHolder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH"},
|
"holder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH"},
|
||||||
"relType": "ACCOUNTING",
|
"type": "DEBITOR",
|
||||||
"contact": {
|
"contact": {
|
||||||
"label": "first contact",
|
"label": "first contact",
|
||||||
"postalAddress": "\\nVorname Nachname\\nStraße Hnr\\nPLZ Stadt\\n",
|
"postalAddress": "\\nVorname Nachname\\nStraße Hnr\\nPLZ Stadt\\n",
|
||||||
@ -468,11 +468,11 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
"debitorNumberSuffix": 11,
|
"debitorNumberSuffix": 11,
|
||||||
"partner": {
|
"partner": {
|
||||||
"partnerNumber": 10001,
|
"partnerNumber": 10001,
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG"},
|
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG"},
|
||||||
"relHolder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH"},
|
"holder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH"},
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"relMark": null,
|
"mark": null,
|
||||||
"contact": {
|
"contact": {
|
||||||
"label": "first contact",
|
"label": "first contact",
|
||||||
"postalAddress": "\\nVorname Nachname\\nStraße Hnr\\nPLZ Stadt\\n",
|
"postalAddress": "\\nVorname Nachname\\nStraße Hnr\\nPLZ Stadt\\n",
|
||||||
@ -576,7 +576,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("vatBusiness", is(true))
|
.body("vatBusiness", is(true))
|
||||||
.body("defaultPrefix", is("for"))
|
.body("defaultPrefix", is("for"))
|
||||||
// FIXME .body("billingContact.label", is(givenContact.getLabel()))
|
// FIXME .body("billingContact.label", is(givenContact.getLabel()))
|
||||||
// FIXME .body("partner.partnerRole.relHolder.tradeName", is(givenDebitor.getPartner().getPartnerRole().getRelHolder().getTradeName()))
|
// FIXME .body("partner.partnerRel.holder.tradeName", is(givenDebitor.getPartner().getPartnerRel().getHolder().getTradeName()))
|
||||||
;
|
;
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
@ -584,8 +584,8 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
assertThat(debitorRepo.findByUuid(givenDebitor.getUuid())).isPresent().get()
|
assertThat(debitorRepo.findByUuid(givenDebitor.getUuid())).isPresent().get()
|
||||||
.matches(debitor -> {
|
.matches(debitor -> {
|
||||||
assertThat(debitor.getDebitorRel().getRelHolder().getTradeName())
|
assertThat(debitor.getDebitorRel().getHolder().getTradeName())
|
||||||
.isEqualTo(givenDebitor.getDebitorRel().getRelHolder().getTradeName());
|
.isEqualTo(givenDebitor.getDebitorRel().getHolder().getTradeName());
|
||||||
assertThat(debitor.getDebitorRel().getContact().getLabel()).isEqualTo("fourth contact");
|
assertThat(debitor.getDebitorRel().getContact().getLabel()).isEqualTo("fourth contact");
|
||||||
assertThat(debitor.getVatId()).isEqualTo("VAT222222");
|
assertThat(debitor.getVatId()).isEqualTo("VAT222222");
|
||||||
assertThat(debitor.getVatCountryCode()).isEqualTo("AA");
|
assertThat(debitor.getVatCountryCode()).isEqualTo("AA");
|
||||||
@ -627,8 +627,8 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
// finally, the debitor is actually updated
|
// finally, the debitor is actually updated
|
||||||
assertThat(debitorRepo.findByUuid(givenDebitor.getUuid())).isPresent().get()
|
assertThat(debitorRepo.findByUuid(givenDebitor.getUuid())).isPresent().get()
|
||||||
.matches(partner -> {
|
.matches(partner -> {
|
||||||
assertThat(partner.getDebitorRel().getRelHolder().getTradeName())
|
assertThat(partner.getDebitorRel().getHolder().getTradeName())
|
||||||
.isEqualTo(givenDebitor.getDebitorRel().getRelHolder().getTradeName());
|
.isEqualTo(givenDebitor.getDebitorRel().getHolder().getTradeName());
|
||||||
// FIXME assertThat(partner.getDebitorRel().getContact().getLabel()).isEqualTo("sixth contact");
|
// FIXME assertThat(partner.getDebitorRel().getContact().getLabel()).isEqualTo("sixth contact");
|
||||||
assertThat(partner.getVatId()).isEqualTo("VAT999999");
|
assertThat(partner.getVatId()).isEqualTo("VAT999999");
|
||||||
assertThat(partner.getVatCountryCode()).isEqualTo(givenDebitor.getVatCountryCode());
|
assertThat(partner.getVatCountryCode()).isEqualTo(givenDebitor.getVatCountryCode());
|
||||||
@ -711,10 +711,10 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.debitorNumberSuffix(++nextDebitorSuffix)
|
.debitorNumberSuffix(++nextDebitorSuffix)
|
||||||
.billable(true)
|
.billable(true)
|
||||||
.debitorRel(
|
.debitorRel(
|
||||||
HsOfficeRelationshipEntity.builder()
|
HsOfficeRelationEntity.builder()
|
||||||
.relType(ACCOUNTING)
|
.type(DEBITOR)
|
||||||
.relAnchor(givenPartner.getPartnerRole().getRelHolder())
|
.anchor(givenPartner.getPartnerRel().getHolder())
|
||||||
.relHolder(givenPartner.getPartnerRole().getRelHolder())
|
.holder(givenPartner.getPartnerRel().getHolder())
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.debitor;
|
|||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.test.PatchUnitTestBase;
|
import net.hostsharing.test.PatchUnitTestBase;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
@ -44,7 +44,7 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
private static final UUID INITIAL_REFUND_BANK_ACCOUNT_UUID = UUID.randomUUID();
|
private static final UUID INITIAL_REFUND_BANK_ACCOUNT_UUID = UUID.randomUUID();
|
||||||
private static final UUID PATCHED_REFUND_BANK_ACCOUNT_UUID = UUID.randomUUID();
|
private static final UUID PATCHED_REFUND_BANK_ACCOUNT_UUID = UUID.randomUUID();
|
||||||
|
|
||||||
private final HsOfficeRelationshipEntity givenInitialDebitorRel = HsOfficeRelationshipEntity.builder()
|
private final HsOfficeRelationEntity givenInitialDebitorRel = HsOfficeRelationEntity.builder()
|
||||||
.uuid(INITIAL_DEBITOR_REL_UUID)
|
.uuid(INITIAL_DEBITOR_REL_UUID)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void initMocks() {
|
void initMocks() {
|
||||||
lenient().when(em.getReference(eq(HsOfficeRelationshipEntity.class), any())).thenAnswer(invocation ->
|
lenient().when(em.getReference(eq(HsOfficeRelationEntity.class), any())).thenAnswer(invocation ->
|
||||||
HsOfficeRelationshipEntity.builder().uuid(invocation.getArgument(1)).build());
|
HsOfficeRelationEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||||
lenient().when(em.getReference(eq(HsOfficeBankAccountEntity.class), any())).thenAnswer(invocation ->
|
lenient().when(em.getReference(eq(HsOfficeBankAccountEntity.class), any())).thenAnswer(invocation ->
|
||||||
HsOfficeBankAccountEntity.builder().uuid(invocation.getArgument(1)).build());
|
HsOfficeBankAccountEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||||
}
|
}
|
||||||
@ -141,8 +141,8 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HsOfficeRelationshipEntity newDebitorRel(final UUID uuid) {
|
private HsOfficeRelationEntity newDebitorRel(final UUID uuid) {
|
||||||
return HsOfficeRelationshipEntity.builder()
|
return HsOfficeRelationEntity.builder()
|
||||||
.uuid(uuid)
|
.uuid(uuid)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,19 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
|||||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class HsOfficeDebitorEntityUnitTest {
|
class HsOfficeDebitorEntityUnitTest {
|
||||||
|
|
||||||
private HsOfficeRelationshipEntity givenDebitorRel = HsOfficeRelationshipEntity.builder()
|
private HsOfficeRelationEntity givenDebitorRel = HsOfficeRelationEntity.builder()
|
||||||
.relAnchor(HsOfficePersonEntity.builder()
|
.anchor(HsOfficePersonEntity.builder()
|
||||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||||
.tradeName("some partner trade name")
|
.tradeName("some partner trade name")
|
||||||
.build())
|
.build())
|
||||||
.relHolder(HsOfficePersonEntity.builder()
|
.holder(HsOfficePersonEntity.builder()
|
||||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||||
.tradeName("some billing trade name")
|
.tradeName("some billing trade name")
|
||||||
.build())
|
.build())
|
||||||
@ -36,7 +36,7 @@ class HsOfficeDebitorEntityUnitTest {
|
|||||||
|
|
||||||
final var result = given.toString();
|
final var result = given.toString();
|
||||||
|
|
||||||
assertThat(result).isEqualTo("debitor(D-1234567: rel(relAnchor='LP some partner trade name', relHolder='LP some billing trade name'), som)");
|
assertThat(result).isEqualTo("debitor(D-1234567: rel(anchor='LP some partner trade name', holder='LP some billing trade name'), som)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -5,8 +5,8 @@ import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountReposi
|
|||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipType;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||||
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
|
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
|
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService;
|
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantsDiagramService;
|
||||||
@ -89,10 +89,10 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final var result = attempt(em, () -> {
|
final var result = attempt(em, () -> {
|
||||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||||
.debitorNumberSuffix((byte)21)
|
.debitorNumberSuffix((byte)21)
|
||||||
.debitorRel(HsOfficeRelationshipEntity.builder()
|
.debitorRel(HsOfficeRelationEntity.builder()
|
||||||
.relType(HsOfficeRelationshipType.ACCOUNTING)
|
.type(HsOfficeRelationType.DEBITOR)
|
||||||
.relAnchor(givenPartnerPerson)
|
.anchor(givenPartnerPerson)
|
||||||
.relHolder(givenPartnerPerson)
|
.holder(givenPartnerPerson)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build())
|
.build())
|
||||||
.defaultPrefix("abc")
|
.defaultPrefix("abc")
|
||||||
@ -121,10 +121,10 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final var result = attempt(em, () -> {
|
final var result = attempt(em, () -> {
|
||||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||||
.debitorNumberSuffix((byte)21)
|
.debitorNumberSuffix((byte)21)
|
||||||
.debitorRel(HsOfficeRelationshipEntity.builder()
|
.debitorRel(HsOfficeRelationEntity.builder()
|
||||||
.relType(HsOfficeRelationshipType.ACCOUNTING)
|
.type(HsOfficeRelationType.DEBITOR)
|
||||||
.relAnchor(givenPartnerPerson)
|
.anchor(givenPartnerPerson)
|
||||||
.relHolder(givenPartnerPerson)
|
.holder(givenPartnerPerson)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build())
|
.build())
|
||||||
.billable(true)
|
.billable(true)
|
||||||
@ -156,10 +156,10 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final var givenContact = one(contactRepo.findContactByOptionalLabelLike("fourth contact"));
|
final var givenContact = one(contactRepo.findContactByOptionalLabelLike("fourth contact"));
|
||||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||||
.debitorNumberSuffix((byte)22)
|
.debitorNumberSuffix((byte)22)
|
||||||
.debitorRel(HsOfficeRelationshipEntity.builder()
|
.debitorRel(HsOfficeRelationEntity.builder()
|
||||||
.relType(HsOfficeRelationshipType.ACCOUNTING)
|
.type(HsOfficeRelationType.DEBITOR)
|
||||||
.relAnchor(givenPartnerPerson)
|
.anchor(givenPartnerPerson)
|
||||||
.relHolder(givenDebitorPerson)
|
.holder(givenDebitorPerson)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build())
|
.build())
|
||||||
.defaultPrefix("abc")
|
.defaultPrefix("abc")
|
||||||
@ -171,45 +171,45 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
// then
|
// then
|
||||||
assertThat(distinctRoleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(Array.from(
|
assertThat(distinctRoleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(Array.from(
|
||||||
initialRoleNames,
|
initialRoleNames,
|
||||||
"hs_office_relationship#FirstGmbH-with-ACCOUNTING-FourtheG.owner",
|
"hs_office_relation#FirstGmbH-with-DEBITOR-FourtheG.owner",
|
||||||
"hs_office_relationship#FirstGmbH-with-ACCOUNTING-FourtheG.admin",
|
"hs_office_relation#FirstGmbH-with-DEBITOR-FourtheG.admin",
|
||||||
"hs_office_relationship#FirstGmbH-with-ACCOUNTING-FourtheG.agent",
|
"hs_office_relation#FirstGmbH-with-DEBITOR-FourtheG.agent",
|
||||||
"hs_office_relationship#FirstGmbH-with-ACCOUNTING-FourtheG.tenant"));
|
"hs_office_relation#FirstGmbH-with-DEBITOR-FourtheG.tenant"));
|
||||||
assertThat(distinctGrantDisplaysOf(rawGrantRepo.findAll()))
|
assertThat(distinctGrantDisplaysOf(rawGrantRepo.findAll()))
|
||||||
.map(s -> s.replace("hs_office_", ""))
|
.map(s -> s.replace("hs_office_", ""))
|
||||||
.containsExactlyInAnyOrder(Array.fromFormatted(
|
.containsExactlyInAnyOrder(Array.fromFormatted(
|
||||||
initialGrantNames,
|
initialGrantNames,
|
||||||
// FIXME: the next line is completely wrong, the format as well that it exists
|
// FIXME: the next line is completely wrong, the format as well that it exists
|
||||||
"{ grant perm INSERT on relationship#FirstGmbH-with-ACCOUNTING-FourtheG to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.admin by system and assume }",
|
"{ grant perm INSERT on relation#FirstGmbH-with-DEBITOR-FourtheG to role relation#FirstGmbH-with-DEBITOR-FourtheG.admin by system and assume }",
|
||||||
|
|
||||||
// owner
|
// owner
|
||||||
"{ grant perm DELETE on debitor#D-1000122 to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.owner by system and assume }",
|
"{ grant perm DELETE on debitor#D-1000122 to role relation#FirstGmbH-with-DEBITOR-FourtheG.owner by system and assume }",
|
||||||
"{ grant perm DELETE on relationship#FirstGmbH-with-ACCOUNTING-FourtheG to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.owner by system and assume }",
|
"{ grant perm DELETE on relation#FirstGmbH-with-DEBITOR-FourtheG to role relation#FirstGmbH-with-DEBITOR-FourtheG.owner by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.owner to role global#global.admin by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.owner to role global#global.admin by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.owner to user superuser-alex@hostsharing.net by relationship#FirstGmbH-with-ACCOUNTING-FourtheG.owner and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.owner to user superuser-alex@hostsharing.net by relation#FirstGmbH-with-DEBITOR-FourtheG.owner and assume }",
|
||||||
|
|
||||||
// admin
|
// admin
|
||||||
"{ grant perm UPDATE on debitor#D-1000122 to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.admin by system and assume }",
|
"{ grant perm UPDATE on debitor#D-1000122 to role relation#FirstGmbH-with-DEBITOR-FourtheG.admin by system and assume }",
|
||||||
"{ grant perm UPDATE on relationship#FirstGmbH-with-ACCOUNTING-FourtheG to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.admin by system and assume }",
|
"{ grant perm UPDATE on relation#FirstGmbH-with-DEBITOR-FourtheG to role relation#FirstGmbH-with-DEBITOR-FourtheG.admin by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.admin to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.owner by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.admin to role relation#FirstGmbH-with-DEBITOR-FourtheG.owner by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.admin to role person#FirstGmbH.admin by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.admin to role person#FirstGmbH.admin by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.admin to role relationship#HostsharingeG-with-PARTNER-FirstGmbH.admin by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.admin to role relation#HostsharingeG-with-PARTNER-FirstGmbH.admin by system and assume }",
|
||||||
|
|
||||||
// agent
|
// agent
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.agent to role person#FourtheG.admin by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.agent to role person#FourtheG.admin by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.agent to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.admin by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.agent to role relation#FirstGmbH-with-DEBITOR-FourtheG.admin by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.agent to role relationship#HostsharingeG-with-PARTNER-FirstGmbH.agent by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.agent to role relation#HostsharingeG-with-PARTNER-FirstGmbH.agent by system and assume }",
|
||||||
|
|
||||||
// tenant
|
// tenant
|
||||||
"{ grant perm SELECT on debitor#D-1000122 to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.tenant by system and assume }",
|
"{ grant perm SELECT on debitor#D-1000122 to role relation#FirstGmbH-with-DEBITOR-FourtheG.tenant by system and assume }",
|
||||||
"{ grant perm SELECT on relationship#FirstGmbH-with-ACCOUNTING-FourtheG to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.tenant by system and assume }",
|
"{ grant perm SELECT on relation#FirstGmbH-with-DEBITOR-FourtheG to role relation#FirstGmbH-with-DEBITOR-FourtheG.tenant by system and assume }",
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-FirstGmbH.tenant to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.agent by system and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-FirstGmbH.tenant to role relation#FirstGmbH-with-DEBITOR-FourtheG.agent by system and assume }",
|
||||||
"{ grant role contact#fourthcontact.referrer to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.tenant by system and assume }",
|
"{ grant role contact#fourthcontact.referrer to role relation#FirstGmbH-with-DEBITOR-FourtheG.tenant by system and assume }",
|
||||||
"{ grant role person#FirstGmbH.referrer to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.tenant by system and assume }",
|
"{ grant role person#FirstGmbH.referrer to role relation#FirstGmbH-with-DEBITOR-FourtheG.tenant by system and assume }",
|
||||||
"{ grant role person#FourtheG.referrer to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.tenant by system and assume }",
|
"{ grant role person#FourtheG.referrer to role relation#FirstGmbH-with-DEBITOR-FourtheG.tenant by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.tenant to role contact#fourthcontact.admin by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.tenant to role contact#fourthcontact.admin by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.tenant to role person#FourtheG.admin by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.tenant to role person#FourtheG.admin by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.tenant to role relationship#FirstGmbH-with-ACCOUNTING-FourtheG.agent by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FourtheG.tenant to role relation#FirstGmbH-with-DEBITOR-FourtheG.agent by system and assume }",
|
||||||
|
|
||||||
null));
|
null));
|
||||||
}
|
}
|
||||||
@ -235,9 +235,9 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
// then
|
// then
|
||||||
allTheseDebitorsAreReturned(
|
allTheseDebitorsAreReturned(
|
||||||
result,
|
result,
|
||||||
"debitor(D-1000111: rel(relAnchor='LP First GmbH', relType='ACCOUNTING', relHolder='LP First GmbH'), fir)",
|
"debitor(D-1000111: rel(anchor='LP First GmbH', type='DEBITOR', holder='LP First GmbH'), fir)",
|
||||||
"debitor(D-1000212: rel(relAnchor='LP Second e.K.', relType='ACCOUNTING', relHolder='LP Second e.K.'), sec)",
|
"debitor(D-1000212: rel(anchor='LP Second e.K.', type='DEBITOR', holder='LP Second e.K.'), sec)",
|
||||||
"debitor(D-1000313: rel(relAnchor='IF Third OHG', relType='ACCOUNTING', relHolder='IF Third OHG'), thi)");
|
"debitor(D-1000313: rel(anchor='IF Third OHG', type='DEBITOR', holder='IF Third OHG'), thi)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ -286,7 +286,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
exactlyTheseDebitorsAreReturned(result,
|
exactlyTheseDebitorsAreReturned(result,
|
||||||
"debitor(D-1000313: rel(relAnchor='IF Third OHG', relType='ACCOUNTING', relHolder='IF Third OHG'), thi)");
|
"debitor(D-1000313: rel(anchor='IF Third OHG', type='DEBITOR', holder='IF Third OHG'), thi)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final var result = debitorRepo.findDebitorByOptionalNameLike("third contact");
|
final var result = debitorRepo.findDebitorByOptionalNameLike("third contact");
|
||||||
|
|
||||||
// then
|
// then
|
||||||
exactlyTheseDebitorsAreReturned(result, "debitor(D-1000313: rel(relAnchor='IF Third OHG', relType='ACCOUNTING', relHolder='IF Third OHG'), thi)");
|
exactlyTheseDebitorsAreReturned(result, "debitor(D-1000313: rel(anchor='IF Third OHG', type='DEBITOR', holder='IF Third OHG'), thi)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
|
|
||||||
assertThatDebitorIsVisibleForUserWithRole(
|
assertThatDebitorIsVisibleForUserWithRole(
|
||||||
givenDebitor,
|
givenDebitor,
|
||||||
"hs_office_relationship#FourtheG-with-ACCOUNTING-FourtheG.admin");
|
"hs_office_relation#FourtheG-with-DEBITOR-FourtheG.admin");
|
||||||
final var givenNewPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First"));
|
final var givenNewPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First"));
|
||||||
final var givenNewBillingPerson = one(personRepo.findPersonByOptionalNameLike("Firby"));
|
final var givenNewBillingPerson = one(personRepo.findPersonByOptionalNameLike("Firby"));
|
||||||
final var givenNewContact = one(contactRepo.findContactByOptionalLabelLike("sixth contact"));
|
final var givenNewContact = one(contactRepo.findContactByOptionalLabelLike("sixth contact"));
|
||||||
@ -329,10 +329,10 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
givenDebitor.setDebitorRel(HsOfficeRelationshipEntity.builder()
|
givenDebitor.setDebitorRel(HsOfficeRelationEntity.builder()
|
||||||
.relType(HsOfficeRelationshipType.ACCOUNTING)
|
.type(HsOfficeRelationType.DEBITOR)
|
||||||
.relAnchor(givenNewPartnerPerson)
|
.anchor(givenNewPartnerPerson)
|
||||||
.relHolder(givenNewBillingPerson)
|
.holder(givenNewBillingPerson)
|
||||||
.contact(givenNewContact)
|
.contact(givenNewContact)
|
||||||
.build());
|
.build());
|
||||||
givenDebitor.setRefundBankAccount(givenNewBankAccount);
|
givenDebitor.setRefundBankAccount(givenNewBankAccount);
|
||||||
@ -351,10 +351,10 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
// ... partner role was reassigned:
|
// ... partner role was reassigned:
|
||||||
assertThatDebitorIsNotVisibleForUserWithRole(
|
assertThatDebitorIsNotVisibleForUserWithRole(
|
||||||
result.returnedValue(),
|
result.returnedValue(),
|
||||||
"hs_office_relationship#FourtheG-with-ACCOUNTING-FourtheG.admin");
|
"hs_office_relation#FourtheG-with-DEBITOR-FourtheG.admin");
|
||||||
assertThatDebitorIsVisibleForUserWithRole(
|
assertThatDebitorIsVisibleForUserWithRole(
|
||||||
result.returnedValue(),
|
result.returnedValue(),
|
||||||
"hs_office_relationship#FirstGmbH-with-ACCOUNTING-FirbySusan.agent");
|
"hs_office_relation#FirstGmbH-with-DEBITOR-FirbySusan.agent");
|
||||||
|
|
||||||
// ... contact role was reassigned:
|
// ... contact role was reassigned:
|
||||||
assertThatDebitorIsNotVisibleForUserWithRole(
|
assertThatDebitorIsNotVisibleForUserWithRole(
|
||||||
@ -380,7 +380,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final var givenDebitor = givenSomeTemporaryDebitor("Fourth", "fifth contact", null, "fig");
|
final var givenDebitor = givenSomeTemporaryDebitor("Fourth", "fifth contact", null, "fig");
|
||||||
assertThatDebitorIsVisibleForUserWithRole(
|
assertThatDebitorIsVisibleForUserWithRole(
|
||||||
givenDebitor,
|
givenDebitor,
|
||||||
"hs_office_relationship#FourtheG-with-ACCOUNTING-FourtheG.admin");
|
"hs_office_relation#FourtheG-with-DEBITOR-FourtheG.admin");
|
||||||
assertThatDebitorActuallyInDatabase(givenDebitor);
|
assertThatDebitorActuallyInDatabase(givenDebitor);
|
||||||
final var givenNewBankAccount = one(bankAccountRepo.findByOptionalHolderLike("first"));
|
final var givenNewBankAccount = one(bankAccountRepo.findByOptionalHolderLike("first"));
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final var givenDebitor = givenSomeTemporaryDebitor("Fourth", "fifth contact", "Fourth", "fih");
|
final var givenDebitor = givenSomeTemporaryDebitor("Fourth", "fifth contact", "Fourth", "fih");
|
||||||
assertThatDebitorIsVisibleForUserWithRole(
|
assertThatDebitorIsVisibleForUserWithRole(
|
||||||
givenDebitor,
|
givenDebitor,
|
||||||
"hs_office_relationship#HostsharingeG-with-PARTNER-FourtheG.agent");
|
"hs_office_relation#HostsharingeG-with-PARTNER-FourtheG.agent");
|
||||||
assertThatDebitorActuallyInDatabase(givenDebitor);
|
assertThatDebitorActuallyInDatabase(givenDebitor);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -439,12 +439,12 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final var givenDebitor = givenSomeTemporaryDebitor("Fourth", "eighth", "Fourth", "eig");
|
final var givenDebitor = givenSomeTemporaryDebitor("Fourth", "eighth", "Fourth", "eig");
|
||||||
assertThatDebitorIsVisibleForUserWithRole(
|
assertThatDebitorIsVisibleForUserWithRole(
|
||||||
givenDebitor,
|
givenDebitor,
|
||||||
"hs_office_relationship#HostsharingeG-with-PARTNER-FourtheG.agent");
|
"hs_office_relation#HostsharingeG-with-PARTNER-FourtheG.agent");
|
||||||
assertThatDebitorActuallyInDatabase(givenDebitor);
|
assertThatDebitorActuallyInDatabase(givenDebitor);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net", "hs_office_relationship#HostsharingeG-with-PARTNER-FourtheG.agent");
|
context("superuser-alex@hostsharing.net", "hs_office_relation#HostsharingeG-with-PARTNER-FourtheG.agent");
|
||||||
givenDebitor.setVatId("NEW-VAT-ID");
|
givenDebitor.setVatId("NEW-VAT-ID");
|
||||||
return toCleanup(debitorRepo.save(givenDebitor));
|
return toCleanup(debitorRepo.save(givenDebitor));
|
||||||
});
|
});
|
||||||
@ -489,7 +489,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
if ( saved.getPartner() != null) { // FIXME: check, why there is no partner for the updated contact
|
if ( saved.getPartner() != null) { // FIXME: check, why there is no partner for the updated contact
|
||||||
assertThat(foundEntity.getPartner()).isNotNull();
|
assertThat(foundEntity.getPartner()).isNotNull();
|
||||||
}
|
}
|
||||||
assertThat(foundEntity.getDebitorRel()).extracting(HsOfficeRelationshipEntity::toString)
|
assertThat(foundEntity.getDebitorRel()).extracting(HsOfficeRelationEntity::toString)
|
||||||
.isEqualTo(saved.getDebitorRel().toString());
|
.isEqualTo(saved.getDebitorRel().toString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -545,7 +545,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net", "hs_office_relationship#FourtheG-with-ACCOUNTING-FourtheG.admin");
|
context("superuser-alex@hostsharing.net", "hs_office_relation#FourtheG-with-DEBITOR-FourtheG.admin");
|
||||||
assertThat(debitorRepo.findByUuid(givenDebitor.getUuid())).isPresent();
|
assertThat(debitorRepo.findByUuid(givenDebitor.getUuid())).isPresent();
|
||||||
|
|
||||||
debitorRepo.deleteByUuid(givenDebitor.getUuid());
|
debitorRepo.deleteByUuid(givenDebitor.getUuid());
|
||||||
@ -614,10 +614,10 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
bankAccountHolder != null ? one(bankAccountRepo.findByOptionalHolderLike(bankAccountHolder)) : null;
|
bankAccountHolder != null ? one(bankAccountRepo.findByOptionalHolderLike(bankAccountHolder)) : null;
|
||||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||||
.debitorNumberSuffix((byte)20)
|
.debitorNumberSuffix((byte)20)
|
||||||
.debitorRel(HsOfficeRelationshipEntity.builder()
|
.debitorRel(HsOfficeRelationEntity.builder()
|
||||||
.relType(HsOfficeRelationshipType.ACCOUNTING)
|
.type(HsOfficeRelationType.DEBITOR)
|
||||||
.relAnchor(givenPartnerPerson)
|
.anchor(givenPartnerPerson)
|
||||||
.relHolder(givenPartnerPerson)
|
.holder(givenPartnerPerson)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build())
|
.build())
|
||||||
.refundBankAccount(givenBankAccount)
|
.refundBankAccount(givenBankAccount)
|
||||||
|
@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.debitor;
|
|||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
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.relation.HsOfficeRelationEntity;
|
||||||
|
|
||||||
import static net.hostsharing.hsadminng.hs.office.contact.TestHsOfficeContact.TEST_CONTACT;
|
import static net.hostsharing.hsadminng.hs.office.contact.TestHsOfficeContact.TEST_CONTACT;
|
||||||
import static net.hostsharing.hsadminng.hs.office.partner.TestHsOfficePartner.TEST_PARTNER;
|
import static net.hostsharing.hsadminng.hs.office.partner.TestHsOfficePartner.TEST_PARTNER;
|
||||||
@ -14,9 +14,9 @@ public class TestHsOfficeDebitor {
|
|||||||
|
|
||||||
public static final HsOfficeDebitorEntity TEST_DEBITOR = HsOfficeDebitorEntity.builder()
|
public static final HsOfficeDebitorEntity TEST_DEBITOR = HsOfficeDebitorEntity.builder()
|
||||||
.debitorNumberSuffix(DEFAULT_DEBITOR_SUFFIX)
|
.debitorNumberSuffix(DEFAULT_DEBITOR_SUFFIX)
|
||||||
.debitorRel(HsOfficeRelationshipEntity.builder()
|
.debitorRel(HsOfficeRelationEntity.builder()
|
||||||
.relHolder(HsOfficePersonEntity.builder().build())
|
.holder(HsOfficePersonEntity.builder().build())
|
||||||
.relAnchor(HsOfficePersonEntity.builder().build())
|
.anchor(HsOfficePersonEntity.builder().build())
|
||||||
.contact(TEST_CONTACT)
|
.contact(TEST_CONTACT)
|
||||||
.build())
|
.build())
|
||||||
.partner(TEST_PARTNER)
|
.partner(TEST_PARTNER)
|
||||||
|
@ -269,7 +269,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
|
|||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "superuser-alex@hostsharing.net")
|
.header("current-user", "superuser-alex@hostsharing.net")
|
||||||
.header("assumed-roles", "hs_office_relationship#HostsharingeG-with-PARTNER-ThirdOHG.agent")
|
.header("assumed-roles", "hs_office_relation#HostsharingeG-with-PARTNER-ThirdOHG.agent")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/office/memberships/" + givenMembershipUuid)
|
.get("http://localhost/api/hs/office/memberships/" + givenMembershipUuid)
|
||||||
@ -338,7 +338,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
|
|||||||
void partnerRelAgent_canPatchValidityOfRelatedMembership() {
|
void partnerRelAgent_canPatchValidityOfRelatedMembership() {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
final var givenPartnerAgent = "hs_office_relationship#HostsharingeG-with-PARTNER-FirstGmbH.agent";
|
final var givenPartnerAgent = "hs_office_relation#HostsharingeG-with-PARTNER-FirstGmbH.agent";
|
||||||
context.define("superuser-alex@hostsharing.net", givenPartnerAgent);
|
context.define("superuser-alex@hostsharing.net", givenPartnerAgent);
|
||||||
final var givenMembership = givenSomeTemporaryMembershipBessler("First");
|
final var givenMembership = givenSomeTemporaryMembershipBessler("First");
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle
|
|||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "superuser-alex@hostsharing.net")
|
.header("current-user", "superuser-alex@hostsharing.net")
|
||||||
.header("assumed-roles", "hs_office_relationship#HostsharingeG-with-PARTNER-FirstGmbH.agent")
|
.header("assumed-roles", "hs_office_relation#HostsharingeG-with-PARTNER-FirstGmbH.agent")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.delete("http://localhost/api/hs/office/memberships/" + givenMembership.getUuid())
|
.delete("http://localhost/api/hs/office/memberships/" + givenMembership.getUuid())
|
||||||
|
@ -126,16 +126,16 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCl
|
|||||||
// admin
|
// admin
|
||||||
"{ grant perm UPDATE on membership#M-1000117 to role membership#M-1000117.admin by system and assume }",
|
"{ grant perm UPDATE on membership#M-1000117 to role membership#M-1000117.admin by system and assume }",
|
||||||
"{ grant role membership#M-1000117.admin to role membership#M-1000117.owner by system and assume }",
|
"{ grant role membership#M-1000117.admin to role membership#M-1000117.owner by system and assume }",
|
||||||
"{ grant role membership#M-1000117.owner to role relationship#HostsharingeG-with-PARTNER-FirstGmbH.admin by system and assume }",
|
"{ grant role membership#M-1000117.owner to role relation#HostsharingeG-with-PARTNER-FirstGmbH.admin by system and assume }",
|
||||||
"{ grant role membership#M-1000117.owner to user superuser-alex@hostsharing.net by membership#M-1000117.owner and assume }",
|
"{ grant role membership#M-1000117.owner to user superuser-alex@hostsharing.net by membership#M-1000117.owner and assume }",
|
||||||
|
|
||||||
// agent
|
// agent
|
||||||
"{ grant role membership#M-1000117.admin to role relationship#HostsharingeG-with-PARTNER-FirstGmbH.agent by system and assume }",
|
"{ grant role membership#M-1000117.admin to role relation#HostsharingeG-with-PARTNER-FirstGmbH.agent by system and assume }",
|
||||||
|
|
||||||
// referrer
|
// referrer
|
||||||
"{ grant perm SELECT on membership#M-1000117 to role membership#M-1000117.referrer by system and assume }",
|
"{ grant perm SELECT on membership#M-1000117 to role membership#M-1000117.referrer by system and assume }",
|
||||||
"{ grant role membership#M-1000117.referrer to role membership#M-1000117.admin by system and assume }",
|
"{ grant role membership#M-1000117.referrer to role membership#M-1000117.admin by system and assume }",
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-FirstGmbH.tenant to role membership#M-1000117.referrer by system and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-FirstGmbH.tenant to role membership#M-1000117.referrer by system and assume }",
|
||||||
|
|
||||||
null));
|
null));
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCl
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net", "hs_office_relationship#HostsharingeG-with-PARTNER-FirstGmbH.agent");
|
context("superuser-alex@hostsharing.net", "hs_office_relation#HostsharingeG-with-PARTNER-FirstGmbH.agent");
|
||||||
assertThat(membershipRepo.findByUuid(givenMembership.getUuid())).isPresent();
|
assertThat(membershipRepo.findByUuid(givenMembership.getUuid())).isPresent();
|
||||||
|
|
||||||
membershipRepo.deleteByUuid(givenMembership.getUuid());
|
membershipRepo.deleteByUuid(givenMembership.getUuid());
|
||||||
|
@ -182,26 +182,26 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
// no contacts yet => mostly null values
|
// no contacts yet => mostly null values
|
||||||
assertThat(toFormattedString(partners)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(partners)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
17=partner(null null, null),
|
17=partner(P-10017: null null, null),
|
||||||
20=partner(null null, null),
|
20=partner(P-10020: null null, null),
|
||||||
22=partner(null null, null),
|
22=partner(P-11022: null null, null),
|
||||||
99=partner(null null, null)
|
99=partner(P-19999: null null, null)
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
assertThat(toFormattedString(contacts)).isEqualTo("{}");
|
assertThat(toFormattedString(contacts)).isEqualTo("{}");
|
||||||
assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
17=debitor(D-1001700: null null, null: mih),
|
17=debitor(D-1001700: rel(anchor='null null, null', type='DEBITOR', holder='null null, null'), mih),
|
||||||
20=debitor(D-1002000: null null, null: xyz),
|
20=debitor(D-1002000: rel(anchor='null null, null', type='DEBITOR', holder='null null, null'), xyz),
|
||||||
22=debitor(D-1102200: null null, null: xxx),
|
22=debitor(D-1102200: rel(anchor='null null, null', type='DEBITOR', holder='null null, null'), xxx),
|
||||||
99=debitor(D-1999900: null null, null: zzz)
|
99=debitor(D-1999900: rel(anchor='null null, null', type='DEBITOR', holder='null null, null'), zzz)
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
17=Membership(M-1001700, null null, null, D-1001700, [2000-12-06,), NONE),
|
17=Membership(M-1001700, P-10017, [2000-12-06,), NONE),
|
||||||
20=Membership(M-1002000, null null, null, D-1002000, [2000-12-06,2016-01-01), UNKNOWN),
|
20=Membership(M-1002000, P-10020, [2000-12-06,2016-01-01), UNKNOWN),
|
||||||
22=Membership(M-1102200, null null, null, D-1102200, [2021-04-01,), NONE)
|
22=Membership(M-1102200, P-11022, [2021-04-01,), NONE)
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
.type(HsOfficeRelationType.DEBITOR)
|
.type(HsOfficeRelationType.DEBITOR)
|
||||||
.anchor(debitor.getPartner().getPartnerRel().getHolder())
|
.anchor(debitor.getPartner().getPartnerRel().getHolder())
|
||||||
.holder(debitor.getPartner().getPartnerRel().getHolder()) // just 1 debitor/partner in legacy hsadmin
|
.holder(debitor.getPartner().getPartnerRel().getHolder()) // just 1 debitor/partner in legacy hsadmin
|
||||||
.contact(debitor.getBillingContact())
|
// FIXME .contact()
|
||||||
.build();
|
.build();
|
||||||
if (debitorRel.getAnchor() != null && debitorRel.getHolder() != null &&
|
if (debitorRel.getAnchor() != null && debitorRel.getHolder() != null &&
|
||||||
debitorRel.getContact() != null ) {
|
debitorRel.getContact() != null ) {
|
||||||
@ -242,10 +242,10 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
|
|
||||||
assertThat(toFormattedString(partners)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(partners)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
17=partner(NP Mellies, Michael: Herr Michael Mellies ),
|
17=partner(P-10017: NP Mellies, Michael, Herr Michael Mellies ),
|
||||||
20=partner(LP JM GmbH: Herr Philip Meyer-Contract , JM GmbH),
|
20=partner(P-10020: LP JM GmbH, Herr Philip Meyer-Contract , JM GmbH),
|
||||||
22=partner(?? Test PS: Petra Schmidt , Test PS),
|
22=partner(P-11022: ?? Test PS, Petra Schmidt , Test PS),
|
||||||
99=partner(null null, null)
|
99=partner(P-19999: null null, null)
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
assertThat(toFormattedString(contacts)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(contacts)).isEqualToIgnoringWhitespace("""
|
||||||
@ -275,41 +275,42 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
""");
|
""");
|
||||||
assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
17=debitor(D-1001700: NP Mellies, Michael: mih),
|
17=debitor(D-1001700: rel(anchor='NP Mellies, Michael', type='DEBITOR', holder='NP Mellies, Michael'), mih),
|
||||||
20=debitor(D-1002000: LP JM GmbH: xyz),
|
20=debitor(D-1002000: rel(anchor='LP JM GmbH', type='DEBITOR', holder='LP JM GmbH'), xyz),
|
||||||
22=debitor(D-1102200: ?? Test PS: xxx),
|
22=debitor(D-1102200: rel(anchor='?? Test PS', type='DEBITOR', holder='?? Test PS'), xxx),
|
||||||
99=debitor(D-1999900: null null, null: zzz)
|
99=debitor(D-1999900: rel(anchor='null null, null', type='DEBITOR', holder='null null, null'), zzz)
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
17=Membership(M-1001700, NP Mellies, Michael, D-1001700, [2000-12-06,), NONE),
|
17=Membership(M-1001700, P-10017, [2000-12-06,), NONE),
|
||||||
20=Membership(M-1002000, LP JM GmbH, D-1002000, [2000-12-06,2016-01-01), UNKNOWN),
|
20=Membership(M-1002000, P-10020, [2000-12-06,2016-01-01), UNKNOWN),
|
||||||
22=Membership(M-1102200, ?? Test PS, D-1102200, [2021-04-01,), NONE)
|
22=Membership(M-1102200, P-11022, [2021-04-01,), NONE)
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
assertThat(toFormattedString(relations)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(relations)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
2000000=rel(anchor='LP Hostsharing eG', type='PARTNER', holder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
2000000=rel(anchor='LP Hostsharing eG', type='PARTNER', holder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
||||||
2000001=rel(anchor='LP Hostsharing eG', type='PARTNER', holder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
2000001=rel(anchor='NP Mellies, Michael', type='DEBITOR', holder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
||||||
2000002=rel(anchor='LP Hostsharing eG', type='PARTNER', holder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
2000002=rel(anchor='LP Hostsharing eG', type='PARTNER', holder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
||||||
2000003=rel(anchor='LP Hostsharing eG', type='PARTNER', holder='null null, null'),
|
2000003=rel(anchor='LP JM GmbH', type='DEBITOR', holder='LP JM GmbH', contact='Frau Dr. Jenny Meyer-Billing , JM GmbH'),
|
||||||
2000004=rel(anchor='NP Mellies, Michael', type='OPERATIONS', holder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
2000004=rel(anchor='LP Hostsharing eG', type='PARTNER', holder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
||||||
2000005=rel(anchor='NP Mellies, Michael', type='REPRESENTATIVE', holder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
2000005=rel(anchor='?? Test PS', type='DEBITOR', holder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
||||||
2000006=rel(anchor='LP JM GmbH', type='EX_PARTNER', holder='LP JM e.K.', contact='JM e.K.'),
|
2000006=rel(anchor='LP Hostsharing eG', type='PARTNER', holder='null null, null'),
|
||||||
2000007=rel(anchor='LP JM GmbH', type='OPERATIONS', holder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
|
2000007=rel(anchor='null null, null', type='DEBITOR', holder='null null, null'),
|
||||||
2000008=rel(anchor='LP JM GmbH', type='VIP_CONTACT', holder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
|
2000008=rel(anchor='NP Mellies, Michael', type='OPERATIONS', holder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
||||||
2000009=rel(anchor='LP JM GmbH', type='SUBSCRIBER', mark='operations-announce', holder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
|
2000009=rel(anchor='NP Mellies, Michael', type='REPRESENTATIVE', holder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
||||||
2000010=rel(anchor='LP JM GmbH', type='REPRESENTATIVE', holder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
2000010=rel(anchor='LP JM GmbH', type='EX_PARTNER', holder='LP JM e.K.', contact='JM e.K.'),
|
||||||
2000011=rel(anchor='LP JM GmbH', type='SUBSCRIBER', mark='members-announce', holder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
2000011=rel(anchor='LP JM GmbH', type='OPERATIONS', holder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
|
||||||
2000012=rel(anchor='LP JM GmbH', type='SUBSCRIBER', mark='customers-announce', holder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
2000012=rel(anchor='LP JM GmbH', type='VIP_CONTACT', holder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
|
||||||
2000013=rel(anchor='LP JM GmbH', type='VIP_CONTACT', holder='LP JM GmbH', contact='Frau Tammy Meyer-VIP , JM GmbH'),
|
2000013=rel(anchor='LP JM GmbH', type='SUBSCRIBER', mark='operations-announce', holder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
|
||||||
2000014=rel(anchor='?? Test PS', type='OPERATIONS', holder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
2000014=rel(anchor='LP JM GmbH', type='REPRESENTATIVE', holder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
||||||
2000015=rel(anchor='?? Test PS', type='REPRESENTATIVE', holder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
2000015=rel(anchor='LP JM GmbH', type='SUBSCRIBER', mark='members-announce', holder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
||||||
2000016=rel(anchor='NP Mellies, Michael', type='SUBSCRIBER', mark='operations-announce', holder='NP Fanninga, Frauke', contact='Frau Frauke Fanninga '),
|
2000016=rel(anchor='LP JM GmbH', type='SUBSCRIBER', mark='customers-announce', holder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
||||||
2000017=rel(anchor='NP Mellies, Michael', type='DEBITOR', holder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
2000017=rel(anchor='LP JM GmbH', type='VIP_CONTACT', holder='LP JM GmbH', contact='Frau Tammy Meyer-VIP , JM GmbH'),
|
||||||
2000018=rel(anchor='LP JM GmbH', type='DEBITOR', holder='LP JM GmbH', contact='Frau Dr. Jenny Meyer-Billing , JM GmbH'),
|
2000018=rel(anchor='?? Test PS', type='OPERATIONS', holder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
||||||
2000019=rel(anchor='?? Test PS', type='DEBITOR', holder='?? Test PS', contact='Petra Schmidt , Test PS')
|
2000019=rel(anchor='?? Test PS', type='REPRESENTATIVE', holder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
||||||
|
2000020=rel(anchor='NP Mellies, Michael', type='SUBSCRIBER', mark='operations-announce', holder='NP Fanninga, Frauke', contact='Frau Frauke Fanninga ')
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
@ -333,9 +334,9 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
|
|
||||||
assertThat(toFormattedString(bankAccounts)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(bankAccounts)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
234234=bankAccount(holder='Michael Mellies', iban='DE37500105177419788228', bic='INGDDEFFXXX'),
|
234234=bankAccount(DE37500105177419788228: holder='Michael Mellies', bic='INGDDEFFXXX'),
|
||||||
235600=bankAccount(holder='JM e.K.', iban='DE02300209000106531065', bic='CMCIDEDD'),
|
235600=bankAccount(DE02300209000106531065: holder='JM e.K.', bic='CMCIDEDD'),
|
||||||
235662=bankAccount(holder='JM GmbH', iban='DE49500105174516484892', bic='INGDDEFFXXX')
|
235662=bankAccount(DE49500105174516484892: holder='JM GmbH', bic='INGDDEFFXXX')
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
assertThat(toFormattedString(sepaMandates)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(sepaMandates)).isEqualToIgnoringWhitespace("""
|
||||||
@ -359,7 +360,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1049)
|
@Order(1041)
|
||||||
void verifyCoopShares() {
|
void verifyCoopShares() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
|
|
||||||
@ -392,14 +393,14 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
|
|
||||||
assertThat(toFormattedString(coopAssets)).isEqualToIgnoringWhitespace("""
|
assertThat(toFormattedString(coopAssets)).isEqualToIgnoringWhitespace("""
|
||||||
{
|
{
|
||||||
30000=CoopAssetsTransaction(1001700, 2000-12-06, DEPOSIT, 1280.00, for subscription A),
|
30000=CoopAssetsTransaction(M-1001700: 2000-12-06, DEPOSIT, 1280.00, for subscription A),
|
||||||
31000=CoopAssetsTransaction(1002000, 2000-12-06, DEPOSIT, 128.00, for subscription B),
|
31000=CoopAssetsTransaction(M-1002000: 2000-12-06, DEPOSIT, 128.00, for subscription B),
|
||||||
32000=CoopAssetsTransaction(1001700, 2005-01-10, DEPOSIT, 2560.00, for subscription C),
|
32000=CoopAssetsTransaction(M-1001700: 2005-01-10, DEPOSIT, 2560.00, for subscription C),
|
||||||
33001=CoopAssetsTransaction(1001700, 2005-01-10, TRANSFER, -512.00, for transfer to 10),
|
33001=CoopAssetsTransaction(M-1001700: 2005-01-10, TRANSFER, -512.00, for transfer to 10),
|
||||||
33002=CoopAssetsTransaction(1002000, 2005-01-10, ADOPTION, 512.00, for transfer from 7),
|
33002=CoopAssetsTransaction(M-1002000: 2005-01-10, ADOPTION, 512.00, for transfer from 7),
|
||||||
34001=CoopAssetsTransaction(1002000, 2016-12-31, CLEARING, -8.00, for cancellation D),
|
34001=CoopAssetsTransaction(M-1002000: 2016-12-31, CLEARING, -8.00, for cancellation D),
|
||||||
34002=CoopAssetsTransaction(1002000, 2016-12-31, DISBURSAL, -100.00, for cancellation D),
|
34002=CoopAssetsTransaction(M-1002000: 2016-12-31, DISBURSAL, -100.00, for cancellation D),
|
||||||
34003=CoopAssetsTransaction(1002000, 2016-12-31, LOSS, -20.00, for cancellation D)
|
34003=CoopAssetsTransaction(M-1002000: 2016-12-31, LOSS, -20.00, for cancellation D)
|
||||||
}
|
}
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
@ -408,11 +409,13 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
@Order(2000)
|
@Order(2000)
|
||||||
void verifyAllPartnersHavePersons() {
|
void verifyAllPartnersHavePersons() {
|
||||||
partners.forEach((id, p) -> {
|
partners.forEach((id, p) -> {
|
||||||
|
final var partnerRel = p.getPartnerRel();
|
||||||
|
assertThat(partnerRel).describedAs("partner " + id + " without partnerRel").isNotNull();
|
||||||
if ( id != 99 ) {
|
if ( id != 99 ) {
|
||||||
assertThat(p.getContact()).describedAs("partner " + id + " without contact").isNotNull();
|
assertThat(partnerRel.getContact()).describedAs("partner " + id + " without partnerRel.contact").isNotNull();
|
||||||
assertThat(p.getContact().getLabel()).describedAs("partner " + id + " without valid contact").isNotNull();
|
assertThat(partnerRel.getContact().getLabel()).describedAs("partner " + id + " without valid partnerRel.contact").isNotNull();
|
||||||
assertThat(p.getPerson()).describedAs("partner " + id + " without person").isNotNull();
|
assertThat(partnerRel.getHolder()).describedAs("partner " + id + " without partnerRel.relHolder").isNotNull();
|
||||||
assertThat(p.getPerson().getPersonType()).describedAs("partner " + id + " without valid person").isNotNull();
|
assertThat(partnerRel.getHolder().getPersonType()).describedAs("partner " + id + " without valid partnerRel.relHolder").isNotNull();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -427,11 +430,11 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
relations.forEach( (id, r) -> {
|
relations.forEach( (id, r) -> {
|
||||||
// such a record
|
// such a record
|
||||||
if (r.getContact() == null || r.getContact().getLabel() == null ||
|
if (r.getContact() == null || r.getContact().getLabel() == null ||
|
||||||
r.getHolder() == null | r.getHolder().getPersonType() == null ) {
|
r.getHolder() == null || r.getHolder().getPersonType() == null ) {
|
||||||
idsToRemove.add(id);
|
idsToRemove.add(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99 (partner+contractual roles)
|
assertThat(idsToRemove.size()).isEqualTo(2); // partner #99 + Hostsharing eG itself
|
||||||
idsToRemove.forEach(id -> relations.remove(id));
|
idsToRemove.forEach(id -> relations.remove(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,9 +446,11 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
// avoid a error when persisting the deliberately invalid partner entry #99
|
// avoid a error when persisting the deliberately invalid partner entry #99
|
||||||
final var idsToRemove = new HashSet<Integer>();
|
final var idsToRemove = new HashSet<Integer>();
|
||||||
partners.forEach( (id, r) -> {
|
partners.forEach( (id, r) -> {
|
||||||
// such a record
|
final var partnerRole = r.getPartnerRel();
|
||||||
if (r.getContact() == null || r.getContact().getLabel() == null ||
|
|
||||||
r.getPerson() == null | r.getPerson().getPersonType() == null ) {
|
// such a record is in test data to test error messages
|
||||||
|
if (partnerRole.getContact() == null || partnerRole.getContact().getLabel() == null ||
|
||||||
|
partnerRole.getHolder() == null | partnerRole.getHolder().getPersonType() == null ) {
|
||||||
idsToRemove.add(id);
|
idsToRemove.add(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -460,10 +465,11 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
|
|
||||||
// avoid a error when persisting the deliberately invalid partner entry #99
|
// avoid a error when persisting the deliberately invalid partner entry #99
|
||||||
final var idsToRemove = new HashSet<Integer>();
|
final var idsToRemove = new HashSet<Integer>();
|
||||||
debitors.forEach( (id, r) -> {
|
debitors.forEach( (id, d) -> {
|
||||||
// such a record
|
final var debitorRel = d.getDebitorRel();
|
||||||
if (r.getBillingContact() == null || r.getBillingContact().getLabel() == null ||
|
if (debitorRel.getContact() == null || debitorRel.getContact().getLabel() == null ||
|
||||||
r.getPartner().getPerson() == null | r.getPartner().getPerson().getPersonType() == null ) {
|
debitorRel.getAnchor() == null || debitorRel.getAnchor().getPersonType() == null ||
|
||||||
|
debitorRel.getHolder() == null || debitorRel.getHolder().getPersonType() == null ) {
|
||||||
idsToRemove.add(id);
|
idsToRemove.add(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -676,28 +682,33 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
.forEach(rec -> {
|
.forEach(rec -> {
|
||||||
final var person = HsOfficePersonEntity.builder().build();
|
final var person = HsOfficePersonEntity.builder().build();
|
||||||
|
|
||||||
final var partnerRelation = HsOfficeRelationEntity.builder()
|
final var partnerRel = HsOfficeRelationEntity.builder()
|
||||||
.holder(person)
|
.holder(person)
|
||||||
.type(HsOfficeRelationType.PARTNER)
|
.type(HsOfficeRelationType.PARTNER)
|
||||||
.anchor(mandant)
|
.anchor(mandant)
|
||||||
.contact(null) // is set during contacts import depending on assigned roles
|
.contact(null) // is set during contacts import depending on assigned roles
|
||||||
.build();
|
.build();
|
||||||
relations.put(relationId++, partnerRelation);
|
relations.put(relationId++, partnerRel);
|
||||||
|
|
||||||
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())
|
||||||
.partnerRel(partnerRelation)
|
.partnerRel(partnerRel)
|
||||||
.contact(null) // is set during contacts import depending on assigned roles
|
|
||||||
.person(person)
|
|
||||||
.build();
|
.build();
|
||||||
partners.put(rec.getInteger("bp_id"), partner);
|
partners.put(rec.getInteger("bp_id"), partner);
|
||||||
|
|
||||||
|
final var debitorRel = HsOfficeRelationEntity.builder()
|
||||||
|
.type(HsOfficeRelationType.DEBITOR)
|
||||||
|
.anchor(partnerRel.getHolder())
|
||||||
|
.holder(partnerRel.getHolder()) // currently debitor = partner
|
||||||
|
.build();
|
||||||
|
relations.put(relationId++, debitorRel);
|
||||||
|
|
||||||
final var debitor = HsOfficeDebitorEntity.builder()
|
final var debitor = HsOfficeDebitorEntity.builder()
|
||||||
.partner(partner)
|
|
||||||
.debitorNumberSuffix((byte) 0)
|
.debitorNumberSuffix((byte) 0)
|
||||||
.defaultPrefix(rec.getString("member_code").replace("hsh00-", ""))
|
|
||||||
.partner(partner)
|
.partner(partner)
|
||||||
|
.debitorRel(debitorRel)
|
||||||
|
.defaultPrefix(rec.getString("member_code").replace("hsh00-", ""))
|
||||||
.billable(rec.isEmpty("free") || rec.getString("free").equals("f"))
|
.billable(rec.isEmpty("free") || rec.getString("free").equals("f"))
|
||||||
.vatReverseCharge(rec.getBoolean("exempt_vat"))
|
.vatReverseCharge(rec.getBoolean("exempt_vat"))
|
||||||
.vatBusiness("GROSS".equals(rec.getString("indicator_vat"))) // TODO: remove
|
.vatBusiness("GROSS".equals(rec.getString("indicator_vat"))) // TODO: remove
|
||||||
@ -718,7 +729,6 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
isBlank(rec.getString("member_until"))
|
isBlank(rec.getString("member_until"))
|
||||||
? HsOfficeReasonForTermination.NONE
|
? HsOfficeReasonForTermination.NONE
|
||||||
: HsOfficeReasonForTermination.UNKNOWN)
|
: HsOfficeReasonForTermination.UNKNOWN)
|
||||||
.mainDebitor(debitor)
|
|
||||||
.build();
|
.build();
|
||||||
memberships.put(rec.getInteger("bp_id"), membership);
|
memberships.put(rec.getInteger("bp_id"), membership);
|
||||||
}
|
}
|
||||||
@ -844,9 +854,9 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
final var partner = partners.get(bpId);
|
final var partner = partners.get(bpId);
|
||||||
final var debitor = debitors.get(bpId);
|
final var debitor = debitors.get(bpId);
|
||||||
|
|
||||||
final var partnerPerson = partner.getPerson();
|
final var partnerPerson = partner.getPartnerRel().getHolder();
|
||||||
if (containsPartnerRel(rec)) {
|
if (containsPartnerRel(rec)) {
|
||||||
initPerson(partner.getPerson(), rec);
|
initPerson(partnerPerson, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
HsOfficePersonEntity contactPerson = partnerPerson;
|
HsOfficePersonEntity contactPerson = partnerPerson;
|
||||||
@ -860,13 +870,12 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
initContact(contact, rec);
|
initContact(contact, rec);
|
||||||
|
|
||||||
if (containsPartnerRel(rec)) {
|
if (containsPartnerRel(rec)) {
|
||||||
assertThat(partner.getContact()).isNull();
|
assertThat(partner.getPartnerRel().getContact()).isNull();
|
||||||
partner.setContact(contact);
|
|
||||||
partner.getPartnerRel().setContact(contact);
|
partner.getPartnerRel().setContact(contact);
|
||||||
}
|
}
|
||||||
if (containsRole(rec, "billing")) {
|
if (containsRole(rec, "billing")) {
|
||||||
assertThat(debitor.getBillingContact()).isNull();
|
assertThat(debitor.getDebitorRel().getContact()).isNull();
|
||||||
debitor.setBillingContact(contact);
|
debitor.getDebitorRel().setContact(contact);
|
||||||
}
|
}
|
||||||
if (containsRole(rec, "operation")) {
|
if (containsRole(rec, "operation")) {
|
||||||
addRelation(partnerPerson, contactPerson, contact, HsOfficeRelationType.OPERATIONS);
|
addRelation(partnerPerson, contactPerson, contact, HsOfficeRelationType.OPERATIONS);
|
||||||
@ -896,13 +905,14 @@ public class ImportOfficeData extends ContextBasedTest {
|
|||||||
private static void optionallyAddMissingContractualRelations() {
|
private static void optionallyAddMissingContractualRelations() {
|
||||||
final var contractualMissing = new HashSet<Integer>();
|
final var contractualMissing = new HashSet<Integer>();
|
||||||
partners.forEach( (id, partner) -> {
|
partners.forEach( (id, partner) -> {
|
||||||
final var partnerPerson = partner.getPerson();
|
final var partnerPerson = partner.getPartnerRel().getHolder();
|
||||||
if (relations.values().stream()
|
if (relations.values().stream()
|
||||||
.filter(rel -> rel.getAnchor() == partnerPerson && rel.getType() == HsOfficeRelationType.REPRESENTATIVE)
|
.filter(rel -> rel.getAnchor() == partnerPerson && rel.getType() == HsOfficeRelationType.REPRESENTATIVE)
|
||||||
.findFirst().isEmpty()) {
|
.findFirst().isEmpty()) {
|
||||||
contractualMissing.add(partner.getPartnerNumber());
|
contractualMissing.add(partner.getPartnerNumber());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
assertThat(contractualMissing).containsOnly(19999); // deliberately wrong partner entry
|
||||||
}
|
}
|
||||||
private static boolean containsRole(final Record rec, final String role) {
|
private static boolean containsRole(final Record rec, final String role) {
|
||||||
final var roles = rec.getString("roles");
|
final var roles = rec.getString("roles");
|
||||||
|
@ -7,9 +7,9 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
|||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipRepository;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipType;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||||
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
|
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
|
||||||
import net.hostsharing.test.Accepts;
|
import net.hostsharing.test.Accepts;
|
||||||
import net.hostsharing.test.JpaAttempt;
|
import net.hostsharing.test.JpaAttempt;
|
||||||
@ -41,7 +41,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
HsOfficePartnerRepository partnerRepo;
|
HsOfficePartnerRepository partnerRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsOfficeRelationshipRepository relationshipRepository;
|
HsOfficeRelationRepository relationRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsOfficePersonRepository personRepo;
|
HsOfficePersonRepository personRepo;
|
||||||
@ -102,9 +102,9 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"partnerNumber": "20002",
|
"partnerNumber": "20002",
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
},
|
},
|
||||||
"details": {
|
"details": {
|
||||||
@ -125,11 +125,11 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("", lenientlyEquals("""
|
.body("", lenientlyEquals("""
|
||||||
{
|
{
|
||||||
"partnerNumber": 20002,
|
"partnerNumber": 20002,
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchor": { "tradeName": "Hostsharing eG" },
|
"anchor": { "tradeName": "Hostsharing eG" },
|
||||||
"relHolder": { "tradeName": "Third OHG" },
|
"holder": { "tradeName": "Third OHG" },
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"relMark": null,
|
"mark": null,
|
||||||
"contact": { "label": "fourth contact" }
|
"contact": { "label": "fourth contact" }
|
||||||
},
|
},
|
||||||
"details": {
|
"details": {
|
||||||
@ -161,9 +161,9 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"partnerNumber": "20003",
|
"partnerNumber": "20003",
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
},
|
},
|
||||||
"personUuid": "%s",
|
"personUuid": "%s",
|
||||||
@ -199,9 +199,9 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"partnerNumber": "20004",
|
"partnerNumber": "20004",
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
},
|
},
|
||||||
"personUuid": "%s",
|
"personUuid": "%s",
|
||||||
@ -247,10 +247,10 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("", lenientlyEquals("""
|
.body("", lenientlyEquals("""
|
||||||
{
|
{
|
||||||
"partnerNumber": 10001,
|
"partnerNumber": 10001,
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchor": { "tradeName": "Hostsharing eG" },
|
"anchor": { "tradeName": "Hostsharing eG" },
|
||||||
"relHolder": { "tradeName": "First GmbH" },
|
"holder": { "tradeName": "First GmbH" },
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"contact": { "label": "first contact" }
|
"contact": { "label": "first contact" }
|
||||||
},
|
},
|
||||||
"details": {
|
"details": {
|
||||||
@ -295,8 +295,8 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.body("", lenientlyEquals("""
|
.body("", lenientlyEquals("""
|
||||||
{
|
{
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relHolder": { "tradeName": "First GmbH" },
|
"holder": { "tradeName": "First GmbH" },
|
||||||
"contact": { "label": "first contact" }
|
"contact": { "label": "first contact" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"partnerNumber": "20011",
|
"partnerNumber": "20011",
|
||||||
"partnerRoleUuid": "%s",
|
"partnerRelUuid": "%s",
|
||||||
"details": {
|
"details": {
|
||||||
"registrationOffice": "Temp Registergericht Aurich",
|
"registrationOffice": "Temp Registergericht Aurich",
|
||||||
"registrationNumber": "222222",
|
"registrationNumber": "222222",
|
||||||
@ -342,10 +342,10 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.body("", lenientlyEquals("""
|
.body("", lenientlyEquals("""
|
||||||
{
|
{
|
||||||
"partnerNumber": 20011,
|
"partnerNumber": 20011,
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchor": { "tradeName": "Hostsharing eG" },
|
"anchor": { "tradeName": "Hostsharing eG" },
|
||||||
"relHolder": { "tradeName": "Third OHG" },
|
"holder": { "tradeName": "Third OHG" },
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"contact": { "label": "third contact" }
|
"contact": { "label": "third contact" }
|
||||||
},
|
},
|
||||||
"details": {
|
"details": {
|
||||||
@ -365,8 +365,8 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isPresent().get()
|
assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isPresent().get()
|
||||||
.matches(partner -> {
|
.matches(partner -> {
|
||||||
assertThat(partner.getPartnerNumber()).isEqualTo(givenPartner.getPartnerNumber());
|
assertThat(partner.getPartnerNumber()).isEqualTo(givenPartner.getPartnerNumber());
|
||||||
assertThat(partner.getPartnerRole().getRelHolder().getTradeName()).isEqualTo("Third OHG");
|
assertThat(partner.getPartnerRel().getHolder().getTradeName()).isEqualTo("Third OHG");
|
||||||
assertThat(partner.getPartnerRole().getContact().getLabel()).isEqualTo("third contact");
|
assertThat(partner.getPartnerRel().getContact().getLabel()).isEqualTo("third contact");
|
||||||
assertThat(partner.getDetails().getRegistrationOffice()).isEqualTo("Temp Registergericht Aurich");
|
assertThat(partner.getDetails().getRegistrationOffice()).isEqualTo("Temp Registergericht Aurich");
|
||||||
assertThat(partner.getDetails().getRegistrationNumber()).isEqualTo("222222");
|
assertThat(partner.getDetails().getRegistrationNumber()).isEqualTo("222222");
|
||||||
assertThat(partner.getDetails().getBirthName()).isEqualTo("Maja Schmidt");
|
assertThat(partner.getDetails().getBirthName()).isEqualTo("Maja Schmidt");
|
||||||
@ -403,7 +403,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("uuid", isUuidValid())
|
.body("uuid", isUuidValid())
|
||||||
.body("details.birthName", is("Maja Schmidt"));
|
.body("details.birthName", is("Maja Schmidt"));
|
||||||
// TODO: assert partnerRole
|
// TODO: assert partnerRel
|
||||||
// .body("contact.label", is(givenPartner.getContact().getLabel()))
|
// .body("contact.label", is(givenPartner.getContact().getLabel()))
|
||||||
// .body("person.tradeName", is(givenPartner.getPerson().getTradeName()));
|
// .body("person.tradeName", is(givenPartner.getPerson().getTradeName()));
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
@ -411,7 +411,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
// finally, the partner is actually updated
|
// finally, the partner is actually updated
|
||||||
assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isPresent().get()
|
assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isPresent().get()
|
||||||
.matches(person -> {
|
.matches(person -> {
|
||||||
// TODO: assert partnerRole
|
// TODO: assert partnerRel
|
||||||
// assertThat(person.getPerson().getTradeName()).isEqualTo(givenPartner.getPerson().getTradeName());
|
// assertThat(person.getPerson().getTradeName()).isEqualTo(givenPartner.getPerson().getTradeName());
|
||||||
// assertThat(person.getContact().getLabel()).isEqualTo(givenPartner.getContact().getLabel());
|
// assertThat(person.getContact().getLabel()).isEqualTo(givenPartner.getContact().getLabel());
|
||||||
assertThat(person.getDetails().getRegistrationOffice()).isEqualTo("Temp Registergericht Leer");
|
assertThat(person.getDetails().getRegistrationOffice()).isEqualTo("Temp Registergericht Leer");
|
||||||
@ -446,7 +446,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(relationRepository.findByUuid(givenPartner.getPartnerRel().getUuid())).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -454,7 +454,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
void contactAdminUser_canNotDeleteRelatedPartner() {
|
void contactAdminUser_canNotDeleteRelatedPartner() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenPartner = givenSomeTemporaryPartnerBessler(20014);
|
final var givenPartner = givenSomeTemporaryPartnerBessler(20014);
|
||||||
assertThat(givenPartner.getPartnerRole().getContact().getLabel()).isEqualTo("fourth contact");
|
assertThat(givenPartner.getPartnerRel().getContact().getLabel()).isEqualTo("fourth contact");
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
@ -474,7 +474,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
void normalUser_canNotDeleteUnrelatedPartner() {
|
void normalUser_canNotDeleteUnrelatedPartner() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenPartner = givenSomeTemporaryPartnerBessler(20015);
|
final var givenPartner = givenSomeTemporaryPartnerBessler(20015);
|
||||||
assertThat(givenPartner.getPartnerRole().getContact().getLabel()).isEqualTo("fourth contact");
|
assertThat(givenPartner.getPartnerRel().getContact().getLabel()).isEqualTo("fourth contact");
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
@ -490,7 +490,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private HsOfficeRelationshipEntity givenSomeTemporaryPartnerRel(
|
private HsOfficeRelationEntity givenSomeTemporaryPartnerRel(
|
||||||
final String partnerHolderName,
|
final String partnerHolderName,
|
||||||
final String contactName) {
|
final String contactName) {
|
||||||
return jpaAttempt.transacted(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
@ -499,22 +499,22 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
final var givenPerson = personRepo.findPersonByOptionalNameLike(partnerHolderName).stream().findFirst().orElseThrow();
|
final var givenPerson = personRepo.findPersonByOptionalNameLike(partnerHolderName).stream().findFirst().orElseThrow();
|
||||||
final var givenContact = contactRepo.findContactByOptionalLabelLike(contactName).stream().findFirst().orElseThrow();
|
final var givenContact = contactRepo.findContactByOptionalLabelLike(contactName).stream().findFirst().orElseThrow();
|
||||||
|
|
||||||
final var partnerRole = new HsOfficeRelationshipEntity();
|
final var partnerRel = new HsOfficeRelationEntity();
|
||||||
partnerRole.setRelType(HsOfficeRelationshipType.PARTNER);
|
partnerRel.setType(HsOfficeRelationType.PARTNER);
|
||||||
partnerRole.setRelAnchor(givenMandantPerson);
|
partnerRel.setAnchor(givenMandantPerson);
|
||||||
partnerRole.setRelHolder(givenPerson);
|
partnerRel.setHolder(givenPerson);
|
||||||
partnerRole.setContact(givenContact);
|
partnerRel.setContact(givenContact);
|
||||||
em.persist(partnerRole);
|
em.persist(partnerRel);
|
||||||
return partnerRole;
|
return partnerRel;
|
||||||
}).assertSuccessful().returnedValue();
|
}).assertSuccessful().returnedValue();
|
||||||
}
|
}
|
||||||
private HsOfficePartnerEntity givenSomeTemporaryPartnerBessler(final Integer partnerNumber) {
|
private HsOfficePartnerEntity givenSomeTemporaryPartnerBessler(final Integer partnerNumber) {
|
||||||
return jpaAttempt.transacted(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var partnerRole = em.merge(givenSomeTemporaryPartnerRel("Erben Bessler", "fourth contact"));
|
final var partnerRel = em.merge(givenSomeTemporaryPartnerRel("Erben Bessler", "fourth contact"));
|
||||||
|
|
||||||
final var newPartner = HsOfficePartnerEntity.builder()
|
final var newPartner = HsOfficePartnerEntity.builder()
|
||||||
.partnerRole(partnerRole)
|
.partnerRel(partnerRel)
|
||||||
.partnerNumber(partnerNumber)
|
.partnerNumber(partnerNumber)
|
||||||
.details(HsOfficePartnerDetailsEntity.builder()
|
.details(HsOfficePartnerDetailsEntity.builder()
|
||||||
.registrationOffice("Temp Registergericht Leer")
|
.registrationOffice("Temp Registergericht Leer")
|
||||||
@ -531,6 +531,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
cleanupAllNew(HsOfficePartnerEntity.class);
|
cleanupAllNew(HsOfficePartnerEntity.class);
|
||||||
|
|
||||||
// TODO: should not be necessary anymore, once it's deleted via after delete trigger
|
// TODO: should not be necessary anymore, once it's deleted via after delete trigger
|
||||||
cleanupAllNew(HsOfficeRelationshipEntity.class);
|
cleanupAllNew(HsOfficeRelationEntity.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
|||||||
import net.hostsharing.hsadminng.context.Context;
|
import net.hostsharing.hsadminng.context.Context;
|
||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||||
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.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipRepository;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||||
import net.hostsharing.hsadminng.mapper.Mapper;
|
import net.hostsharing.hsadminng.mapper.Mapper;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
@ -54,7 +54,7 @@ class HsOfficePartnerControllerRestTest {
|
|||||||
HsOfficePartnerRepository partnerRepo;
|
HsOfficePartnerRepository partnerRepo;
|
||||||
|
|
||||||
@MockBean
|
@MockBean
|
||||||
HsOfficeRelationshipRepository relationshipRepo;
|
HsOfficeRelationRepository relationRepo;
|
||||||
|
|
||||||
@MockBean
|
@MockBean
|
||||||
EntityManager em;
|
EntityManager em;
|
||||||
@ -100,9 +100,9 @@ class HsOfficePartnerControllerRestTest {
|
|||||||
.content("""
|
.content("""
|
||||||
{
|
{
|
||||||
"partnerNumber": "20002",
|
"partnerNumber": "20002",
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
},
|
},
|
||||||
"personUuid": "%s",
|
"personUuid": "%s",
|
||||||
@ -137,9 +137,9 @@ class HsOfficePartnerControllerRestTest {
|
|||||||
.content("""
|
.content("""
|
||||||
{
|
{
|
||||||
"partnerNumber": "20002",
|
"partnerNumber": "20002",
|
||||||
"partnerRole": {
|
"partnerRel": {
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
},
|
},
|
||||||
"personUuid": "%s",
|
"personUuid": "%s",
|
||||||
@ -175,11 +175,11 @@ class HsOfficePartnerControllerRestTest {
|
|||||||
when(partnerRepo.findByUuid(givenPartnerUuid)).thenReturn(Optional.of(partnerMock));
|
when(partnerRepo.findByUuid(givenPartnerUuid)).thenReturn(Optional.of(partnerMock));
|
||||||
when(partnerRepo.deleteByUuid(givenPartnerUuid)).thenReturn(0);
|
when(partnerRepo.deleteByUuid(givenPartnerUuid)).thenReturn(0);
|
||||||
|
|
||||||
final UUID givenRelationshipUuid = UUID.randomUUID();
|
final UUID givenRelationUuid = UUID.randomUUID();
|
||||||
when(partnerMock.getPartnerRole()).thenReturn(HsOfficeRelationshipEntity.builder()
|
when(partnerMock.getPartnerRel()).thenReturn(HsOfficeRelationEntity.builder()
|
||||||
.uuid(givenRelationshipUuid)
|
.uuid(givenRelationUuid)
|
||||||
.build());
|
.build());
|
||||||
when(relationshipRepo.deleteByUuid(givenRelationshipUuid)).thenReturn(0);
|
when(relationRepo.deleteByUuid(givenRelationUuid)).thenReturn(0);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
|||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||||
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.person.HsOfficePersonEntity;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.test.PatchUnitTestBase;
|
import net.hostsharing.test.PatchUnitTestBase;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
@ -48,8 +48,8 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void initMocks() {
|
void initMocks() {
|
||||||
lenient().when(em.getReference(eq(HsOfficeRelationshipEntity.class), any())).thenAnswer(invocation ->
|
lenient().when(em.getReference(eq(HsOfficeRelationEntity.class), any())).thenAnswer(invocation ->
|
||||||
HsOfficeRelationshipEntity.builder().uuid(invocation.getArgument(1)).build());
|
HsOfficeRelationEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,8 +57,8 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
final var entity = HsOfficePartnerEntity.builder()
|
final var entity = HsOfficePartnerEntity.builder()
|
||||||
.uuid(INITIAL_PARTNER_UUID)
|
.uuid(INITIAL_PARTNER_UUID)
|
||||||
.partnerNumber(12345)
|
.partnerNumber(12345)
|
||||||
.partnerRole(HsOfficeRelationshipEntity.builder()
|
.partnerRel(HsOfficeRelationEntity.builder()
|
||||||
.relHolder(givenInitialPerson)
|
.holder(givenInitialPerson)
|
||||||
.contact(givenInitialContact)
|
.contact(givenInitialContact)
|
||||||
.build())
|
.build())
|
||||||
.details(givenInitialDetails)
|
.details(givenInitialDetails)
|
||||||
@ -80,19 +80,19 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
|||||||
protected Stream<Property> propertyTestDescriptors() {
|
protected Stream<Property> propertyTestDescriptors() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
new JsonNullableProperty<>(
|
new JsonNullableProperty<>(
|
||||||
"partnerRole",
|
"partnerRel",
|
||||||
HsOfficePartnerPatchResource::setPartnerRoleUuid,
|
HsOfficePartnerPatchResource::setPartnerRelUuid,
|
||||||
PATCHED_PARTNER_ROLE_UUID,
|
PATCHED_PARTNER_ROLE_UUID,
|
||||||
HsOfficePartnerEntity::setPartnerRole,
|
HsOfficePartnerEntity::setPartnerRel,
|
||||||
newPartnerRole(PATCHED_PARTNER_ROLE_UUID))
|
newPartnerRel(PATCHED_PARTNER_ROLE_UUID))
|
||||||
.notNullable()
|
.notNullable()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HsOfficeRelationshipEntity newPartnerRole(final UUID uuid) {
|
private static HsOfficeRelationEntity newPartnerRel(final UUID uuid) {
|
||||||
final var newPartnerRole = HsOfficeRelationshipEntity.builder()
|
final var newPartnerRel = HsOfficeRelationEntity.builder()
|
||||||
.uuid(uuid)
|
.uuid(uuid)
|
||||||
.build();
|
.build();
|
||||||
return newPartnerRole;
|
return newPartnerRel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
|||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipType;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -13,13 +13,13 @@ class HsOfficePartnerEntityUnitTest {
|
|||||||
|
|
||||||
private final HsOfficePartnerEntity givenPartner = HsOfficePartnerEntity.builder()
|
private final HsOfficePartnerEntity givenPartner = HsOfficePartnerEntity.builder()
|
||||||
.partnerNumber(12345)
|
.partnerNumber(12345)
|
||||||
.partnerRole(HsOfficeRelationshipEntity.builder()
|
.partnerRel(HsOfficeRelationEntity.builder()
|
||||||
.relAnchor(HsOfficePersonEntity.builder()
|
.anchor(HsOfficePersonEntity.builder()
|
||||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||||
.tradeName("Hostsharing eG")
|
.tradeName("Hostsharing eG")
|
||||||
.build())
|
.build())
|
||||||
.relType(HsOfficeRelationshipType.PARTNER)
|
.type(HsOfficeRelationType.PARTNER)
|
||||||
.relHolder(HsOfficePersonEntity.builder()
|
.holder(HsOfficePersonEntity.builder()
|
||||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||||
.tradeName("some trade name")
|
.tradeName("some trade name")
|
||||||
.build())
|
.build())
|
||||||
|
@ -3,9 +3,9 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
|||||||
import net.hostsharing.hsadminng.context.Context;
|
import net.hostsharing.hsadminng.context.Context;
|
||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipRepository;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipType;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||||
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
|
import net.hostsharing.hsadminng.hs.office.test.ContextBasedTestWithCleanup;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
|
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
|
||||||
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacObjectRepository;
|
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacObjectRepository;
|
||||||
@ -43,7 +43,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
HsOfficePartnerRepository partnerRepo;
|
HsOfficePartnerRepository partnerRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsOfficeRelationshipRepository relationshipRepo;
|
HsOfficeRelationRepository relationRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsOfficePersonRepository personRepo;
|
HsOfficePersonRepository personRepo;
|
||||||
@ -77,13 +77,13 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var count = partnerRepo.count();
|
final var count = partnerRepo.count();
|
||||||
final var partnerRole = givenSomeTemporaryHostsharingPartnerRole("First GmbH", "first contact");
|
final var partnerRel = givenSomeTemporaryHostsharingPartnerRel("First GmbH", "first contact");
|
||||||
|
|
||||||
// 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)
|
||||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||||
.build();
|
.build();
|
||||||
return partnerRepo.save(newPartner);
|
return partnerRepo.save(newPartner);
|
||||||
@ -113,17 +113,17 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0);
|
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0);
|
||||||
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
||||||
|
|
||||||
final var newRelationship = HsOfficeRelationshipEntity.builder()
|
final var newRelation = HsOfficeRelationEntity.builder()
|
||||||
.relHolder(givenPartnerPerson)
|
.holder(givenPartnerPerson)
|
||||||
.relType(HsOfficeRelationshipType.PARTNER)
|
.type(HsOfficeRelationType.PARTNER)
|
||||||
.relAnchor(givenMandantPerson)
|
.anchor(givenMandantPerson)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build();
|
.build();
|
||||||
relationshipRepo.save(newRelationship);
|
relationRepo.save(newRelation);
|
||||||
|
|
||||||
final var newPartner = HsOfficePartnerEntity.builder()
|
final var newPartner = HsOfficePartnerEntity.builder()
|
||||||
.partnerNumber(20032)
|
.partnerNumber(20032)
|
||||||
.partnerRole(newRelationship)
|
.partnerRel(newRelation)
|
||||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||||
.build();
|
.build();
|
||||||
return partnerRepo.save(newPartner);
|
return partnerRepo.save(newPartner);
|
||||||
@ -132,10 +132,10 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
// then
|
// then
|
||||||
assertThat(distinctRoleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(Array.from(
|
assertThat(distinctRoleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(Array.from(
|
||||||
initialRoleNames,
|
initialRoleNames,
|
||||||
"hs_office_relationship#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.owner",
|
"hs_office_relation#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.owner",
|
||||||
"hs_office_relationship#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.admin",
|
"hs_office_relation#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.admin",
|
||||||
"hs_office_relationship#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.agent",
|
"hs_office_relation#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.agent",
|
||||||
"hs_office_relationship#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.tenant"));
|
"hs_office_relation#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.tenant"));
|
||||||
assertThat(distinctGrantDisplaysOf(rawGrantRepo.findAll()))
|
assertThat(distinctGrantDisplaysOf(rawGrantRepo.findAll()))
|
||||||
.map(s -> s.replace("ErbenBesslerMelBessler", "EBess"))
|
.map(s -> s.replace("ErbenBesslerMelBessler", "EBess"))
|
||||||
.map(s -> s.replace("fourthcontact", "4th"))
|
.map(s -> s.replace("fourthcontact", "4th"))
|
||||||
@ -143,42 +143,42 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
.containsExactlyInAnyOrder(distinct(fromFormatted(
|
.containsExactlyInAnyOrder(distinct(fromFormatted(
|
||||||
initialGrantNames,
|
initialGrantNames,
|
||||||
// FIXME: this entry is wrong in existance and format
|
// FIXME: this entry is wrong in existance and format
|
||||||
"{ grant perm INSERT on relationship#HostsharingeG-with-PARTNER-EBess to role relationship#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
"{ grant perm INSERT on relation#HostsharingeG-with-PARTNER-EBess to role relation#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
||||||
|
|
||||||
// permissions on partner
|
// permissions on partner
|
||||||
"{ grant perm DELETE on partner#P-20032 to role relationship#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
"{ grant perm DELETE on partner#P-20032 to role relation#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
||||||
"{ grant perm UPDATE on partner#P-20032 to role relationship#HostsharingeG-with-PARTNER-EBess.agent by system and assume }",
|
"{ grant perm UPDATE on partner#P-20032 to role relation#HostsharingeG-with-PARTNER-EBess.agent by system and assume }",
|
||||||
"{ grant perm SELECT on partner#P-20032 to role relationship#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
"{ grant perm SELECT on partner#P-20032 to role relation#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
||||||
|
|
||||||
// permissions on partner-details
|
// permissions on partner-details
|
||||||
"{ grant perm DELETE on partner_details#P-20032-details to role relationship#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
"{ grant perm DELETE on partner_details#P-20032-details to role relation#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
||||||
"{ grant perm UPDATE on partner_details#P-20032-details to role relationship#HostsharingeG-with-PARTNER-EBess.agent by system and assume }",
|
"{ grant perm UPDATE on partner_details#P-20032-details to role relation#HostsharingeG-with-PARTNER-EBess.agent by system and assume }",
|
||||||
"{ grant perm SELECT on partner_details#P-20032-details to role relationship#HostsharingeG-with-PARTNER-EBess.agent by system and assume }",
|
"{ grant perm SELECT on partner_details#P-20032-details to role relation#HostsharingeG-with-PARTNER-EBess.agent by system and assume }",
|
||||||
|
|
||||||
// permissions on partner-relationship
|
// permissions on partner-relation
|
||||||
"{ grant perm DELETE on relationship#HostsharingeG-with-PARTNER-EBess to role relationship#HostsharingeG-with-PARTNER-EBess.owner by system and assume }",
|
"{ grant perm DELETE on relation#HostsharingeG-with-PARTNER-EBess to role relation#HostsharingeG-with-PARTNER-EBess.owner by system and assume }",
|
||||||
"{ grant perm UPDATE on relationship#HostsharingeG-with-PARTNER-EBess to role relationship#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
"{ grant perm UPDATE on relation#HostsharingeG-with-PARTNER-EBess to role relation#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
||||||
"{ grant perm SELECT on relationship#HostsharingeG-with-PARTNER-EBess to role relationship#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
"{ grant perm SELECT on relation#HostsharingeG-with-PARTNER-EBess to role relation#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
||||||
|
|
||||||
// relationship owner
|
// relation owner
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.owner to role global#global.admin by system and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-EBess.owner to role global#global.admin by system and assume }",
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.owner to user superuser-alex@hostsharing.net by relationship#HostsharingeG-with-PARTNER-EBess.owner and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-EBess.owner to user superuser-alex@hostsharing.net by relation#HostsharingeG-with-PARTNER-EBess.owner and assume }",
|
||||||
|
|
||||||
// relationship admin
|
// relation admin
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.admin to role relationship#HostsharingeG-with-PARTNER-EBess.owner by system and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-EBess.admin to role relation#HostsharingeG-with-PARTNER-EBess.owner by system and assume }",
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.admin to role person#HostsharingeG.admin by system and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-EBess.admin to role person#HostsharingeG.admin by system and assume }",
|
||||||
|
|
||||||
// relationship agent
|
// relation agent
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.agent to role person#EBess.admin by system and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-EBess.agent to role person#EBess.admin by system and assume }",
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.agent to role relationship#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-EBess.agent to role relation#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
||||||
|
|
||||||
// relationship tenant
|
// relation tenant
|
||||||
"{ grant role contact#4th.referrer to role relationship#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
"{ grant role contact#4th.referrer to role relation#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
||||||
"{ grant role person#EBess.referrer to role relationship#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
"{ grant role person#EBess.referrer to role relation#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
||||||
"{ grant role person#HostsharingeG.referrer to role relationship#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
"{ grant role person#HostsharingeG.referrer to role relation#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.tenant to role contact#4th.admin by system and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-EBess.tenant to role contact#4th.admin by system and assume }",
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.tenant to role person#EBess.admin by system and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-EBess.tenant to role person#EBess.admin by system and assume }",
|
||||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.tenant to role relationship#HostsharingeG-with-PARTNER-EBess.agent by system and assume }",
|
"{ grant role relation#HostsharingeG-with-PARTNER-EBess.tenant to role relation#HostsharingeG-with-PARTNER-EBess.agent by system and assume }",
|
||||||
null)));
|
null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
givenPartner.setPartnerRole(givenSomeTemporaryHostsharingPartnerRole("Third OHG", "sixth contact"));
|
givenPartner.setPartnerRel(givenSomeTemporaryHostsharingPartnerRel("Third OHG", "sixth contact"));
|
||||||
return partnerRepo.save(givenPartner);
|
return partnerRepo.save(givenPartner);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net",
|
context("superuser-alex@hostsharing.net",
|
||||||
"hs_office_relationship#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.tenant");
|
"hs_office_relation#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.tenant");
|
||||||
givenPartner.getDetails().setBirthName("new birthname");
|
givenPartner.getDetails().setBirthName("new birthname");
|
||||||
return partnerRepo.save(givenPartner);
|
return partnerRepo.save(givenPartner);
|
||||||
});
|
});
|
||||||
@ -335,7 +335,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
// then
|
// then
|
||||||
result.assertExceptionWithRootCauseMessage(JpaSystemException.class,
|
result.assertExceptionWithRootCauseMessage(JpaSystemException.class,
|
||||||
// FIXME: the assumed role should appear, but it does not:
|
// FIXME: the assumed role should appear, but it does not:
|
||||||
//"[403] insert into hs_office_partner_details not allowed for current subjects {hs_office_relationship#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.tenant}");
|
//"[403] insert into hs_office_partner_details not allowed for current subjects {hs_office_relation#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.tenant}");
|
||||||
"[403] insert into hs_office_partner_details not allowed for current subjects");
|
"[403] insert into hs_office_partner_details not allowed for current subjects");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,11 +457,11 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final Integer partnerNumber, final String person, final String contact) {
|
final Integer partnerNumber, final String person, final String contact) {
|
||||||
return jpaAttempt.transacted(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var partnerRole = givenSomeTemporaryHostsharingPartnerRole(person, contact);
|
final var partnerRel = givenSomeTemporaryHostsharingPartnerRel(person, contact);
|
||||||
|
|
||||||
final var newPartner = HsOfficePartnerEntity.builder()
|
final var newPartner = HsOfficePartnerEntity.builder()
|
||||||
.partnerNumber(partnerNumber)
|
.partnerNumber(partnerNumber)
|
||||||
.partnerRole(partnerRole)
|
.partnerRel(partnerRel)
|
||||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ -469,19 +469,19 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
}).assertSuccessful().returnedValue();
|
}).assertSuccessful().returnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HsOfficeRelationshipEntity givenSomeTemporaryHostsharingPartnerRole(final String person, final String contact) {
|
private HsOfficeRelationEntity givenSomeTemporaryHostsharingPartnerRel(final String person, final String contact) {
|
||||||
final var givenMandantorPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
final var givenMandantorPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
||||||
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 = HsOfficeRelationEntity.builder()
|
||||||
.relHolder(givenPartnerPerson)
|
.holder(givenPartnerPerson)
|
||||||
.relType(HsOfficeRelationshipType.PARTNER)
|
.type(HsOfficeRelationType.PARTNER)
|
||||||
.relAnchor(givenMandantorPerson)
|
.anchor(givenMandantorPerson)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build();
|
.build();
|
||||||
relationshipRepo.save(partnerRole);
|
relationRepo.save(partnerRel);
|
||||||
return partnerRole;
|
return partnerRel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exactlyThesePartnersAreReturned(final List<HsOfficePartnerEntity> actualResult, final String... partnerNames) {
|
void exactlyThesePartnersAreReturned(final List<HsOfficePartnerEntity> actualResult, final String... partnerNames) {
|
||||||
|
@ -2,8 +2,8 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
|||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||||
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.relation.HsOfficeRelationEntity;
|
||||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipType;
|
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||||
|
|
||||||
import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.LEGAL_PERSON;
|
import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.LEGAL_PERSON;
|
||||||
|
|
||||||
@ -14,14 +14,14 @@ public class TestHsOfficePartner {
|
|||||||
static public HsOfficePartnerEntity hsOfficePartnerWithLegalPerson(final String tradeName) {
|
static public HsOfficePartnerEntity hsOfficePartnerWithLegalPerson(final String tradeName) {
|
||||||
return HsOfficePartnerEntity.builder()
|
return HsOfficePartnerEntity.builder()
|
||||||
.partnerNumber(10001)
|
.partnerNumber(10001)
|
||||||
.partnerRole(
|
.partnerRel(
|
||||||
HsOfficeRelationshipEntity.builder()
|
HsOfficeRelationEntity.builder()
|
||||||
.relHolder(HsOfficePersonEntity.builder()
|
.holder(HsOfficePersonEntity.builder()
|
||||||
.personType(LEGAL_PERSON)
|
.personType(LEGAL_PERSON)
|
||||||
.tradeName("Hostsharing eG")
|
.tradeName("Hostsharing eG")
|
||||||
.build())
|
.build())
|
||||||
.relType(HsOfficeRelationshipType.PARTNER)
|
.type(HsOfficeRelationType.PARTNER)
|
||||||
.relHolder(HsOfficePersonEntity.builder()
|
.holder(HsOfficePersonEntity.builder()
|
||||||
.personType(LEGAL_PERSON)
|
.personType(LEGAL_PERSON)
|
||||||
.tradeName(tradeName)
|
.tradeName(tradeName)
|
||||||
.build())
|
.build())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.relationship;
|
package net.hostsharing.hsadminng.hs.office.relation;
|
||||||
|
|
||||||
import io.restassured.RestAssured;
|
import io.restassured.RestAssured;
|
||||||
import io.restassured.http.ContentType;
|
import io.restassured.http.ContentType;
|
||||||
@ -7,7 +7,7 @@ import net.hostsharing.test.Accepts;
|
|||||||
import net.hostsharing.hsadminng.HsadminNgApplication;
|
import net.hostsharing.hsadminng.HsadminNgApplication;
|
||||||
import net.hostsharing.hsadminng.context.Context;
|
import net.hostsharing.hsadminng.context.Context;
|
||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationshipTypeResource;
|
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationTypeResource;
|
||||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||||
import net.hostsharing.test.JpaAttempt;
|
import net.hostsharing.test.JpaAttempt;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.startsWith;
|
|||||||
classes = { HsadminNgApplication.class, JpaAttempt.class }
|
classes = { HsadminNgApplication.class, JpaAttempt.class }
|
||||||
)
|
)
|
||||||
@Transactional
|
@Transactional
|
||||||
class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithCleanup {
|
class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithCleanup {
|
||||||
|
|
||||||
public static final UUID GIVEN_NON_EXISTING_HOLDER_PERSON_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
public static final UUID GIVEN_NON_EXISTING_HOLDER_PERSON_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
||||||
@LocalServerPort
|
@LocalServerPort
|
||||||
@ -44,7 +44,7 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
|
|||||||
Context contextMock;
|
Context contextMock;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsOfficeRelationshipRepository relationshipRepo;
|
HsOfficeRelationRepository relationRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsOfficePersonRepository personRepo;
|
HsOfficePersonRepository personRepo;
|
||||||
@ -56,11 +56,11 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
|
|||||||
JpaAttempt jpaAttempt;
|
JpaAttempt jpaAttempt;
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@Accepts({ "Relationship:F(Find)" })
|
@Accepts({ "Relation:F(Find)" })
|
||||||
class ListRelationships {
|
class ListRelations {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_withoutAssumedRoles_canViewAllRelationshipsOfGivenPersonAndType_ifNoCriteriaGiven() throws JSONException {
|
void globalAdmin_withoutAssumedRoles_canViewAllRelationsOfGivenPersonAndType_ifNoCriteriaGiven() throws JSONException {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
@ -71,45 +71,45 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
|
|||||||
.header("current-user", "superuser-alex@hostsharing.net")
|
.header("current-user", "superuser-alex@hostsharing.net")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/office/relationships?personUuid=%s&relationshipType=%s"
|
.get("http://localhost/api/hs/office/relations?personUuid=%s&relationType=%s"
|
||||||
.formatted(givenPerson.getUuid(), HsOfficeRelationshipTypeResource.PARTNER))
|
.formatted(givenPerson.getUuid(), HsOfficeRelationTypeResource.PARTNER))
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.body("", lenientlyEquals("""
|
.body("", lenientlyEquals("""
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
|
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
|
||||||
"relHolder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH" },
|
"holder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH" },
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"relMark": null,
|
"mark": null,
|
||||||
"contact": { "label": "first contact" }
|
"contact": { "label": "first contact" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
|
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
|
||||||
"relHolder": { "personType": "LEGAL_PERSON", "tradeName": "Fourth eG" },
|
"holder": { "personType": "LEGAL_PERSON", "tradeName": "Fourth eG" },
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"contact": { "label": "fourth contact" }
|
"contact": { "label": "fourth contact" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
|
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
|
||||||
"relHolder": { "personType": "LEGAL_PERSON", "tradeName": "Second e.K.", "givenName": "Peter", "familyName": "Smith" },
|
"holder": { "personType": "LEGAL_PERSON", "tradeName": "Second e.K.", "givenName": "Peter", "familyName": "Smith" },
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"relMark": null,
|
"mark": null,
|
||||||
"contact": { "label": "second contact" }
|
"contact": { "label": "second contact" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
|
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
|
||||||
"relHolder": { "personType": "NATURAL_PERSON", "givenName": "Peter", "familyName": "Smith" },
|
"holder": { "personType": "NATURAL_PERSON", "givenName": "Peter", "familyName": "Smith" },
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"relMark": null,
|
"mark": null,
|
||||||
"contact": { "label": "sixth contact" }
|
"contact": { "label": "sixth contact" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
|
"anchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
|
||||||
"relHolder": { "personType": "INCORPORATED_FIRM", "tradeName": "Third OHG" },
|
"holder": { "personType": "INCORPORATED_FIRM", "tradeName": "Third OHG" },
|
||||||
"relType": "PARTNER",
|
"type": "PARTNER",
|
||||||
"relMark": null,
|
"mark": null,
|
||||||
"contact": { "label": "third contact" }
|
"contact": { "label": "third contact" }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -119,11 +119,11 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@Accepts({ "Relationship:C(Create)" })
|
@Accepts({ "Relation:C(Create)" })
|
||||||
class AddRelationship {
|
class AddRelation {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_withoutAssumedRole_canAddRelationship() {
|
void globalAdmin_withoutAssumedRole_canAddRelation() {
|
||||||
|
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
|
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
|
||||||
@ -136,38 +136,38 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
|
|||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"relType": "%s",
|
"type": "%s",
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
}
|
}
|
||||||
""".formatted(
|
""".formatted(
|
||||||
HsOfficeRelationshipTypeResource.ACCOUNTING,
|
HsOfficeRelationTypeResource.DEBITOR,
|
||||||
givenAnchorPerson.getUuid(),
|
givenAnchorPerson.getUuid(),
|
||||||
givenHolderPerson.getUuid(),
|
givenHolderPerson.getUuid(),
|
||||||
givenContact.getUuid()))
|
givenContact.getUuid()))
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.post("http://localhost/api/hs/office/relationships")
|
.post("http://localhost/api/hs/office/relations")
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(201)
|
.statusCode(201)
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("uuid", isUuidValid())
|
.body("uuid", isUuidValid())
|
||||||
.body("relType", is("ACCOUNTING"))
|
.body("type", is("DEBITOR"))
|
||||||
.body("relAnchor.tradeName", is("Third OHG"))
|
.body("anchor.tradeName", is("Third OHG"))
|
||||||
.body("relHolder.givenName", is("Paul"))
|
.body("holder.givenName", is("Paul"))
|
||||||
.body("contact.label", is("second contact"))
|
.body("contact.label", is("second contact"))
|
||||||
.header("Location", startsWith("http://localhost"))
|
.header("Location", startsWith("http://localhost"))
|
||||||
.extract().header("Location"); // @formatter:on
|
.extract().header("Location"); // @formatter:on
|
||||||
|
|
||||||
// finally, the new relationship can be accessed under the generated UUID
|
// finally, the new relation can be accessed under the generated UUID
|
||||||
final var newUserUuid = toCleanup(HsOfficeRelationshipEntity.class, UUID.fromString(
|
final var newUserUuid = toCleanup(HsOfficeRelationEntity.class, UUID.fromString(
|
||||||
location.substring(location.lastIndexOf('/') + 1)));
|
location.substring(location.lastIndexOf('/') + 1)));
|
||||||
assertThat(newUserUuid).isNotNull();
|
assertThat(newUserUuid).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_canNotAddRelationship_ifAnchorPersonDoesNotExist() {
|
void globalAdmin_canNotAddRelation_ifAnchorPersonDoesNotExist() {
|
||||||
|
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenAnchorPersonUuid = GIVEN_NON_EXISTING_HOLDER_PERSON_UUID;
|
final var givenAnchorPersonUuid = GIVEN_NON_EXISTING_HOLDER_PERSON_UUID;
|
||||||
@ -180,27 +180,27 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
|
|||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"relType": "%s",
|
"type": "%s",
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
}
|
}
|
||||||
""".formatted(
|
""".formatted(
|
||||||
HsOfficeRelationshipTypeResource.ACCOUNTING,
|
HsOfficeRelationTypeResource.DEBITOR,
|
||||||
givenAnchorPersonUuid,
|
givenAnchorPersonUuid,
|
||||||
givenHolderPerson.getUuid(),
|
givenHolderPerson.getUuid(),
|
||||||
givenContact.getUuid()))
|
givenContact.getUuid()))
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.post("http://localhost/api/hs/office/relationships")
|
.post("http://localhost/api/hs/office/relations")
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
.body("message", is("cannot find relAnchorUuid " + GIVEN_NON_EXISTING_HOLDER_PERSON_UUID));
|
.body("message", is("cannot find anchorUuid " + GIVEN_NON_EXISTING_HOLDER_PERSON_UUID));
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_canNotAddRelationship_ifHolderPersonDoesNotExist() {
|
void globalAdmin_canNotAddRelation_ifHolderPersonDoesNotExist() {
|
||||||
|
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
|
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
|
||||||
@ -212,27 +212,27 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
|
|||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"relType": "%s",
|
"type": "%s",
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
}
|
}
|
||||||
""".formatted(
|
""".formatted(
|
||||||
HsOfficeRelationshipTypeResource.ACCOUNTING,
|
HsOfficeRelationTypeResource.DEBITOR,
|
||||||
givenAnchorPerson.getUuid(),
|
givenAnchorPerson.getUuid(),
|
||||||
GIVEN_NON_EXISTING_HOLDER_PERSON_UUID,
|
GIVEN_NON_EXISTING_HOLDER_PERSON_UUID,
|
||||||
givenContact.getUuid()))
|
givenContact.getUuid()))
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.post("http://localhost/api/hs/office/relationships")
|
.post("http://localhost/api/hs/office/relations")
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
.body("message", is("cannot find relHolderUuid " + GIVEN_NON_EXISTING_HOLDER_PERSON_UUID));
|
.body("message", is("cannot find holderUuid " + GIVEN_NON_EXISTING_HOLDER_PERSON_UUID));
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_canNotAddRelationship_ifContactDoesNotExist() {
|
void globalAdmin_canNotAddRelation_ifContactDoesNotExist() {
|
||||||
|
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
|
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
|
||||||
@ -245,19 +245,19 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
|
|||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"relType": "%s",
|
"type": "%s",
|
||||||
"relAnchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"relHolderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
}
|
}
|
||||||
""".formatted(
|
""".formatted(
|
||||||
HsOfficeRelationshipTypeResource.ACCOUNTING,
|
HsOfficeRelationTypeResource.DEBITOR,
|
||||||
givenAnchorPerson.getUuid(),
|
givenAnchorPerson.getUuid(),
|
||||||
givenHolderPerson.getUuid(),
|
givenHolderPerson.getUuid(),
|
||||||
givenContactUuid))
|
givenContactUuid))
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.post("http://localhost/api/hs/office/relationships")
|
.post("http://localhost/api/hs/office/relations")
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
.body("message", is("cannot find contactUuid 00000000-0000-0000-0000-000000000000"));
|
.body("message", is("cannot find contactUuid 00000000-0000-0000-0000-000000000000"));
|
||||||
@ -266,97 +266,97 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@Accepts({ "Relationship:R(Read)" })
|
@Accepts({ "Relation:R(Read)" })
|
||||||
class GetRelationship {
|
class GetRelation {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_withoutAssumedRole_canGetArbitraryRelationship() {
|
void globalAdmin_withoutAssumedRole_canGetArbitraryRelation() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final UUID givenRelationshipUuid = findRelationship("First", "Firby").getUuid();
|
final UUID givenRelationUuid = findRelation("First", "Firby").getUuid();
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "superuser-alex@hostsharing.net")
|
.header("current-user", "superuser-alex@hostsharing.net")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/office/relationships/" + givenRelationshipUuid)
|
.get("http://localhost/api/hs/office/relations/" + givenRelationUuid)
|
||||||
.then().log().body().assertThat()
|
.then().log().body().assertThat()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.body("", lenientlyEquals("""
|
.body("", lenientlyEquals("""
|
||||||
{
|
{
|
||||||
"relAnchor": { "tradeName": "First GmbH" },
|
"anchor": { "tradeName": "First GmbH" },
|
||||||
"relHolder": { "familyName": "Firby" },
|
"holder": { "familyName": "Firby" },
|
||||||
"contact": { "label": "first contact" }
|
"contact": { "label": "first contact" }
|
||||||
}
|
}
|
||||||
""")); // @formatter:on
|
""")); // @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Accepts({ "Relationship:X(Access Control)" })
|
@Accepts({ "Relation:X(Access Control)" })
|
||||||
void normalUser_canNotGetUnrelatedRelationship() {
|
void normalUser_canNotGetUnrelatedRelation() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final UUID givenRelationshipUuid = findRelationship("First", "Firby").getUuid();
|
final UUID givenRelationUuid = findRelation("First", "Firby").getUuid();
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "selfregistered-user-drew@hostsharing.org")
|
.header("current-user", "selfregistered-user-drew@hostsharing.org")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/office/relationships/" + givenRelationshipUuid)
|
.get("http://localhost/api/hs/office/relations/" + givenRelationUuid)
|
||||||
.then().log().body().assertThat()
|
.then().log().body().assertThat()
|
||||||
.statusCode(404); // @formatter:on
|
.statusCode(404); // @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Accepts({ "Relationship:X(Access Control)" })
|
@Accepts({ "Relation:X(Access Control)" })
|
||||||
void contactAdminUser_canGetRelatedRelationship() {
|
void contactAdminUser_canGetRelatedRelation() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenRelationship = findRelationship("First", "Firby");
|
final var givenRelation = findRelation("First", "Firby");
|
||||||
assertThat(givenRelationship.getContact().getLabel()).isEqualTo("first contact");
|
assertThat(givenRelation.getContact().getLabel()).isEqualTo("first contact");
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "contact-admin@firstcontact.example.com")
|
.header("current-user", "contact-admin@firstcontact.example.com")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.get("http://localhost/api/hs/office/relationships/" + givenRelationship.getUuid())
|
.get("http://localhost/api/hs/office/relations/" + givenRelation.getUuid())
|
||||||
.then().log().body().assertThat()
|
.then().log().body().assertThat()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.body("", lenientlyEquals("""
|
.body("", lenientlyEquals("""
|
||||||
{
|
{
|
||||||
"relAnchor": { "tradeName": "First GmbH" },
|
"anchor": { "tradeName": "First GmbH" },
|
||||||
"relHolder": { "familyName": "Firby" },
|
"holder": { "familyName": "Firby" },
|
||||||
"contact": { "label": "first contact" }
|
"contact": { "label": "first contact" }
|
||||||
}
|
}
|
||||||
""")); // @formatter:on
|
""")); // @formatter:on
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private HsOfficeRelationshipEntity findRelationship(
|
private HsOfficeRelationEntity findRelation(
|
||||||
final String anchorPersonName,
|
final String anchorPersonName,
|
||||||
final String holderPersoneName) {
|
final String holderPersoneName) {
|
||||||
final var anchorPersonUuid = personRepo.findPersonByOptionalNameLike(anchorPersonName).get(0).getUuid();
|
final var anchorPersonUuid = personRepo.findPersonByOptionalNameLike(anchorPersonName).get(0).getUuid();
|
||||||
final var holderPersonUuid = personRepo.findPersonByOptionalNameLike(holderPersoneName).get(0).getUuid();
|
final var holderPersonUuid = personRepo.findPersonByOptionalNameLike(holderPersoneName).get(0).getUuid();
|
||||||
final var givenRelationship = relationshipRepo
|
final var givenRelation = relationRepo
|
||||||
.findRelationshipRelatedToPersonUuid(anchorPersonUuid)
|
.findRelationRelatedToPersonUuid(anchorPersonUuid)
|
||||||
.stream()
|
.stream()
|
||||||
.filter(r -> r.getRelHolder().getUuid().equals(holderPersonUuid))
|
.filter(r -> r.getHolder().getUuid().equals(holderPersonUuid))
|
||||||
.findFirst().orElseThrow();
|
.findFirst().orElseThrow();
|
||||||
return givenRelationship;
|
return givenRelation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@Accepts({ "Relationship:U(Update)" })
|
@Accepts({ "Relation:U(Update)" })
|
||||||
class PatchRelationship {
|
class PatchRelation {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_withoutAssumedRole_canPatchContactOfArbitraryRelationship() {
|
void globalAdmin_withoutAssumedRole_canPatchContactOfArbitraryRelation() {
|
||||||
|
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenRelationship = givenSomeTemporaryRelationshipBessler();
|
final var givenRelation = givenSomeTemporaryRelationBessler();
|
||||||
assertThat(givenRelationship.getContact().getLabel()).isEqualTo("seventh contact");
|
assertThat(givenRelation.getContact().getLabel()).isEqualTo("seventh contact");
|
||||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0);
|
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0);
|
||||||
|
|
||||||
final var location = RestAssured // @formatter:off
|
final var location = RestAssured // @formatter:off
|
||||||
@ -370,109 +370,109 @@ class HsOfficeRelationshipControllerAcceptanceTest extends ContextBasedTestWithC
|
|||||||
""".formatted(givenContact.getUuid()))
|
""".formatted(givenContact.getUuid()))
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.patch("http://localhost/api/hs/office/relationships/" + givenRelationship.getUuid())
|
.patch("http://localhost/api/hs/office/relations/" + givenRelation.getUuid())
|
||||||
.then().log().all().assertThat()
|
.then().log().all().assertThat()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("uuid", isUuidValid())
|
.body("uuid", isUuidValid())
|
||||||
.body("relType", is("REPRESENTATIVE"))
|
.body("type", is("REPRESENTATIVE"))
|
||||||
.body("relAnchor.tradeName", is("Erben Bessler"))
|
.body("anchor.tradeName", is("Erben Bessler"))
|
||||||
.body("relHolder.familyName", is("Winkler"))
|
.body("holder.familyName", is("Winkler"))
|
||||||
.body("contact.label", is("fourth contact"));
|
.body("contact.label", is("fourth contact"));
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
// finally, the relationship is actually updated
|
// finally, the relation is actually updated
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
assertThat(relationshipRepo.findByUuid(givenRelationship.getUuid())).isPresent().get()
|
assertThat(relationRepo.findByUuid(givenRelation.getUuid())).isPresent().get()
|
||||||
.matches(rel -> {
|
.matches(rel -> {
|
||||||
assertThat(rel.getRelAnchor().getTradeName()).contains("Bessler");
|
assertThat(rel.getAnchor().getTradeName()).contains("Bessler");
|
||||||
assertThat(rel.getRelHolder().getFamilyName()).contains("Winkler");
|
assertThat(rel.getHolder().getFamilyName()).contains("Winkler");
|
||||||
assertThat(rel.getContact().getLabel()).isEqualTo("fourth contact");
|
assertThat(rel.getContact().getLabel()).isEqualTo("fourth contact");
|
||||||
assertThat(rel.getRelType()).isEqualTo(HsOfficeRelationshipType.REPRESENTATIVE);
|
assertThat(rel.getType()).isEqualTo(HsOfficeRelationType.REPRESENTATIVE);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@Accepts({ "Relationship:D(Delete)" })
|
@Accepts({ "Relation:D(Delete)" })
|
||||||
class DeleteRelationship {
|
class DeleteRelation {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_withoutAssumedRole_canDeleteArbitraryRelationship() {
|
void globalAdmin_withoutAssumedRole_canDeleteArbitraryRelation() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenRelationship = givenSomeTemporaryRelationshipBessler();
|
final var givenRelation = givenSomeTemporaryRelationBessler();
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "superuser-alex@hostsharing.net")
|
.header("current-user", "superuser-alex@hostsharing.net")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.delete("http://localhost/api/hs/office/relationships/" + givenRelationship.getUuid())
|
.delete("http://localhost/api/hs/office/relations/" + givenRelation.getUuid())
|
||||||
.then().log().body().assertThat()
|
.then().log().body().assertThat()
|
||||||
.statusCode(204); // @formatter:on
|
.statusCode(204); // @formatter:on
|
||||||
|
|
||||||
// then the given relationship is gone
|
// then the given relation is gone
|
||||||
assertThat(relationshipRepo.findByUuid(givenRelationship.getUuid())).isEmpty();
|
assertThat(relationRepo.findByUuid(givenRelation.getUuid())).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Accepts({ "Relationship:X(Access Control)" })
|
@Accepts({ "Relation:X(Access Control)" })
|
||||||
void contactAdminUser_canNotDeleteRelatedRelationship() {
|
void contactAdminUser_canNotDeleteRelatedRelation() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenRelationship = givenSomeTemporaryRelationshipBessler();
|
final var givenRelation = givenSomeTemporaryRelationBessler();
|
||||||
assertThat(givenRelationship.getContact().getLabel()).isEqualTo("seventh contact");
|
assertThat(givenRelation.getContact().getLabel()).isEqualTo("seventh contact");
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "contact-admin@seventhcontact.example.com")
|
.header("current-user", "contact-admin@seventhcontact.example.com")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.delete("http://localhost/api/hs/office/relationships/" + givenRelationship.getUuid())
|
.delete("http://localhost/api/hs/office/relations/" + givenRelation.getUuid())
|
||||||
.then().log().body().assertThat()
|
.then().log().body().assertThat()
|
||||||
.statusCode(403); // @formatter:on
|
.statusCode(403); // @formatter:on
|
||||||
|
|
||||||
// then the given relationship is still there
|
// then the given relation is still there
|
||||||
assertThat(relationshipRepo.findByUuid(givenRelationship.getUuid())).isNotEmpty();
|
assertThat(relationRepo.findByUuid(givenRelation.getUuid())).isNotEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Accepts({ "Relationship:X(Access Control)" })
|
@Accepts({ "Relation:X(Access Control)" })
|
||||||
void normalUser_canNotDeleteUnrelatedRelationship() {
|
void normalUser_canNotDeleteUnrelatedRelation() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenRelationship = givenSomeTemporaryRelationshipBessler();
|
final var givenRelation = givenSomeTemporaryRelationBessler();
|
||||||
assertThat(givenRelationship.getContact().getLabel()).isEqualTo("seventh contact");
|
assertThat(givenRelation.getContact().getLabel()).isEqualTo("seventh contact");
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
.header("current-user", "selfregistered-user-drew@hostsharing.org")
|
.header("current-user", "selfregistered-user-drew@hostsharing.org")
|
||||||
.port(port)
|
.port(port)
|
||||||
.when()
|
.when()
|
||||||
.delete("http://localhost/api/hs/office/relationships/" + givenRelationship.getUuid())
|
.delete("http://localhost/api/hs/office/relations/" + givenRelation.getUuid())
|
||||||
.then().log().body().assertThat()
|
.then().log().body().assertThat()
|
||||||
.statusCode(404); // @formatter:on
|
.statusCode(404); // @formatter:on
|
||||||
|
|
||||||
// then the given relationship is still there
|
// then the given relation is still there
|
||||||
assertThat(relationshipRepo.findByUuid(givenRelationship.getUuid())).isNotEmpty();
|
assertThat(relationRepo.findByUuid(givenRelation.getUuid())).isNotEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private HsOfficeRelationshipEntity givenSomeTemporaryRelationshipBessler() {
|
private HsOfficeRelationEntity givenSomeTemporaryRelationBessler() {
|
||||||
return jpaAttempt.transacted(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||||
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Winkler").get(0);
|
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Winkler").get(0);
|
||||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("seventh contact").get(0);
|
final var givenContact = contactRepo.findContactByOptionalLabelLike("seventh contact").get(0);
|
||||||
final var newRelationship = HsOfficeRelationshipEntity.builder()
|
final var newRelation = HsOfficeRelationEntity.builder()
|
||||||
.relType(HsOfficeRelationshipType.REPRESENTATIVE)
|
.type(HsOfficeRelationType.REPRESENTATIVE)
|
||||||
.relAnchor(givenAnchorPerson)
|
.anchor(givenAnchorPerson)
|
||||||
.relHolder(givenHolderPerson)
|
.holder(givenHolderPerson)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assertThat(toCleanup(relationshipRepo.save(newRelationship))).isEqualTo(newRelationship);
|
assertThat(toCleanup(relationRepo.save(newRelation))).isEqualTo(newRelation);
|
||||||
|
|
||||||
return newRelationship;
|
return newRelation;
|
||||||
}).assertSuccessful().returnedValue();
|
}).assertSuccessful().returnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.relationship;
|
package net.hostsharing.hsadminng.hs.office.relation;
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.context.Context;
|
import net.hostsharing.hsadminng.context.Context;
|
||||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||||
@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
|
|
||||||
@DataJpaTest
|
@DataJpaTest
|
||||||
@Import( { Context.class, JpaAttempt.class })
|
@Import( { Context.class, JpaAttempt.class })
|
||||||
class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
|
class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsOfficeRelationshipRepository relationshipRepo;
|
HsOfficeRelationRepository relationRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HsOfficePersonRepository personRepo;
|
HsOfficePersonRepository personRepo;
|
||||||
@ -58,13 +58,13 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTestWith
|
|||||||
HttpServletRequest request;
|
HttpServletRequest request;
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class CreateRelationship {
|
class CreateRelation {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHostsharingAdmin_withoutAssumedRole_canCreateNewRelationship() {
|
public void testHostsharingAdmin_withoutAssumedRole_canCreateNewRelation() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var count = relationshipRepo.count();
|
final var count = relationRepo.count();
|
||||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Bessler").stream()
|
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Bessler").stream()
|
||||||
.filter(p -> p.getPersonType() == UNINCORPORATED_FIRM)
|
.filter(p -> p.getPersonType() == UNINCORPORATED_FIRM)
|
||||||
.findFirst().orElseThrow();
|
.findFirst().orElseThrow();
|
||||||
@ -76,20 +76,20 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTestWith
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = attempt(em, () -> {
|
final var result = attempt(em, () -> {
|
||||||
final var newRelationship = HsOfficeRelationshipEntity.builder()
|
final var newRelation = HsOfficeRelationEntity.builder()
|
||||||
.relAnchor(givenAnchorPerson)
|
.anchor(givenAnchorPerson)
|
||||||
.relHolder(givenHolderPerson)
|
.holder(givenHolderPerson)
|
||||||
.relType(HsOfficeRelationshipType.REPRESENTATIVE)
|
.type(HsOfficeRelationType.REPRESENTATIVE)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build();
|
.build();
|
||||||
return toCleanup(relationshipRepo.save(newRelationship));
|
return toCleanup(relationRepo.save(newRelation));
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertSuccessful();
|
result.assertSuccessful();
|
||||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeRelationshipEntity::getUuid).isNotNull();
|
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeRelationEntity::getUuid).isNotNull();
|
||||||
assertThatRelationshipIsPersisted(result.returnedValue());
|
assertThatRelationIsPersisted(result.returnedValue());
|
||||||
assertThat(relationshipRepo.count()).isEqualTo(count + 1);
|
assertThat(relationRepo.count()).isEqualTo(count + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -109,62 +109,62 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTestWith
|
|||||||
.findFirst().orElseThrow();
|
.findFirst().orElseThrow();
|
||||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").stream()
|
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").stream()
|
||||||
.findFirst().orElseThrow();
|
.findFirst().orElseThrow();
|
||||||
final var newRelationship = HsOfficeRelationshipEntity.builder()
|
final var newRelation = HsOfficeRelationEntity.builder()
|
||||||
.relAnchor(givenAnchorPerson)
|
.anchor(givenAnchorPerson)
|
||||||
.relHolder(givenHolderPerson)
|
.holder(givenHolderPerson)
|
||||||
.relType(HsOfficeRelationshipType.REPRESENTATIVE)
|
.type(HsOfficeRelationType.REPRESENTATIVE)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build();
|
.build();
|
||||||
return toCleanup(relationshipRepo.save(newRelationship));
|
return toCleanup(relationRepo.save(newRelation));
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(distinctRoleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(Array.from(
|
assertThat(distinctRoleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(Array.from(
|
||||||
initialRoleNames,
|
initialRoleNames,
|
||||||
"hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner",
|
"hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner",
|
||||||
"hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin",
|
"hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin",
|
||||||
"hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.agent",
|
"hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.agent",
|
||||||
"hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant"));
|
"hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant"));
|
||||||
assertThat(distinctGrantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(Array.fromFormatted(
|
assertThat(distinctGrantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(Array.fromFormatted(
|
||||||
initialGrantNames,
|
initialGrantNames,
|
||||||
"{ grant perm INSERT on hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert to role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin by system and assume }",
|
"{ grant perm INSERT on hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert to role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin by system and assume }",
|
||||||
|
|
||||||
"{ grant perm DELETE on hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert to role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner by system and assume }",
|
"{ grant perm DELETE on hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert to role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner by system and assume }",
|
||||||
"{ grant role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner to role global#global.admin by system and assume }",
|
"{ grant role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner to role global#global.admin by system and assume }",
|
||||||
"{ grant role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner to user superuser-alex@hostsharing.net by hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner and assume }",
|
"{ grant role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner to user superuser-alex@hostsharing.net by hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner and assume }",
|
||||||
|
|
||||||
"{ grant perm UPDATE on hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert to role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin by system and assume }",
|
"{ grant perm UPDATE on hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert to role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin by system and assume }",
|
||||||
"{ grant role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin to role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner by system and assume }",
|
"{ grant role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin to role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.owner by system and assume }",
|
||||||
"{ grant role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin to role hs_office_person#ErbenBesslerMelBessler.admin by system and assume }",
|
"{ grant role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin to role hs_office_person#ErbenBesslerMelBessler.admin by system and assume }",
|
||||||
|
|
||||||
"{ grant role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.agent to role hs_office_person#BesslerBert.admin by system and assume }",
|
"{ grant role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.agent to role hs_office_person#BesslerBert.admin by system and assume }",
|
||||||
"{ grant role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.agent to role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin by system and assume }",
|
"{ grant role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.agent to role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.admin by system and assume }",
|
||||||
|
|
||||||
"{ grant perm SELECT on hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert to role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant by system and assume }",
|
"{ grant perm SELECT on hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert to role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant by system and assume }",
|
||||||
"{ grant role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant to role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.agent by system and assume }",
|
"{ grant role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant to role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.agent by system and assume }",
|
||||||
"{ grant role hs_office_person#BesslerBert.referrer to role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant by system and assume }",
|
"{ grant role hs_office_person#BesslerBert.referrer to role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant by system and assume }",
|
||||||
"{ grant role hs_office_person#ErbenBesslerMelBessler.referrer to role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant by system and assume }",
|
"{ grant role hs_office_person#ErbenBesslerMelBessler.referrer to role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant by system and assume }",
|
||||||
"{ grant role hs_office_contact#fourthcontact.referrer to role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant by system and assume }",
|
"{ grant role hs_office_contact#fourthcontact.referrer to role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant by system and assume }",
|
||||||
|
|
||||||
// REPRESENTATIVE holder person -> (represented) anchor person
|
// REPRESENTATIVE holder person -> (represented) anchor person
|
||||||
"{ grant role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant to role hs_office_contact#fourthcontact.admin by system and assume }",
|
"{ grant role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant to role hs_office_contact#fourthcontact.admin by system and assume }",
|
||||||
"{ grant role hs_office_relationship#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant to role hs_office_person#BesslerBert.admin by system and assume }",
|
"{ grant role hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerBert.tenant to role hs_office_person#BesslerBert.admin by system and assume }",
|
||||||
|
|
||||||
null)
|
null)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatRelationshipIsPersisted(final HsOfficeRelationshipEntity saved) {
|
private void assertThatRelationIsPersisted(final HsOfficeRelationEntity saved) {
|
||||||
final var found = relationshipRepo.findByUuid(saved.getUuid());
|
final var found = relationRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class FindAllRelationships {
|
class FindAllRelations {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void globalAdmin_withoutAssumedRole_canViewAllRelationshipsOfArbitraryPerson() {
|
public void globalAdmin_withoutAssumedRole_canViewAllRelationsOfArbitraryPerson() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var person = personRepo.findPersonByOptionalNameLike("Smith").stream()
|
final var person = personRepo.findPersonByOptionalNameLike("Smith").stream()
|
||||||
@ -172,18 +172,18 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTestWith
|
|||||||
.findFirst().orElseThrow();
|
.findFirst().orElseThrow();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = relationshipRepo.findRelationshipRelatedToPersonUuid(person.getUuid());
|
final var result = relationRepo.findRelationRelatedToPersonUuid(person.getUuid());
|
||||||
|
|
||||||
// then
|
// then
|
||||||
allTheseRelationshipsAreReturned(
|
allTheseRelationsAreReturned(
|
||||||
result,
|
result,
|
||||||
"rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='NP Smith, Peter', contact='sixth contact')",
|
"rel(anchor='LP Hostsharing eG', type='PARTNER', holder='NP Smith, Peter', contact='sixth contact')",
|
||||||
"rel(relAnchor='LP Second e.K.', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='second contact')",
|
"rel(anchor='LP Second e.K.', type='REPRESENTATIVE', holder='NP Smith, Peter', contact='second contact')",
|
||||||
"rel(relAnchor='IF Third OHG', relType='SUBSCRIBER', relMark='members-announce', relHolder='NP Smith, Peter', contact='third contact')");
|
"rel(anchor='IF Third OHG', type='SUBSCRIBER', mark='members-announce', holder='NP Smith, Peter', contact='third contact')");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void normalUser_canViewRelationshipsOfOwnedPersons() {
|
public void normalUser_canViewRelationsOfOwnedPersons() {
|
||||||
// given:
|
// given:
|
||||||
context("person-SmithPeter@example.com");
|
context("person-SmithPeter@example.com");
|
||||||
final var person = personRepo.findPersonByOptionalNameLike("Smith").stream()
|
final var person = personRepo.findPersonByOptionalNameLike("Smith").stream()
|
||||||
@ -191,124 +191,124 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTestWith
|
|||||||
.findFirst().orElseThrow();
|
.findFirst().orElseThrow();
|
||||||
|
|
||||||
// when:
|
// when:
|
||||||
final var result = relationshipRepo.findRelationshipRelatedToPersonUuid(person.getUuid());
|
final var result = relationRepo.findRelationRelatedToPersonUuid(person.getUuid());
|
||||||
|
|
||||||
// then:
|
// then:
|
||||||
exactlyTheseRelationshipsAreReturned(
|
exactlyTheseRelationsAreReturned(
|
||||||
result,
|
result,
|
||||||
"rel(relAnchor='LP Second e.K.', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='second contact')",
|
"rel(anchor='LP Second e.K.', type='REPRESENTATIVE', holder='NP Smith, Peter', contact='second contact')",
|
||||||
"rel(relAnchor='IF Third OHG', relType='SUBSCRIBER', relMark='members-announce', relHolder='NP Smith, Peter', contact='third contact')",
|
"rel(anchor='IF Third OHG', type='SUBSCRIBER', mark='members-announce', holder='NP Smith, Peter', contact='third contact')",
|
||||||
"rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='NP Smith, Peter', contact='sixth contact')",
|
"rel(anchor='LP Hostsharing eG', type='PARTNER', holder='NP Smith, Peter', contact='sixth contact')",
|
||||||
"rel(relAnchor='NP Smith, Peter', relType='ACCOUNTING', relHolder='NP Smith, Peter', contact='third contact')");
|
"rel(anchor='NP Smith, Peter', type='DEBITOR', holder='NP Smith, Peter', contact='third contact')");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class UpdateRelationship {
|
class UpdateRelation {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hostsharingAdmin_withoutAssumedRole_canUpdateContactOfArbitraryRelationship() {
|
public void hostsharingAdmin_withoutAssumedRole_canUpdateContactOfArbitraryRelation() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var givenRelationship = givenSomeTemporaryRelationshipBessler(
|
final var givenRelation = givenSomeTemporaryRelationBessler(
|
||||||
"Bert", "fifth contact");
|
"Bert", "fifth contact");
|
||||||
assertThatRelationshipIsVisibleForUserWithRole(
|
assertThatRelationIsVisibleForUserWithRole(
|
||||||
givenRelationship,
|
givenRelation,
|
||||||
"hs_office_person#ErbenBesslerMelBessler.admin");
|
"hs_office_person#ErbenBesslerMelBessler.admin");
|
||||||
assertThatRelationshipActuallyInDatabase(givenRelationship);
|
assertThatRelationActuallyInDatabase(givenRelation);
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("sixth contact").stream().findFirst().orElseThrow();
|
final var givenContact = contactRepo.findContactByOptionalLabelLike("sixth contact").stream().findFirst().orElseThrow();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
givenRelationship.setContact(givenContact);
|
givenRelation.setContact(givenContact);
|
||||||
return toCleanup(relationshipRepo.save(givenRelationship));
|
return toCleanup(relationRepo.save(givenRelation));
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertSuccessful();
|
result.assertSuccessful();
|
||||||
assertThat(result.returnedValue().getContact().getLabel()).isEqualTo("sixth contact");
|
assertThat(result.returnedValue().getContact().getLabel()).isEqualTo("sixth contact");
|
||||||
assertThatRelationshipIsVisibleForUserWithRole(
|
assertThatRelationIsVisibleForUserWithRole(
|
||||||
result.returnedValue(),
|
result.returnedValue(),
|
||||||
"global#global.admin");
|
"global#global.admin");
|
||||||
assertThatRelationshipIsVisibleForUserWithRole(
|
assertThatRelationIsVisibleForUserWithRole(
|
||||||
result.returnedValue(),
|
result.returnedValue(),
|
||||||
"hs_office_contact#sixthcontact.admin");
|
"hs_office_contact#sixthcontact.admin");
|
||||||
|
|
||||||
assertThatRelationshipIsNotVisibleForUserWithRole(
|
assertThatRelationIsNotVisibleForUserWithRole(
|
||||||
result.returnedValue(),
|
result.returnedValue(),
|
||||||
"hs_office_contact#fifthcontact.admin");
|
"hs_office_contact#fifthcontact.admin");
|
||||||
|
|
||||||
relationshipRepo.deleteByUuid(givenRelationship.getUuid());
|
relationRepo.deleteByUuid(givenRelation.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void relHolderAdmin_canNotUpdateRelatedRelationship() {
|
public void holderAdmin_canNotUpdateRelatedRelation() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var givenRelationship = givenSomeTemporaryRelationshipBessler(
|
final var givenRelation = givenSomeTemporaryRelationBessler(
|
||||||
"Anita", "eighth");
|
"Anita", "eighth");
|
||||||
assertThatRelationshipIsVisibleForUserWithRole(
|
assertThatRelationIsVisibleForUserWithRole(
|
||||||
givenRelationship,
|
givenRelation,
|
||||||
"hs_office_person#BesslerAnita.admin");
|
"hs_office_person#BesslerAnita.admin");
|
||||||
assertThatRelationshipActuallyInDatabase(givenRelationship);
|
assertThatRelationActuallyInDatabase(givenRelation);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net", "hs_office_person#BesslerAnita.admin");
|
context("superuser-alex@hostsharing.net", "hs_office_person#BesslerAnita.admin");
|
||||||
givenRelationship.setContact(null);
|
givenRelation.setContact(null);
|
||||||
return relationshipRepo.save(givenRelationship);
|
return relationRepo.save(givenRelation);
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertExceptionWithRootCauseMessage(JpaSystemException.class,
|
result.assertExceptionWithRootCauseMessage(JpaSystemException.class,
|
||||||
"[403] Subject ", " is not allowed to update hs_office_relationship uuid");
|
"[403] Subject ", " is not allowed to update hs_office_relation uuid");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contactAdmin_canNotUpdateRelatedRelationship() {
|
public void contactAdmin_canNotUpdateRelatedRelation() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var givenRelationship = givenSomeTemporaryRelationshipBessler(
|
final var givenRelation = givenSomeTemporaryRelationBessler(
|
||||||
"Anita", "ninth");
|
"Anita", "ninth");
|
||||||
assertThatRelationshipIsVisibleForUserWithRole(
|
assertThatRelationIsVisibleForUserWithRole(
|
||||||
givenRelationship,
|
givenRelation,
|
||||||
"hs_office_contact#ninthcontact.admin");
|
"hs_office_contact#ninthcontact.admin");
|
||||||
assertThatRelationshipActuallyInDatabase(givenRelationship);
|
assertThatRelationActuallyInDatabase(givenRelation);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net", "hs_office_contact#ninthcontact.admin");
|
context("superuser-alex@hostsharing.net", "hs_office_contact#ninthcontact.admin");
|
||||||
givenRelationship.setContact(null); // TODO
|
givenRelation.setContact(null); // TODO
|
||||||
return relationshipRepo.save(givenRelationship);
|
return relationRepo.save(givenRelation);
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertExceptionWithRootCauseMessage(JpaSystemException.class,
|
result.assertExceptionWithRootCauseMessage(JpaSystemException.class,
|
||||||
"[403] Subject ", " is not allowed to update hs_office_relationship uuid");
|
"[403] Subject ", " is not allowed to update hs_office_relation uuid");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatRelationshipActuallyInDatabase(final HsOfficeRelationshipEntity saved) {
|
private void assertThatRelationActuallyInDatabase(final HsOfficeRelationEntity saved) {
|
||||||
final var found = relationshipRepo.findByUuid(saved.getUuid());
|
final var found = relationRepo.findByUuid(saved.getUuid());
|
||||||
assertThat(found).isNotEmpty().get().isNotSameAs(saved).usingRecursiveComparison().isEqualTo(saved);
|
assertThat(found).isNotEmpty().get().isNotSameAs(saved).usingRecursiveComparison().isEqualTo(saved);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatRelationshipIsVisibleForUserWithRole(
|
private void assertThatRelationIsVisibleForUserWithRole(
|
||||||
final HsOfficeRelationshipEntity entity,
|
final HsOfficeRelationEntity entity,
|
||||||
final String assumedRoles) {
|
final String assumedRoles) {
|
||||||
jpaAttempt.transacted(() -> {
|
jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net", assumedRoles);
|
context("superuser-alex@hostsharing.net", assumedRoles);
|
||||||
assertThatRelationshipActuallyInDatabase(entity);
|
assertThatRelationActuallyInDatabase(entity);
|
||||||
}).assertSuccessful();
|
}).assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatRelationshipIsNotVisibleForUserWithRole(
|
private void assertThatRelationIsNotVisibleForUserWithRole(
|
||||||
final HsOfficeRelationshipEntity entity,
|
final HsOfficeRelationEntity entity,
|
||||||
final String assumedRoles) {
|
final String assumedRoles) {
|
||||||
jpaAttempt.transacted(() -> {
|
jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net", assumedRoles);
|
context("superuser-alex@hostsharing.net", assumedRoles);
|
||||||
final var found = relationshipRepo.findByUuid(entity.getUuid());
|
final var found = relationRepo.findByUuid(entity.getUuid());
|
||||||
assertThat(found).isEmpty();
|
assertThat(found).isEmpty();
|
||||||
}).assertSuccessful();
|
}).assertSuccessful();
|
||||||
}
|
}
|
||||||
@ -318,63 +318,63 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTestWith
|
|||||||
class DeleteByUuid {
|
class DeleteByUuid {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void globalAdmin_withoutAssumedRole_canDeleteAnyRelationship() {
|
public void globalAdmin_withoutAssumedRole_canDeleteAnyRelation() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net", null);
|
context("superuser-alex@hostsharing.net", null);
|
||||||
final var givenRelationship = givenSomeTemporaryRelationshipBessler(
|
final var givenRelation = givenSomeTemporaryRelationBessler(
|
||||||
"Anita", "tenth");
|
"Anita", "tenth");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
relationshipRepo.deleteByUuid(givenRelationship.getUuid());
|
relationRepo.deleteByUuid(givenRelation.getUuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertSuccessful();
|
result.assertSuccessful();
|
||||||
assertThat(jpaAttempt.transacted(() -> {
|
assertThat(jpaAttempt.transacted(() -> {
|
||||||
context("superuser-fran@hostsharing.net", null);
|
context("superuser-fran@hostsharing.net", null);
|
||||||
return relationshipRepo.findByUuid(givenRelationship.getUuid());
|
return relationRepo.findByUuid(givenRelation.getUuid());
|
||||||
}).assertSuccessful().returnedValue()).isEmpty();
|
}).assertSuccessful().returnedValue()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contactUser_canViewButNotDeleteTheirRelatedRelationship() {
|
public void contactUser_canViewButNotDeleteTheirRelatedRelation() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net", null);
|
context("superuser-alex@hostsharing.net", null);
|
||||||
final var givenRelationship = givenSomeTemporaryRelationshipBessler(
|
final var givenRelation = givenSomeTemporaryRelationBessler(
|
||||||
"Anita", "eleventh");
|
"Anita", "eleventh");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("contact-admin@eleventhcontact.example.com");
|
context("contact-admin@eleventhcontact.example.com");
|
||||||
assertThat(relationshipRepo.findByUuid(givenRelationship.getUuid())).isPresent();
|
assertThat(relationRepo.findByUuid(givenRelation.getUuid())).isPresent();
|
||||||
relationshipRepo.deleteByUuid(givenRelationship.getUuid());
|
relationRepo.deleteByUuid(givenRelation.getUuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertExceptionWithRootCauseMessage(
|
result.assertExceptionWithRootCauseMessage(
|
||||||
JpaSystemException.class,
|
JpaSystemException.class,
|
||||||
"[403] Subject ", " not allowed to delete hs_office_relationship");
|
"[403] Subject ", " not allowed to delete hs_office_relation");
|
||||||
assertThat(jpaAttempt.transacted(() -> {
|
assertThat(jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
return relationshipRepo.findByUuid(givenRelationship.getUuid());
|
return relationRepo.findByUuid(givenRelation.getUuid());
|
||||||
}).assertSuccessful().returnedValue()).isPresent(); // still there
|
}).assertSuccessful().returnedValue()).isPresent(); // still there
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deletingARelationshipAlsoDeletesRelatedRolesAndGrants() {
|
public void deletingARelationAlsoDeletesRelatedRolesAndGrants() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var initialRoleNames = Array.from(distinctRoleNamesOf(rawRoleRepo.findAll()));
|
final var initialRoleNames = Array.from(distinctRoleNamesOf(rawRoleRepo.findAll()));
|
||||||
final var initialGrantNames = Array.from(distinctGrantDisplaysOf(rawGrantRepo.findAll()));
|
final var initialGrantNames = Array.from(distinctGrantDisplaysOf(rawGrantRepo.findAll()));
|
||||||
final var givenRelationship = givenSomeTemporaryRelationshipBessler(
|
final var givenRelation = givenSomeTemporaryRelationBessler(
|
||||||
"Anita", "twelfth");
|
"Anita", "twelfth");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
return relationshipRepo.deleteByUuid(givenRelationship.getUuid());
|
return relationRepo.deleteByUuid(givenRelation.getUuid());
|
||||||
});
|
});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
@ -391,7 +391,7 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTestWith
|
|||||||
final var query = em.createNativeQuery("""
|
final var query = em.createNativeQuery("""
|
||||||
select currentTask, targetTable, targetOp
|
select currentTask, targetTable, targetOp
|
||||||
from tx_journal_v
|
from tx_journal_v
|
||||||
where targettable = 'hs_office_relationship';
|
where targettable = 'hs_office_relation';
|
||||||
""");
|
""");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -399,40 +399,40 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTestWith
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||||
"[creating relationship test-data HostsharingeG-FirstGmbH, hs_office_relationship, INSERT]",
|
"[creating relation test-data HostsharingeG-FirstGmbH, hs_office_relation, INSERT]",
|
||||||
"[creating relationship test-data FirstGmbH-Firby, hs_office_relationship, INSERT]");
|
"[creating relation test-data FirstGmbH-Firby, hs_office_relation, INSERT]");
|
||||||
}
|
}
|
||||||
|
|
||||||
private HsOfficeRelationshipEntity givenSomeTemporaryRelationshipBessler(final String holderPerson, final String contact) {
|
private HsOfficeRelationEntity givenSomeTemporaryRelationBessler(final String holderPerson, final String contact) {
|
||||||
return jpaAttempt.transacted(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||||
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike(holderPerson).get(0);
|
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike(holderPerson).get(0);
|
||||||
final var givenContact = contactRepo.findContactByOptionalLabelLike(contact).get(0);
|
final var givenContact = contactRepo.findContactByOptionalLabelLike(contact).get(0);
|
||||||
final var newRelationship = HsOfficeRelationshipEntity.builder()
|
final var newRelation = HsOfficeRelationEntity.builder()
|
||||||
.relType(HsOfficeRelationshipType.REPRESENTATIVE)
|
.type(HsOfficeRelationType.REPRESENTATIVE)
|
||||||
.relAnchor(givenAnchorPerson)
|
.anchor(givenAnchorPerson)
|
||||||
.relHolder(givenHolderPerson)
|
.holder(givenHolderPerson)
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return toCleanup(relationshipRepo.save(newRelationship));
|
return toCleanup(relationRepo.save(newRelation));
|
||||||
}).assertSuccessful().returnedValue();
|
}).assertSuccessful().returnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void exactlyTheseRelationshipsAreReturned(
|
void exactlyTheseRelationsAreReturned(
|
||||||
final List<HsOfficeRelationshipEntity> actualResult,
|
final List<HsOfficeRelationEntity> actualResult,
|
||||||
final String... relationshipNames) {
|
final String... relationNames) {
|
||||||
assertThat(actualResult)
|
assertThat(actualResult)
|
||||||
.extracting(HsOfficeRelationshipEntity::toString)
|
.extracting(HsOfficeRelationEntity::toString)
|
||||||
.containsExactlyInAnyOrder(relationshipNames);
|
.containsExactlyInAnyOrder(relationNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
void allTheseRelationshipsAreReturned(
|
void allTheseRelationsAreReturned(
|
||||||
final List<HsOfficeRelationshipEntity> actualResult,
|
final List<HsOfficeRelationEntity> actualResult,
|
||||||
final String... relationshipNames) {
|
final String... relationNames) {
|
||||||
assertThat(actualResult)
|
assertThat(actualResult)
|
||||||
.extracting(HsOfficeRelationshipEntity::toString)
|
.extracting(HsOfficeRelationEntity::toString)
|
||||||
.contains(relationshipNames);
|
.contains(relationNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
|
|||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get()
|
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get()
|
||||||
.matches(mandate -> {
|
.matches(mandate -> {
|
||||||
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: rel(relAnchor='LP First GmbH', relType='ACCOUNTING', relHolder='LP First GmbH'), fir)");
|
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: rel(anchor='LP First GmbH', type='DEBITOR', holder='LP First GmbH'), fir)");
|
||||||
assertThat(mandate.getBankAccount().toShortString()).isEqualTo("First GmbH");
|
assertThat(mandate.getBankAccount().toShortString()).isEqualTo("First GmbH");
|
||||||
assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z - patched");
|
assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z - patched");
|
||||||
assertThat(mandate.getValidFrom()).isEqualTo("2020-06-05");
|
assertThat(mandate.getValidFrom()).isEqualTo("2020-06-05");
|
||||||
@ -398,7 +398,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
|
|||||||
// finally, the sepaMandate is actually updated
|
// finally, the sepaMandate is actually updated
|
||||||
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get()
|
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get()
|
||||||
.matches(mandate -> {
|
.matches(mandate -> {
|
||||||
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: rel(relAnchor='LP First GmbH', relType='ACCOUNTING', relHolder='LP First GmbH'), fir)");
|
assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(D-1000111: rel(anchor='LP First GmbH', type='DEBITOR', holder='LP First GmbH'), fir)");
|
||||||
assertThat(mandate.getBankAccount().toShortString()).isEqualTo("First GmbH");
|
assertThat(mandate.getBankAccount().toShortString()).isEqualTo("First GmbH");
|
||||||
assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z");
|
assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z");
|
||||||
assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2023-01-01)");
|
assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2023-01-01)");
|
||||||
@ -503,8 +503,8 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
|
|||||||
return jpaAttempt.transacted(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenDebitor = debitorRepo.findDebitorByDebitorNumber(debitorNumber).get(0);
|
final var givenDebitor = debitorRepo.findDebitorByDebitorNumber(debitorNumber).get(0);
|
||||||
final var bankAccountHolder = ofNullable(givenDebitor.getPartner().getPartnerRole().getRelHolder().getTradeName())
|
final var bankAccountHolder = ofNullable(givenDebitor.getPartner().getPartnerRel().getHolder().getTradeName())
|
||||||
.orElse(givenDebitor.getPartner().getPartnerRole().getRelHolder().getFamilyName());
|
.orElse(givenDebitor.getPartner().getPartnerRel().getHolder().getFamilyName());
|
||||||
final var givenBankAccount = bankAccountRepo.findByOptionalHolderLike(bankAccountHolder).get(0);
|
final var givenBankAccount = bankAccountRepo.findByOptionalHolderLike(bankAccountHolder).get(0);
|
||||||
final var newSepaMandate = HsOfficeSepaMandateEntity.builder()
|
final var newSepaMandate = HsOfficeSepaMandateEntity.builder()
|
||||||
.uuid(UUID.randomUUID())
|
.uuid(UUID.randomUUID())
|
||||||
|
@ -138,14 +138,14 @@ class HsOfficeSepaMandateRepositoryIntegrationTest extends ContextBasedTestWithC
|
|||||||
// agent
|
// agent
|
||||||
"{ grant role bankaccount#DE02600501010002034304.referrer to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).agent by system and assume }",
|
"{ grant role bankaccount#DE02600501010002034304.referrer to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).agent by system and assume }",
|
||||||
"{ grant role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).agent to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).admin by system and assume }",
|
"{ grant role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).agent to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).admin by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FirstGmbH.agent to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).agent by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FirstGmbH.agent to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).agent by system and assume }",
|
||||||
|
|
||||||
// referrer
|
// referrer
|
||||||
"{ grant perm SELECT on sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01) to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).referrer by system and assume }",
|
"{ grant perm SELECT on sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01) to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).referrer by system and assume }",
|
||||||
"{ grant role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).referrer to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).agent by system and assume }",
|
"{ grant role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).referrer to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).agent by system and assume }",
|
||||||
"{ grant role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).referrer to role bankaccount#DE02600501010002034304.admin by system and assume }",
|
"{ grant role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).referrer to role bankaccount#DE02600501010002034304.admin by system and assume }",
|
||||||
"{ grant role relationship#FirstGmbH-with-ACCOUNTING-FirstGmbH.tenant to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).referrer by system and assume }",
|
"{ grant role relation#FirstGmbH-with-DEBITOR-FirstGmbH.tenant to role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).referrer by system and assume }",
|
||||||
"{ grant role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).referrer to role relationship#FirstGmbH-with-ACCOUNTING-FirstGmbH.agent by system and assume }",
|
"{ grant role sepamandate#DE02600501010002034304-[2020-01-01,2023-01-01).referrer to role relation#FirstGmbH-with-DEBITOR-FirstGmbH.agent by system and assume }",
|
||||||
|
|
||||||
null));
|
null));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user