Skip to content

Commit

Permalink
fix: Sync associations
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Mar 19, 2024
1 parent 8e630cc commit be01be5
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 115 deletions.
36 changes: 19 additions & 17 deletions capella_ros_tools/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
218 changes: 120 additions & 98 deletions tests/data/data_model/example_msgs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit be01be5

Please sign in to comment.