Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Re: OCL function
Re: OCL function [message #21693] Thu, 03 May 2007 12:04 Go to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Andrej,

OCL has its own newsgroup where you should ask this question. I've
added it to the "to" list in my reply so you don't need to repost your
question.


Andrej S wrote:
> Hallo all!
>
> I am trying to describe a constraint for a non-cyclic relation with OCL,
> therefor I need a recursive function, like this
>
> def: parents : Set = self.super->
> union (self.super ->collect ( p | p.parents()))
> inv: not self.parents() ->includes (self)
>
> But this does not work.
> Any suggestions? Can I write it so, as is, in EMF model?
> I'm using OCL 1.1M6 and EMF 2.3.0M6
>
> regards
> Andrej
>
Re: OCL function [message #21738 is a reply to message #21693] Thu, 03 May 2007 15:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Andrej,

You need to specify an element type for your collection type. e.g.,

def: parents : Set(Thing) = self.super->union(
self.super->collect(p | p.parents()))
inv: not self.parents()->includes(self)

Note, just for fun, that you can write this a little more succinctly:

def: parents : Set(Thing) = super->union(super.parents())

If the absence of an element type in your posting was just a typo, then
perhaps you are running into the following bug?

https://bugs.eclipse.org/bugs/show_bug.cgi?id=176109

HTH,

Christian


Ed Merks wrote:

> Andrej,
>
> OCL has its own newsgroup where you should ask this question. I've
> added it to the "to" list in my reply so you don't need to repost your
> question.
>
>
> Andrej S wrote:
>> Hallo all!
>>
>> I am trying to describe a constraint for a non-cyclic relation with OCL,
>> therefor I need a recursive function, like this
>>
>> def: parents : Set = self.super->
>> union (self.super ->collect ( p | p.parents()))
>> inv: not self.parents() ->includes (self)
>>
>> But this does not work.
>> Any suggestions? Can I write it so, as is, in EMF model?
>> I'm using OCL 1.1M6 and EMF 2.3.0M6
>>
>> regards
>> Andrej
>>
Re: OCL function [message #21917 is a reply to message #21738] Mon, 07 May 2007 14:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nospam74.gmx.net

Hi, Christian!

thanks for your answer. It was not a typo, in fact I forgot to declare
the type of set, but it does not work with type specification neither. I
get even for simply examples such as

def: n: String = 'test'

an error "Invalid OCL" ( I use interactive OCL console on dynamic instances)

Do I miss anything?

Christian W. Damus wrote:
> Hi, Andrej,
>
> You need to specify an element type for your collection type. e.g.,
>
> def: parents : Set(Thing) = self.super->union(
> self.super->collect(p | p.parents()))
> inv: not self.parents()->includes(self)
>
> Note, just for fun, that you can write this a little more succinctly:
>
> def: parents : Set(Thing) = super->union(super.parents())
>
> If the absence of an element type in your posting was just a typo, then
> perhaps you are running into the following bug?
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176109
>
> HTH,
>
> Christian
Re: OCL function [message #21962 is a reply to message #21917] Mon, 07 May 2007 19:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Andrej,

The interactive OCL Console example (even the vastly improved version coming
in M7) currently does not support def: expressions. Nor, indeed, does it
support the context declaration syntax (including the "inv:" token).

In M2 (metamodel) mode, the console will parse all expressions as query
expressions. In M1 (model) mode, it will parse the expressions that you
type in as follows:

- when the selection is a classifier (Ecore EClassifier or UML CLassifier)
it parses the expression as an invariant constraint
- when the selection is an operation (EOperation or Operation), it parses
as a post-condition constraint
- when the selection is an attribute (EStructuralFeature or Property), it
parses as a derivation constraint

Note that, for parsing OCL from text files, I have just committed a fix for

https://bugs.eclipse.org/bugs/show_bug.cgi?id=176109

in which constraints in the OCL document are, in fact, parsed in reverse
order, so that your def: expression would not have been processed when the
inv: constraint attempted to use it.

Cheers,

Christian


Andrej S wrote:

> Hi, Christian!
>
> thanks for your answer. It was not a typo, in fact I forgot to declare
> the type of set, but it does not work with type specification neither. I
> get even for simply examples such as
>
> def: n: String = 'test'
>
> an error "Invalid OCL" ( I use interactive OCL console on dynamic
> instances)
>
> Do I miss anything?
>
> Christian W. Damus wrote:
>> Hi, Andrej,
>>
>> You need to specify an element type for your collection type. e.g.,
>>
>> def: parents : Set(Thing) = self.super->union(
>> self.super->collect(p | p.parents()))
>> inv: not self.parents()->includes(self)
>>
>> Note, just for fun, that you can write this a little more succinctly:
>>
>> def: parents : Set(Thing) = super->union(super.parents())
>>
>> If the absence of an element type in your posting was just a typo, then
>> perhaps you are running into the following bug?
>>
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176109
>>
>> HTH,
>>
>> Christian
Re: OCL function [message #22097 is a reply to message #21962] Wed, 09 May 2007 11:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nospam74.gmx.net

Hi!

Every def: expression is marked as invalid by validation in GMF mapping.

def: n: String = 'test'
inv: n = 'test'

results in "Invalid expression body [...] Invalid OCL"

Is there another way to set OCL constraints?

greets
Andrej

Christian W. Damus wrote:
> Hi, Andrej,
>
> The interactive OCL Console example (even the vastly improved version coming
> in M7) currently does not support def: expressions. Nor, indeed, does it
> support the context declaration syntax (including the "inv:" token).
>
> In M2 (metamodel) mode, the console will parse all expressions as query
> expressions. In M1 (model) mode, it will parse the expressions that you
> type in as follows:
>
> - when the selection is a classifier (Ecore EClassifier or UML CLassifier)
> it parses the expression as an invariant constraint
> - when the selection is an operation (EOperation or Operation), it parses
> as a post-condition constraint
> - when the selection is an attribute (EStructuralFeature or Property), it
> parses as a derivation constraint
>
> Note that, for parsing OCL from text files, I have just committed a fix for
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176109
>
> in which constraints in the OCL document are, in fact, parsed in reverse
> order, so that your def: expression would not have been processed when the
> inv: constraint attempted to use it.
>
> Cheers,
>
> Christian
Re: OCL function [message #22187 is a reply to message #22097] Wed, 09 May 2007 12:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Andrej,

It would be better to ask that question on the GMF newsgroup (which I have
included in the To: list).

From the result, I would guess that GMF expects as input simply a
boolean-valued expression. However, it may be that GMF provides some means
to specify additional operations and attributes that I don't know about.

Cheers,

Christian


Andrej S wrote:

> Hi!
>
> Every def: expression is marked as invalid by validation in GMF mapping.
>
> def: n: String = 'test'
> inv: n = 'test'
>
> results in "Invalid expression body [...] Invalid OCL"
>
> Is there another way to set OCL constraints?
>
> greets
> Andrej
>
> Christian W. Damus wrote:
>> Hi, Andrej,
>>
>> The interactive OCL Console example (even the vastly improved version
>> coming
>> in M7) currently does not support def: expressions. Nor, indeed, does it
>> support the context declaration syntax (including the "inv:" token).
>>
>> In M2 (metamodel) mode, the console will parse all expressions as query
>> expressions. In M1 (model) mode, it will parse the expressions that you
>> type in as follows:
>>
>> - when the selection is a classifier (Ecore EClassifier or UML
>> CLassifier)
>> it parses the expression as an invariant constraint
>> - when the selection is an operation (EOperation or Operation), it
>> parses
>> as a post-condition constraint
>> - when the selection is an attribute (EStructuralFeature or Property),
>> it
>> parses as a derivation constraint
>>
>> Note that, for parsing OCL from text files, I have just committed a fix
>> for
>>
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176109
>>
>> in which constraints in the OCL document are, in fact, parsed in reverse
>> order, so that your def: expression would not have been processed when
>> the inv: constraint attempted to use it.
>>
>> Cheers,
>>
>> Christian
Re: OCL function [message #22337 is a reply to message #22187] Wed, 09 May 2007 16:14 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Christian,

Right, looks like GMF related but I am not sure I fully understand
what Andrej has done.

Andrej,
could you please submit some more details or a test model which would
help me reproduce this problem?

Regards,
/Radek

On Wed, 09 May 2007 14:26:54 +0200, Christian W. Damus <cdamus@ca.ibm.co=
m> =

wrote:

>
> Hi, Andrej,
>
> It would be better to ask that question on the GMF newsgroup (which I =
=

> have
> included in the To: list).
>
> From the result, I would guess that GMF expects as input simply a
> boolean-valued expression. However, it may be that GMF provides some =
=

> means
> to specify additional operations and attributes that I don't know abou=
t.
>
> Cheers,
>
> Christian
>
>
> Andrej S wrote:
>
>> Hi!
>>
>> Every def: expression is marked as invalid by validation in GMF mappi=
ng.
>>
>> def: n: String =3D 'test'
>> inv: n =3D 'test'
>>
>> results in "Invalid expression body [...] Invalid OCL"
>>
>> Is there another way to set OCL constraints?
>>
>> greets
>> Andrej
>>
>> Christian W. Damus wrote:
>>> Hi, Andrej,
>>>
>>> The interactive OCL Console example (even the vastly improved versio=
n
>>> coming
>>> in M7) currently does not support def: expressions. Nor, indeed, do=
es =

>>> it
>>> support the context declaration syntax (including the "inv:" token).=

>>>
>>> In M2 (metamodel) mode, the console will parse all expressions as qu=
ery
>>> expressions. In M1 (model) mode, it will parse the expressions that=
=

>>> you
>>> type in as follows:
>>>
>>> - when the selection is a classifier (Ecore EClassifier or UML
>>> CLassifier)
>>> it parses the expression as an invariant constraint
>>> - when the selection is an operation (EOperation or Operation), it=

>>> parses
>>> as a post-condition constraint
>>> - when the selection is an attribute (EStructuralFeature or =

>>> Property),
>>> it
>>> parses as a derivation constraint
>>>
>>> Note that, for parsing OCL from text files, I have just committed a =
fix
>>> for
>>>
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=3D176109
>>>
>>> in which constraints in the OCL document are, in fact, parsed in =

>>> reverse
>>> order, so that your def: expression would not have been processed wh=
en
>>> the inv: constraint attempted to use it.
>>>
>>> Cheers,
>>>
>>> Christian
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: OCL function [message #22776 is a reply to message #22337] Thu, 10 May 2007 08:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nospam74.gmx.net

Hi, Radek!

I don't believe that my problem is GMF related, I tried it in EMF too.

I have model that includes inheritance relation, so I want to forbid
cyclic inheritance. For this purpose is a recursive function needed,
defined with "def:" keyword.
My problem is that "def:", however, does not work correctly.

Regards
Andrej

Radek Dvorak wrote:
> Hi Christian,
>
> Right, looks like GMF related but I am not sure I fully understand
> what Andrej has done.
>
> Andrej,
> could you please submit some more details or a test model which would
> help me reproduce this problem?
>
> Regards,
> /Radek
Re: OCL function [message #22864 is a reply to message #22776] Thu, 10 May 2007 12:52 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Andrej,

The concrete syntax for context declarations (including the def, inv, etc.
keywords) is only supported by the OCL.parse(OCLInput) API. If you are
using the OCLHelper API, then you must supply only the OCL constraint or
body expression (depending on whether an invariant, precondition,
definition, etc.).

Which of these APIs is ultimately trying to parse your input?

Christian


Andrej S wrote:

> Hi, Radek!
>
> I don't believe that my problem is GMF related, I tried it in EMF too.
>
> I have model that includes inheritance relation, so I want to forbid
> cyclic inheritance. For this purpose is a recursive function needed,
> defined with "def:" keyword.
> My problem is that "def:", however, does not work correctly.
>
> Regards
> Andrej
>
> Radek Dvorak wrote:
>> Hi Christian,
>>
>> Right, looks like GMF related but I am not sure I fully understand
>> what Andrej has done.
>>
>> Andrej,
>> could you please submit some more details or a test model which would
>> help me reproduce this problem?
>>
>> Regards,
>> /Radek
Previous Topic:three entries so far, and growing
Next Topic:OCL Models Regenerated -- Action for Extenders
Goto Forum:
  


Current Time: Fri Apr 19 19:59:10 GMT 2024

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

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

Back to the top