Compare commits
No commits in common. "56f316ef80223e07fbd50075bd6408c2428cb6fd" and "d565099f3b5a69419baf782db4d11154a63545b9" have entirely different histories.
56f316ef80
...
d565099f3b
@ -394,7 +394,7 @@ public class RbacView {
|
||||
});
|
||||
importedRbacView.getGrantDefs().forEach(grantDef -> {
|
||||
if ( grantDef.grantType() == RbacGrantDefinition.GrantType.ROLE_TO_ROLE &&
|
||||
(grantDef.forCases == null || grantDef.matchesCase(forCase)) ) {
|
||||
grantDef.matchesCase(forCase) ) {
|
||||
final var importedGrantDef = findOrCreateGrantDef(
|
||||
findRbacRole(
|
||||
mapper.map(grantDef.getSubRoleDef().entityAlias.aliasName),
|
||||
@ -483,7 +483,7 @@ public class RbacView {
|
||||
public void generateWithBaseFileName(final String baseFileName) {
|
||||
if (allCases.size() > 1) {
|
||||
allCases.forEach(caseDef -> {
|
||||
final var fileName = baseFileName + (caseDef.isDefaultCase() ? "" : "-" + caseDef.value) + ".md";
|
||||
final var fileName = baseFileName + (caseDef.isDefaultCase() ? "" : "-" + caseDef.val) + ".md";
|
||||
new RbacViewMermaidFlowchartGenerator(this, caseDef)
|
||||
.generateToMarkdownFile(Path.of(OUTPUT_BASEDIR, fileName));
|
||||
});
|
||||
@ -596,12 +596,22 @@ public class RbacView {
|
||||
}
|
||||
|
||||
boolean matchesCase(final ColumnValue requestedCase) {
|
||||
if (forCases == null) {
|
||||
return true;
|
||||
}
|
||||
final var noCasesDefined = forCases.isEmpty();
|
||||
final var generateForAllCases = requestedCase == null;
|
||||
final boolean isGrantedForRequestedCase = forCases.stream().anyMatch(c -> c.isCase(requestedCase));
|
||||
return noCasesDefined || generateForAllCases || isGrantedForRequestedCase;
|
||||
}
|
||||
|
||||
boolean matchesCase(final CaseDef requestedCase) {
|
||||
final var noCasesDefined = forCases.isEmpty();
|
||||
final var generateForAllCases = requestedCase == null;
|
||||
final boolean isGrantedForRequestedCase = forCases.contains(requestedCase);
|
||||
return noCasesDefined || generateForAllCases || isGrantedForRequestedCase;
|
||||
}
|
||||
|
||||
boolean isToCreate() {
|
||||
return toCreate;
|
||||
}
|
||||
@ -1122,12 +1132,14 @@ public class RbacView {
|
||||
}
|
||||
}
|
||||
|
||||
public static class CaseDef extends ColumnValue {
|
||||
// FIXME: subclass of ColumnValue
|
||||
public static class CaseDef {
|
||||
|
||||
final String val;
|
||||
final Consumer<RbacView> def;
|
||||
|
||||
private CaseDef(final String discriminatorColumnValue, final Consumer<RbacView> def) {
|
||||
super(discriminatorColumnValue);
|
||||
this.val = discriminatorColumnValue;
|
||||
this.def = def;
|
||||
}
|
||||
|
||||
@ -1142,7 +1154,7 @@ public class RbacView {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ofNullable(value).map(String::hashCode).orElse(0);
|
||||
return ofNullable(val).map(String::hashCode).orElse(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1152,22 +1164,22 @@ public class RbacView {
|
||||
if (other == null || getClass() != other.getClass())
|
||||
return false;
|
||||
final CaseDef caseDef = (CaseDef) other;
|
||||
return Objects.equals(value, caseDef.value);
|
||||
return Objects.equals(val, caseDef.val);
|
||||
}
|
||||
|
||||
boolean isDefaultCase() {
|
||||
return value == null;
|
||||
return val == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return isDefaultCase()
|
||||
? "inOtherCases"
|
||||
: "inCaseOf:" + value;
|
||||
: "inCaseOf:" + val;
|
||||
}
|
||||
|
||||
public boolean isCase(final ColumnValue requestedCase) {
|
||||
return Objects.equals(requestedCase.value, this.value);
|
||||
return Objects.equals(requestedCase.value, this.val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ public class RbacViewMermaidFlowchartGenerator {
|
||||
Files.writeString(
|
||||
path,
|
||||
"""
|
||||
### rbac %{entityAlias}%{case}
|
||||
### rbac %{entityAlias} %{case}
|
||||
|
||||
This code generated was by RbacViewMermaidFlowchartGenerator, do not amend manually.
|
||||
|
||||
@ -175,7 +175,7 @@ public class RbacViewMermaidFlowchartGenerator {
|
||||
"""
|
||||
.replace("%{entityAlias}", rbacDef.getRootEntityAlias().aliasName())
|
||||
.replace("%{flowchart}", flowchart.toString())
|
||||
.replace("%{case}", forCase == null ? "" : " " + forCase),
|
||||
.replace("%{case}", forCase == null ? "" : (forCase.toString()) ),
|
||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
System.out.println("Markdown-File: " + path.toAbsolutePath());
|
||||
}
|
||||
|
@ -197,8 +197,8 @@ class RolesGrantsAndPermissionsGenerator {
|
||||
plPgSql.writeLn();
|
||||
final var ifOrElsIf = new AtomicReference<>("IF ");
|
||||
rbacDef.getAllCases().forEach(caseDef -> {
|
||||
if (caseDef.value != null) {
|
||||
plPgSql.writeLn(ifOrElsIf + "NEW." + rbacDef.getDiscriminatorColumName() + " = '" + caseDef.value + "' THEN");
|
||||
if (caseDef.val != null) {
|
||||
plPgSql.writeLn(ifOrElsIf + "NEW." + rbacDef.getDiscriminatorColumName() + " = '" + caseDef.val + "' THEN");
|
||||
} else {
|
||||
plPgSql.writeLn("ELSE");
|
||||
}
|
||||
|
@ -149,16 +149,6 @@ role:debitorRel.holderPerson:ADMIN -.-> role:debitorRel.holderPerson:REFERRER
|
||||
role:global:ADMIN -.-> role:debitorRel.contact:OWNER
|
||||
role:debitorRel.contact:OWNER -.-> role:debitorRel.contact:ADMIN
|
||||
role:debitorRel.contact:ADMIN -.-> role:debitorRel.contact:REFERRER
|
||||
role:global:ADMIN -.-> role:debitorRel:OWNER
|
||||
role:debitorRel:OWNER -.-> role:debitorRel:ADMIN
|
||||
role:debitorRel:ADMIN -.-> role:debitorRel:AGENT
|
||||
role:debitorRel:AGENT -.-> role:debitorRel:TENANT
|
||||
role:debitorRel.contact:ADMIN -.-> role:debitorRel:TENANT
|
||||
role:debitorRel:TENANT -.-> role:debitorRel.anchorPerson:REFERRER
|
||||
role:debitorRel:TENANT -.-> role:debitorRel.holderPerson:REFERRER
|
||||
role:debitorRel:TENANT -.-> role:debitorRel.contact:REFERRER
|
||||
role:debitorRel.anchorPerson:ADMIN -.-> role:debitorRel:OWNER
|
||||
role:debitorRel.holderPerson:ADMIN -.-> role:debitorRel:AGENT
|
||||
role:global:ADMIN -.-> role:refundBankAccount:OWNER
|
||||
role:refundBankAccount:OWNER -.-> role:refundBankAccount:ADMIN
|
||||
role:refundBankAccount:ADMIN -.-> role:refundBankAccount:REFERRER
|
||||
|
Loading…
Reference in New Issue
Block a user