|
Re: Change save options [message #1850148 is a reply to message #1850110] |
Fri, 18 February 2022 01:08   |
|
Hello,
I think that the simplest way would be by overriding the org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.save(Map<?, ?>, IProgressMonitor) with your own list of options. To do so, you will need to provide your own session factory with the extension point org.eclipse.sirius.sessionFactory.
I will keep digging if I can find an exemple where we would have modified these options.
Meanwhile, what is the goal of modifying this serialization value? Couldn't it be a parameter to change it the genmodel of your metamodel plugin instead?
Best regards,
Steve
Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Re: Change save options [message #1850168 is a reply to message #1850164] |
Fri, 18 February 2022 23:57   |
|
Hi Martial,
I can't find a tutorial so far ( I guess it is not really common to change the doSave), but I don't think it should be that painful. Once you have added the extension to your plugin, you just need to create a class that extends SessionFactoryImpl. In your class, I think you should only need to override createSession so instead of returning a new DAnalysisSessionImpl, you return your own class that overrides DAnalysisSessionImpl. In that class, you will just override the doSave method. 1 extension point, 2 classes, 2 methods :)
If I follow correctly your serialization issue, if in your metamodel you have an EAttribute typed EBoolean with a default value false, you want that information to be serialize in your model even if for an element it is valued as true? That seems redundant with the metamodel, but I do not know how your M2M tool. I really think that is an issue that could (and probably should) be handled on the EMF side. I have not done this kind of tweak in a while, but for instance once I wanted to change the serialization of references from being index based to being based on elements URI and I had done it in the genmodel or with some custom code in the generated files (I can't remember at the moment).
Best regards,
Steve
Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Re: Change save options [message #1850228 is a reply to message #1850168] |
Tue, 22 February 2022 10:33  |
Martial Montrichard Messages: 3 Registered: February 2022 |
Junior Member |
|
|
Hi Steve,
Quote:I can't find a tutorial so far ( I guess it is not really common to change the doSave), but I don't think it should be that painful. Once you have added the extension to your plugin, you just need to create a class that extends SessionFactoryImpl. In your class, I think you should only need to override createSession so instead of returning a new DAnalysisSessionImpl, you return your own class that overrides DAnalysisSessionImpl. In that class, you will just override the doSave method. 1 extension point, 2 classes, 2 methods :)
OK I'll look at it.
Quote:If I follow correctly your serialization issue, if in your metamodel you have an EAttribute typed EBoolean with a default value false, you want that information to be serialize in your model even if for an element it is valued as true?
Not exactly. If the EAttribute is not set, the serialized value is the default one, meaning false in your example. If the EAttribute is set, the serialized value is the set one, meaning false or true in your example. In the default EMF behavior, the EAttribute value is serialized only if it is set. You need to load the option OPTION_KEEP_DEFAULT_CONTENT to have unset EAttributes to be serialized with the default value.
Quote:That seems redundant with the metamodel, but I do not know how your M2M tool.
That's totally true if your M2M tool is taking the model schema as an input because the default values will be available. But it's not always the case.
Quote:I really think that is an issue that could (and probably should) be handled on the EMF side. I have not done this kind of tweak in a while, but for instance once I wanted to change the serialization of references from being index based to being based on elements URI and I had done it in the genmodel or with some custom code in the generated files (I can't remember at the moment).
One other option is to override the shouldSaveFeature() method.
|
|
|
Powered by
FUDForum. Page generated in 0.01630 seconds