Closed chgio closed 2 weeks ago
Hi and thank you for using Python4Capella,
the Python class StateTransition
uses capella_query_by_name()
for implementing
get_source() and get_target(). capella_query_by_name()
returns a List... That's why you have this error message:
AttributeError: 'JavaList' object has no attribute 'get_name'
The implementation should directly call the Java method:
def get_source(self):
"""
Returns: AbstractState
"""
value = self.get_java_object().getSource()
if value is None:
return value
else:
e_object_class = getattr(sys.modules["__main__"], "EObject")
specific_cls = e_object_class.get_class(value)
if specific_cls is None:
return None
else:
return specific_cls(value)
def get_target(self):
"""
Returns: AbstractState
"""
value = self.get_java_object().getTarget()
if value is None:
return value
else:
e_object_class = getattr(sys.modules["__main__"], "EObject")
specific_cls = e_object_class.get_class(value)
if specific_cls is None:
return None
else:
return specific_cls(value)
Just copy-pasted this in simplified_api/capella.py
and it works like a charm!
Now I can get my data:
states:
Detumbling
incoming transitions:
Idle --- Ejection Loop Entry --> Detumbling
Thank you for the quick and effective bugfix :heart:
Hello, firstly thank you very much for this project. I just started using it and I'm very excited, it seems very powerful and well-documented.
I'm trying to build a Finite State Machine parser for usage with formal verification frameworks. Here is some simple code I've been playing around with:
This works perfectly to get the
State
s at these_lv
level, and theStateTransition
s for eachState
-- however, when it comes to getting the source and targetState
s for eachStateTransition
, this is what I get:Indeed, trying to call
.get_name()
onsrc
ortgt
(as done ons
andt
) gives:I've taken a look at the code and tried substituting
capella_query_by_name(t, "Source")
(the current implementation ofStateTransition.get_source()
) witht.get_java_object().getSource()
(as done forState.get_incoming()
), but to no avail. Starting fromse_lv.get_all_contents_by_type(StateTransition)
and getting all the source and targetState
s from there also doesn't change anything.To my understanding, this happens despite the presence of relations between
AbstractState
andStateTransition
entities in the metamodel... I've double-checked my model and the semantic browser does show all the links I need; this issue also seems to extend to multiple levels, as my model hasStateMachine
s inSystemAnalysis
,LogicalArchitecture
, andPhysicalArchitecture
, which all replicate the same behaviour.