I am having problems designing a proper UML activity diagram.
I've seen similar questions and possible answers: How to present a loop in activity diagram?
Even with these answers I am having doubts and my own answer doesn't correspond with the UML definitions.
Summarization of the problem: Loop over folders and files in each folder, act upon each folder depending on its name and upon each file depending on its name. The main problem I am having is if I am using the expansion region correctly.
Many sources tell that an expansion region must have an input collection and an output collection. But I don't necessarily have an output collection.
Is it automatically assumed that the Region will iterate over all items until no items are left before it goes into ActivityFinal?
Here is a Enterprise Architect screenshot of what I've done:
First of all, your Expansion Nodes are connected with Control Flows or your Actions are connected with Object Flows, either of which is impossible (too bad, that EA doesn't enforce this rule). That means you need to have an Action after the Initial Node, that provides you with a collection. Also you are using Activities in an Activity-Diagram. Contrary to popular believe (and to EA), this is not allowed. You should use Actions (possibly CallBehaviorActions calling Activities, but that's up to you).
I don't know exactly what you try to model. However here is my suggestion for a valid use of Expansion Regions: The first Expansion Node creates an object token for each folder in the directory. The second Expansion Node creates an object token for each file in the folder. If you need to access the folder name, you can simply draw an Object Flow into the Region. This will then provide a separate folder token for each execution of the inner Expansion Region.
It is not necessary to model an output Expansion Node, if you don't need one. Simply end each execution with a Flow Final Node. After the last execution finishes, the Region will produce a token for the outgoing Control Flow.