adjust Export

This commit is contained in:
mr
2026-03-18 09:10:58 +01:00
parent 6a907236fa
commit d1214fe622

View File

@@ -15,20 +15,52 @@ import (
// PlantUML export // PlantUML export
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// ToPlantUML serializes the workflow graph back to a PlantUML file that is // plantUMLProcedures defines the !procedure blocks for each resource type.
// compatible with ExtractFromPlantUML (round-trip). // These make the output valid, renderable PlantUML while remaining parseable
// Resource attributes and instance attributes are merged and written as // by ExtractFromPlantUML (which already skips lines containing "!procedure").
// human-readable comments: "key: value, nested.key: value". const plantUMLProcedures = `!procedure Processing($var, $name)
component "$name" as $var <<Processing>>
!endprocedure
!procedure Data($var, $name)
file "$name" as $var <<Data>>
!endprocedure
!procedure Storage($var, $name)
database "$name" as $var <<Storage>>
!endprocedure
!procedure ComputeUnit($var, $name)
node "$name" as $var <<ComputeUnit>>
!endprocedure
!procedure WorkflowEvent($var, $name)
usecase "$name" as $var <<WorkflowEvent>>
!endprocedure
!procedure Workflow($var, $name)
frame "$name" as $var <<Workflow>>
!endprocedure
`
// ToPlantUML serializes the workflow graph to a valid, renderable PlantUML file
// that is also compatible with ExtractFromPlantUML (round-trip).
// Resource and instance attributes are written as human-readable comments:
//
// Processing(p1, "NDVI") ' access.container.image: myrepo/ndvi:1.2, infrastructure: 0
func (w *Workflow) ToPlantUML() string { func (w *Workflow) ToPlantUML() string {
var sb strings.Builder var sb strings.Builder
sb.WriteString("@startuml\n\n") sb.WriteString("@startuml\n\n")
sb.WriteString(plantUMLProcedures)
sb.WriteByte('\n')
varNames := plantUMLVarNames(w.Graph.Items) varNames := plantUMLVarNames(w.Graph.Items)
// --- resource declarations --- // --- resource declarations ---
for id, item := range w.Graph.Items { for id, item := range w.Graph.Items {
sb.WriteString(plantUMLItemLine(varNames[id], item)) if line := plantUMLItemLine(varNames[id], item); line != "" {
sb.WriteByte('\n') sb.WriteString(line + "\n")
}
} }
sb.WriteByte('\n') sb.WriteByte('\n')