Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » start EVL validation from wizard
start EVL validation from wizard [message #1681345] Tue, 17 March 2015 09:15 Go to next message
Florian Haupt is currently offline Florian HauptFriend
Messages: 5
Registered: February 2015
Junior Member
Hi all,

I created a GMF editor using Epsilon / Eugenia and I also defined some EVL constraints for the model. Validation works as expected. What I do with the model is that I offer a wizard to transform the model to a different model, which also works fine. What I want to achieve now is, that before the transformation is executed, the model is automatically validated (using my EVL contraints) and that the transformation is only started when there are no errors.

So my question is basically how to execute EVL validation programmatically as part of a wizard (which is started by right-clicking on the model file and selecting the corresponding option in the context menu).

Thanks in advance for any hints.

Florian
Re: start EVL validation from wizard [message #1681763 is a reply to message #1681345] Tue, 17 March 2015 12:59 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Florian,

This is not supported out of the box I'm afraid, but it should be possible to achieve through a custom Java "tool" [1] that would get hold of the current GMF editor and invoke validation programmatically (see the last line of [2]).

Cheers,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/articles/call-java-from-epsilon/
[2] https://www.eclipse.org/epsilon/doc/articles/evl-gmf-integration/
Re: start EVL validation from wizard [message #1682292 is a reply to message #1681763] Tue, 17 March 2015 17:27 Go to previous messageGo to next message
Florian Haupt is currently offline Florian HauptFriend
Messages: 5
Registered: February 2015
Junior Member
Hi Dimitris,

thanks for the fast feedback.

If I create a tool, who will call it? The ETL transformation?

You suggested to run the validation programmatically using:

ValidateAction.runValidation((View) document.getContent());


Where do I get the View (or IDocument) object from if I put this code into a tool (and not into the DocumentProvider class)?

If I understand correctly, the use of a View indicates a dependency to GMF, i.e. to a graphical editor. What I currently do is independent of GMF, maybe this is my main problem. Let me show some code snippets:

public class MyHandler extends AbstractHandler {
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IFile selectedFile = ...;
    fileURI = selectedFile.getLocationURI().toString();
    // TODO validate model here
    // open a SaveAs dialog for the target file
    ...
    // run a wizard to ask the user for some transformation parameters
    ...
    // run the transformation
    ETLExecutor executor = new ETLExecutor(MODEL_NAME, ETL_SCRIPT_LOCATION);
    ...
    executor.execute();
  }
}


The handler is activated when right-clicking on a EMF model file (that has been created using a GMF editor). Before processing the file I want to validate it, this is what my question was about. After that (this is already working) the user is asked for a target file and some parameters and the ETL transformation is executed.

I can load the EMF model from the file using the following code:

EmfModel model = EmfModelFactory.getInstance().loadEmfModel(MODEL_NAME, file, MODEL_NS, AccessMode.READ_ONLY);


Is there any chance to execute a EVL validation on this model without having the model opened in a GMF editor?

Thanks and regards
Florian
Re: start EVL validation from wizard [message #1682856 is a reply to message #1682292] Tue, 17 March 2015 22:22 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Florian,

Please ignore my previous response - I misundestood your use case. You'll only need to add a few lines of code that runs your EVL constraints before running your ETL transformation. An example demonstrating running EVL from Java is available here: https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/tree/examples/org.eclipse.epsilon.examples.standalone/src/org/eclipse/epsilon/examples/standalone/evl/EvlStandaloneExample.java

Cheers,
Dimitris
Re: start EVL validation from wizard [message #1683876 is a reply to message #1682856] Wed, 18 March 2015 07:39 Go to previous message
Florian Haupt is currently offline Florian HauptFriend
Messages: 5
Registered: February 2015
Junior Member
Hi Dimitris,

many thanks, it works now! And I realized that it works the same way as the transformation that is executed afterwards, so the solution was already in my code (although I did not write that part)...

Florian
Previous Topic:Is there a CodeCoverage Tool for epsilon?
Next Topic:[EWL] Using functions
Goto Forum:
  


Current Time: Wed Apr 24 21:30:12 GMT 2024

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

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

Back to the top