3

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.

Kaadzia
  • 1,393
  • 1
  • 14
  • 34
  • I have no idea about plantuml but on your additional arrows there should be guards. Maybe that's what plantuml expects? – qwerty_so Mar 10 '20 at 11:11
  • And as a side note: your two "guards" must be written in square brackets in order to be syntactically correct. – qwerty_so Mar 10 '20 at 11:12
  • @qwerty_so: In the final diagram there should be guards, that's true. (Otherwise there would be no chance of knowing when to take which path). But I don't think this is the missing part to making it work in plantUML as guards are optional there. – Kaadzia Mar 10 '20 at 12:15

1 Answers1

3

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"

bruno
  • 32,421
  • 7
  • 25
  • 37
  • Thanks @bruno, this works for me :-) It also put me on the right track for what I really needed. I am much better of modeling my case as a state chart than an activity diagram. (Would give you two upvotes if I could ;-) ) – Kaadzia Mar 11 '20 at 07:26
  • *you cannot have* should probably end with "for PlantUML" since UML can have it. – qwerty_so Mar 11 '20 at 10:51