diff --git a/li.strolch.model/src/main/java/li/strolch/model/activity/Activity.java b/li.strolch.model/src/main/java/li/strolch/model/activity/Activity.java index 345be8ae4..3df104464 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/activity/Activity.java +++ b/li.strolch.model/src/main/java/li/strolch/model/activity/Activity.java @@ -306,6 +306,34 @@ public class Activity extends AbstractStrolchRootElement return this.elements; } + /** + * Returns all the actions as a flat list + * + * @return the list of actions + */ + public List getActionsAsFlatList() { + List actions = new ArrayList<>(); + getActionsAsFlatList(actions); + return actions; + } + + private void getActionsAsFlatList(List actions) { + for (IActivityElement element : this.elements.values()) { + if (element instanceof Activity) + ((Activity) element).getActionsAsFlatList(actions); + else + actions.add((Action) element); + } + } + + /** + * Returns all the actions in the entire hierarchy with the given state + * + * @param state + * the state of the action to return + * + * @return the list of actions with the given state + */ public List getActionsWithState(State state) { List actions = new ArrayList<>(); getActionsWithState(actions, state); @@ -321,6 +349,29 @@ public class Activity extends AbstractStrolchRootElement } } + /** + * Returns all the actions in the entire hierarchy with the given type + * + * @param type + * the type of action to return + * + * @return the list of actions with the given type + */ + public List getActionsByType(String type) { + List actions = new ArrayList<>(); + getActionsByType(actions, type); + return actions; + } + + private void getActionsByType(List actions, String type) { + for (IActivityElement element : this.elements.values()) { + if (element instanceof Activity) + ((Activity) element).getActionsByType(actions, type); + else if (element.getType().equals(type)) + actions.add((Action) element); + } + } + /** * @return the iterator for entries, which include the id as key and the {@link IActivityElement} as value */