Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Change save options(How to change the resource save options such as OPTION_KEEP_DEFAULT_CONTENT in Sirius)
Change save options [message #1850110] Wed, 16 February 2022 10:42 Go to next message
Martial Montrichard is currently offline Martial MontrichardFriend
Messages: 3
Registered: February 2022
Junior Member
I'm trying to find an easy way to change the resource save option in Sirius.
More specifically I would like to active the default value serialization with the option OPTION_KEEP_DEFAULT_CONTENT.

I found a way to do it using the generated EMF editor but it is not used by Sirius to save the resources.

Any suggestion?

Martial
Re: Change save options [message #1850148 is a reply to message #1850110] Fri, 18 February 2022 01:08 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 566
Registered: May 2011
Senior Member
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 #1850164 is a reply to message #1850148] Fri, 18 February 2022 15:23 Go to previous messageGo to next message
Martial Montrichard is currently offline Martial MontrichardFriend
Messages: 3
Registered: February 2022
Junior Member
Thanks Steve for this answer.


Quote:
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.

Never did that yet. Probably gonna to be painful. Hope I'll find some tuto.


Quote:
Meanwhile, what is the goal of modifying this serialization value?

I want to use the saved ecore model file as an input for a M2M tool. I need the default value to be saved.



Quote:
Couldn't it be a parameter to change it the genmodel of your metamodel plugin instead?

I searched for a solution in that direction as well. Just find one to modify the DoSave() method in the model editor generated code. It works but Sirius does not use the model editor.
Re: Change save options [message #1850168 is a reply to message #1850164] Fri, 18 February 2022 23:57 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 566
Registered: May 2011
Senior Member
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 Go to previous message
Martial Montrichard is currently offline Martial MontrichardFriend
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.
Previous Topic:Import Diagram in another Viewpoint in Same .Odesign file.
Next Topic:Having trouble in opening editor in sirus
Goto Forum:
  


Current Time: Sun Aug 07 16:35:31 GMT 2022

Powered by FUDForum. Page generated in 0.02480 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top