diff --git a/capella_ros_tools/importer.py b/capella_ros_tools/importer.py index 49ba452..8bf5998 100644 --- a/capella_ros_tools/importer.py +++ b/capella_ros_tools/importer.py @@ -95,13 +95,12 @@ def _convert_package( sync["enumerations"] = enums if packages: sync["packages"] = packages + if associations: + sync["owned_associations"] = associations yml = {} if sync: yml["sync"] = sync - if associations: - yml["extend"] = {} - yml["extend"]["owned_associations"] = associations return yml @@ -134,20 +133,23 @@ def _convert_class( associations.append( { - "navigable_members": [decl.Promise(prop_promise_id)], - "members": [ - { - "_type": "Property", - "type": decl.Promise(promise_id), - "kind": "ASSOCIATION", - "min_card": decl.NewObject( - "LiteralNumericValue", value="1" - ), - "max_card": decl.NewObject( - "LiteralNumericValue", value="1" - ), - } - ], + "find": {"name": prop_promise_id}, + "set": { + "navigable_members": [decl.Promise(prop_promise_id)], + "members": [ + { + "_type": "Property", + "type": decl.Promise(promise_id), + "kind": "ASSOCIATION", + "min_card": decl.NewObject( + "LiteralNumericValue", value="1" + ), + "max_card": decl.NewObject( + "LiteralNumericValue", value="1" + ), + } + ], + }, } ) props.append(prop_yml) diff --git a/tests/data/data_model/example_msgs.yaml b/tests/data/data_model/example_msgs.yaml index 7fb5c49..9e6b757 100644 --- a/tests/data/data_model/example_msgs.yaml +++ b/tests/data/data_model/example_msgs.yaml @@ -122,68 +122,82 @@ value: !new_object _type: LiteralNumericValue value: "3" - extend: owned_associations: - - navigable_members: - - !promise package1.SampleClass.sample_field1 - members: - - _type: Property - type: !promise package1.SampleClass - kind: ASSOCIATION - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - - navigable_members: - - !promise package1.SampleClass.sample_field2 - members: - - _type: Property - type: !promise package1.SampleClass - kind: ASSOCIATION - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - - navigable_members: - - !promise package1.SampleClass.sample_field3 - members: - - _type: Property - type: !promise package1.SampleClass - kind: ASSOCIATION - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - - navigable_members: - - !promise package1.SampleClass.sample_field4 - members: - - _type: Property - type: !promise package1.SampleClass - kind: ASSOCIATION - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - - navigable_members: - - !promise package1.SampleClass.sample_field5 - members: - - _type: Property - type: !promise package1.SampleClass - kind: ASSOCIATION - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" + - find: + name: package1.SampleClass.sample_field1 + set: + navigable_members: + - !promise package1.SampleClass.sample_field1 + members: + - _type: Property + type: !promise package1.SampleClass + kind: ASSOCIATION + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + - find: + name: package1.SampleClass.sample_field2 + set: + navigable_members: + - !promise package1.SampleClass.sample_field2 + members: + - _type: Property + type: !promise package1.SampleClass + kind: ASSOCIATION + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + - find: + name: package1.SampleClass.sample_field3 + set: + navigable_members: + - !promise package1.SampleClass.sample_field3 + members: + - _type: Property + type: !promise package1.SampleClass + kind: ASSOCIATION + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + - find: + name: package1.SampleClass.sample_field4 + set: + navigable_members: + - !promise package1.SampleClass.sample_field4 + members: + - _type: Property + type: !promise package1.SampleClass + kind: ASSOCIATION + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + - find: + name: package1.SampleClass.sample_field5 + set: + navigable_members: + - !promise package1.SampleClass.sample_field5 + members: + - _type: Property + type: !promise package1.SampleClass + kind: ASSOCIATION + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" - find: name: package2 sync: @@ -275,44 +289,52 @@ value: !new_object _type: LiteralNumericValue value: "2" - extend: owned_associations: - - navigable_members: - - !promise package2.SampleClassEnum.status - members: - - _type: Property - type: !promise package2.SampleClassEnum - kind: ASSOCIATION - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - - navigable_members: - - !promise package2.SampleClassEnum.color - members: - - _type: Property - type: !promise package2.SampleClassEnum - kind: ASSOCIATION - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" - - navigable_members: - - !promise package2.SampleClassEnum.field - members: - - _type: Property - type: !promise package2.SampleClassEnum - kind: ASSOCIATION - min_card: !new_object - _type: LiteralNumericValue - value: "1" - max_card: !new_object - _type: LiteralNumericValue - value: "1" + - find: + name: package2.SampleClassEnum.status + set: + navigable_members: + - !promise package2.SampleClassEnum.status + members: + - _type: Property + type: !promise package2.SampleClassEnum + kind: ASSOCIATION + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + - find: + name: package2.SampleClassEnum.color + set: + navigable_members: + - !promise package2.SampleClassEnum.color + members: + - _type: Property + type: !promise package2.SampleClassEnum + kind: ASSOCIATION + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" + - find: + name: package2.SampleClassEnum.field + set: + navigable_members: + - !promise package2.SampleClassEnum.field + members: + - _type: Property + type: !promise package2.SampleClassEnum + kind: ASSOCIATION + min_card: !new_object + _type: LiteralNumericValue + value: "1" + max_card: !new_object + _type: LiteralNumericValue + value: "1" - parent: !uuid "00000000-0000-0000-0000-000000000001" sync: