From 229974f2eab9ef0186403e2bb761dcd9655b9f46 Mon Sep 17 00:00:00 2001 From: Andrej Petras Date: Tue, 28 May 2024 16:59:03 +0200 Subject: [PATCH] feat: add assignment operator attribute --- .../domain/di/mappers/TemplateMapper.java | 1 + .../onecx/permission/domain/models/Assignment.java | 6 ++++++ .../v1/controllers/PermissionExportImportV1.java | 1 + .../permission/rs/exim/v1/mappers/EximMapperV1.java | 1 + .../rs/internal/mappers/AssignmentMapper.java | 1 + .../openapi/onecx-permission-internal-openapi.yaml | 3 +++ src/main/resources/db/changeLog.xml | 1 + .../db/v1/2024-05-28-assignment-operator.xml | 13 +++++++++++++ 8 files changed, 27 insertions(+) create mode 100644 src/main/resources/db/v1/2024-05-28-assignment-operator.xml diff --git a/src/main/java/org/tkit/onecx/permission/domain/di/mappers/TemplateMapper.java b/src/main/java/org/tkit/onecx/permission/domain/di/mappers/TemplateMapper.java index c3720f9..c5c6ae3 100644 --- a/src/main/java/org/tkit/onecx/permission/domain/di/mappers/TemplateMapper.java +++ b/src/main/java/org/tkit/onecx/permission/domain/di/mappers/TemplateMapper.java @@ -56,5 +56,6 @@ public interface TemplateMapper { @Mapping(target = "roleId", ignore = true) @Mapping(target = "permissionId", ignore = true) @Mapping(target = "tenantId", ignore = true) + @Mapping(target = "operator", ignore = true) Assignment createAssignment(Role role, Permission permission); } diff --git a/src/main/java/org/tkit/onecx/permission/domain/models/Assignment.java b/src/main/java/org/tkit/onecx/permission/domain/models/Assignment.java index 4444778..5f963d5 100644 --- a/src/main/java/org/tkit/onecx/permission/domain/models/Assignment.java +++ b/src/main/java/org/tkit/onecx/permission/domain/models/Assignment.java @@ -35,6 +35,12 @@ public class Assignment extends TraceableEntity { @JoinColumn(name = "PERMISSION_ID") private Permission permission; + /** + * Flag to identify permissions created by an operator + */ + @Column(name = "OPERATOR") + private Boolean operator; + /** * Flag to protect mandatory data */ diff --git a/src/main/java/org/tkit/onecx/permission/rs/exim/v1/controllers/PermissionExportImportV1.java b/src/main/java/org/tkit/onecx/permission/rs/exim/v1/controllers/PermissionExportImportV1.java index ab50672..9d66745 100644 --- a/src/main/java/org/tkit/onecx/permission/rs/exim/v1/controllers/PermissionExportImportV1.java +++ b/src/main/java/org/tkit/onecx/permission/rs/exim/v1/controllers/PermissionExportImportV1.java @@ -93,6 +93,7 @@ public Response operatorImportAssignments(AssignmentSnapshotDTOV1 assignmentSnap .createProblem("Permission not found", "Permission ID: " + permId)); } else { var assignment = mapper.create(role, permission); + assignment.setOperator(true); assignments.add(assignment); } })); diff --git a/src/main/java/org/tkit/onecx/permission/rs/exim/v1/mappers/EximMapperV1.java b/src/main/java/org/tkit/onecx/permission/rs/exim/v1/mappers/EximMapperV1.java index 2dec490..9e0dbf3 100644 --- a/src/main/java/org/tkit/onecx/permission/rs/exim/v1/mappers/EximMapperV1.java +++ b/src/main/java/org/tkit/onecx/permission/rs/exim/v1/mappers/EximMapperV1.java @@ -21,6 +21,7 @@ public interface EximMapperV1 { @Mapping(target = "roleId", ignore = true) @Mapping(target = "permissionId", ignore = true) @Mapping(target = "tenantId", ignore = true) + @Mapping(target = "operator", ignore = true) Assignment create(Role role, Permission permission); static String permId(Permission p) { diff --git a/src/main/java/org/tkit/onecx/permission/rs/internal/mappers/AssignmentMapper.java b/src/main/java/org/tkit/onecx/permission/rs/internal/mappers/AssignmentMapper.java index 6d220ca..cc1b356 100644 --- a/src/main/java/org/tkit/onecx/permission/rs/internal/mappers/AssignmentMapper.java +++ b/src/main/java/org/tkit/onecx/permission/rs/internal/mappers/AssignmentMapper.java @@ -35,6 +35,7 @@ public interface AssignmentMapper { @Mapping(target = "roleId", ignore = true) @Mapping(target = "permissionId", ignore = true) @Mapping(target = "mandatory", ignore = true) + @Mapping(target = "operator", ignore = true) Assignment create(Role role, Permission permission); @Mapping(target = "appId", source = "permission.appId") diff --git a/src/main/openapi/onecx-permission-internal-openapi.yaml b/src/main/openapi/onecx-permission-internal-openapi.yaml index e8003b7..b213ada 100644 --- a/src/main/openapi/onecx-permission-internal-openapi.yaml +++ b/src/main/openapi/onecx-permission-internal-openapi.yaml @@ -644,6 +644,9 @@ components: mandatory: type: boolean default: false + operator: + type: boolean + default: false UpdateRoleRequest: type: object required: diff --git a/src/main/resources/db/changeLog.xml b/src/main/resources/db/changeLog.xml index 6e329ac..160b7a9 100644 --- a/src/main/resources/db/changeLog.xml +++ b/src/main/resources/db/changeLog.xml @@ -8,5 +8,6 @@ + \ No newline at end of file diff --git a/src/main/resources/db/v1/2024-05-28-assignment-operator.xml b/src/main/resources/db/v1/2024-05-28-assignment-operator.xml new file mode 100644 index 0000000..2827f89 --- /dev/null +++ b/src/main/resources/db/v1/2024-05-28-assignment-operator.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file