Data Model import

Hi all,

I’m currently trying to import a data model, simple one made of Packages/Classes/Enumerations/Properties and Predefined Types. Properties are typed either with Predefined Types or imported Classes/Enumerations.

I have managed to import the Classes into imported Packages but I’m still struggling to import and allocate Properties

I dug into the helpers (org.polarsys.capella.core.data.helpers, org.polarsys.capella.core.model.helpers), without finding ones dedicated to properties creation/allocation

Could someone tell me how import Properties as attributes of Classes?
Which helpers, or whatever, to use?

Many thanks,

Stéphane

You can try:

my_class.get_java_object().getOwnedFeature().add(my_property.get_java_object())
org.polarsys.capella.core.model.helpers.CapellaElementExt.creationService(my_property.get_java_object())
# set my_property feature
# my_property.set_name('Prop1')

Hi Yvan,

Thanks for the answer

I finally managed to import the class properties, through the getOwnedFeatures().add method as you mentionned

I did not use the creationService one (what does it do in this case?)

By the way, the Class’s primitive property getter/setter defined in the Capella.py wrapper are not correct

They are coded self.get_java_object().setPrimitive(value)/isPrimitive() whereas they should be coded self.get_java_object().setIsPrimitive(value)/isIsPrimitive()

I did not check the other class properties getters/setters (Final, Abstract)

1 Like

In this specific case it probably does nothing. But I found that for other elements, like components, it’s mandatory to create corresponding parts.

I opened an issue for the Property API:

Thank you for your feedback.