Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [EVL] Provide variable to EvlModule
[EVL] Provide variable to EvlModule [message #1105184] Mon, 09 September 2013 13:27 Go to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Hello,

Is it possible to provide a variable to EvlModule, e.g. to disable certain checks?

I have modified EVLValidator.java to grab the variable value from the validation context and put it in the EvlModule context to make it available.

It works, but I would like to use an unmodified version of Epsilon in my application, hence my question.

Thanks,
Maarten

[Updated on: Mon, 09 September 2013 13:28]

Report message to a moderator

Re: [EVL] Provide variable to EvlModule [message #1105236 is a reply to message #1105184] Mon, 09 September 2013 14:59 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

It depends Smile. Where is the value of the variable stored, and how are you running the EVL script?
Re: [EVL] Provide variable to EvlModule [message #1105247 is a reply to message #1105236] Mon, 09 September 2013 15:24 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
The EVL script is registered using the constraintsBinding extension point.
From my application I invoke the EMF validator and the registered EVL rules are activated. Something like this:
batchValidator = (IBatchValidator) ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH);
batchValidator.validate(object, monitor);


(Same goes for the live validator)

Next I have registered a custom AbstractModelConstraint class to the constraintProviders extension point, where I invoke a custom Diagnostican object to collect all errors from the validation to embed them in a ContraintStatus.Multi (compound) status list. Which is fed to my custom validation listener.

As fas as I know, this is the route to have/combine life and batch validations, markers, EMF, and EVL validation in an application.

The context of the Diagnostican object, is available in EvlValidator, see Bug #395261. So, in a similar way a variable could be passed to the EvlValidator, like the bug report does for the progress monitor.

Currently I have the following added to the EvlValidator#validate(Resource Map<Object, Object>) to get make the variable/value available:
module.getContext().getFrameStack().put(new Variable("MyVar", context.get("MyVarValue"), EolPrimitiveType.String));

So basically, I grab the value of the variable from the context of the Diagnostican. But in a hack-ish way Smile

But, I was wondering whether there is another/nicer way to pass a variable/value to the EVL validation rules...
If not, I am willing to think of a more generic solution and provide a patch (if you guys want this feature of course!)

[Updated on: Mon, 09 September 2013 15:27]

Report message to a moderator

Re: [EVL] Provide variable to EvlModule [message #1105291 is a reply to message #1105247] Mon, 09 September 2013 16:35 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Well, from a look at Dimitris' fix for bug 395261, it seems we are *almost* there: as you say, we already have the Diagnostician context in EvlValidator#validate(Resource, Map).

The main problem with making this sort of change is ensuring that we don't break existing EVL code. We could always expose the Map object as a variable with a name that will not conflict with the user's variables, e.g. "diagnosticianContext". I don't see many people using this name for something different, but if necessary we could only enable this new behaviour if the developer enabled it in the constraintsBinding extension.

In fact, if we implement the new boolean setting in constraintsBinding, we could do something better than diagnosticianContext.get("MyVarValue"): we could map the "MyVarValue" entry directly to the "MyVarValue" variable.

I think this second way would be both safe and convenient. You'd probably need to add a get/setPropagateDiagnosticianContext(...) pair to EvlValidator and act upon it in #validate(Resource, Map). Then you'd need to query the extension attribute and invoke the set method appropriately in EValidatorPopulator#earlyStartup().

If you could whip up a patch for this, I'd be happy to review it and try it out Smile.
Re: [EVL] Provide variable to EvlModule [message #1105371 is a reply to message #1105291] Mon, 09 September 2013 19:24 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Antonio Garcia-Dominguez wrote on Mon, 09 September 2013 18:35
In fact, if we implement the new boolean setting in constraintsBinding, we could do something better than diagnosticianContext.get("MyVarValue"): we could map the "MyVarValue" entry directly to the "MyVarValue" variable.

I think this second way would be both safe and convenient. You'd probably need to add a get/setPropagateDiagnosticianContext(...) pair to EvlValidator and act upon it in #validate(Resource, Map). Then you'd need to query the extension attribute and invoke the set method appropriately in EValidatorPopulator#earlyStartup().


You mean setting the variable and its value in the constraintsBinding? The value is changing at run-time, so that is not really possible.

I could add a custom key, e.g. "EvlValidatorVariable", with a map as its value. The map then contains the variable/value pairs. If the key is not set, nothing changes, i.e. nothing breaks. If the is set, the variables are added to the EvlModule context.

A more complex method would be to add the variable names to the contextBinding and used these names to grab the values from the context. Thereby, circumventing the map. But it needs more support (and has probably more ways to break?)
Re: [EVL] Provide variable to EvlModule [message #1105402 is a reply to message #1105371] Mon, 09 September 2013 20:33 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Maarten Bezemer wrote on Mon, 09 September 2013 15:24

You mean setting the variable and its value in the constraintsBinding? The value is changing at run-time, so that is not really possible.


No, not that. It'd be just a boolean flag for enabling or disabling the propagation of Diagnostician context entries as EVL global variables.

Maarten Bezemer wrote on Mon, 09 September 2013 15:24

A more complex method would be to add the variable names to the contextBinding and used these names to grab the values from the context. Thereby, circumventing the map. But it needs more support (and has probably more ways to break?


This would provide finer control to the user and would also be a good idea. I don't see the problem myself: most users will leave this variable list empty, after all.

Going back to your example: I propose that by adding the "MyVarValue" name to the hypothetical "diagnosticianVariables" list field in the "constraintBinding" extension, EVL would expose the value associated to the "MyVarValue" key of the Diagnostician's context as the global variable "MyVarValue". This can be postponed until right before the EVL script is run, just like your custom code.

What do you think? Would this solve your problem?

[Updated on: Mon, 09 September 2013 20:39]

Report message to a moderator

Re: [EVL] Provide variable to EvlModule [message #1105413 is a reply to message #1105402] Mon, 09 September 2013 20:56 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Yes, that would solve my problem and seems to be generically usable for others as well.
I'll implement this and provide the patch when finished.
Re: [EVL] Provide variable to EvlModule [message #1105417 is a reply to message #1105413] Mon, 09 September 2013 21:05 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Great, thanks!
Re: [EVL] Provide variable to EvlModule [message #1105770 is a reply to message #1105417] Tue, 10 September 2013 08:55 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Patch available in Bug 416893

PS The SVN repository contains a .gitignore file, is there also a git repository available? (It would be more convenient to use, as Git support is much better in Eclipse)
Re: [EVL] Provide variable to EvlModule [message #1105904 is a reply to message #1105770] Tue, 10 September 2013 12:20 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Maarten Bezemer wrote on Tue, 10 September 2013 04:55
The SVN repository contains a .gitignore file, is there also a git repository available? (It would be more convenient to use, as Git support is much better in Eclipse)


I don't believe that there is a mirrored Git repository. However, some of us use git-svn with Epsilon's SVN repository, which is where the .gitignore file has come from.
Re: [EVL] Provide variable to EvlModule [message #1106029 is a reply to message #1105904] Tue, 10 September 2013 15:31 Go to previous message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Yes, that was probably me Smile.

By the way, good job! I've touched up the patch in your report a bit - could you try it out?
Previous Topic:Cant Generate diagram Tools
Next Topic:[Kepler] virtualEmf EPackage missing
Goto Forum:
  


Current Time: Wed Apr 24 22:22:56 GMT 2024

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

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

Back to the top