From 3877831f9b6e738520610b1a482900eb17badc12 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 2 Jan 2025 09:16:05 +0100 Subject: [PATCH] rename RbacView->RbacSpec --- .../booking/item/HsBookingItemRbacEntity.java | 34 ++++---- .../project/HsBookingProjectRbacEntity.java | 38 ++++----- .../asset/HsHostingAssetRbacEntity.java | 42 +++++----- .../HsOfficeBankAccountEntity.java | 12 +-- .../contact/HsOfficeContactRbacEntity.java | 16 ++-- .../HsOfficeCoopAssetsTransactionEntity.java | 26 +++--- .../HsOfficeCoopSharesTransactionEntity.java | 26 +++--- .../office/debitor/HsOfficeDebitorEntity.java | 28 +++---- .../membership/HsOfficeMembershipEntity.java | 36 ++++---- .../partner/HsOfficePartnerDetailsEntity.java | 14 ++-- .../office/partner/HsOfficePartnerEntity.java | 22 ++--- .../person/HsOfficePersonRbacEntity.java | 16 ++-- .../relation/HsOfficeRelationRbacEntity.java | 42 +++++----- .../HsOfficeSepaMandateEntity.java | 24 +++--- .../generator/InsertTriggerGenerator.java | 32 +++---- .../generator/RbacIdentityViewGenerator.java | 4 +- .../rbac/generator/RbacObjectGenerator.java | 2 +- .../RbacRbacSystemRebuildGenerator.java | 6 +- .../RbacRestrictedViewGenerator.java | 4 +- .../RbacRoleDescriptorsGenerator.java | 2 +- .../{RbacView.java => RbacSpec.java} | 83 +++++++++---------- .../RbacViewMermaidFlowchartGenerator.java | 30 +++---- .../generator/RbacViewPostgresGenerator.java | 4 +- .../RolesGrantsAndPermissionsGenerator.java | 72 ++++++++-------- .../rbac/test/cust/TestCustomerEntity.java | 16 ++-- .../rbac/test/dom/TestDomainEntity.java | 20 ++--- .../rbac/test/pac/TestPackageEntity.java | 20 ++--- 27 files changed, 335 insertions(+), 336 deletions(-) rename src/main/java/net/hostsharing/hsadminng/rbac/generator/{RbacView.java => RbacSpec.java} (95%) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacEntity.java index c07c4d02..bc9988c5 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacEntity.java @@ -5,8 +5,8 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.experimental.SuperBuilder; import net.hostsharing.hsadminng.hs.booking.project.HsBookingProjectRbacEntity; -import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL; import jakarta.persistence.AttributeOverride; import jakarta.persistence.AttributeOverrides; @@ -15,20 +15,20 @@ import jakarta.persistence.Entity; import jakarta.persistence.Table; import java.io.IOException; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Column.dependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingDefaultCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Nullable.NULLABLE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.DELETE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.INSERT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.SELECT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.UPDATE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.ADMIN; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.AGENT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.OWNER; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.TENANT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.directlyFetchedByDependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Column.dependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingDefaultCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.GLOBAL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Nullable.NULLABLE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.DELETE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.INSERT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.SELECT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.UPDATE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.ADMIN; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.AGENT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.OWNER; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.TENANT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL.directlyFetchedByDependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.rbacViewFor; @Entity @Table(schema = "hs_booking", name = "item_rv") @@ -41,7 +41,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; }) public class HsBookingItemRbacEntity extends HsBookingItem { - public static RbacView rbac() { + public static RbacSpec rbac() { return rbacViewFor("bookingItem", HsBookingItemRbacEntity.class) .withIdentityView(SQL.projection("caption")) .withRestrictedViewOrderBy(SQL.expression("validity")) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacEntity.java index 259fe5fa..90417809 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacEntity.java @@ -6,30 +6,30 @@ import lombok.Setter; import lombok.experimental.SuperBuilder; import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity; -import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL; import jakarta.persistence.Entity; import jakarta.persistence.Table; import java.io.IOException; import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.DEBITOR; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Column.dependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingDefaultCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Nullable.NOT_NULL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.DELETE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.INSERT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.SELECT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.UPDATE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.ADMIN; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.AGENT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.OWNER; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.TENANT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.directlyFetchedByDependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.fetchedBySql; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Column.dependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingDefaultCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.GLOBAL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Nullable.NOT_NULL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.DELETE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.INSERT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.SELECT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.UPDATE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.ADMIN; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.AGENT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.OWNER; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.TENANT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL.directlyFetchedByDependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL.fetchedBySql; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.rbacViewFor; @Entity @Table(schema = "hs_booking", name = "project_rv") @@ -39,7 +39,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; @NoArgsConstructor public class HsBookingProjectRbacEntity extends HsBookingProject { - public static RbacView rbac() { + public static RbacSpec rbac() { return rbacViewFor("project", HsBookingProjectRbacEntity.class) .withIdentityView(SQL.query(""" SELECT bookingProject.uuid as uuid, debitorIV.idName || '-' || base.cleanIdentifier(bookingProject.caption) as idName diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacEntity.java index a7f48eb3..4c020d8b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacEntity.java @@ -6,31 +6,31 @@ import lombok.Setter; import lombok.experimental.SuperBuilder; import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemRbacEntity; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity; -import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL; import jakarta.persistence.Entity; import jakarta.persistence.Table; import java.io.IOException; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.CaseDef.inCaseOf; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Column.dependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingDefaultCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Nullable.NULLABLE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.DELETE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.INSERT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.SELECT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.UPDATE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.ADMIN; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.AGENT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.GUEST; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.OWNER; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.REFERRER; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.TENANT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.directlyFetchedByDependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.CaseDef.inCaseOf; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Column.dependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingDefaultCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.GLOBAL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Nullable.NULLABLE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.DELETE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.INSERT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.SELECT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.UPDATE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacSubjectReference.UserRole.CREATOR; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.ADMIN; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.AGENT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.GUEST; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.OWNER; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.REFERRER; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.TENANT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL.directlyFetchedByDependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.rbacViewFor; @Entity @Table(schema = "hs_hosting", name = "asset_rv") @@ -40,7 +40,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; @NoArgsConstructor public class HsHostingAssetRbacEntity extends HsHostingAsset { - public static RbacView rbac() { + public static RbacSpec rbac() { return rbacViewFor("asset", HsHostingAssetRbacEntity.class) .withIdentityView(SQL.projection("identifier")) .withRestrictedViewOrderBy(SQL.expression("identifier")) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java index edc26010..de7f6782 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java @@ -4,7 +4,7 @@ import lombok.*; import lombok.experimental.FieldNameConstants; import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.rbac.generator.RbacView; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec; import net.hostsharing.hsadminng.repr.Stringify; import net.hostsharing.hsadminng.repr.Stringifyable; @@ -12,10 +12,10 @@ import jakarta.persistence.*; import java.io.IOException; import java.util.UUID; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacSubjectReference.UserRole.CREATOR; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.*; import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @@ -57,7 +57,7 @@ public class HsOfficeBankAccountEntity implements BaseEntity, return getTaggedDebitorNumber(); } - public static RbacView rbac() { + public static RbacSpec rbac() { return rbacViewFor("debitor", HsOfficeDebitorEntity.class) .withIdentityView(SQL.query(""" SELECT debitor.uuid AS uuid, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java index 1b05a90c..3b0f58de 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java @@ -11,8 +11,8 @@ import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity; import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; -import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL; import net.hostsharing.hsadminng.repr.Stringify; import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.Type; @@ -38,21 +38,21 @@ import static io.hypersistence.utils.hibernate.type.range.Range.emptyRange; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.lowerInclusiveFromPostgresDateRange; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.upperInclusiveFromPostgresDateRange; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Column.dependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingDefaultCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Nullable.NOT_NULL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.DELETE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.INSERT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.SELECT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.UPDATE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.ADMIN; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.AGENT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.OWNER; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.TENANT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.fetchedBySql; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Column.dependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingDefaultCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.GLOBAL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Nullable.NOT_NULL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.DELETE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.INSERT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.SELECT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.UPDATE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacSubjectReference.UserRole.CREATOR; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.ADMIN; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.AGENT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.OWNER; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.TENANT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL.fetchedBySql; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.rbacViewFor; import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @@ -160,7 +160,7 @@ public class HsOfficeMembershipEntity implements BaseEntity { - public static RbacView rbac() { + public static RbacSpec rbac() { return rbacViewFor("person", HsOfficePersonRbacEntity.class) .withIdentityView(SQL.projection("concat(tradeName, familyName, givenName)")) .withUpdatableColumns("personType", "title", "salutation", "tradeName", "givenName", "familyName") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacEntity.java index 062c3702..c0f8476f 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacEntity.java @@ -7,31 +7,31 @@ import lombok.experimental.SuperBuilder; import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity; -import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL; import jakarta.persistence.Entity; import jakarta.persistence.Table; import java.io.IOException; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.CaseDef.inCaseOf; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.CaseDef.inOtherCases; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Column.dependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingDefaultCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Nullable.NOT_NULL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.DELETE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.INSERT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.SELECT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.UPDATE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.ADMIN; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.AGENT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.OWNER; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.REFERRER; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.TENANT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.directlyFetchedByDependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.CaseDef.inCaseOf; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.CaseDef.inOtherCases; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Column.dependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingDefaultCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.GLOBAL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Nullable.NOT_NULL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.DELETE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.INSERT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.SELECT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.UPDATE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacSubjectReference.UserRole.CREATOR; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.ADMIN; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.AGENT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.OWNER; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.REFERRER; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.TENANT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL.directlyFetchedByDependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.rbacViewFor; @Entity @Table(schema = "hs_office", name = "relation_rv") @@ -42,7 +42,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; @DisplayAs("RbacRelation") public class HsOfficeRelationRbacEntity extends HsOfficeRelation { - public static RbacView rbac() { + public static RbacSpec rbac() { return rbacViewFor("relation", HsOfficeRelationRbacEntity.class) .withIdentityView(SQL.projection(""" (select idName from hs_office.person_iv p where p.uuid = anchorUuid) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java index 94ac21e2..e1d8d973 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java @@ -8,7 +8,7 @@ import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.rbac.generator.RbacView; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec; import net.hostsharing.hsadminng.repr.Stringify; import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.Type; @@ -20,16 +20,16 @@ import java.util.UUID; import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.DEBITOR; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Column.dependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingDefaultCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Nullable.NOT_NULL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Column.dependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingDefaultCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.GLOBAL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Nullable.NOT_NULL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacSubjectReference.UserRole.CREATOR; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.rbacViewFor; import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @@ -100,7 +100,7 @@ public class HsOfficeSepaMandateEntity implements Stringifyable, BaseEntity cases) { + private String toStringList(final Set cases) { return cases.stream().map(c -> "'" + c.value + "'").collect(joining(", ")); } - private boolean isGrantToADifferentTable(final RbacView.RbacGrantDefinition g) { + private boolean isGrantToADifferentTable(final RbacSpec.RbacGrantDefinition g) { return !rbacDef.getRootEntityAlias().getRawTableNameWithSchema().equals(g.getSuperRoleDef().getEntityAlias().getRawTableNameWithSchema()); } - private Stream getInsertGrants() { + private Stream getInsertGrants() { return rbacDef.getGrantDefs().stream() .filter(g -> g.grantType() == PERM_TO_ROLE) .filter(g -> g.getPermDef().toCreate && g.getPermDef().getPermission() == INSERT); @@ -298,14 +298,14 @@ public class InsertTriggerGenerator { g.getSuperRoleDef().getEntityAlias().isGlobal() && g.getSuperRoleDef().getRole() == GUEST); } - private Optional getOptionalInsertGrant() { + private Optional getOptionalInsertGrant() { return getInsertGrants() .reduce(singleton()); } - private Optional getOptionalInsertSuperRole() { + private Optional getOptionalInsertSuperRole() { return getInsertGrants() - .map(RbacView.RbacGrantDefinition::getSuperRoleDef) + .map(RbacSpec.RbacGrantDefinition::getSuperRoleDef) .reduce(singleton()); } @@ -319,12 +319,12 @@ public class InsertTriggerGenerator { }; } - private static String toVar(final RbacView.RbacRoleDefinition roleDef) { + private static String toVar(final RbacSpec.RbacRoleDefinition roleDef) { return uncapitalize(roleDef.getEntityAlias().simpleName()) + capitalize(roleDef.getRole().name()); } - private String toRoleDescriptor(final RbacView.RbacRoleDefinition roleDef, final String ref) { + private String toRoleDescriptor(final RbacSpec.RbacRoleDefinition roleDef, final String ref) { final var functionName = roleDef.descriptorFunctionName(); if (roleDef.getEntityAlias().isGlobal()) { return functionName + "()"; diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacIdentityViewGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacIdentityViewGenerator.java index 473cc394..617794d5 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacIdentityViewGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacIdentityViewGenerator.java @@ -3,12 +3,12 @@ package net.hostsharing.hsadminng.rbac.generator; import static net.hostsharing.hsadminng.rbac.generator.StringWriter.with; public class RbacIdentityViewGenerator { - private final RbacView rbacDef; + private final RbacSpec rbacDef; private final String liquibaseTagPrefix; private final String simpleEntityVarName; private final String rawTableName; - public RbacIdentityViewGenerator(final RbacView rbacDef, final String liquibaseTagPrefix) { + public RbacIdentityViewGenerator(final RbacSpec rbacDef, final String liquibaseTagPrefix) { this.rbacDef = rbacDef; this.liquibaseTagPrefix = liquibaseTagPrefix; this.simpleEntityVarName = rbacDef.getRootEntityAlias().simpleName(); diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacObjectGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacObjectGenerator.java index f641ad99..f8d06730 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacObjectGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacObjectGenerator.java @@ -7,7 +7,7 @@ public class RbacObjectGenerator { private final String liquibaseTagPrefix; private final String rawTableName; - public RbacObjectGenerator(final RbacView rbacDef, final String liquibaseTagPrefix) { + public RbacObjectGenerator(final RbacSpec rbacDef, final String liquibaseTagPrefix) { this.liquibaseTagPrefix = liquibaseTagPrefix; this.rawTableName = rbacDef.getRootEntityAlias().getRawTableNameWithSchema(); } diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRbacSystemRebuildGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRbacSystemRebuildGenerator.java index 7350280d..945cb6c5 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRbacSystemRebuildGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRbacSystemRebuildGenerator.java @@ -1,6 +1,6 @@ package net.hostsharing.hsadminng.rbac.generator; -import net.hostsharing.hsadminng.rbac.generator.RbacView.RbacGrantDefinition; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacGrantDefinition; import java.util.HashSet; import java.util.Set; @@ -8,12 +8,12 @@ import static net.hostsharing.hsadminng.rbac.generator.StringWriter.with; class RbacRbacSystemRebuildGenerator { - private final RbacView rbacDef; + private final RbacSpec rbacDef; private final Set rbacGrants = new HashSet<>(); private final String liquibaseTagPrefix; private final String rawTableName; - RbacRbacSystemRebuildGenerator(final RbacView rbacDef, final String liquibaseTagPrefix) { + RbacRbacSystemRebuildGenerator(final RbacSpec rbacDef, final String liquibaseTagPrefix) { this.rbacDef = rbacDef; this.liquibaseTagPrefix = liquibaseTagPrefix; this.rawTableName = rbacDef.getRootEntityAlias().getRawTableNameWithSchema(); diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRestrictedViewGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRestrictedViewGenerator.java index f493d382..35adfc91 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRestrictedViewGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRestrictedViewGenerator.java @@ -6,11 +6,11 @@ import static net.hostsharing.hsadminng.rbac.generator.StringWriter.indented; import static net.hostsharing.hsadminng.rbac.generator.StringWriter.with; public class RbacRestrictedViewGenerator { - private final RbacView rbacDef; + private final RbacSpec rbacDef; private final String liquibaseTagPrefix; private final String rawTableName; - public RbacRestrictedViewGenerator(final RbacView rbacDef, final String liquibaseTagPrefix) { + public RbacRestrictedViewGenerator(final RbacSpec rbacDef, final String liquibaseTagPrefix) { this.rbacDef = rbacDef; this.liquibaseTagPrefix = liquibaseTagPrefix; this.rawTableName = rbacDef.getRootEntityAlias().getRawTableNameWithSchema(); diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRoleDescriptorsGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRoleDescriptorsGenerator.java index 4d78d0c2..fb242fbf 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRoleDescriptorsGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacRoleDescriptorsGenerator.java @@ -8,7 +8,7 @@ public class RbacRoleDescriptorsGenerator { private final String simpleEntityVarName; private final String rawTableName; - public RbacRoleDescriptorsGenerator(final RbacView rbacDef, final String liquibaseTagPrefix) { + public RbacRoleDescriptorsGenerator(final RbacSpec rbacDef, final String liquibaseTagPrefix) { this.liquibaseTagPrefix = liquibaseTagPrefix; this.simpleEntityVarName = rbacDef.getRootEntityAlias().simpleName(); this.rawTableName = rbacDef.getRootEntityAlias().getRawTableNameWithSchema(); diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacView.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacSpec.java similarity index 95% rename from src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacView.java rename to src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacSpec.java index dfdf3821..8dee16b9 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacView.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacSpec.java @@ -22,19 +22,18 @@ import static java.util.Arrays.asList; import static java.util.Arrays.stream; import static java.util.Collections.max; import static java.util.Optional.ofNullable; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingDefaultCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Nullable.NOT_NULL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacGrantDefinition.GrantType.PERM_TO_ROLE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacGrantDefinition.GrantType.ROLE_TO_ROLE; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.Part.AUTO_FETCH; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingDefaultCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Nullable.NOT_NULL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacGrantDefinition.GrantType.PERM_TO_ROLE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacGrantDefinition.GrantType.ROLE_TO_ROLE; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacSubjectReference.UserRole.CREATOR; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL.Part.AUTO_FETCH; import static org.apache.commons.collections4.SetUtils.hashSet; import static org.apache.commons.lang3.StringUtils.capitalize; import static org.apache.commons.lang3.StringUtils.uncapitalize; @Getter -// TODO.refa: rename to RbacDSL -public class RbacView { +public class RbacSpec { public static final String GLOBAL = "rbac.global"; public static final String OUTPUT_BASEDIR = "src/main/resources/db/changelog"; @@ -90,11 +89,11 @@ public class RbacView { * @param * a JPA entity class extending RbacObject */ - public static > RbacView rbacViewFor(final String alias, final Class entityClass) { - return new RbacView(alias, entityClass); + public static > RbacSpec rbacViewFor(final String alias, final Class entityClass) { + return new RbacSpec(alias, entityClass); } - RbacView(final String alias, final Class> entityClass) { + RbacSpec(final String alias, final Class> entityClass) { rootEntityAlias = new EntityAlias(alias, entityClass); entityAliases.put(alias, rootEntityAlias); new RbacSubjectReference(CREATOR); @@ -110,7 +109,7 @@ public class RbacView { * @return * the `this` instance itself to allow chained calls. */ - public RbacView withUpdatableColumns(final String... columnNames) { + public RbacSpec withUpdatableColumns(final String... columnNames) { Collections.addAll(updatableColumns, columnNames); verifyVersionColumnExists(); return this; @@ -134,7 +133,7 @@ public class RbacView { * @return * the `this` instance itself to allow chained calls. */ - public RbacView withIdentityView(final SQL sqlExpression) { + public RbacSpec withIdentityView(final SQL sqlExpression) { this.identityViewSqlQuery = sqlExpression; return this; } @@ -150,7 +149,7 @@ public class RbacView { * @return * the `this` instance itself to allow chained calls. */ - public RbacView withRestrictedViewOrderBy(final SQL orderBySqlExpression) { + public RbacSpec withRestrictedViewOrderBy(final SQL orderBySqlExpression) { this.orderBySqlExpression = orderBySqlExpression; return this; } @@ -166,7 +165,7 @@ public class RbacView { * @return * the `this` instance itself to allow chained calls. */ - public RbacView createRole(final Role role, final Consumer with) { + public RbacSpec createRole(final Role role, final Consumer with) { final RbacRoleDefinition newRoleDef = findRbacRole(rootEntityAlias, role).toCreate(); with.accept(newRoleDef); previousRoleDef = newRoleDef; @@ -182,7 +181,7 @@ public class RbacView { * @return * the `this` instance itself to allow chained calls. */ - public RbacView createSubRole(final Role role) { + public RbacSpec createSubRole(final Role role) { final RbacRoleDefinition newRoleDef = findRbacRole(rootEntityAlias, role).toCreate(); findOrCreateGrantDef(newRoleDef, previousRoleDef).toCreate(); previousRoleDef = newRoleDef; @@ -202,7 +201,7 @@ public class RbacView { * @return * the `this` instance itself to allow chained calls. */ - public RbacView createSubRole(final Role role, final Consumer with) { + public RbacSpec createSubRole(final Role role, final Consumer with) { final RbacRoleDefinition newRoleDef = findRbacRole(rootEntityAlias, role).toCreate(); findOrCreateGrantDef(newRoleDef, previousRoleDef).toCreate(); with.accept(newRoleDef); @@ -254,7 +253,7 @@ public class RbacView { .orElseGet(() -> new RbacPermissionDefinition(entityAlias, permission, null, true)); } - public RbacView declarePlaceholderEntityAliases(final String... aliasNames) { + public RbacSpec declarePlaceholderEntityAliases(final String... aliasNames) { for (String alias : aliasNames) { entityAliases.put(alias, new EntityAlias(alias)); } @@ -287,7 +286,7 @@ public class RbacView { * @param * a JPA entity class extending RbacObject */ - public > RbacView importRootEntityAliasProxy( + public > RbacSpec importRootEntityAliasProxy( final String aliasName, final Class> entityClass, final ColumnValue forCase, @@ -312,7 +311,7 @@ public class RbacView { * @param * a JPA entity class extending RbacObject */ - public RbacView importSubEntityAlias( + public RbacSpec importSubEntityAlias( final String aliasName, final Class> entityClass, final SQL fetchSql, final Column dependsOnColum) { importEntityAliasImpl(aliasName, entityClass, usingDefaultCase(), fetchSql, dependsOnColum, true, NOT_NULL); @@ -349,7 +348,7 @@ public class RbacView { * @param * a JPA entity class extending RbacObject */ - public RbacView importEntityAlias( + public RbacSpec importEntityAlias( final String aliasName, final Class> entityClass, final ColumnValue usingCase, final Column dependsOnColum, final SQL fetchSql, final Nullable nullable) { importEntityAliasImpl(aliasName, entityClass, usingCase, fetchSql, dependsOnColum, false, nullable); @@ -379,12 +378,12 @@ public class RbacView { return entityAlias; } - private static RbacView rbacDefinition(final Class entityClass) + private static RbacSpec rbacDefinition(final Class entityClass) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - return (RbacView) entityClass.getMethod("rbac").invoke(null); + return (RbacSpec) entityClass.getMethod("rbac").invoke(null); } - private RbacView importAsAlias(final String aliasName, final RbacView importedRbacView, final ColumnValue forCase, final boolean asSubEntity) { + private RbacSpec importAsAlias(final String aliasName, final RbacSpec importedRbacView, final ColumnValue forCase, final boolean asSubEntity) { final var mapper = new AliasNameMapper(importedRbacView, aliasName, asSubEntity ? entityAliases.keySet() : null); copyOf(importedRbacView.getEntityAliases().values()).stream() @@ -416,7 +415,7 @@ public class RbacView { return this; } - public RbacView switchOnColumn(final String discriminatorColumName, final CaseDef... caseDefs) { + public RbacSpec switchOnColumn(final String discriminatorColumName, final CaseDef... caseDefs) { this.discriminatorColumName = discriminatorColumName; allCases.addAll(stream(caseDefs).toList()); @@ -511,7 +510,7 @@ public class RbacView { new RbacViewPostgresGenerator(this).generateToChangeLog(Path.of(OUTPUT_BASEDIR, baseFileName + ".sql")); } - public RbacView limitDiagramTo(final String... aliasNames) { + public RbacSpec limitDiagramTo(final String... aliasNames) { this.limitDiagramToAliasNames = Set.of(aliasNames); return this; } @@ -542,15 +541,15 @@ public class RbacView { this.superRoleDef = findRbacRole(entityAlias, role); } - public RbacView grantRole(final String entityAlias, final Role role) { + public RbacSpec grantRole(final String entityAlias, final Role role) { findOrCreateGrantDef(findRbacRole(entityAlias, role), superRoleDef).toCreate(); - return RbacView.this; + return RbacSpec.this; } - public RbacView grantPermission(final Permission perm) { + public RbacSpec grantPermission(final Permission perm) { final var forTable = rootEntityAlias.getRawTableNameWithSchema(); findOrCreateGrantDef(findRbacPerm(rootEntityAlias, perm, forTable), superRoleDef).toCreate(); - return RbacView.this; + return RbacSpec.this; } } @@ -698,10 +697,10 @@ public class RbacView { this.subRole = role; } - public RbacView wouldBeGrantedTo(final String entityAlias, final Role role) { + public RbacSpec wouldBeGrantedTo(final String entityAlias, final Role role) { this.superRoleEntity = findEntityAlias(entityAlias); this.superRole = role; - return RbacView.this; + return RbacSpec.this; } } @@ -733,9 +732,9 @@ public class RbacView { * @return * The RbacView specification to which this permission definition belongs. */ - public RbacView grantedTo(final String entityAlias, final Role role) { + public RbacSpec grantedTo(final String entityAlias, final Role role) { findOrCreateGrantDef(this, findRbacRole(entityAlias, role)).toCreate(); - return RbacView.this; + return RbacSpec.this; } @Override @@ -1186,12 +1185,12 @@ public class RbacView { private static class AliasNameMapper { - private final RbacView importedRbacView; + private final RbacSpec importedRbacView; private final String outerAliasName; private final Set outerAliasNames; - AliasNameMapper(final RbacView importedRbacView, final String outerAliasName, final Set outerAliasNames) { + AliasNameMapper(final RbacSpec importedRbacView, final String outerAliasName, final Set outerAliasNames) { this.importedRbacView = importedRbacView; this.outerAliasName = outerAliasName; this.outerAliasNames = (outerAliasNames == null) ? Collections.emptySet() : outerAliasNames; @@ -1210,19 +1209,19 @@ public class RbacView { public static class CaseDef extends ColumnValue { - final Consumer def; + final Consumer def; - private CaseDef(final String discriminatorColumnValue, final Consumer def) { + private CaseDef(final String discriminatorColumnValue, final Consumer def) { super(discriminatorColumnValue); this.def = def; } - public static CaseDef inCaseOf(final String discriminatorColumnValue, final Consumer def) { + public static CaseDef inCaseOf(final String discriminatorColumnValue, final Consumer def) { return new CaseDef(discriminatorColumnValue, def); } - public static CaseDef inOtherCases(final Consumer def) { + public static CaseDef inOtherCases(final Consumer def) { return new CaseDef(null, def); } @@ -1281,7 +1280,7 @@ public class RbacView { .filter(c -> stream(c.getDeclaredMethods()) .anyMatch(m -> m.getName().equals("rbac") && isStatic(m.getModifiers())) ) - .map(RbacView::castToSubclassOfBaseEntity) + .map(RbacSpec::castToSubclassOfBaseEntity) .collect(Collectors.toSet()); return rbacEntityClasses; } @@ -1296,6 +1295,6 @@ public class RbacView { */ public static void main(String[] args) throws Exception { findRbacEntityClasses("net.hostsharing.hsadminng") - .forEach(RbacView::generateRbacView); + .forEach(RbacSpec::generateRbacView); } } diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacViewMermaidFlowchartGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacViewMermaidFlowchartGenerator.java index 6a457310..a4c36917 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacViewMermaidFlowchartGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacViewMermaidFlowchartGenerator.java @@ -1,7 +1,7 @@ package net.hostsharing.hsadminng.rbac.generator; import lombok.SneakyThrows; -import net.hostsharing.hsadminng.rbac.generator.RbacView.CaseDef; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.CaseDef; import org.apache.commons.lang3.StringUtils; import java.nio.file.*; @@ -12,7 +12,7 @@ import java.util.stream.Stream; import static java.util.Comparator.comparing; import static java.util.stream.Collectors.joining; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacGrantDefinition.GrantType.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacGrantDefinition.GrantType.*; public class RbacViewMermaidFlowchartGenerator { @@ -20,14 +20,14 @@ public class RbacViewMermaidFlowchartGenerator { public static final String HOSTSHARING_LIGHT_ORANGE = "#feb28c"; public static final String HOSTSHARING_DARK_BLUE = "#274d6e"; public static final String HOSTSHARING_LIGHT_BLUE = "#99bcdb"; - private final RbacView rbacDef; + private final RbacSpec rbacDef; - private final List usedEntityAliases; + private final List usedEntityAliases; private final CaseDef forCase; private final StringWriter flowchart = new StringWriter(); - public RbacViewMermaidFlowchartGenerator(final RbacView rbacDef, final CaseDef forCase) { + public RbacViewMermaidFlowchartGenerator(final RbacSpec rbacDef, final CaseDef forCase) { this.rbacDef = rbacDef; this.forCase = forCase; @@ -37,7 +37,7 @@ public class RbacViewMermaidFlowchartGenerator { g.getSubRoleDef() != null ? g.getSubRoleDef().getEntityAlias() : null, g.getPermDef() != null ? g.getPermDef().getEntityAlias() : null)) .filter(Objects::nonNull) - .sorted(comparing(RbacView.EntityAlias::aliasName)) + .sorted(comparing(RbacSpec.EntityAlias::aliasName)) .distinct() .filter(rbacDef::renderInDiagram) .collect(Collectors.toList()); @@ -50,7 +50,7 @@ public class RbacViewMermaidFlowchartGenerator { renderGrants(); } - public RbacViewMermaidFlowchartGenerator(final RbacView rbacDef) { + public RbacViewMermaidFlowchartGenerator(final RbacSpec rbacDef) { this(rbacDef, null); } private void renderEntitySubgraphs() { @@ -61,7 +61,7 @@ public class RbacViewMermaidFlowchartGenerator { .forEach(this::renderEntitySubgraph); } - private void renderEntitySubgraph(final RbacView.EntityAlias entity) { + private void renderEntitySubgraph(final RbacSpec.EntityAlias entity) { if (!rbacDef.renderInDiagram(entity)) { return; } @@ -128,7 +128,7 @@ public class RbacViewMermaidFlowchartGenerator { renderGrants(PERM_TO_ROLE, "%% granting permissions to roles"); } - private void renderGrants(final RbacView.RbacGrantDefinition.GrantType grantType, final String comment) { + private void renderGrants(final RbacSpec.RbacGrantDefinition.GrantType grantType, final String comment) { final var grantsOfRequestedType = rbacDef.getGrantDefs().stream() .filter(g -> g.grantType() == grantType) .filter(rbacDef::renderInDiagram) @@ -141,7 +141,7 @@ public class RbacViewMermaidFlowchartGenerator { } } - private boolean isToBeRenderedForThisCase(final RbacView.RbacGrantDefinition g) { + private boolean isToBeRenderedForThisCase(final RbacSpec.RbacGrantDefinition g) { if ( g.grantType() == ROLE_TO_USER ) return true; if ( forCase == null && !g.isConditional() ) @@ -150,7 +150,7 @@ public class RbacViewMermaidFlowchartGenerator { return isToBeRenderedInThisGraph; } - private String grantDef(final RbacView.RbacGrantDefinition grant) { + private String grantDef(final RbacSpec.RbacGrantDefinition grant) { final var arrow = (grant.isToCreate() ? " ==>" : " -.->") + (grant.isAssumed() ? " " : "|XX| "); final var grantDef = switch (grant.grantType()) { @@ -164,19 +164,19 @@ public class RbacViewMermaidFlowchartGenerator { return grantDef; } - private String permDef(final RbacView.RbacPermissionDefinition perm) { + private String permDef(final RbacSpec.RbacPermissionDefinition perm) { return permId(perm) + "{{" + perm.getEntityAlias().aliasName() + perm.getPermission() + "}}"; } - private static String permId(final RbacView.RbacPermissionDefinition permDef) { + private static String permId(final RbacSpec.RbacPermissionDefinition permDef) { return "perm:" + permDef.getEntityAlias().aliasName() + permDef.getPermission(); } - private String roleDef(final RbacView.RbacRoleDefinition roleDef) { + private String roleDef(final RbacSpec.RbacRoleDefinition roleDef) { return roleId(roleDef) + "[[" + roleDef.getEntityAlias().aliasName() + roleDef.getRole() + "]]"; } - private static String roleId(final RbacView.RbacRoleDefinition r) { + private static String roleId(final RbacSpec.RbacRoleDefinition r) { return "role:" + r.getEntityAlias().aliasName() + r.getRole(); } diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacViewPostgresGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacViewPostgresGenerator.java index 56f240ab..6b23ef1c 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacViewPostgresGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RbacViewPostgresGenerator.java @@ -11,11 +11,11 @@ import static net.hostsharing.hsadminng.rbac.generator.StringWriter.with; public class RbacViewPostgresGenerator { - private final RbacView rbacDef; + private final RbacSpec rbacDef; private final String liqibaseTagPrefix; private final StringWriter plPgSql = new StringWriter(); - public RbacViewPostgresGenerator(final RbacView forRbacDef) { + public RbacViewPostgresGenerator(final RbacSpec forRbacDef) { rbacDef = forRbacDef; liqibaseTagPrefix = rbacDef.getRootEntityAlias().getRawTableNameWithSchema().replace("_", "-").replace(".", "-"); plPgSql.writeLn(""" diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RolesGrantsAndPermissionsGenerator.java b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RolesGrantsAndPermissionsGenerator.java index 7d588536..67adbe72 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/generator/RolesGrantsAndPermissionsGenerator.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/generator/RolesGrantsAndPermissionsGenerator.java @@ -1,8 +1,8 @@ package net.hostsharing.hsadminng.rbac.generator; -import net.hostsharing.hsadminng.rbac.generator.RbacView.CaseDef; -import net.hostsharing.hsadminng.rbac.generator.RbacView.RbacGrantDefinition; -import net.hostsharing.hsadminng.rbac.generator.RbacView.RbacPermissionDefinition; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.CaseDef; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacGrantDefinition; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacPermissionDefinition; import java.util.HashSet; import java.util.List; @@ -15,22 +15,22 @@ import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toSet; import static net.hostsharing.hsadminng.rbac.generator.PostgresTriggerReference.NEW; import static net.hostsharing.hsadminng.rbac.generator.PostgresTriggerReference.OLD; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.INSERT; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacGrantDefinition.GrantType.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.INSERT; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacGrantDefinition.GrantType.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.*; import static net.hostsharing.hsadminng.rbac.generator.StringWriter.with; import static org.apache.commons.lang3.StringUtils.capitalize; class RolesGrantsAndPermissionsGenerator { - private final RbacView rbacDef; + private final RbacSpec rbacDef; private final Set rbacGrants = new HashSet<>(); private final String liquibaseTagPrefix; private final String simpleEntityName; private final String simpleEntityVarName; private final String qualifiedRawTableName; - RolesGrantsAndPermissionsGenerator(final RbacView rbacDef, final String liquibaseTagPrefix) { + RolesGrantsAndPermissionsGenerator(final RbacSpec rbacDef, final String liquibaseTagPrefix) { this.rbacDef = rbacDef; this.rbacGrants.addAll(rbacDef.getGrantDefs().stream() .filter(RbacGrantDefinition::isToCreate) @@ -95,7 +95,7 @@ class RolesGrantsAndPermissionsGenerator { private void generateSimplifiedUpdateTriggerFunction(final StringWriter plPgSql) { final var updateConditions = updatableEntityAliases() - .map(RbacView.EntityAlias::dependsOnColumName) + .map(RbacSpec.EntityAlias::dependsOnColumName) .distinct() .map(columnName -> "NEW." + columnName + " is distinct from OLD." + columnName) .collect(joining( "\n or ")); @@ -166,7 +166,7 @@ class RolesGrantsAndPermissionsGenerator { private boolean hasAnyUpdatableAndNullableEntityAliases() { return updatableEntityAliases() - .filter(ea -> ea.nullable() == RbacView.Nullable.NULLABLE) + .filter(ea -> ea.nullable() == RbacSpec.Nullable.NULLABLE) .anyMatch(e -> true); } @@ -210,7 +210,7 @@ class RolesGrantsAndPermissionsGenerator { generateGrants(plPgSql, PERM_TO_ROLE); } - private Stream referencedEntityAliases() { + private Stream referencedEntityAliases() { return rbacDef.getEntityAliases().values().stream() .filter(ea -> !rbacDef.isRootEntityAlias(ea)) .filter(ea -> ea.dependsOnColum() != null) @@ -218,7 +218,7 @@ class RolesGrantsAndPermissionsGenerator { .filter(ea -> ea.fetchSql() != null); } - private Stream updatableEntityAliases() { + private Stream updatableEntityAliases() { return referencedEntityAliases() .filter(ea -> rbacDef.getUpdatableColumns().contains(ea.dependsOnColum().column)); } @@ -234,7 +234,7 @@ class RolesGrantsAndPermissionsGenerator { }); updatableEntityAliases() - .map(RbacView.EntityAlias::dependsOnColum) + .map(RbacSpec.EntityAlias::dependsOnColum) .map(c -> c.column) .sorted() .distinct() @@ -250,13 +250,13 @@ class RolesGrantsAndPermissionsGenerator { private void generateFetchedVars( final StringWriter plPgSql, - final RbacView.EntityAlias ea, + final RbacSpec.EntityAlias ea, final PostgresTriggerReference old) { plPgSql.writeLn( ea.fetchSql().sql + " INTO " + entityRefVar(old, ea) + ";", with("columns", ea.aliasName() + ".*"), with("ref", old.name())); - if (ea.nullable() == RbacView.Nullable.NOT_NULL) { + if (ea.nullable() == RbacSpec.Nullable.NOT_NULL) { plPgSql.writeLn( "assert ${entityRefVar}.uuid is not null, format('${entityRefVar} must not be null for ${REF}.${dependsOnColumn} = %s of ${rawTable}', ${REF}.${dependsOnColumn});", with("entityRefVar", entityRefVar(old, ea)), @@ -353,11 +353,11 @@ class RolesGrantsAndPermissionsGenerator { .replace("${perm}", permDef.permission.name()); } - private String refVarName(final PostgresTriggerReference ref, final RbacView.EntityAlias entityAlias) { + private String refVarName(final PostgresTriggerReference ref, final RbacSpec.EntityAlias entityAlias) { return ref.name().toLowerCase() + capitalize(entityAlias.aliasName()); } - private String roleRef(final PostgresTriggerReference rootRefVar, final RbacView.RbacRoleDefinition roleDef) { + private String roleRef(final PostgresTriggerReference rootRefVar, final RbacSpec.RbacRoleDefinition roleDef) { if (roleDef == null) { System.out.println("null"); } @@ -370,17 +370,17 @@ class RolesGrantsAndPermissionsGenerator { private String entityRefVar( final PostgresTriggerReference rootRefVar, - final RbacView.EntityAlias entityAlias) { + final RbacSpec.EntityAlias entityAlias) { return rbacDef.isRootEntityAlias(entityAlias) ? rootRefVar.name() : rootRefVar.name().toLowerCase() + capitalize(entityAlias.aliasName()); } - private void createRolesWithGrantsSql(final StringWriter plPgSql, final RbacView.Role role) { + private void createRolesWithGrantsSql(final StringWriter plPgSql, final RbacSpec.Role role) { final var isToCreate = rbacDef.getRoleDefs().stream() .filter(roleDef -> rbacDef.isRootEntityAlias(roleDef.getEntityAlias()) && roleDef.getRole() == role) - .findFirst().map(RbacView.RbacRoleDefinition::isToCreate).orElse(false); + .findFirst().map(RbacSpec.RbacRoleDefinition::isToCreate).orElse(false); if (!isToCreate) { return; } @@ -404,7 +404,7 @@ class RolesGrantsAndPermissionsGenerator { plPgSql.writeLn(");"); } - private void generateUserGrantsForRole(final StringWriter plPgSql, final RbacView.Role role) { + private void generateUserGrantsForRole(final StringWriter plPgSql, final RbacSpec.Role role) { final var grantsToUsers = findGrantsToUserForRole(rbacDef.getRootEntityAlias(), role); if (!grantsToUsers.isEmpty()) { final var arrayElements = grantsToUsers.stream() @@ -417,13 +417,13 @@ class RolesGrantsAndPermissionsGenerator { } } - private void generatePermissionsForRole(final StringWriter plPgSql, final RbacView.Role role) { + private void generatePermissionsForRole(final StringWriter plPgSql, final RbacSpec.Role role) { final var permissionGrantsForRole = findPermissionsGrantsForRole(rbacDef.getRootEntityAlias(), role); if (!permissionGrantsForRole.isEmpty()) { final var arrayElements = permissionGrantsForRole.stream() .map(RbacGrantDefinition::getPermDef) .map(RbacPermissionDefinition::getPermission) - .map(RbacView.Permission::name) + .map(RbacSpec.Permission::name) .map(p -> "'" + p + "'") .sorted() .toList(); @@ -433,7 +433,7 @@ class RolesGrantsAndPermissionsGenerator { } } - private void generateIncomingSuperRolesForRole(final StringWriter plPgSql, final RbacView.Role role) { + private void generateIncomingSuperRolesForRole(final StringWriter plPgSql, final RbacSpec.Role role) { final var unconditionalIncomingGrants = findIncomingSuperRolesForRole(rbacDef.getRootEntityAlias(), role).stream() .filter(g -> !g.isConditional()) .toList(); @@ -447,7 +447,7 @@ class RolesGrantsAndPermissionsGenerator { } } - private void generateOutgoingSubRolesForRole(final StringWriter plPgSql, final RbacView.Role role) { + private void generateOutgoingSubRolesForRole(final StringWriter plPgSql, final RbacSpec.Role role) { final var unconditionalOutgoingGrants = findOutgoingSuperRolesForRole(rbacDef.getRootEntityAlias(), role).stream() .filter(g -> !g.isConditional()) .toList(); @@ -468,8 +468,8 @@ class RolesGrantsAndPermissionsGenerator { } private Set findPermissionsGrantsForRole( - final RbacView.EntityAlias entityAlias, - final RbacView.Role role) { + final RbacSpec.EntityAlias entityAlias, + final RbacSpec.Role role) { final var roleDef = rbacDef.findRbacRole(entityAlias, role); return rbacGrants.stream() .filter(g -> g.grantType() == PERM_TO_ROLE && g.getSuperRoleDef() == roleDef) @@ -477,8 +477,8 @@ class RolesGrantsAndPermissionsGenerator { } private Set findGrantsToUserForRole( - final RbacView.EntityAlias entityAlias, - final RbacView.Role role) { + final RbacSpec.EntityAlias entityAlias, + final RbacSpec.Role role) { final var roleDef = rbacDef.findRbacRole(entityAlias, role); return rbacGrants.stream() .filter(g -> g.grantType() == ROLE_TO_USER && g.getSubRoleDef() == roleDef) @@ -486,8 +486,8 @@ class RolesGrantsAndPermissionsGenerator { } private Set findIncomingSuperRolesForRole( - final RbacView.EntityAlias entityAlias, - final RbacView.Role role) { + final RbacSpec.EntityAlias entityAlias, + final RbacSpec.Role role) { final var roleDef = rbacDef.findRbacRole(entityAlias, role); return rbacGrants.stream() .filter(g -> g.grantType() == ROLE_TO_ROLE && g.getSubRoleDef() == roleDef) @@ -495,8 +495,8 @@ class RolesGrantsAndPermissionsGenerator { } private Set findOutgoingSuperRolesForRole( - final RbacView.EntityAlias entityAlias, - final RbacView.Role role) { + final RbacSpec.EntityAlias entityAlias, + final RbacSpec.Role role) { final var roleDef = rbacDef.findRbacRole(entityAlias, role); return rbacGrants.stream() .filter(g -> g.grantType() == ROLE_TO_ROLE && g.getSuperRoleDef() == roleDef) @@ -580,7 +580,7 @@ class RolesGrantsAndPermissionsGenerator { plPgSql.writeLn(); } - private String toPlPgSqlReference(final RbacView.RbacSubjectReference userRef) { + private String toPlPgSqlReference(final RbacSpec.RbacSubjectReference userRef) { return switch (userRef.role) { case CREATOR -> "rbac.currentSubjectUuid()"; default -> throw new IllegalArgumentException("unknown user role: " + userRef); @@ -589,7 +589,7 @@ class RolesGrantsAndPermissionsGenerator { private String toPlPgSqlReference( final PostgresTriggerReference triggerRef, - final RbacView.RbacRoleDefinition roleDef, + final RbacSpec.RbacRoleDefinition roleDef, final boolean assumed) { final var assumedArg = assumed ? "" : ", rbac.unassumed()"; return roleDef.descriptorFunctionName() + @@ -600,7 +600,7 @@ class RolesGrantsAndPermissionsGenerator { private static String toTriggerReference( final PostgresTriggerReference triggerRef, - final RbacView.EntityAlias entityAlias) { + final RbacSpec.EntityAlias entityAlias) { return triggerRef.name().toLowerCase() + capitalize(entityAlias.aliasName()); } } diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerEntity.java b/src/main/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerEntity.java index 86fe4d57..0bf4bcc8 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerEntity.java @@ -6,18 +6,18 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL; import jakarta.persistence.*; import java.io.IOException; import java.util.UUID; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.GLOBAL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.RbacSubjectReference.UserRole.CREATOR; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.rbacViewFor; @Entity @Table(schema = "rbactest", name = "customer_rv") @@ -41,7 +41,7 @@ public class TestCustomerEntity implements BaseEntity { @Column(name = "adminusername") private String adminUserName; - public static RbacView rbac() { + public static RbacSpec rbac() { return rbacViewFor("customer", TestCustomerEntity.class) .withIdentityView(SQL.projection("prefix")) .withRestrictedViewOrderBy(SQL.expression("reference")) diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/test/dom/TestDomainEntity.java b/src/main/java/net/hostsharing/hsadminng/rbac/test/dom/TestDomainEntity.java index 00a78a20..09fab825 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/test/dom/TestDomainEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/test/dom/TestDomainEntity.java @@ -5,21 +5,21 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL; import net.hostsharing.hsadminng.rbac.test.pac.TestPackageEntity; import jakarta.persistence.*; import java.io.IOException; import java.util.UUID; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Column.dependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingDefaultCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Nullable.NOT_NULL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.directlyFetchedByDependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Column.dependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingDefaultCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Nullable.NOT_NULL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL.directlyFetchedByDependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.rbacViewFor; @Entity @Table(schema = "rbactest", name = "domain_rv") @@ -44,7 +44,7 @@ public class TestDomainEntity implements BaseEntity { private String description; - public static RbacView rbac() { + public static RbacSpec rbac() { return rbacViewFor("domain", TestDomainEntity.class) .withIdentityView(SQL.projection("name")) .withUpdatableColumns("version", "packageUuid", "description") diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageEntity.java b/src/main/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageEntity.java index 1efadadc..34a20a07 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageEntity.java @@ -5,21 +5,21 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec; +import net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL; import net.hostsharing.hsadminng.rbac.test.cust.TestCustomerEntity; import jakarta.persistence.*; import java.io.IOException; import java.util.UUID; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Column.dependsOnColumn; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.ColumnValue.usingDefaultCase; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Nullable.NOT_NULL; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.*; -import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Column.dependsOnColumn; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.ColumnValue.usingDefaultCase; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Nullable.NOT_NULL; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Permission.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.Role.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacSpec.rbacViewFor; @Entity @Table(schema = "rbactest", name = "package_rv") @@ -45,7 +45,7 @@ public class TestPackageEntity implements BaseEntity { private String description; - public static RbacView rbac() { + public static RbacSpec rbac() { return rbacViewFor("package", TestPackageEntity.class) .withIdentityView(SQL.projection("name")) .withUpdatableColumns("version", "customerUuid", "description")