Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EVL : How to apply fixes in correct order?
EVL : How to apply fixes in correct order? [message #1850358] Sat, 26 February 2022 16:26 Go to next message
jo ber is currently offline jo berFriend
Messages: 94
Registered: August 2018
Member
Hi

I've defined a list of constraints, each of them contains one fix directive. To apply programmatically the fix when an error occurs I'm using the following code:
		EvlModule module = new EvlModule();
		module.parse(new File(validationDefinitions));
		module.getContext().getModelRepository().addModel(inModel);
		Set<UnsatisfiedConstraint> errors = module.execute();

		for(UnsatisfiedConstraint error : errors) {
			for(FixInstance fi : error.getFixes()) {
				fi.perform();
			}
			error.setFixed(true);
			
			if(saveFixes) {
				saveResourceAfterFixApplication(inModel.getResource(), error.getConstraint().getName());
			}
		}


However, the order in which the fixes are applied to my instances seem not to correspond to the order I've defined in my constraints (using
satisfies(...)
).

Thank you and kind regards.
Re: EVL : How to apply fixes in correct order? [message #1850362 is a reply to message #1850358] Sun, 27 February 2022 08:51 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Jo,

The order in which unsatisfied constraints are detected is not preserved in the result of module.execute(). To work around this you could try extending EvlContext and in its constructor [1], set unsatisfiedConstraints to a new LinkedHashSet(), which preserves insertion order.

Best,
Dimitris

[1] https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/tree/plugins/org.eclipse.epsilon.evl.engine/src/org/eclipse/epsilon/evl/execute/context/EvlContext.java#n32
Re: EVL : How to apply fixes in correct order? [message #1850937 is a reply to message #1850362] Tue, 22 March 2022 23:15 Go to previous messageGo to next message
Sina MadaniFriend
Messages: 160
Registered: November 2015
Location: York, UK
Senior Member
I see no harm in changing EvlContext to use LinkedHashSet instead of HashSet. Is that worth doing, to save others the hassle?
Re: EVL : How to apply fixes in correct order? [message #1850950 is a reply to message #1850937] Wed, 23 March 2022 09:06 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Sina,

Sure - I see no harm either.

Thanks,
Dimitris
Previous Topic:Dynamically loading a metamodel in EOL
Next Topic:Logging from within EOL
Goto Forum:
  


Current Time: Sat Apr 27 08:31:42 GMT 2024

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

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

Back to the top