Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Parser for OCL file with constraints
Parser for OCL file with constraints [message #495582] Thu, 05 November 2009 12:13 Go to next message
Carlos  is currently offline Carlos
Messages: 52
Registered: September 2009
Member
Hi.

I have implemented a parser for an OCL file with rules to validate the model (invariants) and that parser is based in IBatchValidator class. I execute "validate" and I obtain IStatus object with results.

However, I need to specificate other kind of rules which does not return a boolean value. For example:

Context ClassA
inv example: self.attribute

If I evaluate that expression in an OCL interpreter, it returns the value for that attribute.
If I declare in my OCL file that invariant, the log shows that is considered an invariant and evaluates it. However, parser compares the result with zero:

[OCL] Evaluate: self.attribute
[OCL] Result : 345
[OCL] Evaluate: 0
[OCL] Result : 0
[OCL] Evaluate: self.length.>(0)
[OCL] Result : true

Is there any way for getting the numeric result from the invariant? Or the only way is implementing an evaluator for expressions... (like the OCL interpreter)

Thanks in advance.
Carlos.
Re: Parser for OCL file with constraints [message #495727 is a reply to message #495582] Thu, 05 November 2009 20:27 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi Carlos

Your message is very confusing.

If you've implemented a parser why should you need help from MDT/OCL
when you didn't use the MDT/OCL parser?

IBatchValidator is provided by EMF/Validation so I'm not sure why you
are asking a question on MDT/OCL.

IBatchValidator validates for correctness which is the truth of
invariants, so I don't understand why you want values.

IBatchValidator is documented as not for implementation or extension
by clients, so why are you using it?

If you want to use the MDT/OCL parser you may find that the OCL class
provides a useful facade. Perhaps you want checkQuery() or evaluate().

Regards

Ed Willink


Carlos wrote:
> Hi.
>
> I have implemented a parser for an OCL file with rules to validate the
> model (invariants) and that parser is based in IBatchValidator class. I
> execute "validate" and I obtain IStatus object with results.
>
> However, I need to specificate other kind of rules which does not return
> a boolean value. For example:
>
> Context ClassA
> inv example: self.attribute
>
> If I evaluate that expression in an OCL interpreter, it returns the
> value for that attribute. If I declare in my OCL file that invariant,
> the log shows that is considered an invariant and evaluates it. However,
> parser compares the result with zero:
>
> [OCL] Evaluate: self.attribute
> [OCL] Result : 345
> [OCL] Evaluate: 0
> [OCL] Result : 0
> [OCL] Evaluate: self.length.>(0)
> [OCL] Result : true
>
> Is there any way for getting the numeric result from the invariant? Or
> the only way is implementing an evaluator for expressions... (like the
> OCL interpreter)
>
> Thanks in advance.
> Carlos.
Re: Parser for OCL file with constraints [message #495833 is a reply to message #495727] Fri, 06 November 2009 11:01 Go to previous message
Carlos  is currently offline Carlos
Messages: 52
Registered: September 2009
Member
Hi Edward.

I have used validation emf framework for verifying the correctness of my models.
I have defined an OCL file with rules (definitions, invariants, etc...) for making the validation, and method "validate" from IBatch... is very useful for me at this point.
Status result shows the information about the violated invariants, in which objects...

However, by other hand, I want to add a specie of "batch evaluator". It was something like going recursively through the model tree and applying evaluation of expressions in each node.
The idea is similar to the validation case, so I thought that I could doing the same for expressions... (using the batch for other purpose: in this case calculating for each model node several expressions).

I suppose that it does not exist such "batch evaluator", so I think that I have to implement a tree iterator and applying "evaluate" in each node for the expressions (I will define it in an OCL file, grouped by context).

Thank you very much.
Regards.
Carlos.
Previous Topic:OCL Console with history
Next Topic:Accessing OCL invariants from model diagram
Goto Forum:
  


Current Time: Sat Oct 25 06:22:15 GMT 2014

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

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