HostingAsset-Hierarchie spec in enum HsHostingAssetType and generates PlantUML #72

Merged
hsh-michaelhoennig merged 9 commits from add-mermaid-graph-generator-for-hosting-asset-type-structure into master 2024-07-09 14:32:14 +02:00
3 changed files with 151 additions and 48 deletions
Showing only changes of commit 672d4ce0f1 - Show all commits

View File

@ -1,8 +1,9 @@
### HostingAsset Type Structure ## HostingAsset Type Structure
### packages Webspace, Domain, Server
```plantuml ```plantuml
@startuml @startuml
left to right direction left to right direction
package Booking #99bcdb { package Booking #99bcdb {
@ -15,22 +16,10 @@ package Booking #99bcdb {
} }
package Hosting #white { package Hosting #white {
package Server #99bcdb { package Webspace #99bcdb {
entity HA_CLOUD_SERVER entity HA_MANAGED_WEBSPACE
entity HA_MANAGED_SERVER entity HA_UNIX_USER
entity HA_IP_NUMBER entity HA_EMAIL_ALIAS
}
package PostgreSQL #99bcdb {
entity HA_PGSQL_INSTANCE
entity HA_PGSQL_USER
entity HA_PGSQL_DATABASE
}
package MariaDB #99bcdb {
entity HA_MARIADB_INSTANCE
entity HA_MARIADB_USER
entity HA_MARIADB_DATABASE
} }
package Domain #99bcdb { package Domain #99bcdb {
@ -41,10 +30,10 @@ package Hosting #white {
entity HA_EMAIL_ADDRESS entity HA_EMAIL_ADDRESS
} }
package Webspace #99bcdb { package Server #99bcdb {
entity HA_MANAGED_WEBSPACE entity HA_CLOUD_SERVER
entity HA_UNIX_USER entity HA_MANAGED_SERVER
entity HA_EMAIL_ALIAS entity HA_IP_NUMBER
} }
} }
@ -66,11 +55,56 @@ HA_DOMAIN_EMAIL_SUBMISSION_SETUP o..> HA_MANAGED_WEBSPACE
HA_DOMAIN_EMAIL_MAILBOX_SETUP *==> HA_MANAGED_WEBSPACE HA_DOMAIN_EMAIL_MAILBOX_SETUP *==> HA_MANAGED_WEBSPACE
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
HA_EMAIL_ADDRESS *==> HA_DOMAIN_EMAIL_MAILBOX_SETUP HA_EMAIL_ADDRESS *==> HA_DOMAIN_EMAIL_MAILBOX_SETUP
HA_PGSQL_INSTANCE *==> HA_MANAGED_SERVER HA_IP_NUMBER o..> HA_CLOUD_SERVER
HA_PGSQL_USER *==> HA_PGSQL_INSTANCE HA_IP_NUMBER o..> HA_MANAGED_SERVER
HA_PGSQL_USER o..> HA_MANAGED_WEBSPACE HA_IP_NUMBER o..> HA_MANAGED_WEBSPACE
HA_PGSQL_DATABASE *==> HA_MANAGED_WEBSPACE ```
HA_PGSQL_DATABASE o..> HA_PGSQL_INSTANCE ### packages Webspace, MariaDB, Server
```plantuml
@startuml
left to right direction
package Booking #99bcdb {
entity BI_PRIVATE_CLOUD
entity BI_CLOUD_SERVER
entity BI_MANAGED_SERVER
entity BI_MANAGED_WEBSPACE
entity BI_DOMAIN_DNS_SETUP
entity BI_DOMAIN_EMAIL_SUBMISSION_SETUP
}
package Hosting #white {
package Webspace #99bcdb {
entity HA_MANAGED_WEBSPACE
entity HA_UNIX_USER
entity HA_EMAIL_ALIAS
}
package MariaDB #99bcdb {
entity HA_MARIADB_INSTANCE
entity HA_MARIADB_USER
entity HA_MARIADB_DATABASE
}
package Server #99bcdb {
entity HA_CLOUD_SERVER
entity HA_MANAGED_SERVER
entity HA_IP_NUMBER
}
}
BI_CLOUD_SERVER o..> BI_PRIVATE_CLOUD
BI_MANAGED_SERVER o..> BI_PRIVATE_CLOUD
BI_MANAGED_WEBSPACE o..> BI_MANAGED_SERVER
HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
HA_MANAGED_WEBSPACE o..> HA_MANAGED_SERVER
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
HA_MARIADB_INSTANCE *==> HA_MANAGED_SERVER HA_MARIADB_INSTANCE *==> HA_MANAGED_SERVER
HA_MARIADB_USER *==> HA_MARIADB_INSTANCE HA_MARIADB_USER *==> HA_MARIADB_INSTANCE
HA_MARIADB_USER o..> HA_MANAGED_WEBSPACE HA_MARIADB_USER o..> HA_MANAGED_WEBSPACE
@ -80,5 +114,59 @@ HA_IP_NUMBER o..> HA_CLOUD_SERVER
HA_IP_NUMBER o..> HA_MANAGED_SERVER HA_IP_NUMBER o..> HA_MANAGED_SERVER
HA_IP_NUMBER o..> HA_MANAGED_WEBSPACE HA_IP_NUMBER o..> HA_MANAGED_WEBSPACE
``` ```
### packages PostgreSQL, Webspace, Server
This code generated was by HsHostingAssetType.main, do not amend manually. ```plantuml
@startuml
left to right direction
package Booking #99bcdb {
entity BI_PRIVATE_CLOUD
entity BI_CLOUD_SERVER
entity BI_MANAGED_SERVER
entity BI_MANAGED_WEBSPACE
entity BI_DOMAIN_DNS_SETUP
entity BI_DOMAIN_EMAIL_SUBMISSION_SETUP
}
package Hosting #white {
package PostgreSQL #99bcdb {
entity HA_PGSQL_INSTANCE
entity HA_PGSQL_USER
entity HA_PGSQL_DATABASE
}
package Webspace #99bcdb {
entity HA_MANAGED_WEBSPACE
entity HA_UNIX_USER
entity HA_EMAIL_ALIAS
}
package Server #99bcdb {
entity HA_CLOUD_SERVER
entity HA_MANAGED_SERVER
entity HA_IP_NUMBER
}
}
BI_CLOUD_SERVER o..> BI_PRIVATE_CLOUD
BI_MANAGED_SERVER o..> BI_PRIVATE_CLOUD
BI_MANAGED_WEBSPACE o..> BI_MANAGED_SERVER
HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
HA_MANAGED_WEBSPACE o..> HA_MANAGED_SERVER
HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
HA_PGSQL_INSTANCE *==> HA_MANAGED_SERVER
HA_PGSQL_USER *==> HA_PGSQL_INSTANCE
HA_PGSQL_USER o..> HA_MANAGED_WEBSPACE
HA_PGSQL_DATABASE *==> HA_MANAGED_WEBSPACE
HA_PGSQL_DATABASE o..> HA_PGSQL_INSTANCE
HA_IP_NUMBER o..> HA_CLOUD_SERVER
HA_IP_NUMBER o..> HA_MANAGED_SERVER
HA_IP_NUMBER o..> HA_MANAGED_WEBSPACE
```
#This code generated was by HsHostingAssetType.main, do not amend manually.

