Skip to content

Commit

Permalink
module_modeling_LLM: Fix the handling of BPMN diagrams without pools (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonWehrhahn authored Aug 6, 2024
1 parent 7ae325c commit 31ca477
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def __serialize_plane(self, model: dict) -> ElementTree.Element:

return plane

def __split_elements_by_owning_pool(self, elements: dict) -> tuple[dict, list]:
def __split_elements_by_owning_pool(self, elements: dict) -> dict:
"""
Splits a given list of elements into a dictionary with the IDs of the root
pool elements as keys and lists of elements contained within the respective pools
Expand Down Expand Up @@ -750,7 +750,11 @@ def __split_elements_by_owning_pool(self, elements: dict) -> tuple[dict, list]:
else:
elements_by_owning_pool[owner].append(element)

return elements_by_owning_pool, unowned_elements
# Add all elements that are not contained in a pool to an unnamed pool
if len(unowned_elements) > 0:
elements_by_owning_pool[""] = unowned_elements

return elements_by_owning_pool

def __find_root_owner_id(self, elements: dict, current_id: str) -> str:
"""
Expand Down Expand Up @@ -798,11 +802,10 @@ def serialize(self, model: dict, omit_layout_info: bool = False) -> ElementTree.
serialized_plane = self.__serialize_plane(model)
diagram.append(serialized_plane)

elements_by_owning_pool, unowned_elements = self.__split_elements_by_owning_pool(model.get("elements", {}))
elements_by_owning_pool = self.__split_elements_by_owning_pool(model.get("elements", {}))

relationships: list[dict] = list(model.get("relationships", {}).values())

# At the moment, this only supports diagrams that contain pools which should be fine for the time being
if len(elements_by_owning_pool.keys()) > 0:

collaboration: ElementTree.Element = ElementTree.Element(
Expand Down

0 comments on commit 31ca477

Please sign in to comment.