Search code examples
umlplantuml

How to realize direct arrows with PlantUML?


I am trying to create an activity diagram with PlantUML that does contain arrows that go back to existing nodes.

What I am looking for is a diagram that includes the two arrows "Arrow 1" and "Arrow 2" in the picture below: plantuml diagram with the desired arrows

I have tried creating this using the PlantUML beta syntax for Activity diagrams.

I achieved the diagram below:

plantuml diagram without the desired arrows

by writing the following PlantUML code:

@startuml

start

:new - please check;

while (check sucessful?) is (is an error)
  :to solve;
  :in progress;
  :solved;
endwhile (not an error)

:erledigt;
note left
    reason:
     * done
     * not an error
     * not fixable
end note
stop

@enduml

Does anybody has a hint on how to achieve this? It does not matter to me if the result is achieved by using the beta syntax or the older syntax.


Solution

  • you cannot have several flows starting from an action nor several flows going to an action

    for the UML point of view so you need to add :

    1. a decision node after the action "to solve" to have your two flows, each with a guard

    2. a decision node after the action "erledigt" to have your two flows, each with a guard

    3. a merge node before the action "to solve" to receive the flows from the decision node "check successful" and the action "erledigt".

    For (1) use a "if-else" or a "split" in PlantUML

    start
    
    :new - please check;
    
    while (check sucessful?) is (is an error)
      :to solve;
      if (duration) then (long)
        :in progress;
      else (immediat)
      endif
      :solved;
    endwhile (not an error)
    
    :erledigt;
    note left
        reason:
         * done
         * not an error
         * not fixable
    end note
    stop
    
    @enduml
    

    enter image description here

    For (3) may be you can use a "repeat while" also managing (2), but not sure you can in PlantUML without duplicating the three actions (to solve - in progress - solved) or doing them in an other activity you call. In PlantUML the code is drawn from control-structure except "goto", that allows to not cross lines, but you need a "goto" crossing lines. Note there is no problem going to the decision "check sucessfull" rather than to the action "to solve"