Skip to content

Commit

Permalink
feat: add assignment operator attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras committed May 28, 2024
1 parent 73955ab commit 229974f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions src/main/openapi/onecx-permission-internal-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ components:
mandatory:
type: boolean
default: false
operator:
type: boolean
default: false
UpdateRoleRequest:
type: object
required:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/db/changeLog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<include relativeToChangelogFile="true" file="v1/2024-04-09-constraint-and-index-fix.xml" />
<include relativeToChangelogFile="true" file="v1/2024-05-13-mandatory-flags.xml" />
<include relativeToChangelogFile="true" file="v1/2024-05-16-operator-flag.xml" />
<include relativeToChangelogFile="true" file="v1/2024-05-28-assignment-operator.xml" />

</databaseChangeLog>
13 changes: 13 additions & 0 deletions src/main/resources/db/v1/2024-05-28-assignment-operator.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"
objectQuotingStrategy="QUOTE_ONLY_RESERVED_WORDS">

<changeSet author="dev (generated)" id="1716816363825-1">
<addColumn tableName="assignment">
<column name="operator" type="bool"/>
</addColumn>
</changeSet>
</databaseChangeLog>

0 comments on commit 229974f

Please sign in to comment.