How it possible to assing unique identifier to node that will not be shown on screen

0 votes
asked Dec 12, 2021 in Question / help by Yehuda K.
For example i want to add uniqe id for one of the nodes in eg. Sequance diagram or Network diagram in order make ?

1 Answer

0 votes
answered Dec 13, 2021 by Martin (8,360 points)

I hope I'm understanding the question correctly, apologies if not...

If you add a description to a node in a network diagram, then the id is no longer shown, so you can have:

@startuml
nwdiag {
  network dmz {
      address = "210.x.x.x/24"

      web01 [address = "210.x.x.1", description = "web"];
      web02 [address = "210.x.x.2", description = "web"];
  }
}
@enduml

Therefore you could write a procedure to automate allocating the id:

@startuml
!$index=1
!unquoted procedure $node($name, $address)
%string($name+$index) [$args, address=$address, description=$name\n(id=%string($name+$index))];
!$index = $index + 1
!endprocedure

nwdiag {
  network dmz {
      address = "210.x.x.x/24"

      $node(web, 210.x.x.1)
      $node(web, 210.x.x.2)
      $node(web, 210.x.x.3)
  }
}
@enduml

For sequence diagrams, I'm not sure what you're calling a 'node'.  If you mean participant, then you can use this syntax to have multiple participants with the same descriptions but different ids.

@startuml
Participant "Alice" as Alice1
Participant "Alice" as Alice2
Alice1 -> Alice2: hello
@enduml

commented Dec 13, 2021 by anonymous
edited Dec 13, 2021

Thank you for detailed answer ! heart

I meant some thing like that:

@startuml
nwdiag {
  network dmz {
      address = "210.x.x.x/24"
      web01 [id="srvA", address = "210.x.x.1", description = "web"];
      web02 [id="srvB", address = "210.x.x.2", description = "web"];
  }
}
@enduml

take a look where that attribute "id"
on in this sample:

@startuml
Participant "Alice" (id="a1") as Alice1
Participant "Alice" (id="a2") as Alice2
Alice1 -> Alice2: hello
@enduml

another example:

@startuml
Participant "Frontend" (id="fesrv.some.ip") as fe
Participant "Backend"  (id="besrv.diff.ip") as be
Participant "Database" (id="dbsrv.other.ip") as db

fe-> be: request helo
be-> db: request helo query
@enduml

in this way:

- i able to present the sequnce with names "Frontend, Backend, Database"
- i able to pland the sequnce with short names "fe,be,db"
- i able to have point of reference to real machine or reference / or knowladge base
- it enable to have cross reference

so it;s might be a feature request :-)

commented Dec 13, 2021 by Martin (8,360 points)

Can I suggest this syntax?

      web01 [address = "210.x.x.1", description = "web"]; /'id="srvA"'/
      web02 [address = "210.x.x.2", description = "web"]; /'id="srvB"'/

wink

...