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 106 additions and 97 deletions
Showing only changes of commit af466dde2e - Show all commits

View File

@ -1,77 +1,84 @@
### HostingAsset Type Structure ### HostingAsset Type Structure
```mermaid ```plantuml
%%{init:{'flowchart':{'htmlLabels':false}}}%% @startuml
flowchart RL
subgraph Booking left to right direction
style Booking fill:white,stroke:white,stroke-width:0px
BI:PRIVATE_CLOUD
BI:CLOUD_SERVER
BI:MANAGED_SERVER
BI:MANAGED_WEBSPACE
BI:DOMAIN_DNS_SETUP
BI:DOMAIN_EMAIL_SUBMISSION_SETUP
end
%% subgraph Hosting package Booking #99bcdb {
subgraph Server[ ] entity BI_PRIVATE_CLOUD
style Server fill:white,stroke:white,stroke-width:0px entity BI_CLOUD_SERVER
HA:CLOUD_SERVER entity BI_MANAGED_SERVER
HA:MANAGED_SERVER entity BI_MANAGED_WEBSPACE
HA:IP_NUMBER entity BI_DOMAIN_DNS_SETUP
end entity BI_DOMAIN_EMAIL_SUBMISSION_SETUP
}
subgraph Domain[ ] package Hosting #white {
style Domain fill:white,stroke:white,stroke-width:0px package Server #99bcdb {
HA:DOMAIN_DNS_SETUP entity HA_CLOUD_SERVER
HA:DOMAIN_HTTP_SETUP entity HA_MANAGED_SERVER
HA:DOMAIN_EMAIL_SUBMISSION_SETUP entity HA_IP_NUMBER
HA:DOMAIN_EMAIL_MAILBOX_SETUP }
HA:EMAIL_ADDRESS
end
subgraph Webspace[ ] package PostgreSQL #99bcdb {
style Webspace fill:white,stroke:white,stroke-width:0px entity HA_PGSQL_INSTANCE
HA:MANAGED_WEBSPACE entity HA_PGSQL_USER
HA:UNIX_USER entity HA_PGSQL_DATABASE
HA:EMAIL_ALIAS }
end
%% end package MariaDB #99bcdb {
entity HA_MARIADB_INSTANCE
entity HA_MARIADB_USER
entity HA_MARIADB_DATABASE
}
style HA:CLOUD_SERVER fill:#99bcdb,stroke:#274d6e,stroke-width:4px package Domain #99bcdb {
style HA:MANAGED_SERVER fill:#99bcdb,stroke:#274d6e,stroke-width:4px entity HA_DOMAIN_DNS_SETUP
style HA:MANAGED_WEBSPACE fill:#99bcdb,stroke:#274d6e,stroke-width:4px entity HA_DOMAIN_HTTP_SETUP
style HA:UNIX_USER fill:#99bcdb,stroke:#274d6e,stroke-width:4px entity HA_DOMAIN_EMAIL_SUBMISSION_SETUP
style HA:DOMAIN_DNS_SETUP fill:#99bcdb,stroke:#274d6e,stroke-width:4px entity HA_DOMAIN_EMAIL_MAILBOX_SETUP
style HA:DOMAIN_HTTP_SETUP fill:#99bcdb,stroke:#274d6e,stroke-width:4px entity HA_EMAIL_ADDRESS
style HA:DOMAIN_EMAIL_SUBMISSION_SETUP fill:#99bcdb,stroke:#274d6e,stroke-width:4px }
style HA:DOMAIN_EMAIL_MAILBOX_SETUP fill:#99bcdb,stroke:#274d6e,stroke-width:4px
style HA:EMAIL_ALIAS fill:#99bcdb,stroke:#274d6e,stroke-width:4px
style HA:EMAIL_ADDRESS fill:#99bcdb,stroke:#274d6e,stroke-width:4px
style HA:IP_NUMBER fill:#99bcdb,stroke:#274d6e,stroke-width:4px
BI:CLOUD_SERVER --> BI:PRIVATE_CLOUD package Webspace #99bcdb {
BI:MANAGED_SERVER --> BI:PRIVATE_CLOUD entity HA_MANAGED_WEBSPACE
BI:MANAGED_WEBSPACE --> BI:MANAGED_SERVER entity HA_UNIX_USER
entity HA_EMAIL_ALIAS
}
HA:CLOUD_SERVER ==> BI:CLOUD_SERVER }
HA:MANAGED_SERVER ==> BI:MANAGED_SERVER
HA:MANAGED_WEBSPACE ==> BI:MANAGED_WEBSPACE BI_CLOUD_SERVER o..> BI_PRIVATE_CLOUD
HA:MANAGED_WEBSPACE ==o HA:MANAGED_SERVER BI_MANAGED_SERVER o..> BI_PRIVATE_CLOUD
HA:UNIX_USER ==> HA:MANAGED_WEBSPACE BI_MANAGED_WEBSPACE o..> BI_MANAGED_SERVER
HA:DOMAIN_DNS_SETUP ==> BI:DOMAIN_DNS_SETUP
HA:DOMAIN_HTTP_SETUP ==> HA:MANAGED_WEBSPACE HA_CLOUD_SERVER *==> BI_CLOUD_SERVER
HA:DOMAIN_HTTP_SETUP -.-> HA:UNIX_USER HA_MANAGED_SERVER *==> BI_MANAGED_SERVER
HA:DOMAIN_EMAIL_SUBMISSION_SETUP ==> BI:DOMAIN_EMAIL_SUBMISSION_SETUP HA_MANAGED_WEBSPACE *==> BI_MANAGED_WEBSPACE
HA:DOMAIN_EMAIL_SUBMISSION_SETUP -.-o HA:MANAGED_WEBSPACE HA_MANAGED_WEBSPACE o..> HA_MANAGED_SERVER
HA:DOMAIN_EMAIL_MAILBOX_SETUP ==> HA:MANAGED_WEBSPACE HA_UNIX_USER *==> HA_MANAGED_WEBSPACE
HA:EMAIL_ALIAS ==> HA:MANAGED_WEBSPACE HA_DOMAIN_DNS_SETUP *==> BI_DOMAIN_DNS_SETUP
HA:EMAIL_ADDRESS ==> HA:DOMAIN_EMAIL_MAILBOX_SETUP HA_DOMAIN_HTTP_SETUP *==> HA_MANAGED_WEBSPACE
HA:IP_NUMBER -.-> HA:CLOUD_SERVER HA_DOMAIN_HTTP_SETUP o..> HA_UNIX_USER
HA:IP_NUMBER -.-> HA:MANAGED_SERVER HA_DOMAIN_EMAIL_SUBMISSION_SETUP *==> BI_DOMAIN_EMAIL_SUBMISSION_SETUP
HA:IP_NUMBER -.-> HA:MANAGED_WEBSPACE HA_DOMAIN_EMAIL_SUBMISSION_SETUP o..> HA_MANAGED_WEBSPACE
HA_DOMAIN_EMAIL_MAILBOX_SETUP *==> HA_MANAGED_WEBSPACE
HA_EMAIL_ALIAS *==> HA_MANAGED_WEBSPACE
HA_EMAIL_ADDRESS *==> HA_DOMAIN_EMAIL_MAILBOX_SETUP
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_MARIADB_INSTANCE *==> HA_MANAGED_SERVER
HA_MARIADB_USER *==> HA_MARIADB_INSTANCE
HA_MARIADB_USER o..> HA_MANAGED_WEBSPACE
HA_MARIADB_DATABASE *==> HA_MANAGED_WEBSPACE
HA_MARIADB_DATABASE o..> HA_MARIADB_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. This code generated was by HsHostingAssetType.main, do not amend manually.