View File

@ -9,11 +9,10 @@ import java.nio.file.Path;
import java.nio.file.StandardOpenOption; import java.nio.file.StandardOpenOption;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.Set;
import static java.util.Arrays.stream; import static java.util.Arrays.stream;
import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toSet;
import static net.hostsharing.hsadminng.hs.hosting.asset.EntityTypeRelation.*; import static net.hostsharing.hsadminng.hs.hosting.asset.EntityTypeRelation.*;
public enum HsHostingAssetType implements Node { public enum HsHostingAssetType implements Node {
@ -137,13 +136,7 @@ public enum HsHostingAssetType implements Node {
return type == null ? null : type.name(); return type == null ? null : type.name();
} }
public static void main(final String[] args) throws IOException { private static void renderAsPlantUML(final Set<String> includedHostingGroups) throws IOException {
final var includedHostingGroups = stream(HsHostingAssetType.values())
.map(t -> t.groupName)
.collect(toSet());
// final var includedHostingGroups = Set.of("Domain", "Server", "Webspace");
final String bookingNodes = stream(HsBookingItemType.values()) final String bookingNodes = stream(HsBookingItemType.values())
.map(t -> " entity " + t.nodeName()) .map(t -> " entity " + t.nodeName())
.collect(joining("\n")); .collect(joining("\n"));
@ -166,7 +159,7 @@ public enum HsHostingAssetType implements Node {
Files.writeString( Files.writeString(
Path.of("doc/hs-hosting-asset-type-structure.md"), Path.of("doc/hs-hosting-asset-type-structure.md"),
""" """
### HostingAsset Type Structure ### packages %{packages}
```plantuml ```plantuml
@startuml @startuml
@ -180,22 +173,18 @@ public enum HsHostingAssetType implements Node {
%{hostingGroups} %{hostingGroups}
} }
Booking -left-> Hosting
%{bookingItemEdges} %{bookingItemEdges}
%{hostingAssetEdges} %{hostingAssetEdges}
``` ```
This code generated was by %{this}.main, do not amend manually.
""" """
.replace("%{this}", HsHostingAssetType.class.getSimpleName()) .replace("%{packages}", String.join(", ", includedHostingGroups))
.replace("%{bookingNodes}", bookingNodes) .replace("%{bookingNodes}", bookingNodes)
.replace("%{hostingGroups}", hostingGroups) .replace("%{hostingGroups}", hostingGroups)
.replace("%{hostingAssetNodeStyles}", hostingAssetNodes) .replace("%{hostingAssetNodeStyles}", hostingAssetNodes)
.replace("%{bookingItemEdges}", bookingItemEdges) .replace("%{bookingItemEdges}", bookingItemEdges)
.replace("%{hostingAssetEdges}", hostingAssetEdges), .replace("%{hostingAssetEdges}", hostingAssetEdges),
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); StandardOpenOption.APPEND);
} }
private static String generateGroup(final String group) { private static String generateGroup(final String group) {
@ -206,6 +195,33 @@ public enum HsHostingAssetType implements Node {
.collect(joining(" \n")) .collect(joining(" \n"))
+ "\n }\n"; + "\n }\n";
} }
public static void main(final String[] args) throws IOException {
Files.writeString(
Path.of("doc/hs-hosting-asset-type-structure.md"),
"""
## HostingAsset Type Structure
""",
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
// renderAsPlantUML(stream(HsHostingAssetType.values())
// .map(t -> t.groupName)
// .collect(toSet()));
renderAsPlantUML(Set.of("Domain", "Server", "Webspace"));
renderAsPlantUML(Set.of("Server", "Webspace", "MariaDB"));
renderAsPlantUML(Set.of("Server", "Webspace", "PostgreSQL"));
Files.writeString(
Path.of("doc/hs-hosting-asset-type-structure.md"),
"""
#This code generated was by %{this}.main, do not amend manually.
"""
.replace("%{this}", HsHostingAssetType.class.getSimpleName()),
StandardOpenOption.APPEND);
}
} }
enum TypeRelationType { enum TypeRelationType {

View File

@ -2,7 +2,6 @@ package net.hostsharing.hsadminng.hs.hosting.asset.validators;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity; import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity;
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType;
import net.hostsharing.hsadminng.system.SystemProcess; import net.hostsharing.hsadminng.system.SystemProcess;
import java.util.List; import java.util.List;