adjust Export
This commit is contained in:
@@ -15,20 +15,52 @@ import (
|
||||
// PlantUML export
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// ToPlantUML serializes the workflow graph back to a PlantUML file that is
|
||||
// compatible with ExtractFromPlantUML (round-trip).
|
||||
// Resource attributes and instance attributes are merged and written as
|
||||
// human-readable comments: "key: value, nested.key: value".
|
||||
// plantUMLProcedures defines the !procedure blocks for each resource type.
|
||||
// These make the output valid, renderable PlantUML while remaining parseable
|
||||
// by ExtractFromPlantUML (which already skips lines containing "!procedure").
|
||||
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 {
|
||||
var sb strings.Builder
|
||||
sb.WriteString("@startuml\n\n")
|
||||
sb.WriteString(plantUMLProcedures)
|
||||
sb.WriteByte('\n')
|
||||
|
||||
varNames := plantUMLVarNames(w.Graph.Items)
|
||||
|
||||
// --- resource declarations ---
|
||||
for id, item := range w.Graph.Items {
|
||||
sb.WriteString(plantUMLItemLine(varNames[id], item))
|
||||
sb.WriteByte('\n')
|
||||
if line := plantUMLItemLine(varNames[id], item); line != "" {
|
||||
sb.WriteString(line + "\n")
|
||||
}
|
||||
}
|
||||
|
||||
sb.WriteByte('\n')
|
||||
|
||||
Reference in New Issue
Block a user