View File

@ -25,13 +25,13 @@ public enum HsBookingItemType implements Node {
@Override @Override
public List<String> edges() { public List<String> edges() {
return ofNullable(parentItemType) return ofNullable(parentItemType)
.map(p -> (nodeName() + " --> " + p.nodeName())) .map(p -> (nodeName() + " o..> " + p.nodeName()))
.stream().toList(); .stream().toList();
} }
@Override @Override
public String nodeName() { public String nodeName() {
return "BI:" + name(); return "BI_" + name();
} }
} }

View File

@ -9,10 +9,11 @@ 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.Set; import java.util.stream.Collectors;
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 {
@ -100,7 +101,7 @@ public enum HsHostingAssetType implements Node {
assignedTo(MANAGED_WEBSPACE) assignedTo(MANAGED_WEBSPACE)
); );
private final String groupName; final String groupName;
private final EntityTypeRelation<?>[] relations; private final EntityTypeRelation<?>[] relations;
HsHostingAssetType( HsHostingAssetType(
@ -125,7 +126,7 @@ public enum HsHostingAssetType implements Node {
@Override @Override
public String nodeName() { public String nodeName() {
return "HA:" + name(); return "HA_" + name();
} }
public static <T extends Enum<?>> HsHostingAssetType of(final T value) { public static <T extends Enum<?>> HsHostingAssetType of(final T value) {
@ -138,17 +139,20 @@ public enum HsHostingAssetType implements Node {
public static void main(final String[] args) throws IOException { public static void main(final String[] args) throws IOException {
final var includedHostingGroups = Set.of("Domain", "Server", "Webspace"); 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 -> " " + t.nodeName()) .map(t -> " entity " + t.nodeName())
.collect(joining("\n")); .collect(joining("\n"));
final String hostingGroups = includedHostingGroups.stream() final String hostingGroups = includedHostingGroups.stream()
.map(HsHostingAssetType::generateGroup) .map(HsHostingAssetType::generateGroup)
.collect(joining("\n")); .collect(joining("\n"));
final String hostingAssetNodeStyles = stream(HsHostingAssetType.values()) final String hostingAssetNodes = stream(HsHostingAssetType.values())
.filter(t -> includedHostingGroups.contains(t.groupName)) .filter(a -> includedHostingGroups.contains(a.groupName))
.map(n -> "style HA:"+n.name()+" fill:#99bcdb,stroke:#274d6e,stroke-width:4px") .map(a -> "entity "+a.nodeName())
.collect(joining("\n")); .collect(joining("\n"));
final String bookingItemEdges = stream(HsBookingItemType.values()) final String bookingItemEdges = stream(HsBookingItemType.values())
.map(HsBookingItemType::edges) .map(HsBookingItemType::edges)
@ -164,20 +168,19 @@ public enum HsHostingAssetType implements Node {
""" """
### HostingAsset Type Structure ### HostingAsset Type Structure
```mermaid ```plantuml
%%{init:{'flowchart':{'htmlLabels':false}}}%% @startuml
flowchart RL left to right direction
subgraph Booking
style Booking fill:white,stroke:white,stroke-width:0px
%{bookingNodes}
end
%% subgraph Hosting
%{hostingGroups}
%% end
%{hostingAssetNodeStyles} package Booking #99bcdb {
%{bookingNodes}
}
package Hosting #white {
%{hostingGroups}
}
Booking -left-> Hosting
%{bookingItemEdges} %{bookingItemEdges}
@ -189,20 +192,19 @@ public enum HsHostingAssetType implements Node {
.replace("%{this}", HsHostingAssetType.class.getSimpleName()) .replace("%{this}", HsHostingAssetType.class.getSimpleName())
.replace("%{bookingNodes}", bookingNodes) .replace("%{bookingNodes}", bookingNodes)
.replace("%{hostingGroups}", hostingGroups) .replace("%{hostingGroups}", hostingGroups)
.replace("%{hostingAssetNodeStyles}", hostingAssetNodeStyles) .replace("%{hostingAssetNodeStyles}", hostingAssetNodes)
.replace("%{bookingItemEdges}", bookingItemEdges) .replace("%{bookingItemEdges}", bookingItemEdges)
.replace("%{hostingAssetEdges}", hostingAssetEdges), .replace("%{hostingAssetEdges}", hostingAssetEdges),
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
} }
private static String generateGroup(final String group) { private static String generateGroup(final String group) {
return "subgraph " + group + "[ ]\n" return " package " + group + " #99bcdb {\n"
+ " style " + group + " fill:white,stroke:white,stroke-width:0px\n"
+ stream(HsHostingAssetType.values()) + stream(HsHostingAssetType.values())
.filter(t -> t.groupName.equals(group)) .filter(t -> t.groupName.equals(group))
.map(HsHostingAssetType::nodeName) .map(t -> " entity " + t.nodeName())
.collect(joining(" \n")) .collect(joining(" \n"))
+ "\nend\n"; + "\n }\n";
} }
} }
@ -222,22 +224,22 @@ class EntityTypeRelation<T extends Node> {
} }
static EntityTypeRelation<HsBookingItemType> requires(final HsBookingItemType bookingItemType) { static EntityTypeRelation<HsBookingItemType> requires(final HsBookingItemType bookingItemType) {
return new EntityTypeRelation<>(" ==> ", TypeRelationType.REQUIRED, bookingItemType); return new EntityTypeRelation<>(" *==> ", TypeRelationType.REQUIRED, bookingItemType);
} }
static EntityTypeRelation<HsHostingAssetType> optionalParent(final HsHostingAssetType hostingAssetType) { static EntityTypeRelation<HsHostingAssetType> optionalParent(final HsHostingAssetType hostingAssetType) {
return new EntityTypeRelation<>(" ==o ", TypeRelationType.OPTIONAL, hostingAssetType); return new EntityTypeRelation<>(" o..> ", TypeRelationType.OPTIONAL, hostingAssetType);
} }
static EntityTypeRelation<HsHostingAssetType> requiredParent(final HsHostingAssetType hostingAssetType) { static EntityTypeRelation<HsHostingAssetType> requiredParent(final HsHostingAssetType hostingAssetType) {
return new EntityTypeRelation<>(" ==> ", TypeRelationType.REQUIRED, hostingAssetType); return new EntityTypeRelation<>(" *==> ", TypeRelationType.REQUIRED, hostingAssetType);
} }
static EntityTypeRelation<HsHostingAssetType> assignedTo(final HsHostingAssetType hostingAssetType) { static EntityTypeRelation<HsHostingAssetType> assignedTo(final HsHostingAssetType hostingAssetType) {
return new EntityTypeRelation<>(" -.-> ", TypeRelationType.REQUIRED, hostingAssetType); return new EntityTypeRelation<>(" o..> ", TypeRelationType.REQUIRED, hostingAssetType);
} }
static EntityTypeRelation<HsHostingAssetType> optionallyAssignedTo(final HsHostingAssetType hostingAssetType) { static EntityTypeRelation<HsHostingAssetType> optionallyAssignedTo(final HsHostingAssetType hostingAssetType) {
return new EntityTypeRelation<>(" -.-o ", TypeRelationType.OPTIONAL, hostingAssetType); return new EntityTypeRelation<>(" o..> ", TypeRelationType.OPTIONAL, hostingAssetType);
} }
} }