Combine two sequence diagrams into one

0 votes
asked 5 days ago in Question / help by vagvaz (140 points)

I am creating a sequence diagram that shows the interaction between various components. I would like to be able to split the sequence diagram into two and be able to combine them, so I get the same effect as having developed only one. This is useful for maintainability, because one of the two diagrams can be used by more diagrams.
Example let's say that there is a frontend and backend component with the following interactions. Ideally, I would like to have two UMLs with FE and BE and being able to generate one unified, so whenever I change the BE internal processes the unified can be updated (after a regeneration of course)

Is there any way to do this with puml ?

http://www.plantuml.com/plantuml/png/RPB1xg8m4CRlFCN44tjO7u33nks2MHDFctWcbKwqMMYnqwhxzbigynTYJoBp-xxo6zYHbyw7eI-yzZr27ORXNt6sJzZicqq10316G7TwbCPFD-5qs80as3VRqo4B_B8E6Pck2pGAOkMhLkHgHGD_yFPR6jMZIrdHRDztie4JeViP_9Ln_f-5HI3I1edWQ2-wuumuPkbQC52B17mfoE2j2SCPNP4M0Dz_i2PKuB13VSVMuIqW-L9-AtWOkPLI1NVPQoKzJjHgDBFiyoRRGEXAkPr-KeQHEL4BgE22Vit9tiDq1SeYWR4UyAd99wyKIWv9fW9qpheocB_6FapxAi2Ua6a-ySC7gdH8A-CGJToczAZA63OgQoUECJ4wso7HSbzfjFHnA5KRxMN9myy2da-gsgHrGUfaJSwjDMUKZsTJ3cJUcKCQhI4iPTwCluMAZs_d9qIr_1ZuIIgWgtsqozPTh0r3_ny0

@startuml

title Dummy

box "FE"

participant "FE UI" as FE.UI

participant "FE Core" as FE.Core

end box

box "BE"

participant "BE ReqHandler" as BE.ReqHandler

participant "BE UserAuth" as BE.UserAuth

participant "BE Bussiness Logic" as BE.BL

participant "BE DB" as BE.DB

end box

autonumber

FE.UI -> FE.Core : receive_request(a)

FE.Core -> BE.ReqHandler: validate(a)

BE.ReqHandler -> BE.UserAuth: validate_user(a.user)

BE.UserAuth -> BE.DB : get_user(a.user)

alt user does not exist

BE.DB -> FE.UI : error(unknown_user)

else

BE.UserAuth -> BE.ReqHandler : user_authenticated()

end

BE.ReqHandler -> BE.BL : process_request(a)

BE.BL -> BE.DB : read_data()

BE.BL -> BE.BL : process_data()

alt invalid request

BE.BL -> FE.UI : error(invalid_request)

else

BE.BL -> BE.ReqHandler: response(a)

end

BE.ReqHandler -> FE.Core: request_processed(a)

FE.Core -> FE.UI: show_response(a)

@enduml

commented 5 days ago by albert (2,510 points)
I didn't try but did you have a look at the include statement?
commented 5 days ago by anonymous
Thanks for the answer.
!include does not solve my problem is that include merges UMLs sequentially so the end result would not be the correct sequence diagram although all the steps will be depicted.

Another way of doing this  is to actually have two UML diagrams and not combine them, but reference certain elements on the other UMLs, but I haven't been able to make it work.
I can add a hyperlink to the other UML diagram, but I cannot find a way to create an anchor (or something similar) so I can reference it i.e have two UML diagrams FE and BE
and in the FE have something like [[BE.svg#ENTRY_POINT]]

1 Answer

0 votes
answered 1 day ago by mgrol (2,240 points)

Hi,

not if you want to intertwine two independent sequences with parallel processes. 

I do something similar. I write these sequences as macros to symolize some kind of services see here for the example below: http://www.plantuml.com/plantuml/uml/ZP11Y_8m68Jl-HLJB_qy2EftMvR5MhieY6ZHizJsZGRIH9EK_Vlxea5NzxANqZQJcMTcuaFbGjTgaUBS1OIJyb0cM5J6XXCvIAM9FneaojIwQmWgY4H9qv34j2YBpMwUhMRBejolitAxo1VhRBNTvsMHROkP0CuSe6frhan0RrgWf0lcRAZ9zL1v7CZHvNJx0UiQVluV2Y3X06Ne3na9cKP9aTu97-GULi9t1q-NZapu2UE5Y17QcYEcLD8cSltBioM7zGLmUyFWuvdp3JCBRrlYmSnH06bTQOssgftraCwsY33-OV8-6BowPCP_aRisUB2855pWjdomY4PWZGSN8o74qwYVXDtYkgMaKPnmDFoboQsZg1f7rNZ8MVVPFF6LAiJacCIMuFPyvxNqqs9ytXSJHknQ_Gq0

which looks like this  .

This will, however, not exacly duplicate your picture as the error arrow would never go directly to the Fe GUI as it would in my eample just go to the Fe Core and from there you would need to draw a separate arrow to the Fe GUI as it probably happens in your real-life sequence too. Just take a look into macros in general and you will find them quite usefull.

When including files I can adjust the visibility of certain services. Some (SIMPLE) will be displayed as ref-boxes and some (default case) just as text and some (TECHNICAL/DETAILED) will display a lot of technical details. I currently have a repository of over hundred files that provide "service calls" and I can use them as I would call a real service in an application. It is like object oriented implementation. Write your services self-sustained such that they don't need to know what you need inside a macro/service.

If you need a working example, please send me your email address and I try to provide an example to you via email.

Here you can find the way I write my sequences:

BR,

Michael


@startuml Service1_ServiceDomain
' generated on 2018-11-09T15:18:49.803
'!define TECHNICAL
'!define SIMPLE
'Definition of participants in a common file
'!include ../../common/common.iuml
!ifndef SIMPLE
    !ifndef SERVICE1_PARTICIPANT_CREATED

        ' this macro is defined in common.iuml as e.g. participant "Service 1" as service1
        SERVICE1_PARTICIPANT
        !define SERVICE1_PARTICIPANT_CREATED true
    !endif
!endif
'!include service macro here
'
' Define soap method here
'
'
!definelong Service1_ServiceDomain_method1(CALLER="consumerMethod1",REQ_PARAM="")
    !ifdef SIMPLE
        referenceBox(CALLER,INTEGRATION_COLOR,Todo)
    !else
        'Technical view
        !ifdef TECHNICAL
            documentBox(service1,Todo)
            CALLER -> service1 ++ : Todo with REQ_PARAM

            'Call_Subsequent_Service(service1,REQ_PARAM)
            CALLER <-- service1 : Todo
            !ifdef SHOW_EXCEPTION
                note over service1
                    Possible errors for Service1_ServiceDomain_method1
                    not yet defined
                end note
            !endif
            deactivate service1
        !else
        'Business view
            CALLER -> service1 ++ : Todo business request

            'Call_Subsequent_Service(service1,REQ_PARAM)
            CALLER <-- service1 --: Todo business response
        !endif
    !endif
!enddefinelong
@enduml

commented 20 hours ago by vagvaz (140 points)
Thanks for your answer.

This is an interesting approach, I have knew macros, but I haven't gone that far in my thinking to use them as you do. I will be interested in a working example, will send you a private msg.
Using macros might provide an acceptable solution in my usecase.
...