From f1bbc85ec62d53c57583997a8734daab91d28865 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sun, 7 Apr 2024 12:37:44 +0200 Subject: [PATCH] amendmends after self-review --- .../office/debitor/HsOfficeDebitorEntity.java | 19 +++++++++++++++---- .../hsadminng/rbac/rbacdef/RbacView.java | 4 ++-- .../RolesGrantsAndPermissionsGenerator.java | 5 ----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java index 8b48e221..509cb165 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java @@ -1,6 +1,10 @@ package net.hostsharing.hsadminng.hs.office.debitor; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import net.hostsharing.hsadminng.errors.DisplayName; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity; import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; @@ -15,7 +19,13 @@ import org.hibernate.annotations.JoinFormula; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; -import jakarta.persistence.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import jakarta.validation.constraints.Pattern; import java.io.IOException; import java.util.UUID; @@ -26,7 +36,7 @@ import static jakarta.persistence.CascadeType.PERSIST; import static jakarta.persistence.CascadeType.REFRESH; import static java.util.Optional.ofNullable; import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Column.dependsOnColumn; -import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.ColumnValue.usingCase; +import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.ColumnValue.usingDefaultCase; import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Nullable.NOT_NULL; import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Nullable.NULLABLE; import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Permission.*; @@ -158,7 +168,8 @@ public class HsOfficeDebitorEntity implements RbacObject, Stringifyable { .toRole("global", ADMIN).grantPermission(INSERT) .importRootEntityAliasProxy("debitorRel", HsOfficeRelationEntity.class, - usingCase("DEBITOR"), + // TODO.spec: do we need a distinct case for DEBITOR-Relation? + usingDefaultCase(), directlyFetchedByDependsOnColumn(), dependsOnColumn("debitorRelUuid")) .createPermission(DELETE).grantedTo("debitorRel", OWNER) diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/rbacdef/RbacView.java b/src/main/java/net/hostsharing/hsadminng/rbac/rbacdef/RbacView.java index 4e792861..90bddc20 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/rbacdef/RbacView.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/rbacdef/RbacView.java @@ -257,7 +257,7 @@ public class RbacView { return permDefs.stream() .filter(p -> p.permission == permission && p.entityAlias == entityAlias) .findFirst() - // .map(g -> g.forCase(processingCase)) TODO: not implemented case dependent + // .map(g -> g.forCase(processingCase)) TODO.impl: not implemented case dependent .orElseGet(() -> new RbacPermissionDefinition(entityAlias, permission, null, true)); } @@ -415,7 +415,6 @@ public class RbacView { this.discriminatorColumName = discriminatorColumName; allCases.addAll(stream(caseDefs).toList()); - // FIXME: currently only the default case is executed stream(caseDefs).forEach(caseDef -> { this.processingCase = caseDef; caseDef.def.accept(this); @@ -1133,6 +1132,7 @@ public class RbacView { } } + // FIXME: subclass of ColumnValue public static class CaseDef { final String val; diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/rbacdef/RolesGrantsAndPermissionsGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/rbacdef/RolesGrantsAndPermissionsGenerator.java index 91a312bf..38632e27 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/rbacdef/RolesGrantsAndPermissionsGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/rbacdef/RolesGrantsAndPermissionsGenerator.java @@ -331,11 +331,6 @@ class RolesGrantsAndPermissionsGenerator { .replace("${permRef}", createPerm(NEW, grantDef.getPermDef())) .replace("${superRoleRef}", roleRef(NEW, grantDef.getSuperRoleDef())); }; -// if (grantDef.isConditional()) { -// return "if " + grantDef.generateCondition() + " then\n" -// + " " + grantSql + "\n" -// + "end if;"; -// } return grantSql; }