Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Dynamic OCL Constraints(How to approach creating dynamic ocl constraints)
Dynamic OCL Constraints [message #1791039] Thu, 21 June 2018 19:14 Go to next message
Ioannis Nearchou is currently offline Ioannis NearchouFriend
Messages: 18
Registered: February 2018
Junior Member
Hello Everyone,

I have been working on an exercise to programmatically create instances of classes from an ecore file, give the instances values befitting their attributes and then running ocl validation checks on each instance. I have been pulling the constraints from the instance annotations and creating OCL invariants with an OCL helper, with the entire string representing a given constraint. Now, I want to expand my program by dynamically creating these constraints, instead. I am still a bit new to EMF and OCL, so I am wondering what are the best resources to read or some general information, to start me in the direction of handling this dynamic OCL approach? I have also been informed to look into Abstract Syntax Trees, so was also wondering about general information regarding them too.

Thank you,
Ioannis Nearchou
Re: Dynamic OCL Constraints [message #1791045 is a reply to message #1791039] Fri, 22 June 2018 05:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I am not sure what you mean by 'pulling' constraints.

If you use OCLinEcore you can embed your constraints and even generate Java from them. Follow the OCLinEcore tutorial.

If you really want separate constraints follw the Complete OCL tutorial.

If you really want dynamic constraints, please clarify your use case. But if necessary you can reuse much of the code within the Eclipse OCL project.

Regards

Ed Willink
Re: Dynamic OCL Constraints [message #1791134 is a reply to message #1791045] Sun, 24 June 2018 19:52 Go to previous messageGo to next message
Ioannis Nearchou is currently offline Ioannis NearchouFriend
Messages: 18
Registered: February 2018
Junior Member
Hello Ed,

Thank you for the response. I am sorry for the lack of context. I meant "pulling" as looking for EAnnotations related to constraints for directly written invariants in the case someone used OCLinEcore to write constraints, or EOperations for written operations or written callable invariants in a UML model that may be converted into an Ecore model.

As for what I meant by dynamic, I meant in the sense of being able to re-evaluate expressions as a model that relies on them is updated in the future with more features that are constrained by those expressions, or possibly if other models are written later, that will also rely upon those expressions. I am considering how to handle this with an OCL Abstract Syntax Model and just wanted to learn more about this approach. Please let me know if you require any further clarification.

Thank you,
Ioannis Nearchou
Re: Dynamic OCL Constraints [message #1791480 is a reply to message #1791134] Sat, 30 June 2018 09:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Sorry for the Delayed response - at the STAF conference.

I don't any further clarification, but if you experct any further response a repro of what fails for you might help me understand what you want.

Regards

Ed Willink
Re: Dynamic OCL Constraints [message #1791676 is a reply to message #1791480] Wed, 04 July 2018 02:26 Go to previous messageGo to next message
Ioannis Nearchou is currently offline Ioannis NearchouFriend
Messages: 18
Registered: February 2018
Junior Member
Hello Ed,

Thank you for the response. I have received further clarification about my present task. I must create ad hoc OCL expressions at run-time, save them as model constraints and evaluating them. I have been pointed to this article http://www.eclipse.org/articles/article.php?file=Article-HowToProcessOCLAbstractSyntaxTrees/index.html, for further information. I am testing with a hard-code example expression, before I proceed with user input.

From what I understand in the article, I will need to implement a visitor for the OCL Expression I create and handle the nodes of the OCL AST appropriately, when evaluating. I wanted to know more about handling expression types with this evaluation visitor, such as encountered if expressions or literal expressions. What should I consider when handling for nested expressions, like literal expressions nested within if expressions?

Thank you,
Ioannis Nearchou
Re: Dynamic OCL Constraints [message #1791679 is a reply to message #1791676] Wed, 04 July 2018 05:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You reference an 11 year old article that has a "This page is deprecated and may contain some information that is no longer relevant or accurate." preface. Much more accurate information can be found in the OCL documentation that accompanies the OCL distribution.

A visitor visits an existing AST; it does not build it.

Your requirement is very vague. Why create OCL on the fly; where does the 'algorithm' come from?

Do you have a user typing OCL into a UI? => use the OCL document/expression parser.

Do you have an algorithm in another formalism? => use an M2M

Are you tweaking standard idioms? => programatic may be sensible

Are you mindlessly trying to do what someone equally mindless has told you to do? => analyze the problem properly

Programmatically, I have steadily built up a family of PivotHelper.createXXXX methods for those elements that I have needed to create for on-the-fly OCL ASTs for the OCL->CG->Java and QVTr->QVTs->QVTi->CG->Java M2Ms. You may find createOperationCallExp particularly helpful since it does the hard work of resolving the referredOperation and specialized types. This is for the newer Pivot-based OCL. If you want to struggle with the long parameter lists of the Classic OCL you will need to write your own helpers.

Regards

Ed Willink
Re: Dynamic OCL Constraints [message #1793377 is a reply to message #1791679] Tue, 07 August 2018 02:12 Go to previous messageGo to next message
Ioannis Nearchou is currently offline Ioannis NearchouFriend
Messages: 18
Registered: February 2018
Junior Member
Hello Ed,

How are you? I apologize for the late update. I received much more context to settle the confusion I had about the direction I was given. I followed the last comment, which was also required in the direction I had been given, using the likes of createOperationCallExp() and other create calls for other expression subtypes, based on a string received from a user entering ocl expression strings into the console.

Now, the link of the deprecated article and asking about ASTs actually regard a plugin that was linked in the article. I found the OCLASTView plugin link in the article and want to use it to get a visual decomposition of an ocl expression by its components. I have downloaded the jar file, but since it is not downloaded from an update site, was wondering to where I would have to move the file to access it in eclipse? I am sorry for this not being an ocl based question, but still felt it relevant since it is connected to an earlier reply.

Thank you,
Ioannis Nearchou
Re: Dynamic OCL Constraints [message #1793380 is a reply to message #1793377] Tue, 07 August 2018 05:12 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I usually put JARs in a project/plugin lib folder. Depending on your IP constraints you can then commit the jar to GIT, or .gitignore it and provide a README explaining how to download it.

If you use Xtext, you will find that Xtext automatically downloads .antlr-generator-3.2.0-patch.jar to the root of your project.

Regards

Ed Willink
Previous Topic:Evaluation of derived OCL Ecore attributes from Java
Next Topic:Announce OCL 6.5.0
Goto Forum:
  


Current Time: Fri Apr 19 15:02:04 GMT 2024

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

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

Back to the top