Alias of interfaces in component diagrams

0 votes
asked Aug 16 in Wanted features by boshka (1,180 points)

is there a way to define a set of interfaces as aliases?

such as in the example below i want to define interfaces a1, a2, a3 as aliases of interface A so that only A will be rendered instead of a1, a2, a3 and the arrows will be from A to d, e and f

 

@startuml
 
 
component comp as comp {
interface a1 as a1
interface a2 as a2
interface a3 as a3
/'
now I want to declare a1, a2, and a3 as aliases of a new interface A that will be used instead of those 3 when rendering
'/
}
 
interface d as d 
interface e as e
interface f as f
 
a1->d
a2->e
a3->f
 
@enduml
 
 
so, that after that redefinition the code would virtually become as follows:
 
@startuml
 
 
component comp as comp {
interface A as A
}
 
interface d as d 
interface e as e
interface f as f
 
A->d
A->e
A->f
 
@enduml
 

1 Answer

0 votes
answered Aug 17 by Serge Wenger Work (4,850 points)

Hello,

Cou can use !define

@startuml
!define a1 A 
!define a2 A 
!define a3 A 
 
component comp as comp {
interface a1 as a1
interface a2 as a2
interface a3 as a3
/'
now I want to declare a1, a2, and a3 as aliases of a new interface A that will be used instead of those 3 when rendering
'/
}
 
interface d as d 
interface e as e
interface f as f
 
a1->d
a2->e
a3->f
@enduml
commented Aug 19 by boshka (1,180 points)
edited Aug 19 by boshka
many thanks! I should have seen this way myself :)
commented Oct 10 by boshka (1,180 points)
edited Oct 10 by boshka
Hi Serge Wenger Work,
while this works perfectly with "interface", now that I was told to use "circle", I replaced all "interface" with "circle" and this approach starts breaking.

In particular:

@startuml
    database "DB" as DB {

         !define DB_at_NSM_CQL DB_at_CQL
         circle "CQL" as DB_at_NSM_CQL

         !define DB_at_MID_CQL DB_at_CQL
         circle "CQL" as DB_at_MID_CQL

         !define DB_at_REPL_CQL DB_at_CQL
         circle "CQL" as DB_at_REPL_CQL
    }
@enduml

this piece breaks, however, if you replace circle with interface it will work.
Please NOTE: it is weird, but this SHORT piece will apparently work for you in both cases, however, within my full iuml code (wich is about 1032 lines) it fails with the error (indicating the error is in these particular lines):

... (skipping 190 lines) ...
database "DB" as DB  {
circle "CQL" as DB_at_CQL
circle "CQL" as DB_at_CQL
This element (DB_at_CQL) is already defined

Could you have a look and try fixing this? If possible, I would not want to share the whole code.
I think, to keep consistency with "interface", such an override should just work too for "circle"
...