Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » How to run OCL in Eclipse?(Beginner question)
How to run OCL in Eclipse? [message #1771073] Mon, 21 August 2017 17:06 Go to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 78
Registered: November 2015
Location: York, UK
Member
Forgive me if I'm missing something obvious, but I can't quite work out how to run an OCL program over a model. I tried with Neon and it didn't work, so I have a fresh install of Eclipse Oxygen and still no luck. Here's what I've tried:

The OCL file is valid according to the parser (no errors). I am trying to run it over "eclipseModel-0.1.xmi" (http://atenea.lcc.uma.es/index.php/Main_Page/Resources/LinTra#Input_Models_3).
Right-click on OCL file -> Run Configurations -> OCL Expression. The path to the model and OCL file are valid - I can even see a list of model elements and expressions. However, I want to run the entire file (all expressions) over the entire model (all elements). Am I using the wrong plug-in / run configuration to do this? I simply want the number of unsatisfied constraints (as EVL provides). Thanks.
Re: How to run OCL in Eclipse? [message #1771075 is a reply to message #1771073] Mon, 21 August 2017 18:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6112
Registered: July 2009
Senior Member
Hi

I suggest that you follow some of the tutorials.

Have you tried "Validate". If you want more precision, the Validity View.

Regards

Ed Willink

Re: How to run OCL in Eclipse? [message #1771079 is a reply to message #1771075] Mon, 21 August 2017 18:27 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 78
Registered: November 2015
Location: York, UK
Member
Hi,

I tried searching for tutorials and the documentation but I can't find anything regarding actually executing OCL from Eclipse. Does this need to be done programatically or is there a run configuration? For example, the Epsilon languages each have a Run Configuration that can be used to launch them and they print results to stdout. I'm unable to find any way to do this with Eclipse OCL. Regarding "Validate", there are no options to specify the input model. I'm sure there must be a tutorial on how to execute an OCL program somewhere but I can't find it, sorry!
Re: How to run OCL in Eclipse? [message #1771081 is a reply to message #1771079] Mon, 21 August 2017 18:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6112
Registered: July 2009
Senior Member
Hi

I'm very confused. I have no idea what you mean by an "OCL program". OCL by itself is almost completely useless. It is only in conjunction with some modeling environment that OCL becomes useful. EMF validation is one such environment. I suggest you follow the "Validation tutorial" in the OCL documentation; load a model and then validate it.

Regards

Ed Willink
Re: How to run OCL in Eclipse? [message #1771083 is a reply to message #1771081] Mon, 21 August 2017 18:57 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 78
Registered: November 2015
Location: York, UK
Member
Hi,

To put some context, I'm trying to evaluate the correctness of EVL (Epsilon Validation Language) against OCL. I have written two identical scripts - one in EVL, the other in OCL. The Epsilon plug-in provides a Run Configuration which can be used to execute the EVL script over a given model. I'd like to do the same with OCL. Upon further inspection of the documentation, it appears that I have overestimated the scope/purpose of Eclipse OCL. If I understand correctly, Eclipse OCL only provides a Java API for navigation of OCL AST rather than a complete model validation program for end users?

Thanks,
Sina
Re: How to run OCL in Eclipse? [message #1771086 is a reply to message #1771083] Mon, 21 August 2017 19:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6112
Registered: July 2009
Senior Member
Hi

Absolutely not. You just open your model and invoke Validate. OCL integrates with the EMNF environment so you just use EMF. EVL is an independent facility so you have to take your models to EVL. But since you have not provided a repro for what you call a program, I really cannot help you.

Regards

Ed Willink
Re: How to run OCL in Eclipse? [message #1771130 is a reply to message #1771086] Tue, 22 August 2017 10:59 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 78
Registered: November 2015
Location: York, UK
Member
Hi,

I'm not sure how Right-click -> Validate works - there are no options to actually specify the input model. Do I click on the model itself? If so, how can I provide the metamodel and OCL program? My understanding of inputs to a model validation program are the following:

- A script (validation logic) containing some constraints
- A metamodel
- A model

I have all of these things but am unsure how to combine them. Note that the script and metamodel are independent of each other. That is, I already have a big metamodel and I want to add some constraints to it. With EVL, you simply specify them in an EVL file. I have done the same thing in OCL. However, the tutorial appears to imply that the OCL invariants need to be embedded in the Ecore file itself. Is this correct?
  • Attachment: java.ecore
    (Size: 52.04KB, Downloaded 73 times)
  • Attachment: java.ocl
    (Size: 5.61KB, Downloaded 27 times)
Re: How to run OCL in Eclipse? [message #1771134 is a reply to message #1771130] Tue, 22 August 2017 11:10 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6112
Registered: July 2009
Senior Member
Hi

Your java.ocl is not an OCL program (e.g. no entry point such as main()), it is a Complete OCL document that may be used to complement another metamodel.

As explained in the OCL tutorials, you use the standard EMF way of validating. i.e load your model, possibly in the Sample Ecore Editor, select an element, possibly the root, and then validate the element (and its children). EMF now has live validation so, if that is enabled, you may find it sufficient to just wait a few seconds for it to kick in.

If you use OCLinEcore you can embed the OCL directly in the Ecore and the above is all you need to do.

If you have a separate OCL document you need to manually enrich the model using OCL->Load Document before you validate.

Regards

Ed Willink
Re: How to run OCL in Eclipse? [message #1771138 is a reply to message #1771134] Tue, 22 August 2017 11:38 Go to previous messageGo to next message
Sina Madani is currently offline Sina MadaniFriend
Messages: 78
Registered: November 2015
Location: York, UK
Member
Hi Ed,

Thanks for the clarification. It isn't practical to load the entire model using the Ecore editor - I want to do some performance testing later on with models that are 1GB in size, so ideally I'm looking for a way to automate this. I suspect the most effective way is to use the Java API instead. Does the API offer a way to simply run all invariants in a separate OCL document over a given model?

Thanks,
Sina
Re: How to run OCL in Eclipse? [message #1771142 is a reply to message #1771138] Tue, 22 August 2017 12:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6112
Registered: July 2009
Senior Member
Hi

Since OCL validation is performed using the EMF EValidator API, you 'just' need to stream your model through a Diagnostician which ironically lacks an outer loop for the whole Resource anyway.

Regards

Ed Willink
Re: How to run OCL in Eclipse? [message #1771144 is a reply to message #1771142] Tue, 22 August 2017 12:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6112
Registered: July 2009
Senior Member
Hi

And if you are dealing with huge models you will probably benefit from using OCLinEcore so that you can use the OCL2Java code generator, which will probably give you a 5 to 50-fold speed up.

Regards

Ed Willink

Re: How to run OCL in Eclipse? [message #1771154 is a reply to message #1771144] Tue, 22 August 2017 14:35 Go to previous message
Sina Madani is currently offline Sina MadaniFriend
Messages: 78
Registered: November 2015
Location: York, UK
Member
Hi Ed

Thank you for the help, insight and ideas!

Cheers,
Sina
Previous Topic:Defining helper operations in Java
Next Topic:includesAll fails
Goto Forum:
  


Current Time: Mon Nov 19 01:54:31 GMT 2018

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

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

Back to the top