Skip to content

Commit eed19f0

Browse files
committed
Fixed JavaIterator.next() and JavaList.get() type wrap.
1 parent 4fd900a commit eed19f0

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

plugins/Python4Capella/java_api/Java_API.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ def next(self) -> T:
4242
nxt = iteratorNext(self.get_java_object())
4343
specific_cls = self.e_object_class.get_class(nxt)
4444
if specific_cls is not None:
45-
if hasattr(self.cls, 'e_class') and hasattr(specific_cls, 'e_class') and specific_cls.e_class.isSuperTypeOf(self.cls.e_class) and not specific_cls.e_class.equals(self.cls.e_class):
46-
return self.cls(nxt)
45+
if hasattr(self.cls, 'e_class') and hasattr(specific_cls, 'e_class') and specific_cls.e_class.isSuperTypeOf(self.cls.e_class):
46+
try:
47+
return self.cls(nxt)
48+
except:
49+
return specific_cls(nxt)
4750
else:
4851
return specific_cls(nxt)
4952
else:
@@ -105,7 +108,10 @@ def get(self, index: int) -> T:
105108
specific_cls = self.e_object_class.get_class(value)
106109
if specific_cls is not None:
107110
if hasattr(self.cls, 'e_class') and hasattr(specific_cls, 'e_class') and specific_cls.e_class.isSuperTypeOf(self.cls.e_class):
108-
return self.cls(value)
111+
try:
112+
return self.cls(value)
113+
except:
114+
return specific_cls(value)
109115
else:
110116
return specific_cls(value)
111117
else:

tests/Python4CapellaTests/capella_manual_tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,3 +724,14 @@ def test_OperationalActivity_incoming_getter(self):
724724
self.assertEqual(Interaction, type(oa.get_incoming()[0]))
725725
for elem in oa.get_incoming():
726726
self.assertEqual(Interaction, type(elem))
727+
728+
def test_LogicalComponentPkg_owned_logical_components(self):
729+
"""
730+
This test need the IFE project to be in the workspace to run
731+
"""
732+
model = CapellaModel()
733+
model.open("/In-Flight Entertainment System/In-Flight Entertainment System.aird")
734+
se = model.get_system_engineering()
735+
for lc in se.get_logical_architecture().get_logical_component_pkg().get_owned_logical_components():
736+
#: :type lc: LogicalComponent
737+
lc.get_name()

0 commit comments

Comments
 (0)