Skip to main content



      Home
Home » Modeling » OCL » run OCL on models programmatically
run OCL on models programmatically [message #1835192] Thu, 26 November 2020 12:28 Go to next message
Eclipse UserFriend
Hi,

I am working on a DSL for writing test scenarios which will be executed on models conforming to different DSLs (e.g., FSM, BPMN, ...).
I want to add an OCL functionality to my test DSL in order to enable the tester to evaluate OCL queries on a model under test.
For instance, I want to simply validate the following OCL query on a Pertinent model:
petrinet.places -> select (p | p.tokens = '0')

and I expect to receive the following answer:
p1, p2, p3, p4

Using my test DSL, the test scenario will look like this:
	Test Description petrinetTestUsingOCL uses configuration oclConfiguration{
		tester.oclTestGate sends oclquery (query = "petrinet.places -> select (p | p.tokens = '0')") 
								to petrinet.oclMUTGate;
		alternatively{
			petrinet.oclMUTGate sends "p1, p2, p3, p4"  to tester.oclTestGate;
			set verdict to PASS;
		} or{
			set verdict to FAIL;
		}
	}


I've implemented an interpreter for my test DSL and for interpreting the above code, I need to programmatically run the OCL query on the intended Petrinet model, in fact, it is required that my interpreter be able to validate and execute OCL queries and check the answer.

I suppose this functionality can be possible using OCL Eclipse (using its provided APIs) but I don't know how and where to start.
Could anyone guide me please?

Bests,
Faezeh
Re: run OCL on models programmatically [message #1835194 is a reply to message #1835192] Thu, 26 November 2020 12:43 Go to previous messageGo to next message
Eclipse UserFriend
Not sure if it's useful but I've also wanted to use OCL programmatically and this is what I came up with (link). Basically you want to use org.eclipse.ocl.pivot.utilities.OCL and call OCL.newInstance(new ResourceSetImpl()). Also need to call org.eclipse.ocl.xtext.completeocl.CompleteOCLStandaloneSetup.doSetup(); and org.eclipse.ocl.pivot.model.OCLstdlib.install(). Use OCL.parse to parse the query. Hope that's somewhat helpful.

[Updated on: Sat, 28 November 2020 10:00] by Moderator

Re: run OCL on models programmatically [message #1835196 is a reply to message #1835194] Thu, 26 November 2020 14:18 Go to previous messageGo to next message
Eclipse UserFriend
Hi

I would love to say it's easy, but sorry it isn't. There are many aspects of OCL / Eclipse / Java that you will need to be proficient with to only find it hard.

If I haven't put you off yet, you should study the QVTd editors that extend OCL in a similar way to what you would need to do if you want a full integration.

If you only want an unparsed opaque String there are many options for fudges.

Regards

Ed Willink
Re: run OCL on models programmatically [message #1835209 is a reply to message #1835194] Fri, 27 November 2020 03:14 Go to previous message
Eclipse UserFriend
thank you for your quick response.

I will try it for sure, but the link you sent doesn't work (error 404).
could you please give me the right link, and also the references to the libraries (e.g., their documentation) that I will need for the implementation?
Previous Topic:Def expressions in OCLInEcore and the Interactive console.
Next Topic:Get the query result from OCL Java API in the format of XText OCL result
Goto Forum:
  


Current Time: Wed Apr 23 08:16:37 EDT 2025

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

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

Back to the top