Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Save Resource Without Alphabetic Sorting
Save Resource Without Alphabetic Sorting [message #1830603] Wed, 29 July 2020 15:55 Go to next message
Hadeer Tarek is currently offline Hadeer TarekFriend
Messages: 1
Registered: July 2020
Junior Member

I am working on a project that uses emf.ecore.resource to read and write arxml files.

sample arxml file:

The file is read in its normal order but when saving it again, the containers are sorted alphabetically as shown:

I want to keep the order as it is.

Sample from my code for saving:

Map<String, Object> options = new HashMap<String, Object>();
options.put("ENCODING", "UTF-8"); options.put(ExtendedResource.OPTION_RESOURCE_VERSION_DESCRIPTOR,Autosar40ResourceFactoryImpl.AUTOSAR_4_0_3_RESOURCE_DESCRIPTOR);
OutputStream outStream = new FileOutputStream(new File("hadeer.arxml"));
ar.getResources().get(1).save(outStream, options);

Kind Regards
Re: Save Resource Without Alphabetic Sorting [message #1830614 is a reply to message #1830603] Wed, 29 July 2020 19:43 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7564
Registered: July 2009
Senior Member

My recollection is that they are no sorted, rather they are in declaration order in the Ecore model, which you could reorder to taste, except that you don't want to change things.

Real EMF experts can work wonders with the ExtendedMetaData, so maybe that can help.

I would be inclined to ensure that you define a BetterResourceImpl for your Better model, and do an in-memory 'sort' into your preferred order as part of the save activity. If necessary cache the old order so that you can revert in-memory afterwards.


Ed Willink
Previous Topic:Getting EObject from an URI
Next Topic:Extending a metamodel without overriding it
Goto Forum:

Current Time: Wed Feb 08 21:45:47 GMT 2023

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

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

Back to the top