labs4capella / python4capella

Python for Capella
Eclipse Public License 2.0
52 stars 10 forks source link

[New Feature]Improve EMF API #200

Open jib63 opened 7 months ago

jib63 commented 7 months ago

I would like to export Classes created with Capella into an ecore model and import an ecore model into capella. I'm seeing the EMF_API.py lack of important features to be able to do that :

Do you think it can be added ? Or this can be achieved in another way with python4capella ?

I can provide an intial pull request as I have a big expertise in ecore but this is the first time I'm working with Python4capella

ylussaud commented 7 months ago

I think we should add this at some point yes. You can already create instances of your EClasses:

e_class = get_e_classifier("http://www.polarsys.org/capella/core/core/" + capella_version(), "PropertyValueGroup")
instance = create_e_object_from_e_classifier(e_class)

instance will be a Java Object (not wrapped in a Python object).

For the resource part, you can use the Java API as a workaround:

uri = org.eclipse.emf.common.util.URI.createURI('...')
rs = org.eclipse.emf.ecore.resource.impl.ResourceSetImpl()
r = rs.createResource(uri)
r.getContents.add(...)
jib63 commented 6 months ago

Hello Yvan, Thanks for your answer,

for your first solution, it does not fit my need as it’s not an instance of a class, but the definition of a class itself using EClass, EStructuralFeature… , and not an instance of a class.

For the second proposal it does not work either as ResourceSet belong to ecore.xmi jar which is probably not included to the Python4Capella platform definition. I will clone the python4Capella to add these features. If I can be added as contributor I can make a pull request, or I will fork the project.

Thanks, Best wishes for the year to come, /JB